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