Sabissimo / AssistantEnabler

[Xposed module] Enable Google Assistant in Marshmallow ROMs http://repo.xposed.info/module/com.sabik.assistantenabler
BSD 3-Clause "New" or "Revised" License
16 stars 8 forks source link

Google 6.10 compatibility, "not available in your locale" fix and general hook changes #10

Closed alice-mkh closed 7 years ago

alice-mkh commented 7 years ago

Hi! I've updated the app for the latest Google (#9), fixed the locale problem and made the hooks depend much less on obfuscated names, so that updating the module for newer Google versions takes less work. More precisely, how the hooking is done here:

  1. Google app checks ro.opa.eligible_device in build.prop. Spoof that directly in android.os.SystemProperties class.
  2. It checks for key_opa_eligible and opa_enabled values in its pref file. For some reason Google reinvented the wheel here and made its own class fo parsing prefs, so still using an obfuscated name here. At least the method name is ok, because it comes from a framework interface (SharedPreferences)
  3. For checking hotword detection, it checks from_hotword extra in some bundle. Spoof this to always be false.
  4. The original "detection methods" are still needed (although I've been able to remove some hooks, since the methods there basically call each other), and the locale check in 6.9+ is also done there.
  5. For Ok Google Everywhere feature I just change a bit the charging intents: if an intent has ACTION_POWER_DISCONNECTED action, I return ACTION_POWER_CONNECTED instead. :) And, similarly, if an intent has ACTION_BATTERY_CHANGED action, I make it so that it returns BATTERY_STATUS_CHARGING for its EXTRA_STATUS extra.

In theory, this approach can have side effects, but it seems ok here. In my opinion that's a better way than changing Google app logic directly, because it's possible to do it in a way that doesn't require updating the module at all, although I haven't reached that here.

alice-mkh commented 7 years ago

Forgot to mention. Despite the name of commit, I tested it afterwards and it works flawlessly.

Sabissimo commented 7 years ago

Thanks a ton! Never got around to look into locale problem, and was looking into 6.10 myself right now, you beat me to it 👍 And some great refactoring there! I've added one thing though - since 6.10 from_hotword spoof is not needed anymore, they've fixed it in app itself, so I've added that check too and not hooking it if version is 6.10 and up.

Anyway, thanks a lot!

alice-mkh commented 7 years ago

I did most of the testing on an early 6.9 version where it still works for any locale (you can see it from the commit name :) ), so perhaps I missed that.