41 lines
1.4 KiB
Java
Raw Normal View History

2017-01-29 16:52:43 +08:00
package com.topjohnwu.magisk.receivers;
2017-02-07 06:02:06 +08:00
import android.app.IntentService;
2017-01-29 16:52:43 +08:00
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
2017-02-01 23:54:32 +08:00
import android.widget.Toast;
2017-01-29 16:52:43 +08:00
2017-02-07 02:01:32 +08:00
import com.topjohnwu.magisk.MagiskManager;
2017-02-01 23:54:32 +08:00
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Async;
2017-02-07 06:02:06 +08:00
import com.topjohnwu.magisk.utils.Shell;
2017-01-29 16:52:43 +08:00
public class BootReceiver extends BroadcastReceiver {
2017-02-05 22:02:14 +08:00
2017-01-29 16:52:43 +08:00
@Override
public void onReceive(Context context, Intent intent) {
2017-02-07 06:02:06 +08:00
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);
}
2017-02-05 22:02:14 +08:00
}
2017-01-29 16:52:43 +08:00
}
}