mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-02 12:37:39 +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 java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -28,7 +30,7 @@ public class AutoRootFragment extends ListFragment {
|
||||
private ApplicationAdapter listadaptor = null;
|
||||
public ListView listView;
|
||||
public SharedPreferences prefs;
|
||||
List<String> arrayBlackList,arrayWhiteList;
|
||||
List<String> arrayBlackList, arrayWhiteList;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@ -45,10 +47,11 @@ public class AutoRootFragment extends ListFragment {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
Set<String> set = new HashSet<>();
|
||||
set.add("com.google.android.apps.walletnfcrel");
|
||||
set.add("com.google.android.gms");
|
||||
editor.putStringSet("auto_blacklist", set);
|
||||
set.clear();
|
||||
set.add("com.kermidas.TitaniumBackupPro");
|
||||
editor.putStringSet("auto_whitelist",set);
|
||||
editor.putStringSet("auto_whitelist", set);
|
||||
editor.apply();
|
||||
}
|
||||
new LoadApplications().execute();
|
||||
@ -61,7 +64,6 @@ public class AutoRootFragment extends ListFragment {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long 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");
|
||||
arrayWhiteList.add(appToCheck);
|
||||
|
||||
|
||||
} else if (arrayWhiteList.contains(appToCheck)) {
|
||||
Log.d("Magisk", "App is in whitelist, moving to blacklist");
|
||||
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_whitelist", new HashSet<>(arrayWhiteList));
|
||||
editor.apply();
|
||||
listadaptor.UpdateRootStatusView(position,v);
|
||||
|
||||
listadaptor.UpdateRootStatusView(position, v);
|
||||
|
||||
}
|
||||
|
||||
@ -126,10 +126,19 @@ public class AutoRootFragment extends ListFragment {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Collections.sort(applist, new CustomComparator());
|
||||
|
||||
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 ProgressDialog progress = null;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
@ -12,13 +11,13 @@ import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Process;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -34,6 +33,7 @@ public class MonitorService extends Service
|
||||
private final Handler handler = new Handler();
|
||||
private Boolean disableroot;
|
||||
private Boolean disablerootprev;
|
||||
private int counter = 0;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@ -43,13 +43,12 @@ public class MonitorService extends Service
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
checkProcesses.run();
|
||||
checkProcesses.run();
|
||||
|
||||
return START_STICKY;
|
||||
return START_STICKY;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Runnable checkProcesses = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -57,31 +56,27 @@ public class MonitorService extends Service
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
if (prefs.getBoolean("autoRootEnable", false)) {
|
||||
|
||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||
|
||||
if (set != null) {
|
||||
disableroot = getStats(set);
|
||||
Set<String> setBlackList = prefs.getStringSet("auto_blacklist", null);
|
||||
Set<String> setWhiteList = prefs.getStringSet("auto_whitelist", null);
|
||||
|
||||
if (setBlackList != null) {
|
||||
disableroot = getStats(setBlackList);
|
||||
}
|
||||
|
||||
if (disableroot != disablerootprev) {
|
||||
int counter = 0;
|
||||
|
||||
String rootstatus = (disableroot ? "disabled" : "enabled");
|
||||
if (disableroot) {
|
||||
ForceDisableRoot();
|
||||
} else {
|
||||
counter +=1;
|
||||
if (counter >=3) {
|
||||
Shell.su("setprop magisk.root 1");
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
ForceEnableRoot();
|
||||
}
|
||||
|
||||
ShowNotification(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);
|
||||
@ -90,22 +85,58 @@ public class MonitorService extends Service
|
||||
};
|
||||
|
||||
private void ForceDisableRoot() {
|
||||
Log.d("Magisk", "MonitorService: Forcedisable called.");
|
||||
Shell.su("setprop magisk.root 0");
|
||||
if (Shell.sh("which su").contains("su")) {
|
||||
|
||||
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.");
|
||||
} else if (Utils.rootStatus()) {
|
||||
Shell.su(("setprop magisk.root 0"));
|
||||
Log.d(TAG, "MonitorService: FORCING.");
|
||||
}
|
||||
if (Shell.sh("which su").contains("su")) {
|
||||
Shell.su(("setprop magisk.root 0"));
|
||||
}
|
||||
if (Shell.sh("which su").contains("su")) {
|
||||
Shell.su(("setprop magisk.root 0"));
|
||||
Log.d("Magisk", "MonitorService: Forcedisable called. " + Utils.rootStatus());
|
||||
}
|
||||
|
||||
private void ForceEnableRoot() {
|
||||
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) {
|
||||
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
NotificationCompat.Builder mBuilder;
|
||||
mNotifyMgr.cancelAll();
|
||||
|
||||
if (rootAction) {
|
||||
|
||||
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)
|
||||
.setContentIntent(pendingIntent)
|
||||
.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 {
|
||||
mBuilder =
|
||||
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 + "!");
|
||||
mNotifyMgr.cancelAll();
|
||||
}
|
||||
// Builds the notification and issues it.
|
||||
int mNotificationId = 1;
|
||||
mNotifyMgr.notify(mNotificationId, mBuilder.build());
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
String topPackageName = "";
|
||||
if (stats != null) {
|
||||
|
||||
SortedMap<Long, UsageStats> mySortedMap = new TreeMap<>();
|
||||
for (UsageStats usageStats : stats) {
|
||||
mySortedMap.put(usageStats.getLastTimeUsed(), usageStats);
|
||||
mySortedMap.put(usageStats.getLastTimeUsed(), usageStats);
|
||||
|
||||
}
|
||||
if (!mySortedMap.isEmpty()) {
|
||||
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.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -18,6 +20,7 @@ import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -74,17 +77,28 @@ public class RootFragment extends Fragment {
|
||||
@BindColor(R.color.accent)
|
||||
int accent;
|
||||
int statusOK = R.drawable.ic_check_circle;
|
||||
int statusAuto = R.drawable.ic_autoroot;
|
||||
int statusError = R.drawable.ic_error;
|
||||
int statusUnknown = R.drawable.ic_help;
|
||||
|
||||
private boolean autoRootStatus;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.root_fragment, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
new updateUI().execute();
|
||||
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 -> {
|
||||
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 -> {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putBoolean("autoRootEnable", ((CompoundButton) toggle).isChecked());
|
||||
editor.commit();
|
||||
if (((CompoundButton) toggle).isChecked()) {
|
||||
Intent myIntent = new Intent(getActivity(), MonitorService.class);
|
||||
getActivity().startService(myIntent);
|
||||
}
|
||||
ToggleAutoRoot(autoRootToggle.isChecked());
|
||||
new Handler().postDelayed(() -> new updateUI().execute(), 1000);
|
||||
|
||||
});
|
||||
|
||||
@ -113,6 +122,25 @@ public class RootFragment extends Fragment {
|
||||
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
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@ -196,26 +224,40 @@ public class RootFragment extends Fragment {
|
||||
break;
|
||||
case 1:
|
||||
// Proper root
|
||||
if (new File("/system/xbin/su").exists()) {
|
||||
// Mounted
|
||||
rootStatusContainer.setBackgroundColor(accent);
|
||||
rootStatusIcon.setImageResource(statusError);
|
||||
rootStatus.setTextColor(accent);
|
||||
rootStatus.setText(R.string.root_mounted);
|
||||
rootToggle.setChecked(true);
|
||||
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;
|
||||
if (autoRootStatus) {
|
||||
rootStatusContainer.setBackgroundColor(green500);
|
||||
rootStatusIcon.setImageResource(statusAuto);
|
||||
rootStatusIcon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
|
||||
rootStatus.setTextColor(green500);
|
||||
rootStatus.setText(R.string.root_auto_unmounted);
|
||||
rootToggle.setEnabled(false);
|
||||
safetyNetStatusIcon.setImageResource(statusOK);
|
||||
safetyNetStatus.setText(R.string.root_auto_unmounted_info);
|
||||
break;
|
||||
} else {
|
||||
rootToggle.setEnabled(true);
|
||||
if (new File("/system/xbin/su").exists()) {
|
||||
// Mounted
|
||||
rootStatusContainer.setBackgroundColor(accent);
|
||||
rootStatusIcon.setImageResource(statusError);
|
||||
rootStatus.setTextColor(accent);
|
||||
rootStatus.setText(R.string.root_mounted);
|
||||
rootToggle.setChecked(true);
|
||||
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:
|
||||
// Improper root
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -35,13 +34,15 @@ import butterknife.ButterKnife;
|
||||
public class WelcomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
||||
private Context mContext;
|
||||
|
||||
private final Handler mDrawerHandler = new Handler();
|
||||
|
||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||
@BindView(R.id.drawer_layout) DrawerLayout drawer;
|
||||
@BindView(R.id.nav_view) NavigationView navigationView;
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.drawer_layout)
|
||||
DrawerLayout drawer;
|
||||
@BindView(R.id.nav_view)
|
||||
NavigationView navigationView;
|
||||
|
||||
@IdRes
|
||||
private int mSelectedId = R.id.magisk;
|
||||
@ -58,7 +59,7 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
||||
|
||||
// Startups
|
||||
PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false);
|
||||
if (!isMyServiceRunning(MonitorService.class)) {
|
||||
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
||||
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
||||
getApplication().startService(myIntent);
|
||||
}
|
||||
@ -76,16 +77,13 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
||||
RepoHelper.TaskDelegate delegate = result -> {
|
||||
//Do a thing here when we get a result we want
|
||||
};
|
||||
if (!prefs.contains("oauth_key")) {
|
||||
|
||||
}
|
||||
if (!prefs.contains("hasCachedRepos")) {
|
||||
new Utils.LoadModules(this, true).execute();
|
||||
new Utils.LoadRepos(this, true,delegate).execute();
|
||||
new Utils.LoadRepos(this, true, delegate).execute();
|
||||
|
||||
} else {
|
||||
new Utils.LoadModules(getApplication(),false).execute();
|
||||
new Utils.LoadRepos(this, false,delegate).execute();
|
||||
new Utils.LoadModules(getApplication(), false).execute();
|
||||
new Utils.LoadRepos(this, false, delegate).execute();
|
||||
|
||||
}
|
||||
|
||||
@ -122,7 +120,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle 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) {
|
||||
Fragment navFragment = null;
|
||||
String tag = "";
|
||||
|
@ -70,7 +70,7 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
appName.setText(applicationInfo.loadLabel(packageManager));
|
||||
packageName.setText(applicationInfo.packageName);
|
||||
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));
|
||||
} else {
|
||||
statusview.setImageDrawable(null);
|
||||
@ -89,9 +89,9 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
ApplicationInfo applicationInfo = appsList.get(position);
|
||||
if (null != applicationInfo) {
|
||||
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));
|
||||
} 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));
|
||||
} else {
|
||||
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) {
|
||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||
arrayList = new ArrayList<>(set);
|
||||
return arrayList.toString().contains(appToCheck);
|
||||
if (set != null) {
|
||||
arrayList = new ArrayList<>(set);
|
||||
for (String string : set) {
|
||||
if (string.equals(appToCheck)) {
|
||||
starter = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Set<String> set = prefs.getStringSet("auto_whitelist", null);
|
||||
arrayList = new ArrayList<>(set);
|
||||
return arrayList.toString().contains(appToCheck);
|
||||
if (set != null) {
|
||||
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.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.DownloadManager;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
@ -396,7 +397,13 @@ public class Utils {
|
||||
public static boolean rootStatus() {
|
||||
try {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
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) {
|
||||
|
||||
String cryptoPass = context.getResources().getString(R.string.pass);
|
||||
|
@ -29,11 +29,14 @@
|
||||
<string name="root_none">Not Rooted</string>
|
||||
<string name="root_none_info">Safety Net (Android Pay) should work</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_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_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_enforcing_info">SELinux is enforced</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user