[MOD][Xposed] Google Search / Now API

Search This thread

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Requires Xposed Framework!

This module adds an API to the Google Search app, commonly referred to as Google Now.
This allows developers to make plugins that react to searches done in Google Search.

As of right now, the developers cannot interact with the cards UI, not sure how feasible that is, if it is, it'll be in future versions.

(I showed this on reddit some days ago: http://www.reddit.com/r/Android/comments/1rmvxs/heres_a_preview_of_my_google_search_now_api/)

Screenshots:
IWbHojml.png
0TQkSlkl.png


Demos:
Lyrics fetching: https://www.youtube.com/watch?v=OsNCHo5JZuA
Song recognition outside US with Shazam: https://www.youtube.com/watch?v=ThbW5glU7zM
AutoVoice: http://www.youtube.com/watch?v=usjqq5hwlSE

Compatibility:
Any 4.1+ device that can run Xposed Framework. ICS not supported at the moment, not sure how recent the Google Search port is.

Download:
Please note that this is a 1.0 release, it may or may not have bugs.
http://repo.xposed.info/module/com.mohammadag.googlesearchapi

Source:
This is open source, you're free to contribute to the source, but you're in now way allowed to release this anywhere else.
https://github.com/MohammadAG/Google-Search-API

Plugins:
This doesn't do anything without plugins, which needs developer support. More on that below. Here are some fully working examples:
  • Music Controls: Control music playback. Supported commands: "play/pause/resume music", "play songs by <artist>", "play song <title>", "next/previous track/song", "volume up/down/max", "what song is this" opens in Shazam, requires Shazam, no idea what happens without it.
  • Voice Toggles: Turn on/off Wi-Fi, Mobile Data, or Bluetooth.
  • AZLyrics Viewer: Shows lyrics for songs from AZLyrics.com. Supported commands: "show lyrics for <song> by <artist>", exact syntax required here, artist is not optional.
  • Autovoice, by @joaomgcd, run Tasker commands from Google Search.

Plugin sources:
  1. Music Controls: https://github.com/MohammadAG/GNAPI-MusicControls
  2. Voice Toggles: https://github.com/MohammadAG/GNAPI-VoiceToggles
  3. AZLyrics Viewer: https://github.com/MohammadAG/Android-AZLyricsViewer

Developers:
Implementing plugins is as easy as copying one file to your source, and implementing a BroadcastReceiver that listens for the search queries (sent as text). If you're implementing a UI, implement TextToSpeech for voice feedback, if not, use GoogleNowApi.speak for voice replies.
All this is demonstrated in the examples above.
You'll also need to add a permission to AndroidManifest.xml: "com.mohammadag.googlesearchapi.permission.ACCESS_GGOGLE_SEARCH_API"
Remember that any package needs one activity to be started to work, see the music controls example for a way around that.
Of course, you're free to make your plugins free/paid/whatever.

What are the two checkboxes for?
If you're using GEL, you basically need to have the first checkbox checked. This is because GEL uses an overlay for the first part of the search, then opens the usual search app without the transitions. This means that if a developer already started an activity, it'll be sent to the background cause search was started after it.

Second checkbox prevents duplicate searches, this can be useful (you'll see how), and not so useful (when you do two volume ups/downs). Experiment as needed.

Support development
This took quite a lot of research, Google Search's code is huge, if you found this useful, please consider a donation.
 
Last edited:

Cptnodegard

Senior Member
Nov 24, 2011
484
178
Any way this could be made to support Tasker out of the box? Basically if it sent a broadcast intent without the need for a permission and such.
 

Dzakus

Member
Apr 4, 2011
14
6
Hi MohammadAG.
What do you think about unlock Remote API? I tried to do this, but I have very limited time.
The problem is reconstruction of the API. Reverse engineering, reverse, reverse
Code:
        <service android:name="com.google.android.sidekick.main.remoteservice.GoogleNowRemoteService" android:permission="com.google.android.apps.now.REMOTE_ACCESS" android:process=":search">
            <intent-filter>
                <action android:name="com.google.android.sidekick.shared.remoteapi.IGoogleNowRemoteService" />
            </intent-filter>
        </service>
In latest version require signature (after upload my module Google change it)
Code:
    <permission android:label="@string/permission_remote_access_label" android:name="com.google.android.apps.now.REMOTE_ACCESS" android:protectionLevel="signature" android:description="@string/permission_remote_access_desc" />

but in android:versionCode="300207090" android:versionName="2.7.9.789824.arm" only hook function:
Code:
    <permission android:label="@string/permission_remote_access_label" android:name="com.google.android.apps.now.REMOTE_ACCESS" android:protectionLevel=">>>normal<<<<" android:description="@string/permission_remote_access_desc" />
Code:
checkForValidSignature(int paramAnonymousInt)


API function is very interesting: ht tp:/ /wk le j.to/g38qK
To prevent spam on the XDA forums, ALL new users prevented from posting outside links in their messages. After approximately 10 posts, you will be able to post outside links. Thank you for understanding!

It requires changing the settings in teamdog "section", which makes my module. Latest version of the module in the repo does not support latest Google Search. I did fix, but not yet released. Do want it it?
 
Last edited:

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Hi MohammadAG.
What do you think about unlock Remote API? I tried to do this, but I have very limited time.
The problem is reconstruction of the API. Reverse engineering, reverse, reverse

<snip>

API function is very interesting: http://wklej.to/g38qK

It requires changing the settings in teamdog "section", which makes my module. Latest version of the module in the repo does not support latest Google Search. I did fix, but not yet released. Do want it it?

That's actually interesting... I didn't notice that part, mainly cause I thought sidekick was the name of some Motorola device.
The fun part is CardResponse implements Parceable, so this could probably be used to do card UI responses.
PM me your module, I'll have a look at this.

The signature shouldn't be a problem, PackageManager can be hooked I guess.
 

Dzakus

Member
Apr 4, 2011
14
6
2242683

That's actually interesting... I didn't notice that part, mainly cause I thought sidekick was the name of some Motorola device.
The fun part is CardResponse implements Parceable, so this could probably be used to do card UI responses.
PM me your module, I'll have a look at this.

The signature shouldn't be a problem, PackageManager can be hooked I guess.

@MohammadAG, dumped from device, so signed debug key APK: http:/ /w w w12.zipp yshare. com/ v/6439333/file.html
I can not find the source code, but I still look for it tomorrow.

byte[] is for protobuf data :-/
 
  • Like
Reactions: MohammadAG

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
I'm totally implementing this in AutoVoice tomorrow so no need for you to go through the trouble if you don't want to. :) haven't tried it but looks great!

Awesome, you'd be the first dev to implement this!
If you have any comments on the API, do tell, it's the first time I've written an almost solid API.

(I image a library that can be imported would be better than copying the .java file, if that's a comment) :p
 

joaomgcd

Senior Member
Aug 21, 2012
71
68
Awesome, you'd be the first dev to implement this!
If you have any comments on the API, do tell, it's the first time I've written an almost solid API.

(I image a library that can be imported would be better than copying the .java file, if that's a comment) :p

Ok, here it is! :D

(oops, can't post a link to the youtube video... Look up my channel on youtube: joaomgcd. If you would be so kind as to post the link to the video it would be cool)

AutoVoice integration couldn't be simpler! Thank you very much for creating this! :)

About the API, it's fine as it is! I personally much prefer a java file like that specially since it's such a simple one. I wouldn't want to import a jar just to get access to a constant. :)

Of course the API could grow, but I actually like having the java file like that. :)

Congrats on the great API, I hope you don't mind that I linked to it in the YouTube video and in the description.
 

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Ok, here it is! :D

(oops, can't post a link to the youtube video... Look up my channel on youtube: joaomgcd. If you would be so kind as to post the link to the video it would be cool)

AutoVoice integration couldn't be simpler! Thank you very much for creating this! :)

About the API, it's fine as it is! I personally much prefer a java file like that specially since it's such a simple one. I wouldn't want to import a jar just to get access to a constant. :)

Of course the API could grow, but I actually like having the java file like that. :)

Congrats on the great API, I hope you don't mind that I linked to it in the YouTube video and in the description.

Added to first post with a link to the video, thanks! :)

Glad you found the API useful as is, I'll keep it as a java file till I implement card responses, then you'd probably need to use a library to create cards :)
 
  • Like
Reactions: mohdhabibkhan

Sc4ryB3ar

Senior Member
Mar 3, 2012
961
516
Plymouth
Google Pixel 5
Ok, here it is! :D

(oops, can't post a link to the youtube video... Look up my channel on youtube: joaomgcd. If you would be so kind as to post the link to the video it would be cool)

AutoVoice integration couldn't be simpler! Thank you very much for creating this! :)

About the API, it's fine as it is! I personally much prefer a java file like that specially since it's such a simple one. I wouldn't want to import a jar just to get access to a constant. :)

Of course the API could grow, but I actually like having the java file like that. :)

Congrats on the great API, I hope you don't mind that I linked to it in the YouTube video and in the description.

Sweet! How can we do this if we don't have your rom?

And have you looked at Utter! At all? Either of you....

Anyway to integrate this?



Sent from my GT-I9505G using Tapatalk
 
  • Like
Reactions: guy4jesuschrist

Cptnodegard

Senior Member
Nov 24, 2011
484
178
Are supported apps supposed to show in the plugin list in the Search API app? Can't get Autovoice to work despite it being the correct version with integration enabled, the xposed plugin is also up and running. The plugin list doesnt show Autovoice however.
 
  • Like
Reactions: abhijeetramgir

spyros.giotakis

Senior Member
Nov 18, 2012
91
82
Are supported apps supposed to show in the plugin list in the Search API app? Can't get Autovoice to work despite it being the correct version with integration enabled, the xposed plugin is also up and running. The plugin list doesnt show Autovoice however.

it shows for me in the plugins section of google search api. what version of autovoice you have? did you reboot?
 
  • Like
Reactions: amigoulo

joaomgcd

Senior Member
Aug 21, 2012
71
68
Added to first post with a link to the video, thanks! :)

Glad you found the API useful as is, I'll keep it as a java file till I implement card responses, then you'd probably need to use a library to create cards :)

Thanks again!

By the way, can you differentiate between text and voice searches? That would be a useful extra to have in the intent from the broadcast.
 

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Stupid question: is it limited to English or should it work for other languages?

Whatever Google Search recognizes is good. Yes, you can use this to implement voice commands in other languages.

Thanks again!

By the way, can you differentiate between text and voice searches? That would be a useful extra to have in the intent from the broadcast.

It's already there. Boolean extra, the key is in the Java file, look at AZLyricsViewer for an example.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 118
    Requires Xposed Framework!

    This module adds an API to the Google Search app, commonly referred to as Google Now.
    This allows developers to make plugins that react to searches done in Google Search.

    As of right now, the developers cannot interact with the cards UI, not sure how feasible that is, if it is, it'll be in future versions.

    (I showed this on reddit some days ago: http://www.reddit.com/r/Android/comments/1rmvxs/heres_a_preview_of_my_google_search_now_api/)

    Screenshots:
    IWbHojml.png
    0TQkSlkl.png


    Demos:
    Lyrics fetching: https://www.youtube.com/watch?v=OsNCHo5JZuA
    Song recognition outside US with Shazam: https://www.youtube.com/watch?v=ThbW5glU7zM
    AutoVoice: http://www.youtube.com/watch?v=usjqq5hwlSE

    Compatibility:
    Any 4.1+ device that can run Xposed Framework. ICS not supported at the moment, not sure how recent the Google Search port is.

    Download:
    Please note that this is a 1.0 release, it may or may not have bugs.
    http://repo.xposed.info/module/com.mohammadag.googlesearchapi

    Source:
    This is open source, you're free to contribute to the source, but you're in now way allowed to release this anywhere else.
    https://github.com/MohammadAG/Google-Search-API

    Plugins:
    This doesn't do anything without plugins, which needs developer support. More on that below. Here are some fully working examples:
    • Music Controls: Control music playback. Supported commands: "play/pause/resume music", "play songs by <artist>", "play song <title>", "next/previous track/song", "volume up/down/max", "what song is this" opens in Shazam, requires Shazam, no idea what happens without it.
    • Voice Toggles: Turn on/off Wi-Fi, Mobile Data, or Bluetooth.
    • AZLyrics Viewer: Shows lyrics for songs from AZLyrics.com. Supported commands: "show lyrics for <song> by <artist>", exact syntax required here, artist is not optional.
    • Autovoice, by @joaomgcd, run Tasker commands from Google Search.

    Plugin sources:
    1. Music Controls: https://github.com/MohammadAG/GNAPI-MusicControls
    2. Voice Toggles: https://github.com/MohammadAG/GNAPI-VoiceToggles
    3. AZLyrics Viewer: https://github.com/MohammadAG/Android-AZLyricsViewer

    Developers:
    Implementing plugins is as easy as copying one file to your source, and implementing a BroadcastReceiver that listens for the search queries (sent as text). If you're implementing a UI, implement TextToSpeech for voice feedback, if not, use GoogleNowApi.speak for voice replies.
    All this is demonstrated in the examples above.
    You'll also need to add a permission to AndroidManifest.xml: "com.mohammadag.googlesearchapi.permission.ACCESS_GGOGLE_SEARCH_API"
    Remember that any package needs one activity to be started to work, see the music controls example for a way around that.
    Of course, you're free to make your plugins free/paid/whatever.

    What are the two checkboxes for?
    If you're using GEL, you basically need to have the first checkbox checked. This is because GEL uses an overlay for the first part of the search, then opens the usual search app without the transitions. This means that if a developer already started an activity, it'll be sent to the background cause search was started after it.

    Second checkbox prevents duplicate searches, this can be useful (you'll see how), and not so useful (when you do two volume ups/downs). Experiment as needed.

    Support development
    This took quite a lot of research, Google Search's code is huge, if you found this useful, please consider a donation.
    26
    3.6.13 Google Search Update

    bir -> bpn
    bjb -> bpy
    bur -> cby
    cmh -> cuc
    w -> x
    azL -> aCT
    heb -> hmu
    bul -> cbs
    bkt ->bqk

    Tested and everything is working including text searches. APK is attached.
    21
    Okay, I mean I have no real life and stuff.
    So I forked @MohammadAG project on Github and fixed it.

    All credits go to the OP! It's confirmed working on Auto voice again, didn't test it myself, though. Needs more testing.
    I've incremented the build number and opened a pull request on Github. The apk above is signed with debug keys if anyone cares.

    If OP doesn't want it, please report this post. Calling @GermainZ just to let him know.
    18
    MohammadAG You are the man! Here is a video I put together on some of the things you can do with it, fantastic Job!

    15
    Enjoy. Updated to 1.31 and should be working perfectly.