Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,785,329 Members 38,754 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][Xposed] Google Search / Now API

Tip us?
 
MohammadAG
Old
(Last edited by MohammadAG; 4th December 2013 at 12:13 PM.)
#1  
Recognized Developer - OP
Thanks Meter 4,868
Posts: 1,071
Join Date: Sep 2009
Location: Jerusalem

 
DONATE TO ME
Default [MOD][Xposed] Google Search / Now API

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/comm...earch_now_api/)

Screenshots:


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.m...ooglesearchapi

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.
Follow me on Twitter: @MohammadAG
Google+: https://plus.google.com/103508952817353883168/posts

Check out my Xposed modules.
Send files with Android Beamô on Android 4.1+: File Beam (Touch to Send)
Enable USB Mass Storage Mode on Samsung devices with SG USB Mass Storage Enabler.
Use your flashlight at different brightness levels with Adjustable Torch.
Enable Music Controls on your S-View screen with S-View Music Controls
The Following 101 Users Say Thank You to MohammadAG For This Useful Post: [ Click to Expand ]
 
ktetreault14
Old
#2  
ktetreault14's Avatar
Senior Member
Thanks Meter 1,100
Posts: 2,737
Join Date: Feb 2012
Location: Largo

 
DONATE TO ME
Downloading and trying on note 3 asap

Sent from my SM-N900T
The Following 2 Users Say Thank You to ktetreault14 For This Useful Post: [ Click to Expand ]
 
Cptnodegard
Old
#3  
Senior Member
Thanks Meter 179
Posts: 476
Join Date: Nov 2011
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.
----------------------------------------------------------------------------------------------------------------------
Galaxy S3 i9305, Ripper ROM | Galaxy S II, Chameleon ROM | Apple iPad mini (jailbroken)
 
MohammadAG
Old
#4  
Recognized Developer - OP
Thanks Meter 4,868
Posts: 1,071
Join Date: Sep 2009
Location: Jerusalem

 
DONATE TO ME
Quote:
Originally Posted by Cptnodegard View Post
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.
It needs a permission right now, but I plan to make a Tasker plugin.
Follow me on Twitter: @MohammadAG
Google+: https://plus.google.com/103508952817353883168/posts

Check out my Xposed modules.
Send files with Android Beamô on Android 4.1+: File Beam (Touch to Send)
Enable USB Mass Storage Mode on Samsung devices with SG USB Mass Storage Enabler.
Use your flashlight at different brightness levels with Adjustable Torch.
Enable Music Controls on your S-View screen with S-View Music Controls
The Following 6 Users Say Thank You to MohammadAG For This Useful Post: [ Click to Expand ]
 
Dzakus
Old
(Last edited by Dzakus; 3rd December 2013 at 10:21 PM.)
#5  
Junior Member
Thanks Meter 5
Posts: 14
Join Date: Apr 2011
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
Quote:
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?
 
MohammadAG
Old
#6  
Recognized Developer - OP
Thanks Meter 4,868
Posts: 1,071
Join Date: Sep 2009
Location: Jerusalem

 
DONATE TO ME
Quote:
Originally Posted by Dzakus View Post
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.
Follow me on Twitter: @MohammadAG
Google+: https://plus.google.com/103508952817353883168/posts

Check out my Xposed modules.
Send files with Android Beamô on Android 4.1+: File Beam (Touch to Send)
Enable USB Mass Storage Mode on Samsung devices with SG USB Mass Storage Enabler.
Use your flashlight at different brightness levels with Adjustable Torch.
Enable Music Controls on your S-View screen with S-View Music Controls
The Following 2 Users Say Thank You to MohammadAG For This Useful Post: [ Click to Expand ]
 
Dzakus
Old
#7  
Junior Member
Thanks Meter 5
Posts: 14
Join Date: Apr 2011
Default 2242683

Quote:
Originally Posted by MohammadAG View Post
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 :-/
The Following User Says Thank You to Dzakus For This Useful Post: [ Click to Expand ]
 
joaomgcd
Old
#8  
Junior Member
Thanks Meter 19
Posts: 22
Join Date: Aug 2012
Quote:
Originally Posted by MohammadAG View Post
It needs a permission right now, but I plan to make a Tasker plugin.
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!
The Following 3 Users Say Thank You to joaomgcd For This Useful Post: [ Click to Expand ]
 
MohammadAG
Old
#9  
Recognized Developer - OP
Thanks Meter 4,868
Posts: 1,071
Join Date: Sep 2009
Location: Jerusalem

 
DONATE TO ME
Quote:
Originally Posted by joaomgcd View Post
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
Follow me on Twitter: @MohammadAG
Google+: https://plus.google.com/103508952817353883168/posts

Check out my Xposed modules.
Send files with Android Beamô on Android 4.1+: File Beam (Touch to Send)
Enable USB Mass Storage Mode on Samsung devices with SG USB Mass Storage Enabler.
Use your flashlight at different brightness levels with Adjustable Torch.
Enable Music Controls on your S-View screen with S-View Music Controls
 
joaomgcd
Old
#10  
Junior Member
Thanks Meter 19
Posts: 22
Join Date: Aug 2012
Quote:
Originally Posted by MohammadAG View Post
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!

(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.

The Following 2 Users Say Thank You to joaomgcd For This Useful Post: [ Click to Expand ]
Tags
api, google now, google search, xposed
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes