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

Commit 2993904f authored by Adnan Begovic's avatar Adnan Begovic Committed by Gerrit Code Review
Browse files

am: Cancel protected app notification on validation launch.

Change-Id: I89d7366e97db04874baa5b19c2dfee7f0100c848
TICKET: CYNGNOS-2130
parent 99b7ddcd
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1400,6 +1400,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final int POST_PRIVACY_NOTIFICATION_MSG = 60;
    static final int CANCEL_PRIVACY_NOTIFICATION_MSG = 61;
    static final int POST_COMPONENT_PROTECTED_MSG = 62;
    static final int CANCEL_PROTECTED_APP_NOTIFICATION = 63;
    static final int FIRST_ACTIVITY_STACK_MSG = 100;
    static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -2237,6 +2238,20 @@ public final class ActivityManagerService extends ActivityManagerNative
                    Slog.w(TAG, "Unable to create context for protected app notification", e);
                }
            } break;
            case CANCEL_PROTECTED_APP_NOTIFICATION: {
                INotificationManager inm = NotificationManager.getService();
                if (inm == null) {
                    return;
                }
                try {
                    inm.cancelNotificationWithTag("android", null,
                            R.string.notify_package_component_protected_title, msg.arg1);
                } catch (RuntimeException e) {
                    Slog.w(ActivityManagerService.TAG,
                            "Error canceling notification for service", e);
                } catch (RemoteException e) {
                }
            } break;
            }
        }
    };
+14 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;

import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;

import android.text.TextUtils;
import android.util.ArraySet;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.content.ReferrerIntent;
@@ -271,6 +272,8 @@ final class ActivityStack {
    }

    private final PerformanceManagerInternal mPerf;
    private static final String PROTECTED_APPS_TARGET_VALIDATION_COMPONENT =
            "com.android.settings/com.android.settings.applications.ProtectedAppsActivity";

    final Handler mHandler;

@@ -1144,6 +1147,7 @@ final class ActivityStack {
        }

        updatePrivacyGuardNotificationLocked(next);
        updateProtectedAppNotificationLocked(next);
    }

    private void setVisible(ActivityRecord r, boolean visible) {
@@ -2100,6 +2104,16 @@ final class ActivityStack {
        updateTaskMovement(task, true);
    }

    private final void updateProtectedAppNotificationLocked(ActivityRecord next) {
        ComponentName componentName = ComponentName.unflattenFromString(next.shortComponentName);
        if (TextUtils.equals(componentName.flattenToString(),
                PROTECTED_APPS_TARGET_VALIDATION_COMPONENT)) {
            Message msg = mService.mHandler.obtainMessage(
                    ActivityManagerService.CANCEL_PROTECTED_APP_NOTIFICATION, next);
            msg.sendToTarget();
        }
    }

    private final void updatePrivacyGuardNotificationLocked(ActivityRecord next) {

        String privacyGuardPackageName = mStackSupervisor.mPrivacyGuardPackageName;