You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Refactor, cleanup, backstack works
This commit is contained in:
@@ -25,7 +25,7 @@ import com.topjohnwu.magisk.utils.Utils;
|
||||
import java.util.Set;
|
||||
|
||||
public class MonitorService extends AccessibilityService {
|
||||
private static final String TAG = "Magisk";
|
||||
private static final String TAG = "MonitorService";
|
||||
private Boolean disableroot;
|
||||
|
||||
@Override
|
||||
@@ -70,10 +70,8 @@ public class MonitorService extends AccessibilityService {
|
||||
if (isActivity) {
|
||||
Logger.dh("MonitorService: CurrentActivity: " + componentName.getPackageName());
|
||||
String mPackage = componentName.getPackageName();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
if (prefs.getBoolean("autoRootEnable", false)) {
|
||||
|
||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||
Set<String> setBlackList = prefs.getStringSet("auto_blacklist", null);
|
||||
|
||||
if (setBlackList != null) {
|
||||
@@ -153,7 +151,7 @@ public class MonitorService extends AccessibilityService {
|
||||
new NotificationCompat.Builder(getApplicationContext())
|
||||
.setSmallIcon(disableroot ? R.drawable.ic_stat_notification_autoroot_off : R.drawable.ic_stat_notification_autoroot_on)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setContentTitle("Auto-root status changed")
|
||||
.setContentTitle(getApplicationContext().getString(R.string.auto_toggle) + " status changed")
|
||||
.setContentText(rootMessage);
|
||||
int mNotificationId = 1;
|
||||
mNotifyMgr.notify(mNotificationId, mBuilder.build());
|
||||
|
||||
@@ -7,15 +7,11 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.IBinder;
|
||||
import android.service.quicksettings.Tile;
|
||||
|
||||
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileServiceCompat extends Service {
|
||||
private static BroadcastReceiver clickTileReceiver;
|
||||
|
||||
@@ -46,7 +42,7 @@ public class TileServiceCompat extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
root = Utils.rootEnabled();
|
||||
autoRoot = Utils.autoRootEnabled(getApplicationContext());
|
||||
autoRoot = Utils.autoToggleEnabled(getApplicationContext());
|
||||
updateTile();
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
@@ -80,7 +76,7 @@ public class TileServiceCompat extends Service {
|
||||
private void onLongClick() {
|
||||
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||
sendBroadcast(it);
|
||||
Utils.toggleAutoRoot(!Utils.autoRootEnabled(getApplicationContext()),getApplicationContext());
|
||||
Utils.toggleAutoRoot(!Utils.autoToggleEnabled(getApplicationContext()),getApplicationContext());
|
||||
}
|
||||
|
||||
public static boolean openApp(Context context, String packageName) {
|
||||
@@ -99,7 +95,7 @@ public class TileServiceCompat extends Service {
|
||||
private void updateTile() {
|
||||
BroadcastTileIntentBuilder broadcastTileIntentBuilder = new BroadcastTileIntentBuilder(this, TILE_ID);
|
||||
if (autoRoot) {
|
||||
broadcastTileIntentBuilder.setLabel("Auto-root");
|
||||
broadcastTileIntentBuilder.setLabel(getApplicationContext().getString(R.string.auto_toggle));
|
||||
broadcastTileIntentBuilder.setIconResource(R.drawable.ic_autoroot_white);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -42,12 +42,12 @@ public class TileServiceNewApi extends android.service.quicksettings.TileService
|
||||
Icon iconRoot = Icon.createWithResource(getApplicationContext(), R.drawable.root);
|
||||
Icon iconAuto = Icon.createWithResource(getApplicationContext(), R.drawable.ic_autoroot);
|
||||
Tile tile = this.getQsTile();
|
||||
boolean autoRootStatus = Utils.autoRootEnabled(getApplicationContext());
|
||||
boolean autoRootStatus = Utils.autoToggleEnabled(getApplicationContext());
|
||||
boolean rootStatus = Utils.rootEnabled();
|
||||
int rootsStatus = Utils.CheckRootsState(getApplicationContext());
|
||||
Log.d("Magisk", "QST: Auto and root are " + autoRootStatus + " and " + rootStatus + Utils.CheckRootsState(getApplicationContext()));
|
||||
if (rootsStatus == 2) {
|
||||
tile.setLabel("Auto-root");
|
||||
tile.setLabel(getApplicationContext().getString(R.string.auto_toggle));
|
||||
tile.setIcon(iconAuto);
|
||||
tile.setState(Tile.STATE_ACTIVE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user