Final fix for flash zip

This commit is contained in:
topjohnwu 2016-09-28 00:33:01 +08:00
parent e73497e4b7
commit a173179b03
16 changed files with 75 additions and 60 deletions

View File

@ -44,7 +44,7 @@ public class AboutActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", ""); String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
Logger.dh("AboutActivity: Theme is " + theme); Logger.dev("AboutActivity: Theme is " + theme);
if (theme.equals("Dark")) { if (theme.equals("Dark")) {
setTheme(R.style.AppTheme_dh); setTheme(R.style.AppTheme_dh);
} }

View File

@ -76,7 +76,7 @@ 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) {
Logger.dh("Click"); Logger.dev("Click");
super.onListItemClick(l, v, position, id); super.onListItemClick(l, v, position, id);
ApplicationInfo app = applist.get(position); ApplicationInfo app = applist.get(position);
ToggleApp(app.packageName, position, v); ToggleApp(app.packageName, position, v);
@ -84,7 +84,7 @@ public class AutoRootFragment extends ListFragment {
} }
private void ToggleApp(String appToCheck, int position, View v) { private void ToggleApp(String appToCheck, int position, View v) {
Logger.dh("Magisk","AutoRootFragment: ToggleApp called for " + appToCheck); Logger.dev("Magisk","AutoRootFragment: ToggleApp called for " + appToCheck);
Set<String> blackListSet = prefs.getStringSet("auto_blacklist", null); Set<String> blackListSet = prefs.getStringSet("auto_blacklist", null);
assert blackListSet != null; assert blackListSet != null;
arrayBlackList = new ArrayList<>(blackListSet); arrayBlackList = new ArrayList<>(blackListSet);
@ -100,7 +100,7 @@ public class AutoRootFragment extends ListFragment {
} }
} }
Logger.dh("Committing set, value is: " + arrayBlackList.toString()); Logger.dev("Committing set, value is: " + arrayBlackList.toString());
SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor editor = prefs.edit();
editor.putStringSet("auto_blacklist", new HashSet<>(arrayBlackList)); editor.putStringSet("auto_blacklist", new HashSet<>(arrayBlackList));
editor.apply(); editor.apply();

View File

@ -40,7 +40,7 @@ import butterknife.ButterKnife;
public class LogFragment extends Fragment { public class LogFragment extends Fragment {
private static final String MAGISK_LOG = "/cache/magisk.log"; private static final String MAGISK_LOG = "/cache/magisk.dev";
@BindView(R.id.txtLog) TextView txtLog; @BindView(R.id.txtLog) TextView txtLog;
@BindView(R.id.svLog) ScrollView svLog; @BindView(R.id.svLog) ScrollView svLog;
@ -154,7 +154,7 @@ public class LogFragment extends Fragment {
Calendar now = Calendar.getInstance(); Calendar now = Calendar.getInstance();
String filename = String.format( String filename = String.format(
"magisk_%s_%04d%02d%02d_%02d%02d%02d.log", "error", "magisk_%s_%04d%02d%02d_%02d%02d%02d.dev", "error",
now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,
now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE), now.get(Calendar.SECOND)); now.get(Calendar.MINUTE), now.get(Calendar.SECOND));

View File

@ -49,7 +49,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", ""); String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
Logger.dh("MainActivity: Theme is " + theme); Logger.dev("MainActivity: Theme is " + theme);
if (theme.equals("Dark")) { if (theme.equals("Dark")) {
setTheme(R.style.AppTheme_dh); setTheme(R.style.AppTheme_dh);
} }
@ -98,7 +98,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
navigationView.setCheckedItem(R.id.downloads); navigationView.setCheckedItem(R.id.downloads);
} }
} }
hm = getFragmentManager().findFragmentByTag("log"); hm = getFragmentManager().findFragmentByTag("dev");
if (hm != null) { if (hm != null) {
if (hm.isVisible()) { if (hm.isVisible()) {
navigationView.setCheckedItem(R.id.log); navigationView.setCheckedItem(R.id.log);
@ -143,7 +143,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
String toLaunch = ""; String toLaunch = "";
toLaunch = getIntent().getExtras().getString("Relaunch"); toLaunch = getIntent().getExtras().getString("Relaunch");
if (toLaunch.equals("Settings")) { if (toLaunch.equals("Settings")) {
Logger.dh("MainActivity: Intent has extras " + getIntent().getExtras().getString("Relaunch")); Logger.dev("MainActivity: Intent has extras " + getIntent().getExtras().getString("Relaunch"));
mSelectedId = R.id.settings; mSelectedId = R.id.settings;
} }
@ -170,7 +170,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.START);
} else { } else {
int backStackEntryCount = getFragmentManager().getBackStackEntryCount(); int backStackEntryCount = getFragmentManager().getBackStackEntryCount();
Logger.dh("Welcomeactivity: Entrycount is " + backStackEntryCount); Logger.dev("Welcomeactivity: Entrycount is " + backStackEntryCount);
if (backStackEntryCount >= 2) { if (backStackEntryCount >= 2) {
super.onBackPressed(); super.onBackPressed();
} else { } else {
@ -227,7 +227,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
break; break;
case R.id.log: case R.id.log:
setTitle(R.string.log); setTitle(R.string.log);
tag = "log"; tag = "dev";
navFragment = new LogFragment(); navFragment = new LogFragment();
break; break;
case R.id.settings: case R.id.settings:

View File

@ -9,20 +9,17 @@ import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView; import android.widget.TextView;
import com.ipaulpro.afilechooser.utils.FileUtils; import com.ipaulpro.afilechooser.utils.FileUtils;
import com.topjohnwu.magisk.module.Module; import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -73,7 +70,7 @@ public class ModulesFragment extends Fragment {
listener = (pref, s) -> { listener = (pref, s) -> {
if (s.equals("module_done")) { if (s.equals("module_done")) {
if (pref.getBoolean(s, false)) { if (pref.getBoolean(s, false)) {
Logger.dh("ModulesFragment: UI refresh triggered"); Logger.dev("ModulesFragment: UI refresh triggered");
updateUI(); updateUI();
} }
} }

View File

@ -9,7 +9,6 @@ import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -66,7 +65,7 @@ public class ReposFragment extends Fragment {
listener = (pref, s) -> { listener = (pref, s) -> {
if (s.equals("repo_done")) { if (s.equals("repo_done")) {
if (pref.getBoolean(s, false)) { if (pref.getBoolean(s, false)) {
Logger.dh("ReposFragment: UI refresh triggered"); Logger.dev("ReposFragment: UI refresh triggered");
updateUI(); updateUI();
} }
} }
@ -146,7 +145,7 @@ public class ReposFragment extends Fragment {
// }; // };
// //
// String theme = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("theme", ""); // String theme = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("theme", "");
// Logger.dh("ReposFragment: Theme is " + theme); // Logger.dev("ReposFragment: Theme is " + theme);
// if (theme.equals("Dark")) { // if (theme.equals("Dark")) {
// builder = new AlertDialog.Builder(getActivity(),R.style.AlertDialog_dh); // builder = new AlertDialog.Builder(getActivity(),R.style.AlertDialog_dh);
// } else { // } else {

View File

@ -174,7 +174,7 @@ public class RootFragment extends Fragment {
listener = (prefs1, key) -> { listener = (prefs1, key) -> {
if ((key.contains("autoRootEnable")) | (key.equals("root"))) { if ((key.contains("autoRootEnable")) | (key.equals("root"))) {
Logger.dh("RootFragmnet, keychange detected for " + key); Logger.dev("RootFragmnet, keychange detected for " + key);
new updateUI().execute(); new updateUI().execute();
} }

View File

@ -100,7 +100,7 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Logger.dh("Settings: NewValue is " + key); Logger.dev("Settings: NewValue is " + key);
if (key.equals("theme")) { if (key.equals("theme")) {
String pref = sharedPreferences.getString(key, ""); String pref = sharedPreferences.getString(key, "");
@ -117,7 +117,7 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
intent.putExtra("Relaunch", "Settings"); intent.putExtra("Relaunch", "Settings");
startActivity(intent); startActivity(intent);
Logger.dh("SettingsFragment: theme is " + pref); Logger.dev("SettingsFragment: theme is " + pref);
} }

View File

@ -10,10 +10,8 @@ import android.support.v7.app.AppCompatActivity;
import com.topjohnwu.magisk.services.MonitorService; import com.topjohnwu.magisk.services.MonitorService;
import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -34,7 +32,7 @@ public class SplashActivity extends AppCompatActivity {
if (!defaultPrefs.contains("auto_blacklist")) { if (!defaultPrefs.contains("auto_blacklist")) {
Logger.dh("SplashActivity: Setting default preferences for application"); Logger.dev("SplashActivity: Setting default preferences for application");
SharedPreferences.Editor editor = defaultPrefs.edit(); SharedPreferences.Editor editor = defaultPrefs.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");

View File

@ -25,7 +25,7 @@ public class Module extends BaseModule {
if (mName == null) if (mName == null)
mName = mId; mName = mId;
Logger.dh("Creating Module, id: " + mId); Logger.dev("Creating Module, id: " + mId);
mEnable = !Utils.itemExist(mDisableFile); mEnable = !Utils.itemExist(mDisableFile);
mRemove = Utils.itemExist(mRemoveFile); mRemove = Utils.itemExist(mRemoveFile);

View File

@ -65,7 +65,7 @@ public class MonitorService extends AccessibilityService {
ActivityInfo activityInfo = tryGetActivity(componentName); ActivityInfo activityInfo = tryGetActivity(componentName);
boolean isActivity = activityInfo != null; boolean isActivity = activityInfo != null;
if (isActivity) { if (isActivity) {
Logger.dh("MonitorService: CurrentActivity: " + event.getPackageName()); Logger.dev("MonitorService: CurrentActivity: " + event.getPackageName());
String mPackage = componentName.getPackageName(); String mPackage = componentName.getPackageName();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
@ -108,11 +108,11 @@ public class MonitorService extends AccessibilityService {
String rootString = rootToggle ? "on" : "off"; String rootString = rootToggle ? "on" : "off";
if (Utils.rootEnabled() != rootToggle) { if (Utils.rootEnabled() != rootToggle) {
Logger.dh("MonitorService: toggling root " + rootString); Logger.dev("MonitorService: toggling root " + rootString);
Utils.toggleRoot(rootToggle, getApplicationContext()); Utils.toggleRoot(rootToggle, getApplicationContext());
if (Utils.rootEnabled() != rootToggle) { if (Utils.rootEnabled() != rootToggle) {
Utils.toggleRoot(rootToggle, getApplicationContext()); Utils.toggleRoot(rootToggle, getApplicationContext());
Logger.dh("MonitorService: FORCING to " + rootString); Logger.dev("MonitorService: FORCING to " + rootString);
} }
} }

View File

@ -19,7 +19,7 @@ public class TileServiceNewApi extends android.service.quicksettings.TileService
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Logger.dh("QST (New): Service start"); Logger.dev("QST (New): Service start");
return super.onStartCommand(intent, flags, startId); return super.onStartCommand(intent, flags, startId);
} }
@ -27,7 +27,7 @@ public class TileServiceNewApi extends android.service.quicksettings.TileService
@Override @Override
public void onTileAdded() { public void onTileAdded() {
super.onTileAdded(); super.onTileAdded();
Logger.dh("QST (New): Tile added"); Logger.dev("QST (New): Tile added");
setupState(); setupState();
this.getQsTile().updateTile(); this.getQsTile().updateTile();
} }
@ -36,7 +36,7 @@ public class TileServiceNewApi extends android.service.quicksettings.TileService
public void onClick() { public void onClick() {
mRootsState = Utils.CheckRootsState(getApplicationContext()); mRootsState = Utils.CheckRootsState(getApplicationContext());
switchState(mRootsState); switchState(mRootsState);
Logger.dh("QST (New): Tile clicked"); Logger.dev("QST (New): Tile clicked");
} }
@ -44,13 +44,13 @@ public class TileServiceNewApi extends android.service.quicksettings.TileService
public void onStartListening() { public void onStartListening() {
super.onStartListening(); super.onStartListening();
setupState(); setupState();
Logger.dh("QST (New): Tile is listening"); Logger.dev("QST (New): Tile is listening");
} }
@Override @Override
public void onStopListening() { public void onStopListening() {
super.onStopListening(); super.onStopListening();
Logger.dh("QST (New): Tile stopped listening"); Logger.dev("QST (New): Tile stopped listening");
} }
private void setupState() { private void setupState() {
@ -58,11 +58,11 @@ public class TileServiceNewApi extends android.service.quicksettings.TileService
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("autoRootEnable",false).apply(); PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("autoRootEnable",false).apply();
} }
mRootsState = Utils.CheckRootsState(getApplicationContext()); mRootsState = Utils.CheckRootsState(getApplicationContext());
Logger.dh("QST (New): SetupState"); Logger.dev("QST (New): SetupState");
Icon iconRoot = Icon.createWithResource(getApplicationContext(), R.drawable.root); Icon iconRoot = Icon.createWithResource(getApplicationContext(), R.drawable.root);
Icon iconAuto = Icon.createWithResource(getApplicationContext(), R.drawable.ic_autoroot); Icon iconAuto = Icon.createWithResource(getApplicationContext(), R.drawable.ic_autoroot);
Tile tile = getQsTile(); Tile tile = getQsTile();
Logger.dh("QST: State is " + mRootsState); Logger.dev("QST: State is " + mRootsState);
switch (mRootsState) { switch (mRootsState) {
case 2: case 2:

View File

@ -3,10 +3,12 @@ package com.topjohnwu.magisk.utils;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.OpenableColumns;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
@ -124,17 +126,17 @@ public class Async {
@Override @Override
protected Void doInBackground(Void... voids) { protected Void doInBackground(Void... voids) {
ModulesFragment.listModules.clear(); ModulesFragment.listModules.clear();
Logger.dh("Loading modules"); Logger.dev("Loading modules");
List<String> magisk = Utils.getModList(Utils.MAGISK_PATH); List<String> magisk = Utils.getModList(Utils.MAGISK_PATH);
List<String> magiskCache = Utils.getModList(Utils.MAGISK_CACHE_PATH); List<String> magiskCache = Utils.getModList(Utils.MAGISK_CACHE_PATH);
for (String mod : magisk) { for (String mod : magisk) {
Logger.dh("Adding modules from " + mod); Logger.dev("Adding modules from " + mod);
ModulesFragment.listModules.add(new Module(mod)); ModulesFragment.listModules.add(new Module(mod));
} }
for (String mod : magiskCache) { for (String mod : magiskCache) {
Logger.dh("Adding cache modules from " + mod); Logger.dev("Adding cache modules from " + mod);
Module cacheMod = new Module(mod); Module cacheMod = new Module(mod);
// Prevent people forgot to change module.prop // Prevent people forgot to change module.prop
cacheMod.setCache(); cacheMod.setCache();
@ -143,7 +145,7 @@ public class Async {
Collections.sort(ModulesFragment.listModules, new Utils.ModuleComparator()); Collections.sort(ModulesFragment.listModules, new Utils.ModuleComparator());
Logger.dh("Module load done"); Logger.dev("Module load done");
return null; return null;
} }
@ -199,7 +201,11 @@ public class Async {
public FlashZIP(Context context, Uri uri) { public FlashZIP(Context context, Uri uri) {
mContext = context; mContext = context;
mUri = uri; mUri = uri;
mName = uri.getLastPathSegment(); Cursor c = mContext.getContentResolver().query(uri, null, null, null, null);
int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
c.moveToFirst();
mName = c.getString(nameIndex);
c.close();
copyToSD = false; copyToSD = false;
} }
@ -217,7 +223,7 @@ public class Async {
} }
outputStream.close(); outputStream.close();
Logger.dh("FlashZip: File created successfully - " + f.getPath()); Logger.dev("FlashZip: File created successfully - " + f.getPath());
} }
@Override @Override
@ -228,7 +234,7 @@ public class Async {
@Override @Override
protected Boolean doInBackground(Void... voids) { protected Boolean doInBackground(Void... voids) {
Logger.dh("FlashZip Running... " + mName); Logger.dev("FlashZip Running... " + mName);
InputStream in; InputStream in;
try { try {
try { try {
@ -248,13 +254,18 @@ public class Async {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
Logger.dev(mName + "; " + mFile.getPath());
// return false;
if (Shell.rootAccess()) { if (Shell.rootAccess()) {
ret = Shell.su( ret = Shell.su(
"unzip -o " + mFile.getPath() + " META-INF/com/google/android/* -d " + mFile.getParent(), "unzip -o " + mFile.getPath() + " META-INF/com/google/android/* -d " + mFile.getParent(),
"BOOTMODE=true sh " + mFile.getParent() + "/META-INF/com/google/android/update-binary dummy 1 "+ mFile.getPath(), "BOOTMODE=true sh " + mFile.getParent() + "/META-INF/com/google/android/update-binary dummy 1 "+ mFile.getPath(),
"if [ $? -eq 0 ]; then echo true; else echo false; fi" "if [ $? -eq 0 ]; then echo true; else echo false; fi"
); );
Logger.dh("FlashZip: Console log:\n" + ret); Logger.dev("FlashZip: Console log:");
for (String line : ret) {
Logger.dev(line);
}
} }
// Copy the file to sdcard // Copy the file to sdcard
if (copyToSD) { if (copyToSD) {
@ -272,7 +283,7 @@ public class Async {
} }
} }
mFile.delete(); mFile.delete();
return ret == null || !Boolean.parseBoolean(ret.get(ret.size() - 1)); return ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1));
} }
@Override @Override
@ -285,9 +296,9 @@ public class Async {
} else { } else {
Toast.makeText(mContext, mContext.getString(R.string.manual_install, mFile.getAbsolutePath()), Toast.LENGTH_LONG).show(); Toast.makeText(mContext, mContext.getString(R.string.manual_install, mFile.getAbsolutePath()), Toast.LENGTH_LONG).show();
} }
return; } else {
done();
} }
done();
} }
protected void done() { protected void done() {

View File

@ -7,9 +7,9 @@ import android.util.Log;
public class Logger { public class Logger {
private static final String LOG_TAG = "Magisk: DH"; private static final String LOG_TAG = "Magisk: DEV";
public static void dh(String msg, Object... args) { public static void dev(String msg, Object... args) {
Context context = null; Context context = null;
try { try {
context = getApplicationUsingReflection(); context = getApplicationUsingReflection();
@ -25,6 +25,18 @@ public class Logger {
} }
} }
public static void dev(String msg) {
Context context = null;
try {
context = getApplicationUsingReflection();
} catch (Exception e) {
e.printStackTrace();
}
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("developer_logging", false)) {
Log.d(LOG_TAG, msg);
}
}
private static Application getApplicationUsingReflection() throws Exception { private static Application getApplicationUsingReflection() throws Exception {
return (Application) Class.forName("android.app.AppGlobals") return (Application) Class.forName("android.app.AppGlobals")
.getMethod("getInitialApplication").invoke(null, (Object[]) null); .getMethod("getInitialApplication").invoke(null, (Object[]) null);

View File

@ -92,7 +92,7 @@ public class Utils {
public static boolean autoToggleEnabled(Context context) { public static boolean autoToggleEnabled(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
Logger.dh("Utils: AutoRootEnableCheck is " + preferences.getBoolean("autoRootEnable", false)); Logger.dev("Utils: AutoRootEnableCheck is " + preferences.getBoolean("autoRootEnable", false));
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("autoRootEnable", false); return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("autoRootEnable", false);
} }
@ -137,7 +137,7 @@ public class Utils {
} }
public static void toggleAutoRoot(Boolean b, Context context) { public static void toggleAutoRoot(Boolean b, Context context) {
Logger.dh("Utils: toggleAutocalled for " + b ); Logger.dev("Utils: toggleAutocalled for " + b );
if (Utils.magiskVersion != -1) { if (Utils.magiskVersion != -1) {
if (!Utils.hasServicePermission(context)) { if (!Utils.hasServicePermission(context)) {
Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS); Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
@ -145,7 +145,7 @@ public class Utils {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); context.startActivity(intent);
} else { } else {
Logger.dh("Utils: toggleAuto checks passed, setting" + b ); Logger.dev("Utils: toggleAuto checks passed, setting" + b );
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("autoRootEnable", b).apply(); PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("autoRootEnable", b).apply();
Intent myServiceIntent = new Intent(context, MonitorService.class); Intent myServiceIntent = new Intent(context, MonitorService.class);
myServiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); myServiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -236,21 +236,21 @@ public class Utils {
} }
public static void SetupQuickSettingsTile(Context mContext) { public static void SetupQuickSettingsTile(Context mContext) {
Logger.dh("Utils: SetupQuickSettings called"); Logger.dev("Utils: SetupQuickSettings called");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Logger.dh("Utils: Starting N quick settings service"); Logger.dev("Utils: Starting N quick settings service");
Intent serviceIntent = new Intent(mContext, TileServiceNewApi.class); Intent serviceIntent = new Intent(mContext, TileServiceNewApi.class);
mContext.startService(serviceIntent); mContext.startService(serviceIntent);
} }
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
Logger.dh("Utils: Marshmallow build detected"); Logger.dev("Utils: Marshmallow build detected");
String mLabelString; String mLabelString;
int mRootIcon = R.drawable.root_white; int mRootIcon = R.drawable.root_white;
int mAutoRootIcon = R.drawable.ic_autoroot_white; int mAutoRootIcon = R.drawable.ic_autoroot_white;
int mRootDisabled = R.drawable.root_grey; int mRootDisabled = R.drawable.root_grey;
int mRootsState = CheckRootsState(mContext); int mRootsState = CheckRootsState(mContext);
Logger.dh("Utils: Root State returned as " + mRootsState); Logger.dev("Utils: Root State returned as " + mRootsState);
final Intent enableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_ENABLEROOT); final Intent enableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_ENABLEROOT);
final Intent disableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_DISABLEROOT); final Intent disableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_DISABLEROOT);
final Intent autoBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_AUTOROOT); final Intent autoBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_AUTOROOT);
@ -304,7 +304,7 @@ public class Utils {
List<String> lines = Shell.su("settings get secure sysui_qs_tiles"); List<String> lines = Shell.su("settings get secure sysui_qs_tiles");
if (lines != null && lines.size() == 1) { if (lines != null && lines.size() == 1) {
List<String> tiles = new LinkedList<>(Arrays.asList(lines.get(0).split(","))); List<String> tiles = new LinkedList<>(Arrays.asList(lines.get(0).split(",")));
Logger.dh("Utils: Current Tile String is " + tiles); Logger.dev("Utils: Current Tile String is " + tiles);
if (tiles.size() > 1) { if (tiles.size() > 1) {
for (String tile : tiles) { for (String tile : tiles) {
if (tile.equals(qsTileId)) { if (tile.equals(qsTileId)) {
@ -315,7 +315,7 @@ public class Utils {
tiles.add(Math.round(tiles.size() / 2), qsTileId); tiles.add(Math.round(tiles.size() / 2), qsTileId);
String newTiles = TextUtils.join(",", tiles); String newTiles = TextUtils.join(",", tiles);
Logger.dh("Utils: NewtilesString is " + newTiles); Logger.dev("Utils: NewtilesString is " + newTiles);
Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\""); Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\"");
Toast.makeText(context, "Tile installed", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Tile installed", Toast.LENGTH_SHORT).show();
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {

View File

@ -1,7 +1,5 @@
package com.topjohnwu.magisk.utils; package com.topjohnwu.magisk.utils;
import android.util.Log;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -52,7 +50,7 @@ public class WebRequest {
*/ */
public static String makeWebServiceCall(String urladdress, int requestmethod, public static String makeWebServiceCall(String urladdress, int requestmethod,
HashMap<String, String> params, boolean addNewLines) { HashMap<String, String> params, boolean addNewLines) {
Logger.dh("WebRequest: Service call " + urladdress); Logger.dev("WebRequest: Service call " + urladdress);
URL url; URL url;
String response = ""; String response = "";
try { try {