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
8176fb7b
Commit
8176fb7b
authored
Sep 20, 2016
by
d8ahazard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP Tile stuff
parent
6a40e181
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
144 additions
and
33 deletions
+144
-33
build.gradle
app/build.gradle
+9
-4
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-2
LogFragment.java
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
+1
-1
WelcomeActivity.java
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
+0
-1
QuickSettingTileService.java
...om/topjohnwu/magisk/services/QuickSettingTileService.java
+1
-1
CustomTileHelper.java
...main/java/com/topjohnwu/magisk/tile/CustomTileHelper.java
+59
-0
PrivateBroadcastReceiver.java
...a/com/topjohnwu/magisk/tile/PrivateBroadcastReceiver.java
+3
-2
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
+13
-22
No files found.
app/build.gradle
View file @
8176fb7b
...
...
@@ -32,11 +32,16 @@ repositories {
dependencies
{
compile
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
compile
'com.android.support:recyclerview-v7:24.2.0'
compile
'com.android.support:cardview-v7:24.2.0'
compile
'com.android.support:design:24.2.0'
compile
'com.android.support:recyclerview-v7:24.2.1'
compile
'com.android.support:cardview-v7: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.github.michalis-vitos:aFileChooser:master'
compile
'com.github.kcoppock:BroadcastTileSupport:master'
annotationProcessor
'com.jakewharton:butterknife-compiler:8.4.0'
}
app/src/main/AndroidManifest.xml
View file @
8176fb7b
...
...
@@ -42,8 +42,9 @@
</service>
<receiver
android:name=
".receivers.PrivateBroadcastReceiver"
android:exported=
"false"
>
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"
/>
...
...
app/src/main/java/com/topjohnwu/magisk/
utils/
LogFragment.java
→
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
View file @
8176fb7b
package
com
.
topjohnwu
.
magisk
.
utils
;
package
com
.
topjohnwu
.
magisk
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
...
...
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
View file @
8176fb7b
...
...
@@ -24,7 +24,6 @@ import android.view.MenuItem;
import
android.view.View
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.utils.LogFragment
;
import
com.topjohnwu.magisk.services.MonitorService
;
import
com.topjohnwu.magisk.utils.Utils
;
...
...
app/src/main/java/com/topjohnwu/magisk/services/QuickSettingTileService.java
View file @
8176fb7b
...
...
@@ -33,7 +33,7 @@ public class QuickSettingTileService extends TileService {
Icon
iconAuto
=
Icon
.
createWithResource
(
getApplicationContext
(),
R
.
drawable
.
ic_autoroot
);
Tile
tile
=
this
.
getQsTile
();
boolean
autoRootStatus
=
Utils
.
autoRootEnabled
(
getApplicationContext
());
boolean
rootStatus
=
Utils
.
root
Status
();
boolean
rootStatus
=
Utils
.
root
Enabled
();
Log
.
d
(
"Magisk"
,
"QST: Auto and root are "
+
autoRootStatus
+
" and "
+
rootStatus
);
if
(
autoRootStatus
)
{
tile
.
setLabel
(
"Auto-root"
);
...
...
app/src/main/java/com/topjohnwu/magisk/tile/CustomTileHelper.java
0 → 100644
View file @
8176fb7b
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/
receivers
/PrivateBroadcastReceiver.java
→
app/src/main/java/com/topjohnwu/magisk/
tile
/PrivateBroadcastReceiver.java
View file @
8176fb7b
package
com
.
topjohnwu
.
magisk
.
receivers
;
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
;
...
...
@@ -18,7 +19,7 @@ public final class PrivateBroadcastReceiver extends BroadcastReceiver {
@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
);
}
...
...
app/src/main/java/com/topjohnwu/magisk/tile/PublicBroadcastReceiver.java
0 → 100644
View file @
8176fb7b
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 @
8176fb7b
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 @
8176fb7b
...
...
@@ -35,9 +35,10 @@ import com.topjohnwu.magisk.ReposFragment;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.
receivers
.PrivateBroadcastReceiver
;
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.JSONObject
;
...
...
@@ -69,12 +70,12 @@ import javax.crypto.spec.DESKeySpec;
public
class
Utils
{
public
static
int
magiskVersion
,
remoteMagiskVersion
=
-
1
,
remoteAppVersion
=
-
1
;
p
rivate
static
String
magiskLink
,
magiskChangelog
,
appChangelog
,
appLink
,
phhLink
,
supersuLink
;
p
ublic
static
String
magiskLink
,
magiskChangelog
,
appChangelog
,
appLink
,
phhLink
,
supersuLink
;
private
static
final
String
TAG
=
"Magisk"
;
p
rivate
static
final
String
MAGISK_PATH
=
"/magisk"
;
p
rivate
static
final
String
MAGISK_CACHE_PATH
=
"/cache/magisk"
;
p
rivate
static
final
String
UPDATE_JSON
=
"https://raw.githubusercontent.com/topjohnwu/MagiskManager/updates/magisk_update.json"
;
p
ublic
static
final
String
MAGISK_PATH
=
"/magisk"
;
p
ublic
static
final
String
MAGISK_CACHE_PATH
=
"/cache/magisk"
;
p
ublic
static
final
String
UPDATE_JSON
=
"https://raw.githubusercontent.com/topjohnwu/MagiskManager/updates/magisk_update.json"
;
public
static
boolean
fileExist
(
String
path
)
{
List
<
String
>
ret
;
...
...
@@ -195,15 +196,18 @@ public class Utils {
}
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
);
...
...
@@ -232,12 +236,13 @@ public class Utils {
break
;
}
Intent
tileConfigurationIntent
=
new
BroadcastTileIntentBuilder
(
mContext
,
"
com.magisk.ROOT_TILE
"
)
Intent
tileConfigurationIntent
=
new
BroadcastTileIntentBuilder
(
mContext
,
"
ROOT
"
)
.
setLabel
(
mLabelString
)
.
setIconResource
(
mIcon
)
.
setOnClickBroadcast
(
intent
)
.
build
();
mContext
.
sendBroadcast
(
tileConfigurationIntent
);
}
}
...
...
@@ -248,7 +253,7 @@ public class Utils {
if
(
autoRootEnabled
(
mContext
))
{
return
2
;
}
else
{
if
(
root
Status
())
{
if
(
root
Enabled
())
{
return
1
;
}
else
{
...
...
@@ -557,21 +562,7 @@ public class Utils {
}
}
public
static
boolean
rootStatus
()
{
try
{
String
rootStatus
=
Shell
.
su
(
"getprop magisk.root"
).
toString
();
String
fuckyeah
=
Shell
.
sh
(
"which su"
).
toString
();
Log
.
d
(
"Magisk"
,
"Utils: Rootstatus Checked, "
+
rootStatus
+
" and "
+
fuckyeah
);
if
(
rootStatus
.
contains
(
"0"
)
&&
!
fuckyeah
.
contains
(
"su"
))
{
return
false
;
}
else
{
return
true
;
}
}
catch
(
NullPointerException
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
public
static
boolean
isMyServiceRunning
(
Class
<?>
serviceClass
,
Context
context
)
{
ActivityManager
manager
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
...
...
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