summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adam Bookatz <bookatz@google.com> 2020-07-30 16:33:45 -0700
committer Adam Bookatz <bookatz@google.com> 2020-08-14 12:15:12 -0700
commit78d63ac323b0c6c05db8968d84a6fa73c850fcdb (patch)
treedacf1ab21951674f73c867398c0f8b36993734f7
parent271e922bb0dd8a5c9cf47d0bc66647e50c8b6d4a (diff)
Fix confusion of userId vs. uid
Some functions were trying to get the UserHandle of a userId, but were instead treating the userId as a uid, and thereby getting the wrong UserHandle. Bug: 162543841 Test: atest com.android.internal.app.ChooserActivityTest Test: atest com.android.internal.app.ResolverActivityTest Test: atest ScreenshotNotificationSmartActionsTest Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest Change-Id: Ib977267e3bae0aa3c7b6b31cfe8f0b3f9cc884b1
-rw-r--r--core/java/android/content/pm/InstantAppRequest.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsTest.java8
-rw-r--r--services/core/java/com/android/server/pm/InstantAppResolver.java2
-rw-r--r--services/print/java/com/android/server/print/UserState.java5
-rw-r--r--services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java2
5 files changed, 12 insertions, 10 deletions
diff --git a/core/java/android/content/pm/InstantAppRequest.java b/core/java/android/content/pm/InstantAppRequest.java
index 84f5021f0538..5b5d109fb863 100644
--- a/core/java/android/content/pm/InstantAppRequest.java
+++ b/core/java/android/content/pm/InstantAppRequest.java
@@ -18,6 +18,7 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.UserIdInt;
import android.content.Intent;
import android.os.Bundle;
@@ -40,7 +41,7 @@ public final class InstantAppRequest {
/** Whether or not the requesting package was an instant app */
public final boolean isRequesterInstantApp;
/** ID of the user requesting the instant application */
- public final int userId;
+ public final @UserIdInt int userId;
/**
* Optional extra bundle provided by the source application to the installer for additional
* verification.
@@ -60,7 +61,7 @@ public final class InstantAppRequest {
public InstantAppRequest(AuxiliaryResolveInfo responseObj, Intent origIntent,
String resolvedType, String callingPackage, @Nullable String callingFeatureId,
- boolean isRequesterInstantApp, int userId, Bundle verificationBundle,
+ boolean isRequesterInstantApp, @UserIdInt int userId, Bundle verificationBundle,
boolean resolveForStart, @Nullable int[] hostDigestPrefixSecure,
@NonNull String token) {
this.responseObj = responseObj;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsTest.java
index 184329ec6e5f..e23f92616565 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsTest.java
@@ -86,7 +86,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
CompletableFuture<List<Notification.Action>> smartActionsFuture =
mScreenshotSmartActions.getSmartActionsFuture(
"", Uri.parse("content://authority/data"), bitmap, smartActionsProvider,
- true, UserHandle.getUserHandleForUid(UserHandle.myUserId()));
+ true, UserHandle.of(UserHandle.myUserId()));
assertNotNull(smartActionsFuture);
List<Notification.Action> smartActions = smartActionsFuture.get(5, TimeUnit.MILLISECONDS);
assertEquals(Collections.emptyList(), smartActions);
@@ -126,7 +126,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
CompletableFuture<List<Notification.Action>> smartActionsFuture =
mScreenshotSmartActions.getSmartActionsFuture(
"", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider,
- true, UserHandle.getUserHandleForUid(UserHandle.myUserId()));
+ true, UserHandle.of(UserHandle.myUserId()));
verify(mSmartActionsProvider, never()).getActions(any(), any(), any(), any(), any());
assertNotNull(smartActionsFuture);
List<Notification.Action> smartActions = smartActionsFuture.get(5, TimeUnit.MILLISECONDS);
@@ -140,7 +140,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
when(bitmap.getConfig()).thenReturn(Bitmap.Config.HARDWARE);
mScreenshotSmartActions.getSmartActionsFuture(
"", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider, true,
- UserHandle.getUserHandleForUid(UserHandle.myUserId()));
+ UserHandle.of(UserHandle.myUserId()));
verify(mSmartActionsProvider, times(1)).getActions(any(), any(), any(), any(), any());
}
@@ -156,7 +156,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
CompletableFuture<List<Notification.Action>> smartActionsFuture =
mScreenshotSmartActions.getSmartActionsFuture("", null, bitmap,
actionsProvider,
- true, UserHandle.getUserHandleForUid(UserHandle.myUserId()));
+ true, UserHandle.of(UserHandle.myUserId()));
assertNotNull(smartActionsFuture);
List<Notification.Action> smartActions = smartActionsFuture.get(5, TimeUnit.MILLISECONDS);
assertEquals(smartActions.size(), 0);
diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java
index 0b0f13929b2a..79f8dc1c9a1e 100644
--- a/services/core/java/com/android/server/pm/InstantAppResolver.java
+++ b/services/core/java/com/android/server/pm/InstantAppResolver.java
@@ -380,7 +380,7 @@ public abstract class InstantAppResolver {
sanitizeIntent(request.origIntent),
// This must only expose the secured version of the host
request.hostDigestPrefixSecure,
- UserHandle.getUserHandleForUid(request.userId),
+ UserHandle.of(request.userId),
request.isRequesterInstantApp,
request.token
);
diff --git a/services/print/java/com/android/server/print/UserState.java b/services/print/java/com/android/server/print/UserState.java
index e8266a574bf5..b93c519ec8e4 100644
--- a/services/print/java/com/android/server/print/UserState.java
+++ b/services/print/java/com/android/server/print/UserState.java
@@ -30,6 +30,7 @@ import static com.android.internal.util.function.pooled.PooledLambda.obtainMessa
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.UserIdInt;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -132,7 +133,7 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
private final Context mContext;
- private final int mUserId;
+ private final @UserIdInt int mUserId;
private final RemotePrintSpooler mSpooler;
@@ -650,7 +651,7 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
mPrintServiceRecommendationsService =
new RemotePrintServiceRecommendationService(mContext,
- UserHandle.getUserHandleForUid(mUserId), this);
+ UserHandle.of(mUserId), this);
}
mPrintServiceRecommendationsChangeListenerRecords.add(
new ListenerRecord<IRecommendationsChangeListener>(listener) {
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 8fc228734f37..867a99fb2b49 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -2623,7 +2623,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
UserHandle.myUserId(), UserManager.RESTRICTION_SOURCE_DEVICE_OWNER))
).when(getServices().userManager).getUserRestrictionSources(
eq(UserManager.DISALLOW_ADJUST_VOLUME),
- eq(UserHandle.getUserHandleForUid(UserHandle.myUserId())));
+ eq(UserHandle.of(UserHandle.myUserId())));
intent = dpm.createAdminSupportIntent(UserManager.DISALLOW_ADJUST_VOLUME);
assertNotNull(intent);
assertEquals(Settings.ACTION_SHOW_ADMIN_SUPPORT_DETAILS, intent.getAction());