@Override public void onReceive(Context context, Intent intent) { /* * Close the notification bar in order to see the toast that module * was enabled successfully. Furthermore, if SU permissions haven't * been granted yet, the SU dialog will be prompted behind the * expanded notification panel and is therefore not visible to the * user. */ sContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); cancelAll(); if (intent.hasExtra(EXTRA_ACTIVATE_MODULE)) { String packageName = intent.getStringExtra(EXTRA_ACTIVATE_MODULE); ModuleUtil moduleUtil = ModuleUtil.getInstance(); moduleUtil.setModuleEnabled(packageName, true); moduleUtil.updateModulesList(false); Toast.makeText(sContext, R.string.module_activated, Toast.LENGTH_SHORT).show(); if (intent.hasExtra(EXTRA_ACTIVATE_MODULE_AND_RETURN)) return; } RootUtil rootUtil = new RootUtil(); if (!rootUtil.startShell()) { Log.e(XposedApp.TAG, "Could not start root shell"); return; } boolean isSoftReboot = intent.getBooleanExtra(EXTRA_SOFT_REBOOT, false); rootUtil.reboot( isSoftReboot ? RootUtil.RebootMode.SOFT : RootUtil.RebootMode.NORMAL, new RootUtil.LogLineCallback()); AssetUtil.removeBusybox(); }
public static void showNotActivatedNotification(String packageName, String appName) { Intent intent = new Intent(sContext, WelcomeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("fragment", 1); PendingIntent pModulesTab = PendingIntent.getActivity( sContext, PENDING_INTENT_OPEN_MODULES, intent, PendingIntent.FLAG_UPDATE_CURRENT); String title = sContext.getString(R.string.module_is_not_activated_yet); NotificationCompat.Builder builder = new NotificationCompat.Builder(sContext) .setContentTitle(title) .setContentText(appName) .setTicker(title) .setContentIntent(pModulesTab) .setVibrate(new long[] {0}) .setAutoCancel(true) .setSmallIcon(R.drawable.ic_notification) .setColor(sContext.getResources().getColor(R.color.colorPrimary)); if (Build.VERSION.SDK_INT >= 21) builder.setPriority(2); Intent iActivateAndReboot = new Intent(sContext, RebootReceiver.class); iActivateAndReboot.putExtra(RebootReceiver.EXTRA_ACTIVATE_MODULE, packageName); PendingIntent pActivateAndReboot = PendingIntent.getBroadcast( sContext, PENDING_INTENT_ACTIVATE_MODULE_AND_REBOOT, iActivateAndReboot, PendingIntent.FLAG_UPDATE_CURRENT); Intent iActivate = new Intent(sContext, RebootReceiver.class); iActivate.putExtra(RebootReceiver.EXTRA_ACTIVATE_MODULE, packageName); iActivate.putExtra(RebootReceiver.EXTRA_ACTIVATE_MODULE_AND_RETURN, true); PendingIntent pActivate = PendingIntent.getBroadcast( sContext, PENDING_INTENT_ACTIVATE_MODULE, iActivate, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle(); notiStyle.setBigContentTitle(title); notiStyle.bigText(sContext.getString(R.string.module_is_not_activated_yet_detailed, appName)); builder.setStyle(notiStyle); // Only show the quick activation button if any module has been // enabled before, // to ensure that the user know the way to disable the module later. if (!ModuleUtil.getInstance().getEnabledModules().isEmpty()) { builder.addAction( R.drawable.ic_menu_refresh, sContext.getString(R.string.activate_and_reboot), pActivateAndReboot); builder.addAction(R.drawable.ic_save, sContext.getString(R.string.activate_only), pActivate); } sNotificationManager.notify( packageName, NOTIFICATION_MODULE_NOT_ACTIVATED_YET, builder.build()); }
static Iterator<Set<Class<? extends Module<?>>>> getDotProductModuleCombinations( Collection<Class<? extends ModuleProvider<?>>> moduleClasses, boolean destructive) { Collection<Set<Class<? extends Module<?>>>> listOfOptions = mergeListsOfSameModuleType(ModuleUtil.getAllPossibleModules(moduleClasses)); return new DotProductIterator<Class<? extends Module<?>>>(listOfOptions); }