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

Commit bac1e07a authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7183002 from 4fa32434 to rvc-qpr3-release

Change-Id: I3391c8e6f569cc9b08507146cbcb6031fdf6caab
parents 073d189a 4fa32434
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -206,6 +206,12 @@ public class Process {
     */
    public static final int SE_UID = 1068;

    /**
     * Defines the UID/GID for the iorapd.
     * @hide
     */
    public static final int IORAPD_UID = 1071;

    /**
     * Defines the UID/GID for the NetworkStack app.
     * @hide
+18 −4
Original line number Diff line number Diff line
@@ -5694,7 +5694,7 @@ public class NotificationManagerService extends SystemService {
                    + " trying to post for invalid pkg " + pkg + " in user " + incomingUserId);
        }

        checkRestrictedCategories(notification);
        checkRestrictedCategories(pkg, notification);

        // Fix the notification as best we can.
        try {
@@ -8537,7 +8537,7 @@ public class NotificationManagerService extends SystemService {
     * Check if the notification is of a category type that is restricted to system use only,
     * if so throw SecurityException
     */
    private void checkRestrictedCategories(final Notification notification) {
    private void checkRestrictedCategories(final String pkg, final Notification notification) {
        try {
            if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE, 0)) {
                return;
@@ -8547,10 +8547,24 @@ public class NotificationManagerService extends SystemService {
                    + "restrictions check thus the check will be done anyway");
        }
        if (Notification.CATEGORY_CAR_EMERGENCY.equals(notification.category)
                || Notification.CATEGORY_CAR_WARNING.equals(notification.category)
                || Notification.CATEGORY_CAR_INFORMATION.equals(notification.category)) {
                || Notification.CATEGORY_CAR_WARNING.equals(notification.category)) {
                    checkCallerIsSystem();
        }

        if (Notification.CATEGORY_CAR_INFORMATION.equals(notification.category)) {
            checkCallerIsSystemOrSUW(pkg);
        }
    }

    private void checkCallerIsSystemOrSUW(final String pkg) {

        final PackageManagerInternal pmi = LocalServices.getService(
                PackageManagerInternal.class);
        String suwPkg =  pmi.getSetupWizardPackageName();
        if (suwPkg != null && suwPkg.equals(pkg)) {
            return;
        }
        checkCallerIsSystem();
    }

    @VisibleForTesting
+4 −0
Original line number Diff line number Diff line
@@ -6178,6 +6178,10 @@ public class PackageManagerService extends IPackageManager.Stub
    @Override
    public List<String> getAllPackages() {
        // Allow iorapd to call this method.
        if (Binder.getCallingUid() != Process.IORAPD_UID) {
            enforceSystemOrRootOrShell("getAllPackages is limited to privileged callers");
        }
        final int callingUid = Binder.getCallingUid();
        final int callingUserId = UserHandle.getUserId(callingUid);
        synchronized (mLock) {
+5 −5
Original line number Diff line number Diff line
@@ -512,7 +512,7 @@ public class LockTaskController {
            setStatusBarState(mLockTaskModeState, userId);
            setKeyguardState(mLockTaskModeState, userId);
            if (oldLockTaskModeState == LOCK_TASK_MODE_PINNED) {
                lockKeyguardIfNeeded();
                lockKeyguardIfNeeded(userId);
            }
            if (getDevicePolicyManager() != null) {
                getDevicePolicyManager().notifyLockTaskModeChanged(false, null, userId);
@@ -824,15 +824,15 @@ public class LockTaskController {
     * Helper method for locking the device immediately. This may be necessary when the device
     * leaves the pinned mode.
     */
    private void lockKeyguardIfNeeded() {
        if (shouldLockKeyguard()) {
    private void lockKeyguardIfNeeded(int userId) {
        if (shouldLockKeyguard(userId)) {
            mWindowManager.lockNow(null);
            mWindowManager.dismissKeyguard(null /* callback */, null /* message */);
            getLockPatternUtils().requireCredentialEntry(USER_ALL);
        }
    }

    private boolean shouldLockKeyguard() {
    private boolean shouldLockKeyguard(int userId) {
        // This functionality should be kept consistent with
        // com.android.settings.security.ScreenPinningSettings (see b/127605586)
        try {
@@ -842,7 +842,7 @@ public class LockTaskController {
        } catch (Settings.SettingNotFoundException e) {
            // Log to SafetyNet for b/127605586
            android.util.EventLog.writeEvent(0x534e4554, "127605586", -1, "");
            return getLockPatternUtils().isSecure(USER_CURRENT);
            return getLockPatternUtils().isSecure(userId);
        }
    }

+23 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutServiceInternal;
@@ -243,6 +244,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    Resources mResources;
    @Mock
    RankingHandler mRankingHandler;
    @Mock
    protected PackageManagerInternal mPackageManagerInternal;

    private static final int MAX_POST_DELAY = 1000;

@@ -1186,6 +1189,26 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertEquals(0, mBinderService.getActiveNotifications(PKG).length);
    }

    @Test
    public void testEnqueuedRestrictedNotifications_asSuwApp() throws Exception {
        LocalServices.removeServiceForTest(PackageManagerInternal.class);
        LocalServices.addService(PackageManagerInternal.class, mPackageManagerInternal);
        when(mPackageManagerInternal.getSetupWizardPackageName()).thenReturn(PKG);

        when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE, 0))
                .thenReturn(true);

        final StatusBarNotification sbn =
                generateNotificationRecord(mTestNotificationChannel, 0, "", false).getSbn();
        sbn.getNotification().category = Notification.CATEGORY_CAR_INFORMATION;
        mBinderService.enqueueNotificationWithTag(PKG, PKG,
                "testEnqueuedRestrictedNotifications_asSuwApp",
                sbn.getId(), sbn.getNotification(), sbn.getUserId());

        waitForIdle();
        assertEquals(1, mBinderService.getActiveNotifications(PKG).length);
    }

    @Test
    public void testBlockedNotifications_blockedByAssistant() throws Exception {
        when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false);
Loading