2017-01-29 16:52:43 +08:00
|
|
|
package com.topjohnwu.magisk.receivers;
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2018-07-21 02:59:36 +08:00
|
|
|
import android.text.TextUtils;
|
2017-01-29 16:52:43 +08:00
|
|
|
|
2018-09-16 04:16:18 -04:00
|
|
|
import com.topjohnwu.magisk.Data;
|
|
|
|
import com.topjohnwu.magisk.SuRequestActivity;
|
|
|
|
import com.topjohnwu.magisk.services.OnBootService;
|
|
|
|
import com.topjohnwu.magisk.utils.SuConnector;
|
2017-01-29 16:52:43 +08:00
|
|
|
|
|
|
|
public class BootReceiver extends BroadcastReceiver {
|
2017-02-05 22:02:14 +08:00
|
|
|
|
2018-06-26 00:29:01 +08:00
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
2018-10-27 22:06:24 -04:00
|
|
|
if (intent == null)
|
|
|
|
return;
|
2018-09-16 04:16:18 -04:00
|
|
|
if (TextUtils.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED)) {
|
2018-10-27 22:06:24 -04:00
|
|
|
String action = intent.getStringExtra("action");
|
|
|
|
if (action == null)
|
|
|
|
action = "boot";
|
|
|
|
switch (action) {
|
2018-09-16 04:16:18 -04:00
|
|
|
case "request":
|
|
|
|
Intent i = new Intent(context, Data.classMap.get(SuRequestActivity.class))
|
|
|
|
.putExtra("socket", intent.getStringExtra("socket"))
|
|
|
|
.putExtra("version", 2)
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
context.startActivity(i);
|
|
|
|
break;
|
|
|
|
case "log":
|
|
|
|
SuConnector.handleLogs(intent, 2);
|
|
|
|
break;
|
2018-10-27 22:06:24 -04:00
|
|
|
case "notify":
|
|
|
|
SuConnector.handleNotify(intent);
|
|
|
|
break;
|
2018-09-16 04:16:18 -04:00
|
|
|
case "boot":
|
|
|
|
OnBootService.enqueueWork(context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-07-01 17:55:43 +08:00
|
|
|
}
|
2017-01-29 16:52:43 +08:00
|
|
|
}
|