├── gradle.properties
├── assets
└── xposed_init
├── ic_launcher-web.png
├── res
├── xml
│ └── backupscheme.xml
├── mipmap-hdpi
│ └── ic_launcher.png
├── mipmap-mdpi
│ └── ic_launcher.png
├── mipmap-xhdpi
│ └── ic_launcher.png
├── mipmap-xxhdpi
│ └── ic_launcher.png
├── mipmap-xxxhdpi
│ └── ic_launcher.png
├── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── styles.xml
│ └── strings.xml
└── layout
│ └── activity_settings.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── java
└── com
│ └── sabik
│ └── assistantenabler
│ ├── ChangeSettingsReceiver.java
│ ├── Settings.java
│ └── AssistantEnabler.java
├── LICENSE
├── README.md
├── AndroidManifest.xml
├── gradlew.bat
├── .gitignore
├── gradlew
└── AssistantEnabler.iml
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx2048M
2 |
--------------------------------------------------------------------------------
/assets/xposed_init:
--------------------------------------------------------------------------------
1 | com.sabik.assistantenabler.AssistantEnabler
--------------------------------------------------------------------------------
/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sabissimo/AssistantEnabler/HEAD/ic_launcher-web.png
--------------------------------------------------------------------------------
/res/xml/backupscheme.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sabissimo/AssistantEnabler/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sabissimo/AssistantEnabler/HEAD/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sabissimo/AssistantEnabler/HEAD/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sabissimo/AssistantEnabler/HEAD/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sabissimo/AssistantEnabler/HEAD/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sabissimo/AssistantEnabler/HEAD/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #03A9F4
4 | #0288D1
5 | #e7524b
6 |
7 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Tue Oct 4 00:20:00 EEST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip
7 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/java/com/sabik/assistantenabler/ChangeSettingsReceiver.java:
--------------------------------------------------------------------------------
1 | package com.sabik.assistantenabler;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.os.Bundle;
8 |
9 | public class ChangeSettingsReceiver extends BroadcastReceiver {
10 | public ChangeSettingsReceiver() {
11 | }
12 |
13 | @Override
14 | public void onReceive(Context context, Intent intent) {
15 |
16 | final SharedPreferences prefs = context.getSharedPreferences("preferences",Context.MODE_WORLD_READABLE);
17 | final SharedPreferences.Editor editor = prefs.edit();
18 |
19 | if(intent.getAction().equals("com.sabik.assistantenabler.CHANGE_SETTINGS"))
20 | {
21 | Bundle extras = intent.getExtras();
22 | String settingName = extras.getString("setting");
23 | Boolean settingValue = extras.getBoolean("value", false);
24 | if(settingName != null)
25 | switch(settingName){
26 | case "googleNowEnabled":
27 | case "assistantEnabled":
28 | case "enableOKGoogleEverywhere":
29 | editor.putBoolean(settingName,settingValue);
30 | editor.apply();
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Assistant Enabler
5 | Enable Google Assistant in Marshmallow ROMs
6 | Enable Assistant
7 | Hide from launcher
8 | Hide application icon from launcher
9 | Enable Google Assistant
10 | Enable Google Now (requires restart)
11 | Enable Google Now in not eligible countries
12 | Donate
13 | If you would like to support this project\'s further development, the creator of this project or the continuous maintenance of this project, feel free to donate.
14 | Enable OK Google everywhere
15 | Enable OK Google everywhere, even with screen off (might cause some battery draining). After changing this, plug/unplug your charger for setting to kick in.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016, Sabik
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * Neither the name of AssistantEnabler nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Assistant Enabler
2 |
3 | Xposed module: Enable Google Assistant in Marshmallow ROMs
4 |
5 | Enable/disable Google Assistant without restart
6 | Bonus feature: Enable Google Now in unsupported countries*
7 |
8 | ## How to install
9 |
10 | Simply grab the module from [the Xposed Module Repository](http://repo.xposed.info/module/com.sabik.assistantenabler).
11 |
12 | To make a build build on your own device from source, feel free to clone this repository and use Gradle for that. You can read more about how to build locally on [Android Developers](https://developer.android.com/tools/building/building-cmdline.html) or just Google around.
13 |
14 |
15 | #After 6.10 update "OK Google" detection is working as intended without any interference, so just go ahead in google settings and configure voice there, it works now!
16 | #For versions below 6.10 use following guide:
17 | #To use "OK Google" hotword you need to do following:
18 | * 1. Update Google App to the latest version (at least 6.8 beta)
19 | * 2. Disable assistant in module
20 | * 3. Configure "OK Google" detection and voice pattern
21 | * 4. Enable assistant in module
22 | * 5. Say "OK Google"
23 | * 6. ....
24 | * 7. Profit!
25 |
26 | # Enable "OK Google" with screen off (even when not charging)
27 | * After enabling it in module settings, plug/unplug your charger for settings to kick in
28 |
29 | # In order to enable Google Now in unsupported country, these steps are required:
30 | * 1) Enable Assistant Enabler module in Xposed Installer
31 | * 2) In Assistant Enabler settings, enable "Enable Google Now"
32 | * 3) Reboot (after rebooting your phone carrier will be identified as US Verizon)
33 | * 4) Either remove your sim, or put your phone in airplane mode
34 | * 5) Enable Wifi
35 | * 6) If google account is added to the phone already - remove it
36 | * 7) Launch google app and login to your google account
37 | * 8) Opt-in to Google Now
38 | * 9) PROFIT!
39 |
40 | P.S. After these steps you can disable "Enable Google Now" setting in Assistant Enabler module, if you don't want your carrier to be identified as VZW. Google Now will continue working.
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
17 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .idea
16 | .gradle
17 | .classpath
18 | .settings/
19 | .loadpath
20 |
21 | # External tool builders
22 | .externalToolBuilders/
23 |
24 | # Locally stored "Eclipse launch configurations"
25 | *.launch
26 |
27 | # CDT-specific
28 | .cproject
29 |
30 | # PDT-specific
31 | .buildpath
32 |
33 |
34 | #################
35 | ## Visual Studio
36 | #################
37 |
38 | ## Ignore Visual Studio temporary files, build results, and
39 | ## files generated by popular Visual Studio add-ons.
40 |
41 | # User-specific files
42 | *.suo
43 | *.user
44 | *.sln.docstates
45 |
46 | # Build results
47 |
48 | [Dd]ebug/
49 | [Rr]elease/
50 | x64/
51 | build/
52 | [Bb]in/
53 | [Oo]bj/
54 |
55 | # MSTest test Results
56 | [Tt]est[Rr]esult*/
57 | [Bb]uild[Ll]og.*
58 |
59 | *_i.c
60 | *_p.c
61 | *.ilk
62 | *.meta
63 | *.obj
64 | *.pch
65 | *.pdb
66 | *.pgc
67 | *.pgd
68 | *.rsp
69 | *.sbr
70 | *.tlb
71 | *.tli
72 | *.tlh
73 | *.tmp
74 | *.tmp_proj
75 | *.log
76 | *.vspscc
77 | *.vssscc
78 | .builds
79 | *.pidb
80 | *.log
81 | *.scc
82 |
83 | # Visual C++ cache files
84 | ipch/
85 | *.aps
86 | *.ncb
87 | *.opensdf
88 | *.sdf
89 | *.cachefile
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 |
103 | # TeamCity is a build add-in
104 | _TeamCity*
105 |
106 | # DotCover is a Code Coverage Tool
107 | *.dotCover
108 |
109 | # NCrunch
110 | *.ncrunch*
111 | .*crunch*.local.xml
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.Publish.xml
131 | *.pubxml
132 | *.publishproj
133 |
134 | # NuGet Packages Directory
135 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
136 | #packages/
137 |
138 | # Windows Azure Build Output
139 | csx
140 | *.build.csdef
141 |
142 | # Windows Store app package directory
143 | AppPackages/
144 |
145 | # Others
146 | sql/
147 | *.Cache
148 | ClientBin/
149 | [Ss]tyle[Cc]op.*
150 | ~$*
151 | *~
152 | *.dbmdl
153 | *.[Pp]ublish.xml
154 | *.pfx
155 | *.publishsettings
156 |
157 | # RIA/Silverlight projects
158 | Generated_Code/
159 |
160 | # Backup & report files from converting an old project file to a newer
161 | # Visual Studio version. Backup files are not needed, because we have git ;-)
162 | _UpgradeReport_Files/
163 | Backup*/
164 | UpgradeLog*.XML
165 | UpgradeLog*.htm
166 |
167 | # SQL Server files
168 | App_Data/*.mdf
169 | App_Data/*.ldf
170 |
171 | #############
172 | ## Windows detritus
173 | #############
174 |
175 | # Windows image file caches
176 | Thumbs.db
177 | ehthumbs.db
178 |
179 | # Folder config file
180 | Desktop.ini
181 |
182 | # Recycle Bin used on file shares
183 | $RECYCLE.BIN/
184 |
185 | # Mac crap
186 | .DS_Store
187 |
188 |
189 | #############
190 | ## Python
191 | #############
192 |
193 | *.py[cod]
194 |
195 | # Packages
196 | *.egg
197 | *.egg-info
198 | dist/
199 | build/
200 | eggs/
201 | parts/
202 | var/
203 | sdist/
204 | develop-eggs/
205 | .installed.cfg
206 |
207 | # Installer logs
208 | pip-log.txt
209 |
210 | # Unit test / coverage reports
211 | .coverage
212 | .tox
213 |
214 | #Translations
215 | *.mo
216 |
217 | #Mr Developer
218 | .mr.developer.cfg
219 |
--------------------------------------------------------------------------------
/java/com/sabik/assistantenabler/Settings.java:
--------------------------------------------------------------------------------
1 | package com.sabik.assistantenabler;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.content.pm.PackageManager;
8 | import android.net.Uri;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.os.Bundle;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.CompoundButton;
14 | import android.widget.Switch;
15 |
16 | public class Settings extends AppCompatActivity {
17 |
18 | public Context context;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_settings);
24 |
25 | final SharedPreferences prefs = getSharedPreferences("preferences",MODE_WORLD_READABLE);
26 | final SharedPreferences.Editor editor = prefs.edit();
27 | context = getApplicationContext();
28 | Switch assistantEnabled = (Switch) findViewById(R.id.assistantEnabled);
29 | Switch enableOKGoogleEverywhere = (Switch) findViewById(R.id.enableOKGoogleEverywhere);
30 | Switch googleNowEnabled = (Switch) findViewById(R.id.googleNowEnabled);
31 | Switch hiddenIcon = (Switch) findViewById(R.id.hiddenIcon);
32 | Button donateButton = (Button) findViewById(R.id.donateButton);
33 |
34 | if (googleNowEnabled!=null) {
35 | googleNowEnabled.setChecked(prefs.getBoolean("googleNowEnabled",false));
36 | googleNowEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
37 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
38 |
39 | editor.putBoolean("googleNowEnabled", isChecked);
40 | editor.apply();
41 |
42 | }
43 | });
44 | }
45 |
46 | if (assistantEnabled!=null) {
47 | assistantEnabled.setChecked(prefs.getBoolean("assistantEnabled",true));
48 | assistantEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
49 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
50 |
51 | editor.putBoolean("assistantEnabled", isChecked);
52 | editor.apply();
53 |
54 | }
55 | });
56 | }
57 |
58 | if (enableOKGoogleEverywhere!=null) {
59 | enableOKGoogleEverywhere.setChecked(prefs.getBoolean("enableOKGoogleEverywhere",false));
60 | enableOKGoogleEverywhere.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
61 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
62 |
63 | editor.putBoolean("enableOKGoogleEverywhere", isChecked);
64 | editor.apply();
65 |
66 | }
67 | });
68 | }
69 |
70 | if (hiddenIcon!=null) {
71 | hiddenIcon.setChecked(prefs.getBoolean("hiddenIcon",false));
72 | hiddenIcon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
73 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
74 |
75 | PackageManager packageManager = context.getPackageManager();
76 | int state = isChecked ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
77 | : PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
78 | String settings = BuildConfig.APPLICATION_ID + ".Preferences";
79 | ComponentName alias = new ComponentName(context, settings);
80 | packageManager.setComponentEnabledSetting(alias, state,
81 | PackageManager.DONT_KILL_APP);
82 |
83 | editor.putBoolean("hiddenIcon", isChecked);
84 | editor.apply();
85 |
86 | }
87 | });
88 | }
89 |
90 | if (donateButton!=null){
91 | donateButton.setOnClickListener(new View.OnClickListener() {
92 |
93 | public void onClick(View v) {
94 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.me/Sabissimo")));
95 | }
96 | });
97 | }
98 |
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/res/layout/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
30 |
31 |
40 |
41 |
49 |
50 |
59 |
60 |
68 |
69 |
78 |
79 |
87 |
88 |
97 |
98 |
106 |
107 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/AssistantEnabler.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/java/com/sabik/assistantenabler/AssistantEnabler.java:
--------------------------------------------------------------------------------
1 | package com.sabik.assistantenabler;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.os.BaseBundle;
7 | import android.os.BatteryManager;
8 | import android.os.Build;
9 | import android.util.Log;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Arrays;
13 | import java.util.List;
14 | import java.util.Objects;
15 |
16 | import de.robv.android.xposed.IXposedHookLoadPackage;
17 | import de.robv.android.xposed.IXposedHookZygoteInit;
18 | import de.robv.android.xposed.XC_MethodHook;
19 | import de.robv.android.xposed.XC_MethodReplacement;
20 | import de.robv.android.xposed.XSharedPreferences;
21 | import de.robv.android.xposed.XposedHelpers;
22 | import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
23 |
24 | import static de.robv.android.xposed.XposedBridge.log;
25 | import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
26 | import static de.robv.android.xposed.XposedHelpers.findClass;
27 | import static de.robv.android.xposed.XposedHelpers.getObjectField;
28 |
29 | public class AssistantEnabler implements IXposedHookZygoteInit, IXposedHookLoadPackage {
30 |
31 | private XSharedPreferences prefs;
32 | private static final String GOOGLE_PACKAGE_NAME = "com.google.android.googlequicksearchbox";
33 | private static final String GSA_PACKAGE = "com.google.android.apps.gsa";
34 | private static final String TELEPHONY_CLASS = "android.telephony.TelephonyManager";
35 | private static final List NOW_PACKAGE_NAMES = new ArrayList<>(Arrays.asList("com.google.android.gms", "com.google.android.apps.maps"));
36 | private String[] detectionMethods;
37 | private String assistantClassName;
38 | private String languageClassName = "";
39 | private String languageMethodName = "";
40 | private String prefsClassName;
41 | private Boolean baseBundleHookNeeded = false;
42 |
43 | @Override
44 | public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable {
45 | prefs = new XSharedPreferences(AssistantEnabler.class.getPackage().getName(), "preferences");
46 | prefs.makeWorldReadable();
47 | }
48 |
49 | @Override
50 | public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
51 | prefs.reload();
52 | if (GOOGLE_PACKAGE_NAME.equals(lpparam.packageName)) {
53 | try {
54 | Boolean assistantHooksNeeded = checkVersion(lpparam);
55 | if(assistantHooksNeeded){
56 | Class assistantClass = findClass(GSA_PACKAGE + assistantClassName, lpparam.classLoader);
57 | Class prefsClass = findClass(GSA_PACKAGE + prefsClassName, lpparam.classLoader);
58 | Class systemPropClass = findClass("android.os.SystemProperties", lpparam.classLoader);
59 |
60 | // Spoof_hotword value in bundles so that the Setup Ok Google screen never shows up, relevant for versions lower than 6.10
61 | if(baseBundleHookNeeded){
62 | findAndHookMethod(BaseBundle.class, "getBoolean", String.class, boolean.class, baseBundleHook);
63 | }
64 |
65 | // Spoof build.prop values
66 | findAndHookMethod(systemPropClass, "getBoolean", String.class, boolean.class, systemPropHook);
67 |
68 | // Spoof opa-related values in config file
69 | // TODO: Find a way to make them name-independent
70 | findAndHookMethod(prefsClass, "getBoolean", String.class, boolean.class, prefsHook);
71 |
72 | // TODO: Find a way to make them name-independent
73 | for (String method : detectionMethods)
74 | findAndHookMethod(assistantClass, method, detectionMethodHook);
75 | }
76 |
77 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
78 | if(!Objects.equals(languageClassName, "")) {
79 | Class languageClass = findClass(GSA_PACKAGE + languageClassName, lpparam.classLoader);
80 | findAndHookMethod(languageClass, languageMethodName, languageHook);
81 | Log.d("sabissimo","all good");
82 | }
83 | }
84 |
85 | // If the power has disconnected, tell Google it has connected instead
86 | findAndHookMethod(Intent.class, "getAction", intentHook1);
87 |
88 | // If Google asks status for BATTERY_CHANGED, tell it it's charging
89 | findAndHookMethod(Intent.class, "getIntExtra", String.class, int.class, intentHook2);
90 | } catch (Throwable t) {
91 | log(t);
92 | }
93 | }
94 | if (NOW_PACKAGE_NAMES.contains(lpparam.packageName) && prefs.getBoolean("googleNowEnabled", false)){
95 | try{
96 | findAndHookMethod(TELEPHONY_CLASS, lpparam.classLoader, "getSimOperator", nowOperatorCodeHook);
97 | findAndHookMethod(TELEPHONY_CLASS, lpparam.classLoader, "getSimCountryIso", nowCountryISOHook);
98 | findAndHookMethod(TELEPHONY_CLASS, lpparam.classLoader, "getSimOperatorName", nowOperatorNameHook);
99 | }
100 | catch (Throwable t){
101 | log(t);
102 | }
103 | }
104 | }
105 |
106 | private Boolean checkVersion(LoadPackageParam lpparam) throws PackageManager.NameNotFoundException {
107 |
108 | Object activityThread = XposedHelpers.callStaticMethod(XposedHelpers.findClass("android.app.ActivityThread", null), "currentActivityThread");
109 | Context context = (Context) XposedHelpers.callMethod(activityThread, "getSystemContext");
110 | String versionName = context.getPackageManager().getPackageInfo(lpparam.packageName, 0).versionName;
111 |
112 | if (versionName.matches("6.6.*")) {
113 | assistantClassName = ".assistant.a.e";
114 | detectionMethods = new String[] {"oZ", "pb"};
115 | prefsClassName = ".search.core.preferences.bf";
116 | baseBundleHookNeeded = true;
117 | } else if (versionName.matches("6.7.*")) {
118 | assistantClassName = ".assistant.a.e";
119 | detectionMethods = new String[] {"pb", "pd"};
120 | prefsClassName = ".search.core.preferences.bg";
121 | baseBundleHookNeeded = true;
122 | } else if (versionName.matches("6.8.*")) {
123 | assistantClassName = ".assistant.a.e";
124 | detectionMethods = new String[] {"pT", "pV"};
125 | prefsClassName = ".search.core.preferences.bg";
126 | baseBundleHookNeeded = true;
127 | } else if (versionName.matches("6.9.*")) {
128 | assistantClassName = ".assistant.shared.f";
129 | detectionMethods = new String[] {"ro", "rq", "rr"};
130 | prefsClassName = ".search.core.preferences.bk";
131 | baseBundleHookNeeded = true;
132 | } else if (versionName.matches("6.10.*")) {
133 | assistantClassName = ".assistant.shared.h";
134 | detectionMethods = new String[] {"rC", "rE", "rF"};
135 | prefsClassName = ".search.core.preferences.bl";
136 | languageClassName = "";
137 | } else if (versionName.matches("6.11.13.*")||versionName.matches("6.11.15.*")||versionName.matches("6.11.16.*")) {
138 | assistantClassName = ".assistant.shared.h";
139 | detectionMethods = new String[] {"sb", "sd", "se"};
140 | prefsClassName = ".search.core.preferences.bl";
141 | } else if (versionName.matches("6.11.*")) {
142 | assistantClassName = ".assistant.shared.h";
143 | detectionMethods = new String[] {"sc", "se", "sf"};
144 | prefsClassName = ".search.core.preferences.bl";
145 | } else if (versionName.matches("6.12.*")) {
146 | assistantClassName = ".assistant.shared.i";
147 | detectionMethods = new String[] {"rS", "rU", "rV"};
148 | prefsClassName = ".search.core.preferences.bl";
149 | } else if (versionName.matches("6.13.*")) {
150 | assistantClassName = ".assistant.shared.i";
151 | detectionMethods = new String[] {"rU", "rX", "rY"};
152 | prefsClassName = ".search.core.preferences.bl";
153 | } else if (versionName.matches("6.14.*")) {
154 | languageClassName = ".assistant.shared.o";
155 | languageMethodName = "sr";
156 | return false;
157 | } else if (versionName.matches("6.15.*")) {
158 | languageClassName = ".assistant.shared.o";
159 | languageMethodName = "sz";
160 | return false;
161 | }
162 |
163 | return true;
164 | }
165 |
166 | private XC_MethodReplacement nowOperatorCodeHook = new XC_MethodReplacement() {
167 | @Override
168 | protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
169 | return "310004";
170 | }
171 | };
172 |
173 | private XC_MethodReplacement nowCountryISOHook = new XC_MethodReplacement() {
174 | @Override
175 | protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
176 | return "us";
177 | }
178 | };
179 |
180 | private XC_MethodReplacement nowOperatorNameHook = new XC_MethodReplacement() {
181 | @Override
182 | protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
183 | return "Verizon";
184 | }
185 | };
186 |
187 | private XC_MethodReplacement detectionMethodHook = new XC_MethodReplacement() {
188 | @Override
189 | protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
190 | prefs.reload();
191 | return prefs.getBoolean("assistantEnabled", true);
192 | }
193 | };
194 |
195 | private XC_MethodHook prefsHook = new XC_MethodHook() {
196 | @Override
197 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
198 | String key = (String) param.args[0];
199 | if (key.equals("key_opa_eligible")) {
200 | prefs.reload();
201 | if (prefs.getBoolean("assistantEnabled", true))
202 | param.setResult(true);
203 | }
204 | }
205 | };
206 |
207 | private XC_MethodHook baseBundleHook = new XC_MethodHook() {
208 | @Override
209 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
210 | String key = (String) param.args[0];
211 | if (key.equals("from_hotword")) {
212 | prefs.reload();
213 | if (prefs.getBoolean("assistantEnabled", true))
214 | param.setResult(false);
215 | }
216 | }
217 | };
218 |
219 | private XC_MethodHook systemPropHook = new XC_MethodHook() {
220 | @Override
221 | protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
222 | String key = (String) param.args[0];
223 | if (key.equals("ro.opa.eligible_device")) {
224 | prefs.reload();
225 | if (prefs.getBoolean("assistantEnabled", true))
226 | param.setResult(true);
227 | }
228 | }
229 | };
230 |
231 | private XC_MethodHook intentHook1 = new XC_MethodHook() {
232 | @Override
233 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
234 | String action = (String) getObjectField(param.thisObject, "mAction");
235 | if (Intent.ACTION_POWER_DISCONNECTED.equals(action)) {
236 | prefs.reload();
237 | if (prefs.getBoolean("enableOKGoogleEverywhere", false))
238 | param.setResult(Intent.ACTION_POWER_CONNECTED);
239 | }
240 | }
241 | };
242 |
243 | private XC_MethodHook intentHook2 = new XC_MethodHook() {
244 | @Override
245 | protected void afterHookedMethod(MethodHookParam param) throws Throwable {
246 | String action = (String) getObjectField(param.thisObject, "mAction");
247 | String key = (String) param.args[0];
248 | if (Intent.ACTION_BATTERY_CHANGED.equals(action) && key.equals(BatteryManager.EXTRA_STATUS)) {
249 | prefs.reload();
250 | if (prefs.getBoolean("enableOKGoogleEverywhere", false))
251 | param.setResult(BatteryManager.BATTERY_STATUS_CHARGING);
252 | }
253 | }
254 | };
255 |
256 | private XC_MethodHook languageHook = new XC_MethodHook() {
257 | @Override
258 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
259 | prefs.reload();
260 | if (prefs.getBoolean("assistantEnabled", true))
261 | param.setResult("en-US");
262 | }
263 | };
264 |
265 | }
--------------------------------------------------------------------------------