Merge SP2A.220505.002

Bug: 231319788
Merged-In: I7707d01be37582461227edcecf5d559f2019c8a5
Change-Id: I1dad245a352258f2a0017b85f14c99f305d8d660
This commit is contained in:
Xin Li
2022-05-03 20:53:01 +00:00
18 changed files with 191 additions and 55 deletions

View File

@@ -55,4 +55,5 @@ interface IPackageInstallerSession {
int getParentSessionId();
boolean isStaged();
int getInstallFlags();
}

View File

@@ -1431,6 +1431,18 @@ public class PackageInstaller {
}
}
/**
* @return Session's {@link SessionParams#installFlags}.
* @hide
*/
public int getInstallFlags() {
try {
return mSession.getInstallFlags();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* @return the session ID of the multi-package session that this belongs to or
* {@link SessionInfo#INVALID_ID} if it does not belong to a multi-package session.

View File

@@ -16,7 +16,7 @@
package com.android.internal.policy;
interface IKeyguardStateCallback {
void onShowingStateChanged(boolean showing);
void onShowingStateChanged(boolean showing, int userId);
void onSimSecureStateChanged(boolean simSecure);
void onInputRestrictedStateChanged(boolean inputRestricted);
void onTrustedChanged(boolean trusted);

View File

@@ -1484,7 +1484,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
public void doKeyguardTimeout(Bundle options) {
mHandler.removeMessages(KEYGUARD_TIMEOUT);
Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT, options);
mHandler.sendMessage(msg);
// Treat these messages with priority - A call to timeout means the device should lock
// as soon as possible and not wait for other messages on the thread to process first.
mHandler.sendMessageAtFrontOfQueue(msg);
}
/**
@@ -1665,12 +1667,15 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
* @see #handleShow
*/
private void showLocked(Bundle options) {
Trace.beginSection("KeyguardViewMediator#showLocked aqcuiring mShowKeyguardWakeLock");
Trace.beginSection("KeyguardViewMediator#showLocked acquiring mShowKeyguardWakeLock");
if (DEBUG) Log.d(TAG, "showLocked");
// ensure we stay awake until we are finished displaying the keyguard
mShowKeyguardWakeLock.acquire();
Message msg = mHandler.obtainMessage(SHOW, options);
mHandler.sendMessage(msg);
// Treat these messages with priority - This call can originate from #doKeyguardTimeout,
// meaning the device should lock as soon as possible and not wait for other messages on
// the thread to process first.
mHandler.sendMessageAtFrontOfQueue(msg);
Trace.endSection();
}
@@ -1871,6 +1876,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
case KEYGUARD_TIMEOUT:
synchronized (KeyguardViewMediator.this) {
doKeyguardLocked((Bundle) msg.obj);
notifyDefaultDisplayCallbacks(mShowing);
}
break;
case DISMISS:
@@ -2880,7 +2886,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
for (int i = size - 1; i >= 0; i--) {
IKeyguardStateCallback callback = mKeyguardStateCallbacks.get(i);
try {
callback.onShowingStateChanged(showing);
callback.onShowingStateChanged(showing, KeyguardUpdateMonitor.getCurrentUser());
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onShowingStateChanged", e);
if (e instanceof DeadObjectException) {
@@ -2914,7 +2920,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
mKeyguardStateCallbacks.add(callback);
try {
callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
callback.onShowingStateChanged(mShowing);
callback.onShowingStateChanged(mShowing, KeyguardUpdateMonitor.getCurrentUser());
callback.onInputRestrictedStateChanged(mInputRestricted);
callback.onTrustedChanged(mUpdateMonitor.getUserHasTrust(
KeyguardUpdateMonitor.getCurrentUser()));

View File

@@ -21,7 +21,7 @@ import android.app.IActivityManager
import android.app.IUidObserver
import android.app.Notification
import android.app.Notification.CallStyle.CALL_TYPE_ONGOING
import android.content.Intent
import android.app.PendingIntent
import android.util.Log
import android.view.View
import androidx.annotation.VisibleForTesting
@@ -98,7 +98,7 @@ class OngoingCallController @Inject constructor(
val newOngoingCallInfo = CallNotificationInfo(
entry.sbn.key,
entry.sbn.notification.`when`,
entry.sbn.notification.contentIntent?.intent,
entry.sbn.notification.contentIntent,
entry.sbn.uid,
entry.sbn.notification.extras.getInt(
Notification.EXTRA_CALL_TYPE, -1) == CALL_TYPE_ONGOING,
@@ -230,7 +230,6 @@ class OngoingCallController @Inject constructor(
logger.logChipClicked()
activityStarter.postStartActivityDismissingKeyguard(
intent,
0,
ActivityLaunchAnimator.Controller.fromView(
backgroundView,
InteractionJankMonitor.CUJ_STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP)
@@ -351,7 +350,7 @@ class OngoingCallController @Inject constructor(
private data class CallNotificationInfo(
val key: String,
val callStartTime: Long,
val intent: Intent?,
val intent: PendingIntent?,
val uid: Int,
/** True if the call is currently ongoing (as opposed to incoming, screening, etc.). */
val isOngoing: Boolean,

View File

@@ -22,7 +22,6 @@ import android.app.IUidObserver
import android.app.Notification
import android.app.PendingIntent
import android.app.Person
import android.content.Intent
import android.service.notification.NotificationListenerService.REASON_USER_STOPPED
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
@@ -429,6 +428,19 @@ class OngoingCallControllerTest : SysuiTestCase() {
.isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_CLICKED.id)
}
/** Regression test for b/212467440. */
@Test
fun chipClicked_activityStarterTriggeredWithUnmodifiedIntent() {
val notifEntry = createOngoingCallNotifEntry()
val pendingIntent = notifEntry.sbn.notification.contentIntent
notifCollectionListener.onEntryUpdated(notifEntry)
chipView.performClick()
// Ensure that the sysui didn't modify the notification's intent -- see b/212467440.
verify(mockActivityStarter).postStartActivityDismissingKeyguard(eq(pendingIntent), any())
}
@Test
fun notifyChipVisibilityChanged_visibleEventLogged() {
controller.notifyChipVisibilityChanged(true)
@@ -570,7 +582,6 @@ class OngoingCallControllerTest : SysuiTestCase() {
notificationEntryBuilder.modifyNotification(context).setContentIntent(null)
} else {
val contentIntent = mock(PendingIntent::class.java)
`when`(contentIntent.intent).thenReturn(mock(Intent::class.java))
notificationEntryBuilder.modifyNotification(context).setContentIntent(contentIntent)
}

View File

@@ -3059,14 +3059,32 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
intent.putExtra(PHONE_CONSTANTS_SLOT_KEY, phoneId);
intent.putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, phoneId);
// Send the broadcast twice -- once for all apps with READ_PHONE_STATE, then again
// for all apps with READ_PRIV but not READ_PHONE_STATE. This ensures that any app holding
// either READ_PRIV or READ_PHONE get this broadcast exactly once.
mContext.sendBroadcastAsUser(intent, UserHandle.ALL, Manifest.permission.READ_PHONE_STATE);
mContext.createContextAsUser(UserHandle.ALL, 0)
.sendBroadcastMultiplePermissions(intent,
new String[] { Manifest.permission.READ_PRIVILEGED_PHONE_STATE },
new String[] { Manifest.permission.READ_PHONE_STATE });
// for all apps with READ_PRIVILEGED_PHONE_STATE but not READ_PHONE_STATE.
// Do this again twice, the first time for apps with ACCESS_FINE_LOCATION, then again with
// the location-sanitized service state for all apps without ACCESS_FINE_LOCATION.
// This ensures that any app holding either READ_PRIVILEGED_PHONE_STATE or READ_PHONE_STATE
// get this broadcast exactly once, and we are not exposing location without permission.
mContext.createContextAsUser(UserHandle.ALL, 0).sendBroadcastMultiplePermissions(intent,
new String[] {Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_FINE_LOCATION});
mContext.createContextAsUser(UserHandle.ALL, 0).sendBroadcastMultiplePermissions(intent,
new String[] {Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
Manifest.permission.ACCESS_FINE_LOCATION},
new String[] {Manifest.permission.READ_PHONE_STATE});
// Replace bundle with location-sanitized ServiceState
data = new Bundle();
state.createLocationInfoSanitizedCopy(true).fillInNotifierBundle(data);
intent.putExtras(data);
mContext.createContextAsUser(UserHandle.ALL, 0).sendBroadcastMultiplePermissions(intent,
new String[] {Manifest.permission.READ_PHONE_STATE},
new String[] {Manifest.permission.ACCESS_FINE_LOCATION});
mContext.createContextAsUser(UserHandle.ALL, 0).sendBroadcastMultiplePermissions(intent,
new String[] {Manifest.permission.READ_PRIVILEGED_PHONE_STATE},
new String[] {Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_FINE_LOCATION});
}
private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int phoneId,

View File

@@ -658,7 +658,14 @@ public class NotificationManagerService extends SystemService {
return mBuffer.descendingIterator();
}
public StatusBarNotification[] getArray(int count, boolean includeSnoozed) {
public StatusBarNotification[] getArray(UserManager um, int count, boolean includeSnoozed) {
ArrayList<Integer> currentUsers = new ArrayList<>();
currentUsers.add(UserHandle.USER_ALL);
Binder.withCleanCallingIdentity(() -> {
for (int user : um.getProfileIds(ActivityManager.getCurrentUser(), false)) {
currentUsers.add(user);
}
});
synchronized (mBufferLock) {
if (count == 0) count = mBufferSize;
List<StatusBarNotification> a = new ArrayList();
@@ -667,8 +674,10 @@ public class NotificationManagerService extends SystemService {
while (iter.hasNext() && i < count) {
Pair<StatusBarNotification, Integer> pair = iter.next();
if (pair.second != REASON_SNOOZED || includeSnoozed) {
i++;
a.add(pair.first);
if (currentUsers.contains(pair.first.getUserId())) {
i++;
a.add(pair.first);
}
}
}
return a.toArray(new StatusBarNotification[a.size()]);
@@ -4034,22 +4043,32 @@ public class NotificationManagerService extends SystemService {
android.Manifest.permission.ACCESS_NOTIFICATIONS,
"NotificationManagerService.getActiveNotifications");
StatusBarNotification[] tmp = null;
ArrayList<StatusBarNotification> tmp = new ArrayList<>();
int uid = Binder.getCallingUid();
ArrayList<Integer> currentUsers = new ArrayList<>();
currentUsers.add(UserHandle.USER_ALL);
Binder.withCleanCallingIdentity(() -> {
for (int user : mUm.getProfileIds(ActivityManager.getCurrentUser(), false)) {
currentUsers.add(user);
}
});
// noteOp will check to make sure the callingPkg matches the uid
if (mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg,
callingAttributionTag, null)
== AppOpsManager.MODE_ALLOWED) {
synchronized (mNotificationLock) {
tmp = new StatusBarNotification[mNotificationList.size()];
final int N = mNotificationList.size();
for (int i=0; i<N; i++) {
tmp[i] = mNotificationList.get(i).getSbn();
for (int i = 0; i < N; i++) {
final StatusBarNotification sbn = mNotificationList.get(i).getSbn();
if (currentUsers.contains(sbn.getUserId())) {
tmp.add(sbn);
}
}
}
}
return tmp;
return tmp.toArray(new StatusBarNotification[tmp.size()]);
}
/**
@@ -4158,7 +4177,7 @@ public class NotificationManagerService extends SystemService {
callingAttributionTag, null)
== AppOpsManager.MODE_ALLOWED) {
synchronized (mArchive) {
tmp = mArchive.getArray(count, includeSnoozed);
tmp = mArchive.getArray(mUm, count, includeSnoozed);
}
}
return tmp;

View File

@@ -126,6 +126,7 @@ import android.system.StructStat;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.EventLog;
import android.util.ExceptionUtils;
import android.util.MathUtils;
import android.util.Slog;
@@ -3097,6 +3098,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
if (mResolvedBaseFile == null) {
mResolvedBaseFile = new File(appInfo.getBaseCodePath());
inheritFileLocked(mResolvedBaseFile);
} else if ((params.installFlags & PackageManager.INSTALL_DONT_KILL_APP) != 0) {
EventLog.writeEvent(0x534e4554, "219044664");
// Installing base.apk. Make sure the app is restarted.
params.setDontKillApp(false);
}
// Inherit splits if not overridden.
@@ -3742,6 +3748,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
return params.isStaged;
}
@Override
public int getInstallFlags() {
return params.installFlags;
}
@Override
public DataLoaderParamsParcel getDataLoaderParams() {
mContext.enforceCallingOrSelfPermission(Manifest.permission.USE_INSTALLER_V2, null);

View File

@@ -195,6 +195,12 @@ public class KeyguardServiceWrapper implements IKeyguardService {
@Override // Binder interface
public void doKeyguardTimeout(Bundle options) {
int userId = mKeyguardStateMonitor.getCurrentUser();
if (mKeyguardStateMonitor.isSecure(userId)) {
// Preemptively inform the cache that the keyguard will soon be showing, as calls to
// doKeyguardTimeout are a signal to lock the device as soon as possible.
mKeyguardStateMonitor.onShowingStateChanged(true, userId);
}
try {
mService.doKeyguardTimeout(options);
} catch (RemoteException e) {

View File

@@ -78,8 +78,14 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
return mTrusted;
}
public int getCurrentUser() {
return mCurrentUserId;
}
@Override // Binder interface
public void onShowingStateChanged(boolean showing) {
public void onShowingStateChanged(boolean showing, int userId) {
if (userId != mCurrentUserId) return;
mIsShowing = showing;
mCallback.onShowingChanged();

View File

@@ -247,6 +247,8 @@ public class SliceManagerService extends ISliceManager.Stub {
if (autoGrantPermissions != null && callingPkg != null) {
// Need to own the Uri to call in with permissions to grant.
enforceOwner(callingPkg, uri, userId);
// b/208232850: Needs to verify caller before granting slice access
verifyCaller(callingPkg);
for (String perm : autoGrantPermissions) {
if (mContext.checkPermission(perm, pid, uid) == PERMISSION_GRANTED) {
int providerUser = ContentProvider.getUserIdFromUri(uri, userId);

View File

@@ -97,7 +97,7 @@ class EnsureActivitiesVisibleHelper {
// activities are actually behind other fullscreen activities, but still required
// to be visible (such as performing Recents animation).
final boolean resumeTopActivity = mTop != null && !mTop.mLaunchTaskBehind
&& mTaskFragment.isTopActivityFocusable()
&& mTaskFragment.canBeResumed(starting)
&& (starting == null || !starting.isDescendantOf(mTaskFragment));
ArrayList<TaskFragment> adjacentTaskFragments = null;

View File

@@ -1979,7 +1979,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
try {
if (mTaskSupervisor.realStartActivityLocked(r, app,
top == r && r.isFocusable() /*andResume*/, true /*checkConfig*/)) {
top == r && r.getTask().canBeResumed(r) /*andResume*/,
true /*checkConfig*/)) {
mTmpBoolean = true;
}
} catch (RemoteException e) {

View File

@@ -3297,9 +3297,6 @@ public class WindowManagerService extends IWindowManager.Stub
if (!checkCallingPermission(permission.CONTROL_KEYGUARD, "dismissKeyguard")) {
throw new SecurityException("Requires CONTROL_KEYGUARD permission");
}
if (mAtmInternal.isDreaming()) {
mAtmService.mTaskSupervisor.wakeUp("dismissKeyguard");
}
synchronized (mGlobalLock) {
mPolicy.dismissKeyguardLw(callback, message);
}

View File

@@ -15,16 +15,22 @@
*/
package com.android.server.notification;
import static android.os.UserHandle.USER_ALL;
import static android.os.UserHandle.USER_CURRENT;
import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_SYSTEM;
import static android.service.notification.NotificationListenerService.REASON_CANCEL;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
import android.app.Notification;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.notification.StatusBarNotification;
import android.test.suitebuilder.annotation.SmallTest;
@@ -35,6 +41,7 @@ import com.android.server.UiServiceTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
@@ -51,6 +58,8 @@ public class ArchiveTest extends UiServiceTestCase {
private static final int SIZE = 5;
private NotificationManagerService.Archive mArchive;
@Mock
private UserManager mUm;
@Before
public void setUp() {
@@ -59,6 +68,9 @@ public class ArchiveTest extends UiServiceTestCase {
mArchive = new NotificationManagerService.Archive(SIZE);
mArchive.updateHistoryEnabled(USER_SYSTEM, true);
mArchive.updateHistoryEnabled(USER_CURRENT, true);
when(mUm.getProfileIds(anyInt(), anyBoolean())).thenReturn(
new int[] {USER_CURRENT, USER_SYSTEM});
}
private StatusBarNotification getNotification(String pkg, int id, UserHandle user) {
@@ -70,7 +82,6 @@ public class ArchiveTest extends UiServiceTestCase {
pkg, pkg, id, null, 0, 0, n, user, null, System.currentTimeMillis());
}
@Test
public void testRecordAndRead() {
List<String> expected = new ArrayList<>();
@@ -81,13 +92,29 @@ public class ArchiveTest extends UiServiceTestCase {
mArchive.record(sbn, REASON_CANCEL);
}
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(mUm, SIZE, true));
assertThat(actual).hasSize(expected.size());
for (StatusBarNotification sbn : actual) {
assertThat(expected).contains(sbn.getKey());
}
}
@Test
public void testCrossUser() {
mArchive.record(getNotification("pkg", 1, UserHandle.of(USER_SYSTEM)), REASON_CANCEL);
mArchive.record(getNotification("pkg", 2, UserHandle.of(USER_CURRENT)), REASON_CANCEL);
mArchive.record(getNotification("pkg", 3, UserHandle.of(USER_ALL)), REASON_CANCEL);
mArchive.record(getNotification("pkg", 4, UserHandle.of(USER_NULL)), REASON_CANCEL);
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(mUm, SIZE, true));
assertThat(actual).hasSize(3);
for (StatusBarNotification sbn : actual) {
if (sbn.getUserId() == USER_NULL) {
fail("leaked notification from wrong user");
}
}
}
@Test
public void testRecordAndRead_overLimit() {
List<String> expected = new ArrayList<>();
@@ -99,7 +126,8 @@ public class ArchiveTest extends UiServiceTestCase {
}
}
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray((SIZE * 2), true));
List<StatusBarNotification> actual = Arrays.asList(
mArchive.getArray(mUm, (SIZE * 2), true));
assertThat(actual).hasSize(expected.size());
for (StatusBarNotification sbn : actual) {
assertThat(expected).contains(sbn.getKey());
@@ -119,7 +147,7 @@ public class ArchiveTest extends UiServiceTestCase {
}
}
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(mUm, SIZE, true));
assertThat(actual).hasSize(expected.size());
for (StatusBarNotification sbn : actual) {
assertThat(expected).contains(sbn.getKey());
@@ -140,7 +168,7 @@ public class ArchiveTest extends UiServiceTestCase {
}
mArchive.updateHistoryEnabled(USER_CURRENT, false);
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(mUm, SIZE, true));
assertThat(actual).hasSize(expected.size());
for (StatusBarNotification sbn : actual) {
assertThat(expected).contains(sbn.getKey());
@@ -165,7 +193,7 @@ public class ArchiveTest extends UiServiceTestCase {
}
mArchive.removeChannelNotifications("pkg", USER_CURRENT, "test0");
mArchive.removeChannelNotifications("pkg", USER_CURRENT, "test" + (SIZE - 2));
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(mUm, SIZE, true));
assertThat(actual).hasSize(expected.size());
for (StatusBarNotification sbn : actual) {
assertThat(expected).contains(sbn.getKey());
@@ -215,7 +243,7 @@ public class ArchiveTest extends UiServiceTestCase {
fail("Concurrent modification exception");
}
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(mUm, SIZE, true));
assertThat(actual).hasSize(expected.size());
for (StatusBarNotification sbn : actual) {
assertThat(expected).contains(sbn.getKey());

View File

@@ -475,6 +475,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
when(mPackageManager.getPackagesForUid(mUid)).thenReturn(new String[]{PKG});
when(mPackageManagerClient.getPackagesForUid(anyInt())).thenReturn(new String[]{PKG});
mContext.addMockSystemService(AppOpsManager.class, mock(AppOpsManager.class));
when(mUm.getProfileIds(0, false)).thenReturn(new int[]{0});
// write to a test file; the system file isn't readable from tests
mFile = new File(mContext.getCacheDir(), "test.xml");
@@ -6970,8 +6971,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
waitForIdle();
// A notification exists for the given record
StatusBarNotification[] notifsBefore = mBinderService.getActiveNotifications(PKG);
assertEquals(1, notifsBefore.length);
List<StatusBarNotification> notifsBefore =
mBinderService.getAppActiveNotifications(PKG, nr.getSbn().getUserId()).getList();
assertEquals(1, notifsBefore.size());
reset(mPackageManager);
@@ -8289,4 +8291,33 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
assertTrue(captor.getValue().isPackageAllowed(new VersionedPackage("apples", 1001)));
assertFalse(captor.getValue().isPackageAllowed(new VersionedPackage("test", 1002)));
}
@Test
public void testGetActiveNotification_filtersUsers() throws Exception {
when(mUm.getProfileIds(0, false)).thenReturn(new int[]{0, 10});
NotificationRecord nr0 =
generateNotificationRecord(mTestNotificationChannel, 0);
mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag0",
nr0.getSbn().getId(), nr0.getSbn().getNotification(), nr0.getSbn().getUserId());
NotificationRecord nr10 =
generateNotificationRecord(mTestNotificationChannel, 10);
mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag10",
nr10.getSbn().getId(), nr10.getSbn().getNotification(), nr10.getSbn().getUserId());
NotificationRecord nr11 =
generateNotificationRecord(mTestNotificationChannel, 11);
mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag11",
nr11.getSbn().getId(), nr11.getSbn().getNotification(), nr11.getSbn().getUserId());
waitForIdle();
StatusBarNotification[] notifs = mBinderService.getActiveNotifications(PKG);
assertEquals(2, notifs.length);
for (StatusBarNotification sbn : notifs) {
if (sbn.getUserId() == 11) {
fail("leaked data across users");
}
}
}
}

View File

@@ -31,7 +31,6 @@ import static android.window.DisplayAreaOrganizer.FEATURE_VENDOR_FIRST;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
@@ -42,7 +41,6 @@ import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -157,16 +155,6 @@ public class WindowManagerServiceTests extends WindowTestsBase {
verify(mWm.mAtmService).setFocusedTask(tappedTask.mTaskId, null);
}
@Test
public void testDismissKeyguardCanWakeUp() {
doReturn(true).when(mWm).checkCallingPermission(anyString(), anyString());
spyOn(mWm.mAtmInternal);
doReturn(true).when(mWm.mAtmInternal).isDreaming();
doNothing().when(mWm.mAtmService.mTaskSupervisor).wakeUp(anyString());
mWm.dismissKeyguard(null, "test-dismiss-keyguard");
verify(mWm.mAtmService.mTaskSupervisor).wakeUp(anyString());
}
@Test
public void testMoveWindowTokenToDisplay_NullToken_DoNothing() {
mWm.moveWindowTokenToDisplay(null, mDisplayContent.getDisplayId());