Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
e922fdc5
Commit
e922fdc5
authored
Sep 21, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Plain Diff
Merge conflict
parents
0addbaa9
8176fb7b
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
259 additions
and
14 deletions
+259
-14
build.gradle
app/build.gradle
+2
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+17
-5
LogFragment.java
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
+1
-0
RootFragment.java
app/src/main/java/com/topjohnwu/magisk/RootFragment.java
+1
-0
WelcomeActivity.java
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
+3
-4
AutoStartReceiver.java
...ava/com/topjohnwu/magisk/receivers/AutoStartReceiver.java
+6
-2
MonitorService.java
...in/java/com/topjohnwu/magisk/services/MonitorService.java
+3
-1
QuickSettingTileService.java
...om/topjohnwu/magisk/services/QuickSettingTileService.java
+2
-1
CustomTileHelper.java
...main/java/com/topjohnwu/magisk/tile/CustomTileHelper.java
+59
-0
PrivateBroadcastReceiver.java
...a/com/topjohnwu/magisk/tile/PrivateBroadcastReceiver.java
+36
-0
PublicBroadcastReceiver.java
...va/com/topjohnwu/magisk/tile/PublicBroadcastReceiver.java
+29
-0
TilePreferenceHelper.java
.../java/com/topjohnwu/magisk/tile/TilePreferenceHelper.java
+26
-0
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+74
-1
No files found.
app/build.gradle
View file @
e922fdc5
...
@@ -35,8 +35,10 @@ dependencies {
...
@@ -35,8 +35,10 @@ dependencies {
compile
'com.android.support:recyclerview-v7:24.2.1'
compile
'com.android.support:recyclerview-v7:24.2.1'
compile
'com.android.support:cardview-v7:24.2.1'
compile
'com.android.support:cardview-v7:24.2.1'
compile
'com.android.support:design:24.2.1'
compile
'com.android.support:design:24.2.1'
compile
'com.github.d8ahazard:BroadcastTileSupportUpdate:master'
compile
'com.jakewharton:butterknife:8.4.0'
compile
'com.jakewharton:butterknife:8.4.0'
compile
'com.github.michalis-vitos:aFileChooser:master'
compile
'com.github.michalis-vitos:aFileChooser:master'
compile
'com.google.code.gson:gson:2.7'
compile
'com.google.code.gson:gson:2.7'
annotationProcessor
'com.jakewharton:butterknife-compiler:8.4.0'
annotationProcessor
'com.jakewharton:butterknife-compiler:8.4.0'
}
}
app/src/main/AndroidManifest.xml
View file @
e922fdc5
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.topjohnwu.magisk"
>
package=
"com.topjohnwu.magisk"
>
<uses-sdk
tools:overrideLibrary=
"com.kcoppock.broadcatsttilesupport"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
...
@@ -20,7 +21,7 @@
...
@@ -20,7 +21,7 @@
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
tools:ignore=
"AllowBackup,GoogleAppIndexingWarning"
>
tools:ignore=
"AllowBackup,GoogleAppIndexingWarning"
>
<service
<service
android:name=
".MonitorService"
android:name=
".
services.
MonitorService"
android:label=
"@string/accessibility_service_name"
android:label=
"@string/accessibility_service_name"
android:permission=
"android.permission.BIND_ACCESSIBILITY_SERVICE"
>
android:permission=
"android.permission.BIND_ACCESSIBILITY_SERVICE"
>
<intent-filter>
<intent-filter>
...
@@ -31,7 +32,7 @@
...
@@ -31,7 +32,7 @@
android:resource=
"@xml/accessibilityservice"
/>
android:resource=
"@xml/accessibilityservice"
/>
</service>
</service>
<service
<service
android:name=
".QuickSettingTileService"
android:name=
".
services.
QuickSettingTileService"
android:icon=
"@drawable/ic_autoroot"
android:icon=
"@drawable/ic_autoroot"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:permission=
"android.permission.BIND_QUICK_SETTINGS_TILE"
>
android:permission=
"android.permission.BIND_QUICK_SETTINGS_TILE"
>
...
@@ -40,6 +41,17 @@
...
@@ -40,6 +41,17 @@
</intent-filter>
</intent-filter>
</service>
</service>
<receiver
android:name=
".tile.PrivateBroadcastReceiver"
android:enabled=
"true"
android:exported=
"true"
>
<intent-filter>
<action
android:name=
"com.topjohnwu.magisk.CUSTOMTILE_ACTION_AUTOROOT"
/>
<action
android:name=
"com.topjohnwu.magisk.CUSTOMTILE_ACTION_DISABLEROOT"
/>
<action
android:name=
"com.topjohnwu.magisk.CUSTOMTILE_ACTION_ENABLEROOT"
/>
</intent-filter>
</receiver>
<activity
<activity
android:name=
".WelcomeActivity"
android:name=
".WelcomeActivity"
android:configChanges=
"orientation|screenSize"
android:configChanges=
"orientation|screenSize"
...
@@ -52,7 +64,7 @@
...
@@ -52,7 +64,7 @@
</activity>
</activity>
<activity
<activity
android:name=
"com.ipaulpro.afilechooser.FileChooserActivity"
android:name=
"com.ipaulpro.afilechooser.FileChooserActivity"
android:enabled=
"
@bool/use_activity
"
android:enabled=
"
true
"
android:exported=
"true"
android:exported=
"true"
android:icon=
"@drawable/ic_chooser"
android:icon=
"@drawable/ic_chooser"
android:label=
"@string/choose_file"
>
android:label=
"@string/choose_file"
>
...
@@ -90,7 +102,7 @@
...
@@ -90,7 +102,7 @@
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/file_paths"
/>
android:resource=
"@xml/file_paths"
/>
</provider>
</provider>
<receiver
android:name=
".
AutoStart
"
>
<receiver
android:name=
".
receivers.AutoStartReceiver
"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
</intent-filter>
</intent-filter>
...
...
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
View file @
e922fdc5
...
@@ -25,6 +25,7 @@ import android.widget.ScrollView;
...
@@ -25,6 +25,7 @@ import android.widget.ScrollView;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.io.File
;
import
java.io.File
;
...
...
app/src/main/java/com/topjohnwu/magisk/RootFragment.java
View file @
e922fdc5
...
@@ -22,6 +22,7 @@ import android.widget.Switch;
...
@@ -22,6 +22,7 @@ import android.widget.Switch;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.services.MonitorService
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
...
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
View file @
e922fdc5
...
@@ -25,6 +25,7 @@ import android.view.View;
...
@@ -25,6 +25,7 @@ import android.view.View;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.services.MonitorService
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -63,10 +64,8 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
...
@@ -63,10 +64,8 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
}
}
}
}
}
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
Utils
.
SetupQuickSettingsTile
(
getApplicationContext
());
Intent
serviceIntent
=
new
Intent
(
this
,
QuickSettingTileService
.
class
);
startService
(
serviceIntent
);
}
if
(
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
if
(
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
requestPermissions
(
new
String
[]{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
},
0
);
requestPermissions
(
new
String
[]{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
},
0
);
...
...
app/src/main/java/com/topjohnwu/magisk/
AutoStart
.java
→
app/src/main/java/com/topjohnwu/magisk/
receivers/AutoStartReceiver
.java
View file @
e922fdc5
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
.
receivers
;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.util.Log
;
import
android.util.Log
;
public
class
AutoStart
extends
BroadcastReceiver
{
import
com.topjohnwu.magisk.services.MonitorService
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
AutoStartReceiver
extends
BroadcastReceiver
{
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Log
.
d
(
"Magisk"
,
"Received Boot call, attempting to start service"
);
Log
.
d
(
"Magisk"
,
"Received Boot call, attempting to start service"
);
Intent
myIntent
=
new
Intent
(
context
,
MonitorService
.
class
);
Intent
myIntent
=
new
Intent
(
context
,
MonitorService
.
class
);
context
.
startService
(
myIntent
);
context
.
startService
(
myIntent
);
Utils
.
SetupQuickSettingsTile
(
context
);
}
}
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/MonitorService.java
→
app/src/main/java/com/topjohnwu/magisk/
services/
MonitorService.java
View file @
e922fdc5
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
.
services
;
import
android.accessibilityservice.AccessibilityService
;
import
android.accessibilityservice.AccessibilityService
;
import
android.accessibilityservice.AccessibilityServiceInfo
;
import
android.accessibilityservice.AccessibilityServiceInfo
;
...
@@ -16,6 +16,8 @@ import android.support.v4.app.NotificationCompat;
...
@@ -16,6 +16,8 @@ import android.support.v4.app.NotificationCompat;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.accessibility.AccessibilityEvent
;
import
android.view.accessibility.AccessibilityEvent
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.WelcomeActivity
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.Set
;
import
java.util.Set
;
...
...
app/src/main/java/com/topjohnwu/magisk/QuickSettingTileService.java
→
app/src/main/java/com/topjohnwu/magisk/
services/
QuickSettingTileService.java
View file @
e922fdc5
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
.
services
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.graphics.drawable.Icon
;
import
android.graphics.drawable.Icon
;
...
@@ -6,6 +6,7 @@ import android.service.quicksettings.Tile;
...
@@ -6,6 +6,7 @@ import android.service.quicksettings.Tile;
import
android.service.quicksettings.TileService
;
import
android.service.quicksettings.TileService
;
import
android.util.Log
;
import
android.util.Log
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
@SuppressLint
(
"NewApi"
)
@SuppressLint
(
"NewApi"
)
...
...
app/src/main/java/com/topjohnwu/magisk/tile/CustomTileHelper.java
0 → 100644
View file @
e922fdc5
package
com
.
topjohnwu
.
magisk
.
tile
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.annotation.NonNull
;
import
com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder
;
import
com.topjohnwu.magisk.R
;
final
public
class
CustomTileHelper
{
/**
* This is the identifier of the custom Broadcast Tile. Whatever action you configured the tile
* for must be used when configuring the tile. For Broadcast tiles, only alphanumeric characters
* (and periods) are allowed. Keep in mind that this excludes underscores.
*/
private
static
final
String
BROADCAST_TILE_IDENTIFIER
=
"com.kcoppock.CUSTOMTILE"
;
/**
* Keeps track of the last known state of the Quick Settings custom tile. There doesn't seem to
* be a way to query the state of the tile.
*/
private
static
final
String
PREF_TILE_SHOWN
=
"com.kcoppock.CUSTOMTILE_SHOWN"
;
private
final
Context
mContext
;
private
final
TilePreferenceHelper
mTilePreferenceHelper
;
CustomTileHelper
(
@NonNull
Context
context
)
{
mContext
=
context
.
getApplicationContext
();
mTilePreferenceHelper
=
new
TilePreferenceHelper
(
mContext
);
}
void
showTile
()
{
mTilePreferenceHelper
.
setBoolean
(
PREF_TILE_SHOWN
,
true
);
// Set up an Intent that will be broadcast by the system, and received by the exported
// PublicBroadcastReceiver.
// Send the update event to the Broadcast Tile. Custom tiles are hidden by default until
// enabled with this broadcast Intent.
mContext
.
sendBroadcast
(
new
BroadcastTileIntentBuilder
(
mContext
,
BROADCAST_TILE_IDENTIFIER
)
.
setVisible
(
true
)
.
build
());
}
void
hideTile
()
{
mTilePreferenceHelper
.
setBoolean
(
PREF_TILE_SHOWN
,
false
);
mContext
.
sendBroadcast
(
new
BroadcastTileIntentBuilder
(
mContext
,
BROADCAST_TILE_IDENTIFIER
)
.
setVisible
(
false
)
.
build
());
}
boolean
isLastTileStateShown
()
{
return
mTilePreferenceHelper
.
getBoolean
(
PREF_TILE_SHOWN
);
}
}
app/src/main/java/com/topjohnwu/magisk/tile/PrivateBroadcastReceiver.java
0 → 100644
View file @
e922fdc5
package
com
.
topjohnwu
.
magisk
.
tile
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.util.Log
;
import
com.topjohnwu.magisk.utils.Utils
;
/**
* Receiver for click events on the custom M Quick Settings tile
*/
public
final
class
PrivateBroadcastReceiver
extends
BroadcastReceiver
{
public
static
final
String
ACTION_AUTOROOT
=
"com.topjohnwu.magisk.CUSTOMTILE_ACTION_AUTOROOT"
;
public
static
final
String
ACTION_DISABLEROOT
=
"com.topjohnwu.magisk.CUSTOMTILE_ACTION_DISABLEROOT"
;
public
static
final
String
ACTION_ENABLEROOT
=
"com.topjohnwu.magisk.CUSTOMTILE_ACTION_ENABLEROOT"
;
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
final
String
action
=
intent
.
getAction
();
Log
.
d
(
"Magisk"
,
"Broadcast Receiver, Made it this far!"
);
if
(
ACTION_AUTOROOT
.
equals
(
action
))
{
Utils
.
toggleAutoRoot
(
true
,
context
);
}
if
(
ACTION_ENABLEROOT
.
equals
(
action
))
{
Utils
.
toggleAutoRoot
(
false
,
context
);
Utils
.
toggleRoot
(
true
);
}
if
(
ACTION_DISABLEROOT
.
equals
(
action
))
{
Utils
.
toggleRoot
(
false
);
}
Utils
.
SetupQuickSettingsTile
(
context
);
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/tile/PublicBroadcastReceiver.java
0 → 100644
View file @
e922fdc5
package
com
.
topjohnwu
.
magisk
.
tile
;
import
android.content.*
;
import
android.widget.Toast
;
/**
* Exported receiver for the custom event on the custom Quick Settings tile
*/
public
final
class
PublicBroadcastReceiver
extends
BroadcastReceiver
{
/**
* The action broadcast from the Quick Settings tile when clicked
*/
public
static
final
String
ACTION_TOAST
=
"com.kcoppock.CUSTOMTILE_ACTION_TOAST"
;
/**
* Constant for the String extra to be displayed in the Toast
*/
public
static
final
String
EXTRA_MESSAGE
=
"com.kcoppock.CUSTOMTILE_EXTRA_MESSAGE"
;
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
final
String
action
=
intent
.
getAction
();
if
(
ACTION_TOAST
.
equals
(
action
))
{
final
String
message
=
intent
.
getStringExtra
(
EXTRA_MESSAGE
);
Toast
.
makeText
(
context
,
message
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/tile/TilePreferenceHelper.java
0 → 100644
View file @
e922fdc5
package
com
.
topjohnwu
.
magisk
.
tile
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.support.annotation.NonNull
;
/**
* Helper class for tracking preference values to keep track of the state of the custom tile
*/
final
public
class
TilePreferenceHelper
{
private
static
final
String
PREFS_NAME
=
"tile_prefs"
;
private
final
SharedPreferences
mSharedPreferences
;
TilePreferenceHelper
(
@NonNull
Context
context
)
{
mSharedPreferences
=
context
.
getSharedPreferences
(
PREFS_NAME
,
Context
.
MODE_PRIVATE
);
}
void
setBoolean
(
@NonNull
String
key
,
boolean
value
)
{
mSharedPreferences
.
edit
().
putBoolean
(
key
,
value
).
apply
();
}
boolean
getBoolean
(
@NonNull
String
key
)
{
return
mSharedPreferences
.
getBoolean
(
key
,
false
);
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
e922fdc5
...
@@ -14,6 +14,7 @@ import android.content.pm.PackageManager;
...
@@ -14,6 +14,7 @@ import android.content.pm.PackageManager;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.provider.DocumentsContract
;
import
android.provider.DocumentsContract
;
...
@@ -27,14 +28,18 @@ import android.util.Log;
...
@@ -27,14 +28,18 @@ import android.util.Log;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.MonitorService
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.module.BaseModule
;
import
com.topjohnwu.magisk.module.BaseModule
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.tile.PrivateBroadcastReceiver
;
import
com.topjohnwu.magisk.services.MonitorService
;
import
com.topjohnwu.magisk.services.QuickSettingTileService
;
import
com.topjohnwu.magisk.tile.CustomTileHelper
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -210,6 +215,74 @@ public class Utils {
...
@@ -210,6 +215,74 @@ public class Utils {
return
value
;
return
value
;
}
}
public
static
void
SetupQuickSettingsTile
(
Context
mContext
)
{
Log
.
d
(
"Magisk"
,
"Utils: SetupQuickSettings called"
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
Intent
serviceIntent
=
new
Intent
(
mContext
,
QuickSettingTileService
.
class
);
mContext
.
startService
(
serviceIntent
);
}
if
(
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
M
)
{
Log
.
d
(
"Magisk"
,
"Utils: Marshmallow build detected"
);
String
mLabelString
;
int
mRootIcon
=
R
.
drawable
.
root
;
int
mAutoRootIcon
=
R
.
drawable
.
ic_autoroot
;
int
mRootsState
=
CheckRootsState
(
mContext
);
Log
.
d
(
"Magisk"
,
"Utils: Root State returned as "
+
mRootsState
);
final
Intent
enableBroadcast
=
new
Intent
(
PrivateBroadcastReceiver
.
ACTION_ENABLEROOT
);
final
Intent
disableBroadcast
=
new
Intent
(
PrivateBroadcastReceiver
.
ACTION_DISABLEROOT
);
final
Intent
autoBroadcast
=
new
Intent
(
PrivateBroadcastReceiver
.
ACTION_AUTOROOT
);
Intent
intent
;
int
mIcon
;
switch
(
mRootsState
)
{
case
2
:
mLabelString
=
"Auto-root"
;
mIcon
=
mAutoRootIcon
;
intent
=
autoBroadcast
;
break
;
case
1
:
mLabelString
=
"Root enabled"
;
mIcon
=
mRootIcon
;
intent
=
enableBroadcast
;
break
;
case
0
:
mLabelString
=
"Root disabled"
;
mIcon
=
mRootIcon
;
intent
=
disableBroadcast
;
break
;
default
:
mLabelString
=
"Root enabled"
;
mIcon
=
mRootIcon
;
intent
=
enableBroadcast
;
break
;
}
Intent
tileConfigurationIntent
=
new
BroadcastTileIntentBuilder
(
mContext
,
"ROOT"
)
.
setLabel
(
mLabelString
)
.
setIconResource
(
mIcon
)
.
setOnClickBroadcast
(
intent
)
.
build
();
mContext
.
sendBroadcast
(
tileConfigurationIntent
);
}
}
// Gets an overall state for the quick settings tile
// 0 for root disabled, 1 for root enabled (no auto), 2 for auto-root
public
static
int
CheckRootsState
(
Context
mContext
)
{
if
(
autoRootEnabled
(
mContext
))
{
return
2
;
}
else
{
if
(
rootEnabled
())
{
return
1
;
}
else
{
return
0
;
}
}
}
// To check if service is enabled
// To check if service is enabled
public
static
boolean
hasServicePermission
(
Context
mContext
)
{
public
static
boolean
hasServicePermission
(
Context
mContext
)
{
int
accessibilityEnabled
=
0
;
int
accessibilityEnabled
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment