mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-12 12:33:37 +00:00
Remove unnecessary BroadcastReceiver
This commit is contained in:
parent
262185046a
commit
6c4d082f35
@ -53,6 +53,7 @@
|
|||||||
<receiver android:name="a.h">
|
<receiver android:name="a.h">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||||
@ -60,11 +61,6 @@
|
|||||||
<data android:scheme="package" />
|
<data android:scheme="package" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<receiver android:name="a.i">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
<!-- Service -->
|
<!-- Service -->
|
||||||
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package a;
|
|
||||||
|
|
||||||
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
|
|
||||||
|
|
||||||
public class i extends ShortcutReceiver {
|
|
||||||
/* stub */
|
|
||||||
}
|
|
@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.components.AboutCardRow;
|
import com.topjohnwu.magisk.components.AboutCardRow;
|
||||||
import com.topjohnwu.magisk.receivers.GeneralReceiver;
|
import com.topjohnwu.magisk.receivers.GeneralReceiver;
|
||||||
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
|
|
||||||
import com.topjohnwu.magisk.services.DownloadModuleService;
|
import com.topjohnwu.magisk.services.DownloadModuleService;
|
||||||
import com.topjohnwu.magisk.services.UpdateCheckService;
|
import com.topjohnwu.magisk.services.UpdateCheckService;
|
||||||
|
|
||||||
@ -20,7 +19,6 @@ public class ClassMap {
|
|||||||
classMap.put(FlashActivity.class, a.f.class);
|
classMap.put(FlashActivity.class, a.f.class);
|
||||||
classMap.put(UpdateCheckService.class, a.g.class);
|
classMap.put(UpdateCheckService.class, a.g.class);
|
||||||
classMap.put(GeneralReceiver.class, a.h.class);
|
classMap.put(GeneralReceiver.class, a.h.class);
|
||||||
classMap.put(ShortcutReceiver.class, a.i.class);
|
|
||||||
classMap.put(DownloadModuleService.class, a.j.class);
|
classMap.put(DownloadModuleService.class, a.j.class);
|
||||||
classMap.put(AboutCardRow.class, a.l.class);
|
classMap.put(AboutCardRow.class, a.l.class);
|
||||||
classMap.put(SuRequestActivity.class, a.m.class);
|
classMap.put(SuRequestActivity.class, a.m.class);
|
||||||
|
@ -7,7 +7,7 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.components.BaseActivity;
|
import com.topjohnwu.magisk.components.BaseActivity;
|
||||||
import com.topjohnwu.magisk.components.Notifications;
|
import com.topjohnwu.magisk.components.Notifications;
|
||||||
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
|
import com.topjohnwu.magisk.components.Shortcuts;
|
||||||
import com.topjohnwu.magisk.tasks.CheckUpdates;
|
import com.topjohnwu.magisk.tasks.CheckUpdates;
|
||||||
import com.topjohnwu.magisk.tasks.UpdateRepos;
|
import com.topjohnwu.magisk.tasks.UpdateRepos;
|
||||||
import com.topjohnwu.magisk.utils.AppUtils;
|
import com.topjohnwu.magisk.utils.AppUtils;
|
||||||
@ -54,7 +54,7 @@ public class SplashActivity extends BaseActivity {
|
|||||||
AppUtils.scheduleUpdateCheck();
|
AppUtils.scheduleUpdateCheck();
|
||||||
|
|
||||||
// Setup shortcuts
|
// Setup shortcuts
|
||||||
sendBroadcast(new Intent(this, ClassMap.get(ShortcutReceiver.class)));
|
Shortcuts.setup(this);
|
||||||
|
|
||||||
if (Networking.checkNetworkStatus(this)) {
|
if (Networking.checkNetworkStatus(this)) {
|
||||||
// Fire update check
|
// Fire update check
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.topjohnwu.magisk.receivers;
|
package com.topjohnwu.magisk.components;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ShortcutInfo;
|
import android.content.pm.ShortcutInfo;
|
||||||
@ -8,7 +7,6 @@ import android.content.pm.ShortcutManager;
|
|||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.App;
|
|
||||||
import com.topjohnwu.magisk.ClassMap;
|
import com.topjohnwu.magisk.ClassMap;
|
||||||
import com.topjohnwu.magisk.Config;
|
import com.topjohnwu.magisk.Config;
|
||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
@ -21,58 +19,58 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
public class ShortcutReceiver extends BroadcastReceiver {
|
public class Shortcuts {
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
public static void setup(Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||||
ShortcutManager manager = context.getSystemService(ShortcutManager.class);
|
ShortcutManager manager = context.getSystemService(ShortcutManager.class);
|
||||||
manager.setDynamicShortcuts(getShortCuts(App.self));
|
manager.setDynamicShortcuts(getShortCuts(context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
|
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
|
||||||
private ArrayList<ShortcutInfo> getShortCuts(App app) {
|
private static ArrayList<ShortcutInfo> getShortCuts(Context context) {
|
||||||
ArrayList<ShortcutInfo> shortCuts = new ArrayList<>();
|
ArrayList<ShortcutInfo> shortCuts = new ArrayList<>();
|
||||||
boolean root = Shell.rootAccess();
|
boolean root = Shell.rootAccess();
|
||||||
if (Utils.showSuperUser()) {
|
if (Utils.showSuperUser()) {
|
||||||
shortCuts.add(new ShortcutInfo.Builder(app, "superuser")
|
shortCuts.add(new ShortcutInfo.Builder(context, "superuser")
|
||||||
.setShortLabel(app.getString(R.string.superuser))
|
.setShortLabel(context.getString(R.string.superuser))
|
||||||
.setIntent(new Intent(app, ClassMap.get(SplashActivity.class))
|
.setIntent(new Intent(context, ClassMap.get(SplashActivity.class))
|
||||||
.putExtra(Const.Key.OPEN_SECTION, "superuser")
|
.putExtra(Const.Key.OPEN_SECTION, "superuser")
|
||||||
.setAction(Intent.ACTION_VIEW)
|
.setAction(Intent.ACTION_VIEW)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
||||||
.setIcon(Icon.createWithResource(app, R.drawable.sc_superuser))
|
.setIcon(Icon.createWithResource(context, R.drawable.sc_superuser))
|
||||||
.setRank(0)
|
.setRank(0)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
if (root && (boolean) Config.get(Config.Key.MAGISKHIDE)) {
|
if (root && (boolean) Config.get(Config.Key.MAGISKHIDE)) {
|
||||||
shortCuts.add(new ShortcutInfo.Builder(app, "magiskhide")
|
shortCuts.add(new ShortcutInfo.Builder(context, "magiskhide")
|
||||||
.setShortLabel(app.getString(R.string.magiskhide))
|
.setShortLabel(context.getString(R.string.magiskhide))
|
||||||
.setIntent(new Intent(app, ClassMap.get(SplashActivity.class))
|
.setIntent(new Intent(context, ClassMap.get(SplashActivity.class))
|
||||||
.putExtra(Const.Key.OPEN_SECTION, "magiskhide")
|
.putExtra(Const.Key.OPEN_SECTION, "magiskhide")
|
||||||
.setAction(Intent.ACTION_VIEW)
|
.setAction(Intent.ACTION_VIEW)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
||||||
.setIcon(Icon.createWithResource(app, R.drawable.sc_magiskhide))
|
.setIcon(Icon.createWithResource(context, R.drawable.sc_magiskhide))
|
||||||
.setRank(1)
|
.setRank(1)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
if (!(boolean) Config.get(Config.Key.COREONLY) && root && Config.magiskVersionCode >= 0) {
|
if (!(boolean) Config.get(Config.Key.COREONLY) && root && Config.magiskVersionCode >= 0) {
|
||||||
shortCuts.add(new ShortcutInfo.Builder(app, "modules")
|
shortCuts.add(new ShortcutInfo.Builder(context, "modules")
|
||||||
.setShortLabel(app.getString(R.string.modules))
|
.setShortLabel(context.getString(R.string.modules))
|
||||||
.setIntent(new Intent(app, ClassMap.get(SplashActivity.class))
|
.setIntent(new Intent(context, ClassMap.get(SplashActivity.class))
|
||||||
.putExtra(Const.Key.OPEN_SECTION, "modules")
|
.putExtra(Const.Key.OPEN_SECTION, "modules")
|
||||||
.setAction(Intent.ACTION_VIEW)
|
.setAction(Intent.ACTION_VIEW)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
||||||
.setIcon(Icon.createWithResource(app, R.drawable.sc_extension))
|
.setIcon(Icon.createWithResource(context, R.drawable.sc_extension))
|
||||||
.setRank(3)
|
.setRank(3)
|
||||||
.build());
|
.build());
|
||||||
shortCuts.add(new ShortcutInfo.Builder(app, "downloads")
|
shortCuts.add(new ShortcutInfo.Builder(context, "downloads")
|
||||||
.setShortLabel(app.getString(R.string.downloads))
|
.setShortLabel(context.getString(R.string.downloads))
|
||||||
.setIntent(new Intent(app, ClassMap.get(SplashActivity.class))
|
.setIntent(new Intent(context, ClassMap.get(SplashActivity.class))
|
||||||
.putExtra(Const.Key.OPEN_SECTION, "downloads")
|
.putExtra(Const.Key.OPEN_SECTION, "downloads")
|
||||||
.setAction(Intent.ACTION_VIEW)
|
.setAction(Intent.ACTION_VIEW)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK))
|
||||||
.setIcon(Icon.createWithResource(app, R.drawable.sc_cloud_download))
|
.setIcon(Icon.createWithResource(context, R.drawable.sc_cloud_download))
|
||||||
.setRank(2)
|
.setRank(2)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ import com.topjohnwu.magisk.Config;
|
|||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
import com.topjohnwu.magisk.SuRequestActivity;
|
import com.topjohnwu.magisk.SuRequestActivity;
|
||||||
import com.topjohnwu.magisk.components.Notifications;
|
import com.topjohnwu.magisk.components.Notifications;
|
||||||
|
import com.topjohnwu.magisk.components.Shortcuts;
|
||||||
import com.topjohnwu.magisk.utils.DownloadApp;
|
import com.topjohnwu.magisk.utils.DownloadApp;
|
||||||
import com.topjohnwu.magisk.utils.SuConnector;
|
import com.topjohnwu.magisk.utils.SuConnector;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
@ -75,6 +76,9 @@ public class GeneralReceiver extends BroadcastReceiver {
|
|||||||
app.mDB.deletePolicy(pkg);
|
app.mDB.deletePolicy(pkg);
|
||||||
Shell.su("magiskhide --rm " + pkg).submit();
|
Shell.su("magiskhide --rm " + pkg).submit();
|
||||||
break;
|
break;
|
||||||
|
case Intent.ACTION_LOCALE_CHANGED:
|
||||||
|
Shortcuts.setup(context);
|
||||||
|
break;
|
||||||
case Const.Key.BROADCAST_MANAGER_UPDATE:
|
case Const.Key.BROADCAST_MANAGER_UPDATE:
|
||||||
Config.managerLink = intent.getStringExtra(Const.Key.INTENT_SET_LINK);
|
Config.managerLink = intent.getStringExtra(Const.Key.INTENT_SET_LINK);
|
||||||
DownloadApp.upgrade(intent.getStringExtra(Const.Key.INTENT_SET_NAME));
|
DownloadApp.upgrade(intent.getStringExtra(Const.Key.INTENT_SET_NAME));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user