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