Skip to content

Instantly share code, notes, and snippets.

@denysvitali
Last active January 21, 2020 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denysvitali/73d5d3f6e2fd4b21d542c8c7a06e7db8 to your computer and use it in GitHub Desktop.
Save denysvitali/73d5d3f6e2fd4b21d542c8c7a06e7db8 to your computer and use it in GitHub Desktop.

Hey! Thanks for your interest in my request.

As probably already (briefly) explained, I'm trying to port the Music Matching feature of Pixel 2 phones (normal and XL) to other Android devices. Without going deeply into technical details, I was already able to port the app itself, but I still need some files that are only available on Pixel 2 (+ XL) devices. If you want to help me, I wrote a short procedure on how to do it.
Once you have the two files (which don't contain any user data, in fact they are system files) you can send them to me and I'll proceed w/ my porting of the app. I'll also give you credit if you want when this feature gets ported :)

Music Matching Feature

These are the files I need:
/system/etc/firmware/music_detector.sound_model
/system/etc/ambient (it's a directory).

The following procedure will not void your warrnaty, nor birck your phone or anything. It is totally safe, and we're only going to read some system files from it.

In order to get them, you need a computer, and a Pixel 2 (or Pixel 2 XL) device. Then proceed as following:

  • Enable Developer Mode (https://recomhub.com/blog/how-to-enable-developer-mode-on-pixel-and-pixel-xl/, TL;DR: Settings => System => About phone => 5 taps on "Build Number" => Press Back => Enter the "Developer Options" menu => Scroll down to "Debugging" and enable "USB debugging"

  • Install ADB on your computer: https://www.xda-developers.com/install-adb-windows-macos-linux/

  • Connect the phone to your computer, allow USB debugging from the popup that appears on the (unlocked) phone

  • On the computer, write adb pull /system/etc/firmware/music_detector.sound_model ., press enter, then write adb pull /system/etc/ambient .

  • If everything goes well, you should have a music_detector.sound_model file and an ambient folder. These two elements are all I need.

I can guarantee you that these files contain no personal information. These are only system files used to identify the songs with the Pixel Ambient Service app that comes preinstalled on every Pixel 2 phone.

Thanks for your help!

@argraur
Copy link

argraur commented Oct 18, 2017

Hi! I also want to port this feature for my own ROM! And I have all files you need! If you can, help me to get this in my ROM.

@argraur
Copy link

argraur commented Oct 18, 2017

@argraur
Copy link

argraur commented Oct 18, 2017

Currently I'm getting this:
10-18 19:05:20.969 7196 7256 E zygote64: No implementation found for long com.google.audio.ambientmusic.NnfpRecognizer.init(java.lang.String[], byte[]) (tried Java_com_google_audio_ambientmusic_NnfpRecognizer_init and Java_com_google_audio_ambientmusic_NnfpRecognizer_init___3Ljava_lang_String_2_3B)

@argraur
Copy link

argraur commented Oct 18, 2017

Also, how did you add this "Now Playing" menu in Settings?

@denysvitali
Copy link
Author

Edited the APK :)

adb shell su -c 'am start com.google.intelligence.sense/com.google.intelligence.sense.ambientmusic.AmbientMusicSettingsActivity' will bring you there too

@denysvitali
Copy link
Author

Pixel 2 files (ambient + system apps + misc):
https://cloud.mastodonti.co/s/TiUDgCqKJh1nlvy

(cc @argraur)

@denysvitali
Copy link
Author

We're still missing libsense.so :(

@denysvitali
Copy link
Author

@argraur
Copy link

argraur commented Oct 19, 2017

@denysvitali Can you give a patch for Settings / SystemUI to get AmbientSense Settings?

@VincentJoshuaET
Copy link

Any update on this? Maybe we can use apktool to modify the lockscreen to show the currently playing music?

@denysvitali
Copy link
Author

The problem we were having was a missing function in Android's framework. I'm pretty sure that Pixel devices do get a special framework, but since Android 8 is almost rolled out on every mainstream device, maybe a porting should be easier.

I honestly haven't look into this issue anymore as I've discontinued the project due to a lack of time / other interests. I can start digging into this as soon as I have more free time 😊

@VincentJoshuaET
Copy link

Maybe it's easier to port it to Pixel Experience ROMs, they pretty much add many Pixel exclusive features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment