Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1016a192 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

Merge "Switch to task manager on tapping on long-running FGS alerts." into tm-dev

parents f16b5fb3 249ccd13
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -182,7 +182,7 @@ public final class AppRestrictionController {
    /**
    /**
     * Whether or not to show the foreground service manager on tapping notifications.
     * Whether or not to show the foreground service manager on tapping notifications.
     */
     */
    private static final boolean ENABLE_SHOW_FOREGROUND_SERVICE_MANAGER = false;
    private static final boolean ENABLE_SHOW_FOREGROUND_SERVICE_MANAGER = true;


    private final Context mContext;
    private final Context mContext;
    private final HandlerThread mBgHandlerThread;
    private final HandlerThread mBgHandlerThread;
@@ -1595,8 +1595,8 @@ public final class AppRestrictionController {
                        cancelRequestBgRestrictedIfNecessary(packageName, uid);
                        cancelRequestBgRestrictedIfNecessary(packageName, uid);
                        final Intent newIntent = new Intent(ACTION_SHOW_FOREGROUND_SERVICE_MANAGER);
                        final Intent newIntent = new Intent(ACTION_SHOW_FOREGROUND_SERVICE_MANAGER);
                        newIntent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                        newIntent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                        mContext.sendBroadcastAsUser(newIntent,
                        // Task manager runs in SystemUI, which is SYSTEM user only.
                                UserHandle.of(UserHandle.getUserId(uid)));
                        mContext.sendBroadcastAsUser(newIntent, UserHandle.SYSTEM);
                        break;
                        break;
                }
                }
            }
            }
@@ -1670,9 +1670,10 @@ public final class AppRestrictionController {
            if (ENABLE_SHOW_FOREGROUND_SERVICE_MANAGER) {
            if (ENABLE_SHOW_FOREGROUND_SERVICE_MANAGER) {
                final Intent intent = new Intent(ACTION_SHOW_FOREGROUND_SERVICE_MANAGER);
                final Intent intent = new Intent(ACTION_SHOW_FOREGROUND_SERVICE_MANAGER);
                intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                // Task manager runs in SystemUI, which is SYSTEM user only.
                pendingIntent = PendingIntent.getBroadcastAsUser(mContext, 0,
                pendingIntent = PendingIntent.getBroadcastAsUser(mContext, 0,
                        intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE,
                        intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE,
                        UserHandle.of(UserHandle.getUserId(uid)));
                        UserHandle.SYSTEM);
            } else {
            } else {
                final Intent intent = new Intent(Settings.ACTION_VIEW_ADVANCED_POWER_USAGE_DETAIL);
                final Intent intent = new Intent(Settings.ACTION_VIEW_ADVANCED_POWER_USAGE_DETAIL);
                intent.setData(Uri.fromParts(PACKAGE_SCHEME, packageName, null));
                intent.setData(Uri.fromParts(PACKAGE_SCHEME, packageName, null));
@@ -1750,7 +1751,7 @@ public final class AppRestrictionController {
                    SYSTEM_UID, UserHandle.getUserId(uid));
                    SYSTEM_UID, UserHandle.getUserId(uid));
            final String title = mContext.getString(titleRes);
            final String title = mContext.getString(titleRes);
            final String message = mContext.getString(messageRes,
            final String message = mContext.getString(messageRes,
                    ai != null ? pm.getText(packageName, ai.labelRes, ai) : packageName);
                    ai != null ? ai.loadLabel(pm) : packageName);
            final Icon icon = ai != null ? Icon.createWithResource(packageName, ai.icon) : null;
            final Icon icon = ai != null ? Icon.createWithResource(packageName, ai.icon) : null;


            postNotification(notificationId, packageName, uid, title, message, icon, pendingIntent,
            postNotification(notificationId, packageName, uid, title, message, icon, pendingIntent,