mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 22:37:49 +00:00
Vroom vroom!
Look at er go!
This commit is contained in:
parent
7836336689
commit
5898534c23
@ -18,6 +18,8 @@ import android.widget.ListView;
|
|||||||
import com.topjohnwu.magisk.utils.ApplicationAdapter;
|
import com.topjohnwu.magisk.utils.ApplicationAdapter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -28,7 +30,7 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
private ApplicationAdapter listadaptor = null;
|
private ApplicationAdapter listadaptor = null;
|
||||||
public ListView listView;
|
public ListView listView;
|
||||||
public SharedPreferences prefs;
|
public SharedPreferences prefs;
|
||||||
List<String> arrayBlackList,arrayWhiteList;
|
List<String> arrayBlackList, arrayWhiteList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
@ -45,10 +47,11 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
set.add("com.google.android.apps.walletnfcrel");
|
set.add("com.google.android.apps.walletnfcrel");
|
||||||
|
set.add("com.google.android.gms");
|
||||||
editor.putStringSet("auto_blacklist", set);
|
editor.putStringSet("auto_blacklist", set);
|
||||||
set.clear();
|
set.clear();
|
||||||
set.add("com.kermidas.TitaniumBackupPro");
|
set.add("com.kermidas.TitaniumBackupPro");
|
||||||
editor.putStringSet("auto_whitelist",set);
|
editor.putStringSet("auto_whitelist", set);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
new LoadApplications().execute();
|
new LoadApplications().execute();
|
||||||
@ -61,7 +64,6 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
super.onListItemClick(l, v, position, id);
|
super.onListItemClick(l, v, position, id);
|
||||||
@ -85,7 +87,6 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
Log.d("Magisk", "App is not in any array, adding to whitelist");
|
Log.d("Magisk", "App is not in any array, adding to whitelist");
|
||||||
arrayWhiteList.add(appToCheck);
|
arrayWhiteList.add(appToCheck);
|
||||||
|
|
||||||
|
|
||||||
} else if (arrayWhiteList.contains(appToCheck)) {
|
} else if (arrayWhiteList.contains(appToCheck)) {
|
||||||
Log.d("Magisk", "App is in whitelist, moving to blacklist");
|
Log.d("Magisk", "App is in whitelist, moving to blacklist");
|
||||||
for (int i = 0; i < arrayWhiteList.size(); i++) {
|
for (int i = 0; i < arrayWhiteList.size(); i++) {
|
||||||
@ -110,8 +111,7 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
editor.putStringSet("auto_blacklist", new HashSet<>(arrayBlackList));
|
editor.putStringSet("auto_blacklist", new HashSet<>(arrayBlackList));
|
||||||
editor.putStringSet("auto_whitelist", new HashSet<>(arrayWhiteList));
|
editor.putStringSet("auto_whitelist", new HashSet<>(arrayWhiteList));
|
||||||
editor.apply();
|
editor.apply();
|
||||||
listadaptor.UpdateRootStatusView(position,v);
|
listadaptor.UpdateRootStatusView(position, v);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,10 +126,19 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Collections.sort(applist, new CustomComparator());
|
||||||
|
|
||||||
return applist;
|
return applist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CustomComparator implements Comparator<ApplicationInfo> {
|
||||||
|
@Override
|
||||||
|
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
|
||||||
|
packageManager = getActivity().getPackageManager();
|
||||||
|
return o1.loadLabel(packageManager).toString().compareTo(o2.loadLabel(packageManager).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class LoadApplications extends AsyncTask<Void, Void, Void> {
|
private class LoadApplications extends AsyncTask<Void, Void, Void> {
|
||||||
private ProgressDialog progress = null;
|
private ProgressDialog progress = null;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.app.AppOpsManager;
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
@ -12,13 +11,13 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Process;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -34,6 +33,7 @@ public class MonitorService extends Service
|
|||||||
private final Handler handler = new Handler();
|
private final Handler handler = new Handler();
|
||||||
private Boolean disableroot;
|
private Boolean disableroot;
|
||||||
private Boolean disablerootprev;
|
private Boolean disablerootprev;
|
||||||
|
private int counter = 0;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -43,13 +43,12 @@ public class MonitorService extends Service
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
checkProcesses.run();
|
checkProcesses.run();
|
||||||
|
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Runnable checkProcesses = new Runnable() {
|
private Runnable checkProcesses = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -57,31 +56,27 @@ public class MonitorService extends Service
|
|||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
if (prefs.getBoolean("autoRootEnable", false)) {
|
if (prefs.getBoolean("autoRootEnable", false)) {
|
||||||
|
|
||||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
Set<String> setBlackList = prefs.getStringSet("auto_blacklist", null);
|
||||||
|
Set<String> setWhiteList = prefs.getStringSet("auto_whitelist", null);
|
||||||
if (set != null) {
|
|
||||||
disableroot = getStats(set);
|
|
||||||
|
|
||||||
|
if (setBlackList != null) {
|
||||||
|
disableroot = getStats(setBlackList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disableroot != disablerootprev) {
|
if (disableroot != disablerootprev) {
|
||||||
int counter = 0;
|
|
||||||
String rootstatus = (disableroot ? "disabled" : "enabled");
|
String rootstatus = (disableroot ? "disabled" : "enabled");
|
||||||
if (disableroot) {
|
if (disableroot) {
|
||||||
ForceDisableRoot();
|
ForceDisableRoot();
|
||||||
} else {
|
} else {
|
||||||
counter +=1;
|
ForceEnableRoot();
|
||||||
if (counter >=3) {
|
}
|
||||||
Shell.su("setprop magisk.root 1");
|
|
||||||
counter = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowNotification(disableroot);
|
ShowNotification(disableroot);
|
||||||
|
|
||||||
}
|
}
|
||||||
disablerootprev = disableroot;
|
disablerootprev = disableroot;
|
||||||
Log.d(TAG,"Root check completed, set to " + (disableroot ? "disabled" : "enabled"));
|
//Log.d(TAG,"Root check completed, set to " + (disableroot ? "disabled" : "enabled"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
handler.postDelayed(checkProcesses, 1000);
|
handler.postDelayed(checkProcesses, 1000);
|
||||||
@ -90,22 +85,58 @@ public class MonitorService extends Service
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void ForceDisableRoot() {
|
private void ForceDisableRoot() {
|
||||||
|
Log.d("Magisk", "MonitorService: Forcedisable called.");
|
||||||
Shell.su("setprop magisk.root 0");
|
Shell.su("setprop magisk.root 0");
|
||||||
if (Shell.sh("which su").contains("su")) {
|
|
||||||
|
if (Utils.rootStatus()) {
|
||||||
Shell.su(("setprop magisk.root 0"));
|
Shell.su(("setprop magisk.root 0"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 0"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 0"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 0"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 0"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 0"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
}
|
}
|
||||||
if (Shell.sh("which su").contains("su")) {
|
Log.d("Magisk", "MonitorService: Forcedisable called. " + Utils.rootStatus());
|
||||||
Shell.su(("setprop magisk.root 0"));
|
}
|
||||||
}
|
|
||||||
if (Shell.sh("which su").contains("su")) {
|
private void ForceEnableRoot() {
|
||||||
Shell.su(("setprop magisk.root 0"));
|
Log.d("Magisk", "MonitorService: ForceEnable called.");
|
||||||
|
if (!Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 1"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (!Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 1"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (!Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 1"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (!Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 1"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (!Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 1"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
|
} else if (!Utils.rootStatus()) {
|
||||||
|
Shell.su(("setprop magisk.root 1"));
|
||||||
|
Log.d(TAG, "MonitorService: FORCING.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowNotification(boolean rootAction) {
|
private void ShowNotification(boolean rootAction) {
|
||||||
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
NotificationCompat.Builder mBuilder;
|
NotificationCompat.Builder mBuilder;
|
||||||
mNotifyMgr.cancelAll();
|
|
||||||
if (rootAction) {
|
if (rootAction) {
|
||||||
|
|
||||||
Intent intent = new Intent(getApplication(), WelcomeActivity.class);
|
Intent intent = new Intent(getApplication(), WelcomeActivity.class);
|
||||||
@ -121,19 +152,13 @@ public class MonitorService extends Service
|
|||||||
.setSmallIcon(disableroot ? R.drawable.ic_stat_notification_autoroot_off : R.drawable.ic_stat_notification_autoroot_on)
|
.setSmallIcon(disableroot ? R.drawable.ic_stat_notification_autoroot_off : R.drawable.ic_stat_notification_autoroot_on)
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.setContentTitle("Auto-root status changed")
|
.setContentTitle("Auto-root status changed")
|
||||||
.setContentText("Auto root has been " + rootAction + "! Tap to re-enable when done.");
|
.setContentText("Root has been disabled.");
|
||||||
|
int mNotificationId = 1;
|
||||||
|
mNotifyMgr.notify(mNotificationId, mBuilder.build());
|
||||||
} else {
|
} else {
|
||||||
mBuilder =
|
mNotifyMgr.cancelAll();
|
||||||
new NotificationCompat.Builder(getApplicationContext())
|
|
||||||
.setAutoCancel(true)
|
|
||||||
.setSmallIcon(disableroot ? R.drawable.ic_stat_notification_autoroot_off : R.drawable.ic_stat_notification_autoroot_on)
|
|
||||||
.setContentTitle("Auto-root status changed")
|
|
||||||
.setContentText("Auto root has been " + rootAction + "!");
|
|
||||||
}
|
}
|
||||||
// Builds the notification and issues it.
|
|
||||||
int mNotificationId = 1;
|
|
||||||
mNotifyMgr.notify(mNotificationId, mBuilder.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getStats(Set<String> seti) {
|
private boolean getStats(Set<String> seti) {
|
||||||
@ -159,12 +184,19 @@ public class MonitorService extends Service
|
|||||||
List<UsageStats> stats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000 * 10, time);
|
List<UsageStats> stats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000 * 10, time);
|
||||||
String topPackageName = "";
|
String topPackageName = "";
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
|
|
||||||
SortedMap<Long, UsageStats> mySortedMap = new TreeMap<>();
|
SortedMap<Long, UsageStats> mySortedMap = new TreeMap<>();
|
||||||
for (UsageStats usageStats : stats) {
|
for (UsageStats usageStats : stats) {
|
||||||
mySortedMap.put(usageStats.getLastTimeUsed(), usageStats);
|
mySortedMap.put(usageStats.getLastTimeUsed(), usageStats);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!mySortedMap.isEmpty()) {
|
if (!mySortedMap.isEmpty()) {
|
||||||
topPackageName = mySortedMap.get(mySortedMap.lastKey()).getPackageName();
|
topPackageName = mySortedMap.get(mySortedMap.lastKey()).getPackageName();
|
||||||
|
if (topPackageName.equals("com.topjohnwu.magisk")) {
|
||||||
|
mySortedMap.remove(mySortedMap.lastKey());
|
||||||
|
topPackageName = mySortedMap.get(mySortedMap.lastKey()).getPackageName();
|
||||||
|
}
|
||||||
|
//Log.d("Magisk", "MonitorService: Hi Captain, the package we need to kill for is " + topPackageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ package com.topjohnwu.magisk;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -18,6 +20,7 @@ import android.widget.Switch;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -74,17 +77,28 @@ public class RootFragment extends Fragment {
|
|||||||
@BindColor(R.color.accent)
|
@BindColor(R.color.accent)
|
||||||
int accent;
|
int accent;
|
||||||
int statusOK = R.drawable.ic_check_circle;
|
int statusOK = R.drawable.ic_check_circle;
|
||||||
|
int statusAuto = R.drawable.ic_autoroot;
|
||||||
int statusError = R.drawable.ic_error;
|
int statusError = R.drawable.ic_error;
|
||||||
int statusUnknown = R.drawable.ic_help;
|
int statusUnknown = R.drawable.ic_help;
|
||||||
|
|
||||||
|
private boolean autoRootStatus;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.root_fragment, container, false);
|
View view = inflater.inflate(R.layout.root_fragment, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
|
||||||
new updateUI().execute();
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
if (prefs.contains("autoRootEnable")) {
|
||||||
|
autoRootStatus = prefs.getBoolean("autoRootEnable",false);
|
||||||
|
rootToggle.setEnabled(false);
|
||||||
|
} else {
|
||||||
|
autoRootStatus = false;
|
||||||
|
rootToggle.setEnabled(true);
|
||||||
|
}
|
||||||
|
autoRootToggle.setChecked(autoRootStatus);
|
||||||
|
new updateUI().execute();
|
||||||
|
|
||||||
rootToggle.setOnClickListener(toggle -> {
|
rootToggle.setOnClickListener(toggle -> {
|
||||||
Shell.su(((CompoundButton) toggle).isChecked() ? "setprop magisk.root 1" : "setprop magisk.root 0");
|
Shell.su(((CompoundButton) toggle).isChecked() ? "setprop magisk.root 1" : "setprop magisk.root 0");
|
||||||
@ -95,13 +109,8 @@ public class RootFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
autoRootToggle.setOnClickListener(toggle -> {
|
autoRootToggle.setOnClickListener(toggle -> {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
ToggleAutoRoot(autoRootToggle.isChecked());
|
||||||
editor.putBoolean("autoRootEnable", ((CompoundButton) toggle).isChecked());
|
new Handler().postDelayed(() -> new updateUI().execute(), 1000);
|
||||||
editor.commit();
|
|
||||||
if (((CompoundButton) toggle).isChecked()) {
|
|
||||||
Intent myIntent = new Intent(getActivity(), MonitorService.class);
|
|
||||||
getActivity().startService(myIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -113,6 +122,25 @@ public class RootFragment extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ToggleAutoRoot(boolean toggleState) {
|
||||||
|
autoRootStatus = toggleState;
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
editor.putBoolean("autoRootEnable", (toggleState));
|
||||||
|
editor.apply();
|
||||||
|
if (toggleState) {
|
||||||
|
Intent myIntent = new Intent(getActivity(), MonitorService.class);
|
||||||
|
getActivity().startService(myIntent);
|
||||||
|
rootToggle.setEnabled(false);
|
||||||
|
boolean boo = Utils.isMyServiceRunning(MonitorService.class, getActivity());
|
||||||
|
if (boo) {
|
||||||
|
Intent myServiceIntent = new Intent(getActivity(), MonitorService.class);
|
||||||
|
getActivity().startService(myServiceIntent);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rootToggle.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@ -196,26 +224,40 @@ public class RootFragment extends Fragment {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Proper root
|
// Proper root
|
||||||
if (new File("/system/xbin/su").exists()) {
|
if (autoRootStatus) {
|
||||||
// Mounted
|
rootStatusContainer.setBackgroundColor(green500);
|
||||||
rootStatusContainer.setBackgroundColor(accent);
|
rootStatusIcon.setImageResource(statusAuto);
|
||||||
rootStatusIcon.setImageResource(statusError);
|
rootStatusIcon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
|
||||||
rootStatus.setTextColor(accent);
|
rootStatus.setTextColor(green500);
|
||||||
rootStatus.setText(R.string.root_mounted);
|
rootStatus.setText(R.string.root_auto_unmounted);
|
||||||
rootToggle.setChecked(true);
|
rootToggle.setEnabled(false);
|
||||||
safetyNetStatusIcon.setImageResource(statusError);
|
safetyNetStatusIcon.setImageResource(statusOK);
|
||||||
safetyNetStatus.setText(R.string.root_mounted_info);
|
safetyNetStatus.setText(R.string.root_auto_unmounted_info);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// Not Mounted
|
rootToggle.setEnabled(true);
|
||||||
rootStatusContainer.setBackgroundColor(green500);
|
if (new File("/system/xbin/su").exists()) {
|
||||||
rootStatusIcon.setImageResource(statusOK);
|
// Mounted
|
||||||
rootStatus.setTextColor(green500);
|
rootStatusContainer.setBackgroundColor(accent);
|
||||||
rootStatus.setText(R.string.root_unmounted);
|
rootStatusIcon.setImageResource(statusError);
|
||||||
rootToggle.setChecked(false);
|
rootStatus.setTextColor(accent);
|
||||||
safetyNetStatusIcon.setImageResource(statusOK);
|
rootStatus.setText(R.string.root_mounted);
|
||||||
safetyNetStatus.setText(R.string.root_unmounted_info);
|
rootToggle.setChecked(true);
|
||||||
break;
|
safetyNetStatusIcon.setImageResource(statusError);
|
||||||
|
safetyNetStatus.setText(R.string.root_mounted_info);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// Not Mounted
|
||||||
|
rootStatusContainer.setBackgroundColor(green500);
|
||||||
|
rootStatusIcon.setImageResource(statusOK);
|
||||||
|
rootStatus.setTextColor(green500);
|
||||||
|
rootStatus.setText(R.string.root_unmounted);
|
||||||
|
rootToggle.setChecked(false);
|
||||||
|
safetyNetStatusIcon.setImageResource(statusOK);
|
||||||
|
safetyNetStatus.setText(R.string.root_unmounted_info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
// Improper root
|
// Improper root
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -35,13 +34,15 @@ import butterknife.ButterKnife;
|
|||||||
public class WelcomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
|
public class WelcomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
|
||||||
|
|
||||||
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
private final Handler mDrawerHandler = new Handler();
|
private final Handler mDrawerHandler = new Handler();
|
||||||
|
|
||||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
@BindView(R.id.toolbar)
|
||||||
@BindView(R.id.drawer_layout) DrawerLayout drawer;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.nav_view) NavigationView navigationView;
|
@BindView(R.id.drawer_layout)
|
||||||
|
DrawerLayout drawer;
|
||||||
|
@BindView(R.id.nav_view)
|
||||||
|
NavigationView navigationView;
|
||||||
|
|
||||||
@IdRes
|
@IdRes
|
||||||
private int mSelectedId = R.id.magisk;
|
private int mSelectedId = R.id.magisk;
|
||||||
@ -58,7 +59,7 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
// Startups
|
// Startups
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false);
|
PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false);
|
||||||
if (!isMyServiceRunning(MonitorService.class)) {
|
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
||||||
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
||||||
getApplication().startService(myIntent);
|
getApplication().startService(myIntent);
|
||||||
}
|
}
|
||||||
@ -76,16 +77,13 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
RepoHelper.TaskDelegate delegate = result -> {
|
RepoHelper.TaskDelegate delegate = result -> {
|
||||||
//Do a thing here when we get a result we want
|
//Do a thing here when we get a result we want
|
||||||
};
|
};
|
||||||
if (!prefs.contains("oauth_key")) {
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!prefs.contains("hasCachedRepos")) {
|
if (!prefs.contains("hasCachedRepos")) {
|
||||||
new Utils.LoadModules(this, true).execute();
|
new Utils.LoadModules(this, true).execute();
|
||||||
new Utils.LoadRepos(this, true,delegate).execute();
|
new Utils.LoadRepos(this, true, delegate).execute();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
new Utils.LoadModules(getApplication(),false).execute();
|
new Utils.LoadModules(getApplication(), false).execute();
|
||||||
new Utils.LoadRepos(this, false,delegate).execute();
|
new Utils.LoadRepos(this, false, delegate).execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +120,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
@ -158,16 +155,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMyServiceRunning(Class<?> serviceClass) {
|
|
||||||
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
|
||||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
|
||||||
if (serviceClass.getName().equals(service.service.getClassName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void navigate(final int itemId) {
|
private void navigate(final int itemId) {
|
||||||
Fragment navFragment = null;
|
Fragment navFragment = null;
|
||||||
String tag = "";
|
String tag = "";
|
||||||
|
@ -70,7 +70,7 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
|||||||
appName.setText(applicationInfo.loadLabel(packageManager));
|
appName.setText(applicationInfo.loadLabel(packageManager));
|
||||||
packageName.setText(applicationInfo.packageName);
|
packageName.setText(applicationInfo.packageName);
|
||||||
iconview.setImageDrawable(applicationInfo.loadIcon(packageManager));
|
iconview.setImageDrawable(applicationInfo.loadIcon(packageManager));
|
||||||
if (CheckApp(applicationInfo.packageName,BLACKLIST_LIST)) {
|
if (CheckApp(applicationInfo.packageName, BLACKLIST_LIST)) {
|
||||||
statusview.setImageDrawable(this.context.getDrawable(R.drawable.root));
|
statusview.setImageDrawable(this.context.getDrawable(R.drawable.root));
|
||||||
} else {
|
} else {
|
||||||
statusview.setImageDrawable(null);
|
statusview.setImageDrawable(null);
|
||||||
@ -89,9 +89,9 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
|||||||
ApplicationInfo applicationInfo = appsList.get(position);
|
ApplicationInfo applicationInfo = appsList.get(position);
|
||||||
if (null != applicationInfo) {
|
if (null != applicationInfo) {
|
||||||
ImageView statusview = (ImageView) view.findViewById(R.id.app_status);
|
ImageView statusview = (ImageView) view.findViewById(R.id.app_status);
|
||||||
if (CheckApp(applicationInfo.packageName,BLACKLIST_LIST)) {
|
if (CheckApp(applicationInfo.packageName, BLACKLIST_LIST)) {
|
||||||
statusview.setImageDrawable(this.context.getDrawable(R.drawable.root));
|
statusview.setImageDrawable(this.context.getDrawable(R.drawable.root));
|
||||||
} else if (CheckApp(applicationInfo.packageName,WHITELIST_LIST)) {
|
} else if (CheckApp(applicationInfo.packageName, WHITELIST_LIST)) {
|
||||||
statusview.setImageDrawable(this.context.getDrawable(R.drawable.ic_stat_notification_autoroot_off));
|
statusview.setImageDrawable(this.context.getDrawable(R.drawable.ic_stat_notification_autoroot_off));
|
||||||
} else {
|
} else {
|
||||||
statusview.setImageDrawable(null);
|
statusview.setImageDrawable(null);
|
||||||
@ -100,20 +100,33 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean CheckApp(String appToCheck,int list) {
|
private boolean CheckApp(String appToCheck, int list) {
|
||||||
|
boolean starter = false;
|
||||||
if (list == BLACKLIST_LIST) {
|
if (list == BLACKLIST_LIST) {
|
||||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||||
arrayList = new ArrayList<>(set);
|
if (set != null) {
|
||||||
return arrayList.toString().contains(appToCheck);
|
arrayList = new ArrayList<>(set);
|
||||||
|
for (String string : set) {
|
||||||
|
if (string.equals(appToCheck)) {
|
||||||
|
starter = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Set<String> set = prefs.getStringSet("auto_whitelist", null);
|
Set<String> set = prefs.getStringSet("auto_whitelist", null);
|
||||||
arrayList = new ArrayList<>(set);
|
if (set != null) {
|
||||||
return arrayList.toString().contains(appToCheck);
|
arrayList = new ArrayList<>(set);
|
||||||
|
for (String string : set) {
|
||||||
|
if (string.equals(appToCheck)) {
|
||||||
|
starter = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return starter;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
};
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
|
||||||
|
|
||||||
|
|
||||||
public class GitAgent {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ package com.topjohnwu.magisk.utils;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@ -396,7 +397,13 @@ public class Utils {
|
|||||||
public static boolean rootStatus() {
|
public static boolean rootStatus() {
|
||||||
try {
|
try {
|
||||||
String rootStatus = Shell.su("getprop magisk.root").toString();
|
String rootStatus = Shell.su("getprop magisk.root").toString();
|
||||||
return Integer.valueOf(rootStatus).equals(1);
|
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) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
@ -404,6 +411,16 @@ public class Utils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) {
|
||||||
|
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||||
|
if (serviceClass.getName().equals(service.service.getClassName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static String procFile(String value, Context context) {
|
public static String procFile(String value, Context context) {
|
||||||
|
|
||||||
String cryptoPass = context.getResources().getString(R.string.pass);
|
String cryptoPass = context.getResources().getString(R.string.pass);
|
||||||
|
@ -29,11 +29,14 @@
|
|||||||
<string name="root_none">Not Rooted</string>
|
<string name="root_none">Not Rooted</string>
|
||||||
<string name="root_none_info">Safety Net (Android Pay) should work</string>
|
<string name="root_none_info">Safety Net (Android Pay) should work</string>
|
||||||
<string name="root_mounted">Root mounted</string>
|
<string name="root_mounted">Root mounted</string>
|
||||||
<string name="root_mounted_info">Root mounted and enabled. Safety Net (Android Pay) will NOT work</string>
|
<string name="root_mounted_info">Root mounted and enabled. Safety Net (Android Pay) will NOT work.</string>
|
||||||
<string name="root_unmounted">Root not mounted</string>
|
<string name="root_unmounted">Root not mounted</string>
|
||||||
<string name="root_unmounted_info">Safety Net (Android Pay) should work, but no root temporarily\nYou might need to manually add a card in Android Pay app to refresh the root status of AP</string>
|
<string name="root_unmounted_info">Safety Net (Android Pay) should work, but no root temporarily\nYou might need to manually add a card in Android Pay app to refresh the root status of AP</string>
|
||||||
|
<string name="root_auto_unmounted">Root set to auto-mount</string>
|
||||||
|
<string name="root_auto_unmounted_info">Root will auto unmount for selected applications. Safety Net (Android Pay) should work.</string>
|
||||||
|
|
||||||
<string name="root_system">Magisk Incompatible Root Detected</string>
|
<string name="root_system">Magisk Incompatible Root Detected</string>
|
||||||
<string name="root_system_info">Root improperly installed. Safety Net (Android Pay) will NOT work, and impossible to toggle</string>
|
<string name="root_system_info">Root improperly installed. Safety Net (Android Pay) will NOT work, and impossible to toggle.</string>
|
||||||
|
|
||||||
<string name="selinux_error_info">SELinux Status Unknown</string>
|
<string name="selinux_error_info">SELinux Status Unknown</string>
|
||||||
<string name="selinux_enforcing_info">SELinux is enforced</string>
|
<string name="selinux_enforcing_info">SELinux is enforced</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user