mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-19 02:11:28 +00:00
Remove unnecessary root calls
This commit is contained in:
parent
7eadc74f6c
commit
36c575023e
@ -12,13 +12,13 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
||||||
<activity android:name=".ui.MainActivity">
|
<!--<activity android:name=".ui.MainActivity">-->
|
||||||
<intent-filter>
|
<!--<intent-filter>-->
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<!--<action android:name="android.intent.action.MAIN"/>-->
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<!--<category android:name="android.intent.category.LAUNCHER"/>-->
|
||||||
</intent-filter>
|
<!--</intent-filter>-->
|
||||||
</activity>
|
<!--</activity>-->
|
||||||
<activity
|
<activity
|
||||||
android:name=".WelcomeActivity"
|
android:name=".WelcomeActivity"
|
||||||
android:configChanges="orientation|screenSize">
|
android:configChanges="orientation|screenSize">
|
||||||
|
@ -19,6 +19,7 @@ import android.view.View;
|
|||||||
import com.topjohnwu.magisk.ui.LogFragment;
|
import com.topjohnwu.magisk.ui.LogFragment;
|
||||||
import com.topjohnwu.magisk.ui.ModulesFragment;
|
import com.topjohnwu.magisk.ui.ModulesFragment;
|
||||||
import com.topjohnwu.magisk.ui.RootFragment;
|
import com.topjohnwu.magisk.ui.RootFragment;
|
||||||
|
import com.topjohnwu.magisk.ui.utils.Utils;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -44,6 +45,9 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils.initialize.execute();
|
||||||
|
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
|
||||||
|
@ -35,6 +35,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -226,13 +227,18 @@ public class LogFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
Utils.su("chmod 755 /cache");
|
|
||||||
Utils.su("chmod 644 /cache/magisk.log");
|
|
||||||
txtLog.setText("");
|
txtLog.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(File... log) {
|
protected String doInBackground(File... log) {
|
||||||
|
// Ensure initialize is done
|
||||||
|
try {
|
||||||
|
Utils.initialize.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 2);
|
Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 2);
|
||||||
|
|
||||||
StringBuilder llog = new StringBuilder(15 * 10 * 1024);
|
StringBuilder llog = new StringBuilder(15 * 10 * 1024);
|
||||||
|
@ -21,6 +21,7 @@ import java.io.File;
|
|||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -81,6 +82,13 @@ public class ModulesFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
|
// Ensure initialize is done
|
||||||
|
try {
|
||||||
|
Utils.initialize.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
File[] magisk = new File(MAGISK_PATH).listFiles(new FileFilter() {
|
File[] magisk = new File(MAGISK_PATH).listFiles(new FileFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
@ -88,8 +96,6 @@ public class ModulesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Utils.su("chmod 755 /cache");
|
|
||||||
|
|
||||||
File[] magiskCache = new File(MAGISK_CACHE_PATH).listFiles(new FileFilter() {
|
File[] magiskCache = new File(MAGISK_CACHE_PATH).listFiles(new FileFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.topjohnwu.magisk.ui.utils;
|
package com.topjohnwu.magisk.ui.utils;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.chainfire.libsuperuser.Shell;
|
import eu.chainfire.libsuperuser.Shell;
|
||||||
@ -7,7 +9,22 @@ import eu.chainfire.libsuperuser.Shell;
|
|||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static final String suPath = sh("getprop magisk.supath");
|
public static final String suPath = sh("getprop magisk.supath");
|
||||||
public static final boolean rootAccess = isRoot();
|
public static boolean rootAccess = false;
|
||||||
|
public static Init initialize = new Init();
|
||||||
|
|
||||||
|
public static class Init extends AsyncTask<Void, Integer, Void> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
// Check root access
|
||||||
|
rootAccess = isRoot();
|
||||||
|
// Permission for java code to read /cache files
|
||||||
|
if (rootAccess) {
|
||||||
|
su("chmod 755 /cache", "chmod 644 /cache/magisk.log");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String sh(String... commands) {
|
public static String sh(String... commands) {
|
||||||
List<String> result = Shell.SH.run(commands);
|
List<String> result = Shell.SH.run(commands);
|
||||||
@ -28,8 +45,6 @@ public class Utils {
|
|||||||
builder.append(s);
|
builder.append(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
Shell.SU.available();
|
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user