Fix MagiskHide startup issue
This commit is contained in:
parent
51b22d1ad4
commit
22a5c11f0d
@ -60,6 +60,8 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name=".receivers.BootReceiver$BootupIntentService" />
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="com.topjohnwu.magisk.provider"
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -3,8 +3,10 @@ package com.topjohnwu.magisk;
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.module.Repo;
|
||||
@ -20,6 +22,7 @@ import java.util.List;
|
||||
public class MagiskManager extends Application {
|
||||
|
||||
public static final String MAGISK_DISABLE_FILE = "/cache/.disable_magisk";
|
||||
public static final String MAGISK_MANAGER_BOOT = "/dev/.magisk_manager_boot";
|
||||
|
||||
// Events
|
||||
public final CallbackEvent<Void> blockDetectionDone = new CallbackEvent<>();
|
||||
@ -64,12 +67,22 @@ public class MagiskManager extends Application {
|
||||
|
||||
public SharedPreferences prefs;
|
||||
|
||||
private static Handler mHandler = new Handler();
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
}
|
||||
|
||||
public void toast(String msg, int duration) {
|
||||
mHandler.post(() -> Toast.makeText(this, msg, duration).show());
|
||||
}
|
||||
|
||||
public void toast(int resId, int duration) {
|
||||
mHandler.post(() -> Toast.makeText(this, resId, duration).show());
|
||||
}
|
||||
|
||||
public void init() {
|
||||
isDarkTheme = prefs.getBoolean("dark_theme", false);
|
||||
devLogging = prefs.getBoolean("developer_logging", false);
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
|
||||
import com.topjohnwu.magisk.components.Activity;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
public class SplashActivity extends Activity {
|
||||
|
||||
@ -17,10 +18,15 @@ public class SplashActivity extends Activity {
|
||||
|
||||
// Init the info and configs and root shell
|
||||
magiskManager.init();
|
||||
boolean boot_done = Utils.itemExist(MagiskManager.MAGISK_MANAGER_BOOT);
|
||||
|
||||
// Now fire all async tasks
|
||||
new Async.CheckUpdates(magiskManager).exec();
|
||||
new Async.GetBootBlocks(magiskManager).exec();
|
||||
if (magiskManager.prefs.getBoolean("magiskhide", false) && !magiskManager.disabled &&
|
||||
magiskManager.magiskVersion > 10.3 && boot_done) {
|
||||
new Async.MagiskHide().enable();
|
||||
}
|
||||
new Async.LoadModules(magiskManager) {
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -1,27 +1,40 @@
|
||||
package com.topjohnwu.magisk.receivers;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MagiskManager magiskManager = (MagiskManager) context.getApplicationContext();
|
||||
magiskManager.initSuAccess();
|
||||
magiskManager.updateMagiskInfo();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (prefs.getBoolean("magiskhide", false) && !magiskManager.disabled && magiskManager.magiskVersion > 10.3) {
|
||||
Toast.makeText(context, R.string.start_magiskhide, Toast.LENGTH_SHORT).show();
|
||||
new Async.MagiskHide(true).enable();
|
||||
context.startService(new Intent(context, BootupIntentService.class));
|
||||
}
|
||||
|
||||
public static class BootupIntentService extends IntentService {
|
||||
|
||||
public BootupIntentService() {
|
||||
super("BootupIntentService");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
MagiskManager magiskManager = (MagiskManager) getApplicationContext();
|
||||
magiskManager.initSuAccess();
|
||||
magiskManager.updateMagiskInfo();
|
||||
if (magiskManager.prefs.getBoolean("magiskhide", false) &&
|
||||
!magiskManager.disabled && magiskManager.magiskVersion > 10.3) {
|
||||
magiskManager.toast(R.string.start_magiskhide, Toast.LENGTH_LONG);
|
||||
Shell.su(true, Async.MAGISK_HIDE_PATH + "enable",
|
||||
"touch " + MagiskManager.MAGISK_MANAGER_BOOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -307,18 +307,10 @@ public class Async {
|
||||
|
||||
public static class MagiskHide extends RootTask<Object, Void, Void> {
|
||||
|
||||
private boolean newShell = false;
|
||||
|
||||
public MagiskHide() {}
|
||||
|
||||
public MagiskHide(boolean b) {
|
||||
newShell = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Object... params) {
|
||||
String command = (String) params[0];
|
||||
Shell.su(newShell, MAGISK_HIDE_PATH + command);
|
||||
Shell.su(MAGISK_HIDE_PATH + command);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,13 @@ public class Shell {
|
||||
process = Runtime.getRuntime().exec("su");
|
||||
STDIN = new DataOutputStream(process.getOutputStream());
|
||||
STDOUT = new StreamGobbler(process.getInputStream(), res);
|
||||
|
||||
// Run the new shell with busybox and proper umask
|
||||
STDIN.write(("umask 022\n").getBytes("UTF-8"));
|
||||
STDIN.flush();
|
||||
STDIN.write(("PATH=`[ -e /dev/busybox ] && echo /dev/busybox || " +
|
||||
"echo /data/busybox`:$PATH\n").getBytes("UTF-8"));
|
||||
STDIN.flush();
|
||||
} catch (IOException err) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.Context;
|
||||
import android.content.IntentFilter;
|
||||
@ -10,6 +9,7 @@ import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebView;
|
||||
|
Loading…
Reference in New Issue
Block a user