mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
More fixes, more breaks...
This commit is contained in:
parent
41a5639711
commit
8a8aaf3297
@ -32,9 +32,9 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
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.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.github.d8ahazard:BroadcastTileSupportUpdate:master'
|
||||
compile 'com.jakewharton:butterknife:8.4.0'
|
||||
compile 'com.github.michalis-vitos:aFileChooser:master'
|
||||
|
@ -32,7 +32,7 @@
|
||||
android:resource="@xml/accessibilityservice"/>
|
||||
</service>
|
||||
<service
|
||||
android:name=".services.QuickSettingTileService"
|
||||
android:name=".services.TileServiceNewApi"
|
||||
android:icon="@drawable/ic_autoroot"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
|
@ -10,12 +10,15 @@ import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.topjohnwu.magisk.utils.ApplicationAdapter;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -34,7 +37,17 @@ public class AutoRootFragment extends ListFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.auto_root_fragment, container, false);
|
||||
View view = inflater.inflate(R.layout.auto_root_fragment, container, false);
|
||||
int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
int verticalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
TypedValue tv = new TypedValue();
|
||||
int actionBarHeight = 130;
|
||||
if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
||||
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
view.setPadding(horizontalMargin, actionBarHeight, horizontalMargin, verticalMargin);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,6 +57,7 @@ public class AutoRootFragment extends ListFragment {
|
||||
packageManager = getActivity().getPackageManager();
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
if (!prefs.contains("auto_blacklist")) {
|
||||
Logger.dh("AutoRootFragment: Setting default preferences for application");
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
Set<String> set = new HashSet<>();
|
||||
set.add("com.google.android.apps.walletnfcrel");
|
||||
@ -63,6 +77,7 @@ public class AutoRootFragment extends ListFragment {
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
Logger.dh("Click");
|
||||
super.onListItemClick(l, v, position, id);
|
||||
ApplicationInfo app = applist.get(position);
|
||||
ToggleApp(app.packageName, position, v);
|
||||
@ -70,10 +85,8 @@ public class AutoRootFragment extends ListFragment {
|
||||
}
|
||||
|
||||
private void ToggleApp(String appToCheck, int position, View v) {
|
||||
|
||||
Logger.dh("Magisk","AutoRootFragment: ToggleApp called for " + appToCheck);
|
||||
Set<String> blackListSet = prefs.getStringSet("auto_blacklist", null);
|
||||
|
||||
|
||||
assert blackListSet != null;
|
||||
arrayBlackList = new ArrayList<>(blackListSet);
|
||||
|
||||
@ -88,7 +101,10 @@ public class AutoRootFragment extends ListFragment {
|
||||
}
|
||||
|
||||
}
|
||||
prefs.edit().putStringSet("auto_blacklist", new HashSet<>(arrayBlackList)).apply();
|
||||
Logger.dh("Committing set, value is: " + arrayBlackList.toString());
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putStringSet("auto_blacklist", new HashSet<>(arrayBlackList));
|
||||
editor.apply();
|
||||
listadaptor.UpdateRootStatusView(position, v);
|
||||
|
||||
}
|
||||
@ -113,7 +129,7 @@ public class AutoRootFragment extends ListFragment {
|
||||
@Override
|
||||
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
|
||||
packageManager = getActivity().getPackageManager();
|
||||
return o1.loadLabel(packageManager).toString().compareTo(o2.loadLabel(packageManager).toString());
|
||||
return o1.loadLabel(packageManager).toString().compareToIgnoreCase(o2.loadLabel(packageManager).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
@ -12,8 +9,7 @@ import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.app.Fragment;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -23,11 +19,10 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.receivers.Receiver;
|
||||
import com.topjohnwu.magisk.receivers.RootFragmentReceiver;
|
||||
import com.topjohnwu.magisk.services.MonitorService;
|
||||
import com.topjohnwu.magisk.utils.PrefHelper;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
@ -91,21 +86,22 @@ public class RootFragment extends Fragment implements Receiver{
|
||||
int statusUnknown = R.drawable.ic_help;
|
||||
|
||||
private boolean autoRootStatus;
|
||||
private View view;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.root_fragment, container, false);
|
||||
view = inflater.inflate(R.layout.root_fragment, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
|
||||
if (prefs.contains("autoRootEnable")) {
|
||||
autoRootStatus = prefs.getBoolean("autoRootEnable", false);
|
||||
rootToggle.setEnabled(false);
|
||||
} else {
|
||||
|
||||
if (autoRootStatus) {
|
||||
if (!Utils.hasServicePermission(getActivity())) {
|
||||
autoRootStatus = false;
|
||||
rootToggle.setEnabled(true);
|
||||
}
|
||||
}
|
||||
rootToggle.setEnabled(!autoRootStatus);
|
||||
autoRootToggle.setChecked(autoRootStatus);
|
||||
new updateUI().execute();
|
||||
|
||||
@ -115,10 +111,15 @@ public class RootFragment extends Fragment implements Receiver{
|
||||
});
|
||||
|
||||
autoRootToggle.setOnClickListener(toggle -> {
|
||||
if (!Utils.hasServicePermission(getActivity())) {
|
||||
Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
|
||||
startActivityForResult(intent, 100);
|
||||
} else {
|
||||
ToggleAutoRoot(autoRootToggle.isChecked());
|
||||
new updateUI().execute();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
selinuxToggle.setOnClickListener(toggle -> {
|
||||
Shell.su(((CompoundButton) toggle).isChecked() ? "setenforce 1" : "setenforce 0");
|
||||
@ -147,14 +148,12 @@ public class RootFragment extends Fragment implements Receiver{
|
||||
// Check which request we're responding to
|
||||
Log.d("Magisk", "Got result: " + requestCode + " and " + resultCode);
|
||||
if (requestCode == 100) {
|
||||
// Make sure the request was successful
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (Utils.hasServicePermission(getActivity())) {
|
||||
Log.d("Magisk", "Got result code OK for permissions");
|
||||
|
||||
ToggleAutoRoot(true);
|
||||
} else {
|
||||
autoRootToggle.setEnabled(false);
|
||||
Toast.makeText(getActivity(), "Auto-root disabled, permissions required.", Toast.LENGTH_LONG).show();
|
||||
|
||||
autoRootToggle.setChecked(false);
|
||||
Snackbar.make(view, "Auto-root disabled, permissions required.", Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
} else if (requestCode == 420) {
|
||||
@ -169,10 +168,6 @@ public class RootFragment extends Fragment implements Receiver{
|
||||
editor.putBoolean("autoRootEnable", (toggleState));
|
||||
editor.apply();
|
||||
if (toggleState) {
|
||||
if (!Utils.hasServicePermission(getActivity())) {
|
||||
Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
|
||||
startActivityForResult(intent, 100);
|
||||
}
|
||||
Intent myIntent = new Intent(getActivity(), MonitorService.class);
|
||||
getActivity().startService(myIntent);
|
||||
rootToggle.setEnabled(false);
|
||||
@ -187,6 +182,8 @@ public class RootFragment extends Fragment implements Receiver{
|
||||
rootToggle.setEnabled(true);
|
||||
}
|
||||
|
||||
new updateUI().execute();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -206,6 +203,10 @@ public class RootFragment extends Fragment implements Receiver{
|
||||
protected Void doInBackground(Void... voids) {
|
||||
// Make sure static block invoked
|
||||
Shell.rootAccess();
|
||||
// Set up Tile on UI Refresh
|
||||
if (PrefHelper.CheckBool("enable_quicktile",getActivity())) {
|
||||
Utils.SetupQuickSettingsTile(getActivity());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,12 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
@ -15,10 +15,10 @@ public class AutoStartReceiver extends BroadcastReceiver {
|
||||
Log.d("Magisk", "Received Boot call, attempting to start service");
|
||||
Intent myIntent = new Intent(context, MonitorService.class);
|
||||
context.startService(myIntent);
|
||||
if (PrefHelper.CheckBool("keep_root_off")) {
|
||||
if (PrefHelper.CheckBool("keep_root_off",context)) {
|
||||
Utils.toggleRoot(false);
|
||||
}
|
||||
if (PrefHelper.CheckBool("enable_quicktile")) {
|
||||
if (PrefHelper.CheckBool("enable_quicktile",context)) {
|
||||
Utils.SetupQuickSettingsTile(context);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.topjohnwu.magisk.services.TileService;
|
||||
import com.topjohnwu.magisk.services.TileServiceCompat;
|
||||
|
||||
public class TileReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "MainReceiver";
|
||||
@ -18,7 +18,7 @@ public class TileReceiver extends BroadcastReceiver {
|
||||
String action = intent.getAction();
|
||||
|
||||
if (action.equals(Intent.ACTION_BOOT_COMPLETED) || action.equals(Intent.ACTION_USER_PRESENT) || action.equals(Intent.ACTION_SCREEN_ON)) {
|
||||
context.startService(new Intent(context,TileService.class));
|
||||
context.startService(new Intent(context,TileServiceCompat.class));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.WelcomeActivity;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.PrefHelper;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
@ -50,6 +51,12 @@ public class MonitorService extends AccessibilityService {
|
||||
Log.d("Magisk", "MonitorService: Service created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d("Magisk", "MonitorService: Service destroyed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccessibilityEvent(AccessibilityEvent event) {
|
||||
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
|
||||
@ -71,11 +78,7 @@ public class MonitorService extends AccessibilityService {
|
||||
|
||||
if (setBlackList != null) {
|
||||
disableroot = setBlackList.contains(mPackage);
|
||||
if (disableroot) {
|
||||
ForceDisableRoot();
|
||||
} else {
|
||||
ForceEnableRoot();
|
||||
}
|
||||
ForceRoot(!disableroot);
|
||||
String appFriendly = getAppName(mPackage);
|
||||
ShowNotification(disableroot, appFriendly);
|
||||
}
|
||||
@ -105,14 +108,18 @@ public class MonitorService extends AccessibilityService {
|
||||
}
|
||||
}
|
||||
|
||||
private void ForceDisableRoot() {
|
||||
Log.d("Magisk", "MonitorService: Forcedisable called.");
|
||||
Utils.toggleRoot(false);
|
||||
if (Utils.rootEnabled()) {
|
||||
Utils.toggleRoot(false);
|
||||
Log.d(TAG, "MonitorService: FORCING.");
|
||||
private void ForceRoot(Boolean rootToggle) {
|
||||
|
||||
String rootString = rootToggle ? "on" : "off";
|
||||
if (Utils.rootEnabled() != rootToggle) {
|
||||
Logger.dh("MonitorService: toggling root " + rootString);
|
||||
Utils.toggleRoot(rootToggle);
|
||||
if (Utils.rootEnabled() != rootToggle) {
|
||||
Utils.toggleRoot(rootToggle);
|
||||
Logger.dh("MonitorService: FORCING to " + rootString);
|
||||
}
|
||||
|
||||
}
|
||||
Log.d("Magisk", "MonitorService: Forcedisable called. " + Utils.rootEnabled());
|
||||
}
|
||||
|
||||
private void ForceEnableRoot() {
|
||||
@ -126,7 +133,7 @@ public class MonitorService extends AccessibilityService {
|
||||
private void ShowNotification(boolean rootAction, String packageName) {
|
||||
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
NotificationCompat.Builder mBuilder;
|
||||
if (!PrefHelper.CheckBool("hide_root_notification")) {
|
||||
if (!PrefHelper.CheckBool("hide_root_notification", getApplicationContext())) {
|
||||
if (rootAction) {
|
||||
|
||||
Intent intent = new Intent(getApplication(), WelcomeActivity.class);
|
||||
|
@ -16,10 +16,9 @@ import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileService extends Service {
|
||||
public class TileServiceCompat extends Service {
|
||||
private static BroadcastReceiver clickTileReceiver;
|
||||
|
||||
private static boolean running = false;
|
||||
private static boolean root, autoRoot;
|
||||
|
||||
public static final String TILE_ID = "com.shovelgrill.magiskmmtile.TILE";
|
||||
@ -29,7 +28,7 @@ public class TileService extends Service {
|
||||
public static final int CLICK_TYPE_SIMPLE = 0;
|
||||
public static final int CLICK_TYPE_LONG = 1;
|
||||
|
||||
public TileService() {
|
||||
public TileServiceCompat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,7 +39,6 @@ public class TileService extends Service {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
running = true;
|
||||
root = true;
|
||||
registerClickTileReceiver();
|
||||
}
|
||||
@ -82,7 +80,7 @@ public class TileService extends Service {
|
||||
private void onLongClick() {
|
||||
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||
sendBroadcast(it);
|
||||
openApp(this,"com.topjohnwu.magisk");
|
||||
Utils.toggleAutoRoot(!Utils.autoRootEnabled(getApplicationContext()),getApplicationContext());
|
||||
}
|
||||
|
||||
public static boolean openApp(Context context, String packageName) {
|
||||
@ -133,7 +131,6 @@ public class TileService extends Service {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unregisterReceiver(clickTileReceiver);
|
||||
running = false;
|
||||
}
|
||||
|
||||
}
|
@ -1,75 +1,92 @@
|
||||
package com.topjohnwu.magisk.services;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
import android.util.Log;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class QuickSettingTileService extends TileService {
|
||||
public class TileServiceNewApi extends android.service.quicksettings.TileService implements
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private int STATE_CURRENT;
|
||||
|
||||
public QuickSettingTileService() {
|
||||
public TileServiceNewApi() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onTileAdded() {
|
||||
super.onTileAdded();
|
||||
setupState();
|
||||
this.getQsTile().updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
switchState();
|
||||
this.getQsTile().updateTile();
|
||||
|
||||
}
|
||||
|
||||
private void setupState() {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
Logger.dh("TileService(New): SetupState");
|
||||
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 rootStatus = Utils.rootEnabled();
|
||||
Log.d("Magisk", "QST: Auto and root are " + autoRootStatus + " and " + rootStatus);
|
||||
if (autoRootStatus) {
|
||||
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.setIcon(iconAuto);
|
||||
tile.setState(Tile.STATE_ACTIVE);
|
||||
STATE_CURRENT = 0;
|
||||
} else {
|
||||
if (rootStatus) {
|
||||
|
||||
} else if (rootsStatus == 1) {
|
||||
tile.setLabel("Root enabled");
|
||||
tile.setIcon(iconRoot);
|
||||
tile.setState(Tile.STATE_ACTIVE);
|
||||
STATE_CURRENT = 1;
|
||||
|
||||
|
||||
} else {
|
||||
tile.setLabel("Root disabled");
|
||||
tile.setIcon(iconRoot);
|
||||
tile.setState(Tile.STATE_INACTIVE);
|
||||
STATE_CURRENT = 2;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tile.updateTile();
|
||||
}
|
||||
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key)
|
||||
{
|
||||
Logger.dh("TileService: Key Change registered for " + key);
|
||||
if (key.equals("autoRootEnable")) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void switchState() {
|
||||
Log.d("Magisk", "QST: Switching state to " + STATE_CURRENT);
|
||||
switch (STATE_CURRENT) {
|
||||
case 0:
|
||||
Utils.toggleRoot(false);
|
||||
switch (Utils.CheckRootsState(getApplicationContext())) {
|
||||
case 2:
|
||||
Utils.toggleRoot(true);
|
||||
Utils.toggleAutoRoot(false, getApplicationContext());
|
||||
break;
|
||||
case 1:
|
||||
Utils.toggleAutoRoot(true, getApplicationContext());
|
||||
Utils.toggleRoot(false);
|
||||
break;
|
||||
case 2:
|
||||
Utils.toggleRoot(true);
|
||||
case 0:
|
||||
Utils.toggleAutoRoot(true, getApplicationContext());
|
||||
break;
|
||||
}
|
||||
setupState();
|
@ -15,7 +15,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -23,7 +22,6 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
private List<ApplicationInfo> appsList = null;
|
||||
private Context context;
|
||||
private PackageManager packageManager;
|
||||
public ArrayList arrayList;
|
||||
public SharedPreferences prefs;
|
||||
|
||||
public ApplicationAdapter(Context context, int textViewResourceId,
|
||||
@ -101,7 +99,6 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
boolean starter = false;
|
||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||
if (set != null) {
|
||||
arrayList = new ArrayList<>(set);
|
||||
for (String string : set) {
|
||||
if (string.equals(appToCheck)) {
|
||||
starter = true;
|
||||
|
@ -1,15 +1,21 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
|
||||
public class Logger {
|
||||
|
||||
private static final String LOG_TAG = "Magisk";
|
||||
private static final String LOG_TAG = "Magisk: DH";
|
||||
|
||||
public static void dh(String msg, Object... args) {
|
||||
if (PrefHelper.CheckBool("developer_logging")) {
|
||||
Context context = null;
|
||||
try {
|
||||
context = getApplicationUsingReflection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (PrefHelper.CheckBool("developer_logging", context)) {
|
||||
if (args.length == 1 && args[0] instanceof Throwable) {
|
||||
Log.d(LOG_TAG, msg, (Throwable) args[0]);
|
||||
} else {
|
||||
@ -17,4 +23,9 @@ public class Logger {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Application getApplicationUsingReflection() throws Exception {
|
||||
return (Application) Class.forName("android.app.AppGlobals")
|
||||
.getMethod("getInitialApplication").invoke(null, (Object[]) null);
|
||||
}
|
||||
}
|
||||
|
@ -10,19 +10,11 @@ public class PrefHelper {
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckBool(String key) {
|
||||
Context context = null;
|
||||
try {
|
||||
context = getApplicationUsingReflection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public static boolean CheckBool(String key, Context context) {
|
||||
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, false);
|
||||
}
|
||||
|
||||
private static Application getApplicationUsingReflection() throws Exception {
|
||||
return (Application) Class.forName("android.app.AppGlobals")
|
||||
.getMethod("getInitialApplication").invoke(null, (Object[]) null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ import com.topjohnwu.magisk.RootFragment;
|
||||
import com.topjohnwu.magisk.module.BaseModule;
|
||||
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
|
||||
import com.topjohnwu.magisk.services.MonitorService;
|
||||
import com.topjohnwu.magisk.services.QuickSettingTileService;
|
||||
import com.topjohnwu.magisk.services.TileService;
|
||||
import com.topjohnwu.magisk.services.TileServiceNewApi;
|
||||
import com.topjohnwu.magisk.services.TileServiceCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -71,10 +71,10 @@ public class Utils {
|
||||
if (!Shell.rootAccess()) {
|
||||
Snackbar.make(((Activity) context).findViewById(android.R.id.content), R.string.no_root_access, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
if (PrefHelper.CheckBool("keep_root_off")) {
|
||||
if (PrefHelper.CheckBool("keep_root_off",context)) {
|
||||
Utils.toggleRoot(false);
|
||||
}
|
||||
if (PrefHelper.CheckBool("enable_quicktile")) {
|
||||
if (PrefHelper.CheckBool("enable_quicktile",context)) {
|
||||
Utils.SetupQuickSettingsTile(context);
|
||||
}
|
||||
}
|
||||
@ -129,6 +129,7 @@ public class Utils {
|
||||
} else {
|
||||
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +213,7 @@ public class Utils {
|
||||
public static void SetupQuickSettingsTile(Context mContext) {
|
||||
Logger.dh("Utils: SetupQuickSettings called");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Intent serviceIntent = new Intent(mContext, QuickSettingTileService.class);
|
||||
Intent serviceIntent = new Intent(mContext, TileServiceNewApi.class);
|
||||
mContext.startService(serviceIntent);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
||||
@ -266,7 +267,7 @@ public class Utils {
|
||||
|
||||
public static void installTile(Context context) {
|
||||
|
||||
String qsTileId = "intent(" + TileService.TILE_ID + ")";
|
||||
String qsTileId = "intent(" + TileServiceCompat.TILE_ID + ")";
|
||||
List<String> lines = Shell.su("settings get secure sysui_qs_tiles");
|
||||
if (lines != null && lines.size() == 1) {
|
||||
List<String> tiles = new LinkedList<String>(Arrays.asList(lines.get(0).split(",")));
|
||||
@ -289,7 +290,7 @@ public class Utils {
|
||||
|
||||
public static void uninstallTile(Context context) {
|
||||
|
||||
String qsTileId = "intent(" + TileService.TILE_ID + ")";
|
||||
String qsTileId = "intent(" + TileServiceCompat.TILE_ID + ")";
|
||||
List<String> lines = Shell.su("settings get secure sysui_qs_tiles");
|
||||
if (lines != null && lines.size() == 1) {
|
||||
List<String> tiles = new LinkedList<String>(Arrays.asList(lines.get(0).split(",")));
|
||||
@ -318,7 +319,7 @@ public class Utils {
|
||||
|
||||
|
||||
private void refreshService(Context context) {
|
||||
context.startService(new Intent(context, TileService.class));
|
||||
context.startService(new Intent(context, TileServiceCompat.class));
|
||||
}
|
||||
|
||||
|
||||
@ -448,7 +449,7 @@ public class Utils {
|
||||
public static class ModuleComparator implements Comparator<BaseModule> {
|
||||
@Override
|
||||
public int compare(BaseModule o1, BaseModule o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/Base.CardView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
@ -9,15 +10,14 @@
|
||||
android:layout_marginLeft="8dip"
|
||||
android:layout_marginRight="8dip"
|
||||
android:layout_marginTop="3dip"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:cardCornerRadius="2dp"
|
||||
card_view:cardElevation="2dp"
|
||||
style="@style/Base.CardView">
|
||||
card_view:cardElevation="2dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
@ -29,41 +29,57 @@
|
||||
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/textLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingEnd="50dp"
|
||||
android:paddingStart="65dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_alignBottom="@+id/app_icon"
|
||||
android:weightSum="1">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_toEndOf="@+id/app_icon"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_alignParentEnd="false"
|
||||
android:paddingEnd="3dp"
|
||||
android:paddingStart="3dp"
|
||||
android:textStyle="bold" />
|
||||
android:textStyle="bold"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_paackage"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@+id/app_name"
|
||||
android:layout_toEndOf="@+id/app_icon"
|
||||
android:layout_height="25dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="3dp"
|
||||
android:paddingStart="3dp" />
|
||||
android:paddingStart="3dp"
|
||||
android:maxLines="1"
|
||||
android:marqueeRepeatLimit ="marquee_forever"
|
||||
android:ellipsize="marquee"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/Linear"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="68dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_menu_overflow_material"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/Top">
|
||||
|
||||
<ListView android:id="@android:id/list"
|
||||
android:paddingTop="5dip"
|
||||
android:paddingBottom="5dip"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="10.0sp"
|
||||
android:dividerHeight="5.0sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="15dp"/>
|
||||
|
Loading…
Reference in New Issue
Block a user