Post Reply

[MOD][Xposed] Google Search / Now API

OP MohammadAG

3rd December 2013, 09:22 PM   |  #1  
OP Recognized Developer
Flag Jerusalem
Thanks Meter: 5,018
 
1,073 posts
Join Date:Joined: Sep 2009
Donate to Me
More
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.
Last edited by MohammadAG; 4th December 2013 at 12:13 PM.
The Following 104 Users Say Thank You to MohammadAG For This Useful Post: [ View ]
3rd December 2013, 09:32 PM   |  #2  
ktetreault14's Avatar
Senior Member
Flag Largo
Thanks Meter: 1,102
 
2,749 posts
Join Date:Joined: Feb 2012
Donate to Me
More
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: [ View ]
3rd December 2013, 09:50 PM   |  #3  
Senior Member
Thanks Meter: 179
 
476 posts
Join Date:Joined: Nov 2011
More
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.
3rd December 2013, 09:54 PM   |  #4  
OP Recognized Developer
Flag Jerusalem
Thanks Meter: 5,018
 
1,073 posts
Join Date:Joined: Sep 2009
Donate to Me
More
Quote:
Originally Posted by Cptnodegard

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.
The Following 6 Users Say Thank You to MohammadAG For This Useful Post: [ View ]
3rd December 2013, 10:12 PM   |  #5  
Junior Member
Thanks Meter: 5
 
14 posts
Join Date:Joined: 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?
Last edited by Dzakus; 3rd December 2013 at 10:21 PM.
3rd December 2013, 10:23 PM   |  #6  
OP Recognized Developer
Flag Jerusalem
Thanks Meter: 5,018
 
1,073 posts
Join Date:Joined: Sep 2009
Donate to Me
More
Quote:
Originally Posted by Dzakus

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.
The Following 2 Users Say Thank You to MohammadAG For This Useful Post: [ View ]
3rd December 2013, 10:50 PM   |  #7  
Junior Member
Thanks Meter: 5
 
14 posts
Join Date:Joined: Apr 2011
2242683
Quote:
Originally Posted by MohammadAG

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: [ View ]
3rd December 2013, 11:46 PM   |  #8  
Junior Member
Thanks Meter: 20
 
22 posts
Join Date:Joined: Aug 2012
Quote:
Originally Posted by MohammadAG

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: [ View ]
4th December 2013, 12:35 AM   |  #9  
OP Recognized Developer
Flag Jerusalem
Thanks Meter: 5,018
 
1,073 posts
Join Date:Joined: Sep 2009
Donate to Me
More
Quote:
Originally Posted by joaomgcd

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
4th December 2013, 11:59 AM   |  #10  
Junior Member
Thanks Meter: 20
 
22 posts
Join Date:Joined: Aug 2012
Quote:
Originally Posted by MohammadAG

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 3 Users Say Thank You to joaomgcd For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
api, google now, google search, xposed
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Xposed Framework Modules by ThreadRank