Revert "Snap for 6793014 from bbbccc3c2b7fc7c5780f6c415c4223e1d0..."
Revert "Snap for 6793014 from 44725f06b7f7d6407b5ee82d989bdd6c7a..."
Revert "Snap for 6793014 from f22ad3164937a8f2e309965c102b6366d5..."
Revert "Snap for 6793014 from 11467102abddb6026aaa164c1361439c2d..."
Revert "Snap for 6793014 from 265280bf5cb4bc14e132c3a35ae5f7ae65..."
Revert "Snap for 6793014 from f2989f9c65556d5155dbd57f82f0c93a16..."
Revert "Snap for 6793014 from 8b8bf0a07b0521bbe8483fbbab1222ffd6..."
Revert "Snap for 6793014 from 3777d883a3857b1a1589181c436d9018d7..."
Revert "Snap for 6793014 from 3157b4ee4325286f0c2ab0f26528460c8b..."
Revert "Snap for 6793014 from a43295d1825da62af038d345a7a861ed7a..."
Revert "Snap for 6793014 from 2076be4d27078d6ebc0a6b5e5ceb386109..."
Revert "Snap for 6793014 from d0e31526c62b2aeb35c293ac96feb180fc..."
Revert "Snap for 6793014 from 7a3a8c6351d5167a6ae0b33bc376efabd2..."
Revert "Snap for 6793014 from 41471cb21bb16b5c3bcc92f84293b79684..."
Revert "Snap for 6793014 from 42e5cca3cfb829690c9d8c6aca57a8e7d5..."
Revert "Snap for 6793014 from 4f81304963d19f4511b1e8e7d0aad87a67..."
Revert "Snap for 6793014 from 07602cdacf5bcc835db41f7eaa24af9964..."
Revert "Snap for 6793014 from 14cb57e107a3abce8b14937b1f92c28d18..."
Revert "Snap for 6793014 from ab1e4a81d09a540a5f927059e5bc03a606..."
Revert "Snap for 6793014 from 8c65adad0bcdfb3acc561063b4048dca24..."
Revert "Snap for 6793014 from b3061942700265e2bf04af9997775dcbbb..."
Revert "Snap for 6793014 from 551c5953fc62e339e4ee884ec2cd0ac3be..."
Revert "Snap for 6793014 from 4919273b2ac5c6347a18e17c5ec70d8da6..."
Revert "Snap for 6793014 from 988d4244914e0c749655e8cb6db18ba44f..."
Revert submission 12465146-release-request-6b259cbc-1f45-4b05-bc7e-c9b893b79d68-for-git_main-busytown-release-6793014
Reason for revert: b/166531456
Reverted Changes:
I5ff7a6c0d:Snap for 6793014 from f2989f9c65556d5155dbd57f82f0...
I77bdff943:Snap for 6793014 from a43295d1825da62af038d345a7a8...
I2ac5c520a:Snap for 6793014 from c3f124cca05579acf0a6cb589ebd...
I023b9702f:Snap for 6793014 from 98756d6d3e2bb0ba28eb125caa7a...
Ibc7893d72:Snap for 6793014 from fd1ad6750ef332d3f50f218f4d5d...
Ic27847bee:Snap for 6793014 from 8c65adad0bcdfb3acc561063b404...
If20bc9352:Snap for 6793014 from 7a3a8c6351d5167a6ae0b33bc376...
I6542d17e8:Snap for 6793014 from 3777d883a3857b1a1589181c436d...
I66e6bb8a9:Snap for 6793014 from 8b8bf0a07b0521bbe8483fbbab12...
I3cd190b6b:Snap for 6793014 from 424180bdc4aa18249e678daebfd0...
If92db7402:Snap for 6793014 from ab1e4a81d09a540a5f927059e5bc...
Iaced03c87:Snap for 6793014 from d0e31526c62b2aeb35c293ac96fe...
I5d28c6b4b:Snap for 6793014 from 4f81304963d19f4511b1e8e7d0aa...
I30d07bea3:Snap for 6793014 from 7594ec6384c4da320726def34f47...
I473205f48:Snap for 6793014 from 551c5953fc62e339e4ee884ec2cd...
I0656b41af:Snap for 6793014 from 44725f06b7f7d6407b5ee82d989b...
I0f9796067:Snap for 6793014 from 4919273b2ac5c6347a18e17c5ec7...
I9a38cda8f:Snap for 6793014 from 2076be4d27078d6ebc0a6b5e5ceb...
I876a82f51:Snap for 6793014 from 11467102abddb6026aaa164c1361...
I749d7d023:Snap for 6793014 from 41471cb21bb16b5c3bcc92f84293...
I038daea41:Snap for 6793014 from 07602cdacf5bcc835db41f7eaa24...
I47aa3131c:Snap for 6793014 from 14cb57e107a3abce8b14937b1f92...
I32dba8a95:Snap for 6793014 from 3157b4ee4325286f0c2ab0f26528...
I2ebc9f9db:Snap for 6793014 from 988d4244914e0c749655e8cb6db1...
Iae7c3370f:Snap for 6793014 from 9ffb8852294e06e2d387dc1fb868...
I6467a7f1b:Snap for 6793014 from 42e5cca3cfb829690c9d8c6aca57...
I8c6375203:Snap for 6793014 from b3061942700265e2bf04af999777...
I843b2e1f3:Snap for 6793014 from 265280bf5cb4bc14e132c3a35ae5...
Ie254f7079:Snap for 6793014 from f22ad3164937a8f2e309965c102b...
I01e0974ed:Snap for 6793014 from bbbccc3c2b7fc7c5780f6c415c42...
Change-Id: I9160aa1ae5523d8e92c618ae1922576bb70a7ac8
diff --git a/services/companion/TEST_MAPPING b/services/companion/TEST_MAPPING
new file mode 100644
index 0000000..63f54fa
--- /dev/null
+++ b/services/companion/TEST_MAPPING
@@ -0,0 +1,12 @@
+{
+ "presubmit": [
+ {
+ "name": "CtsOsTestCases",
+ "options": [
+ {
+ "include-filter": "android.os.cts.CompanionDeviceManagerTest"
+ }
+ ]
+ }
+ ]
+}
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 35e88eb..7d81d41 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -2114,7 +2114,7 @@
* Owner or system user account was renamed, rename the account for
* those users with which the account was shared.
*/
- List<UserInfo> users = getUserManager().getUsers(true);
+ List<UserInfo> users = getUserManager().getAliveUsers();
for (UserInfo user : users) {
if (user.isRestricted()
&& (user.restrictedProfileParentId == parentUserId)) {
@@ -2373,7 +2373,7 @@
int parentUserId = accounts.userId;
if (canHaveProfile(parentUserId)) {
// Remove from any restricted profiles that are sharing this account.
- List<UserInfo> users = getUserManager().getUsers(true);
+ List<UserInfo> users = getUserManager().getAliveUsers();
for (UserInfo user : users) {
if (user.isRestricted() && parentUserId == (user.restrictedProfileParentId)) {
removeSharedAccountAsUser(account, user.id, callingUid);
@@ -4267,7 +4267,7 @@
*/
@NonNull
public AccountAndUser[] getAllAccounts() {
- final List<UserInfo> users = getUserManager().getUsers(true);
+ final List<UserInfo> users = getUserManager().getAliveUsers();
final int[] userIds = new int[users.size()];
for (int i = 0; i < userIds.length; i++) {
userIds[i] = users.get(i).id;
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/Face10.java b/services/core/java/com/android/server/biometrics/sensors/face/Face10.java
index 32bb2db..d9c62df 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/Face10.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/Face10.java
@@ -29,7 +29,6 @@
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
import android.hardware.biometrics.face.V1_0.IBiometricsFaceClientCallback;
import android.hardware.face.Face;
-import android.hardware.face.FaceManager;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.IFaceServiceReceiver;
import android.os.Build;
@@ -383,7 +382,7 @@
// is safe because authenticatorIds only change when A) new template has been enrolled,
// or B) all templates are removed.
mHandler.post(() -> {
- for (UserInfo user : UserManager.get(mContext).getUsers(true /* excludeDying */)) {
+ for (UserInfo user : UserManager.get(mContext).getAliveUsers()) {
final int targetUserId = user.id;
if (!mAuthenticatorIds.containsKey(targetUserId)) {
scheduleUpdateActiveUserWithoutHandler(targetUserId);
@@ -480,7 +479,8 @@
* notifying the previous caller that the interrupting operation is complete (e.g. the
* interrupting client's challenge has been revoked, so that the interrupted client can
* start retry logic if necessary). See
- * {@link FaceManager.GenerateChallengeCallback#onChallengeInterruptFinished(int)}
+ * {@link
+ *android.hardware.face.FaceManager.GenerateChallengeCallback#onChallengeInterruptFinished(int)}
* The only case of conflicting challenges is currently resetLockout --> enroll. So, the second
* option seems better as it prioritizes the new operation, which is user-facing.
*/
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/Fingerprint21.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/Fingerprint21.java
index c5c2822..3754bd7 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/Fingerprint21.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/Fingerprint21.java
@@ -440,7 +440,7 @@
// is safe because authenticatorIds only change when A) new template has been enrolled,
// or B) all templates are removed.
mHandler.post(() -> {
- for (UserInfo user : UserManager.get(mContext).getUsers(true /* excludeDying */)) {
+ for (UserInfo user : UserManager.get(mContext).getAliveUsers()) {
final int targetUserId = user.id;
if (!mAuthenticatorIds.containsKey(targetUserId)) {
scheduleUpdateActiveUserWithoutHandler(targetUserId);
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index ec12a97..b33aa0a 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -367,7 +367,7 @@
}
private void removeStaleAccounts() {
- for (UserInfo user : mUserManager.getUsers(true)) {
+ for (UserInfo user : mUserManager.getAliveUsers()) {
// Skip any partially created/removed users
if (user.partial) continue;
Account[] accountsForUser = AccountManagerService.getSingleton().getAccounts(
@@ -777,7 +777,7 @@
if (!mSyncStorageEngine.shouldGrantSyncAdaptersAccountAccess()) {
return;
}
- List<UserInfo> users = mUserManager.getUsers(true);
+ List<UserInfo> users = mUserManager.getAliveUsers();
final int userCount = users.size();
for (int i = 0; i < userCount; i++) {
UserHandle userHandle = users.get(i).getUserHandle();
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsStorage.java b/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
index e9a05a8..715e41c 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
@@ -746,7 +746,7 @@
public void dump(IndentingPrintWriter pw) {
final UserManager um = UserManager.get(mContext);
- for (UserInfo user : um.getUsers(false)) {
+ for (UserInfo user : um.getUsers()) {
File userPath = getSyntheticPasswordDirectoryForUser(user.id);
pw.println(String.format("User %d [%s]:", user.id, userPath.getAbsolutePath()));
pw.increaseIndent();
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java
index a604625..74b7bd7 100644
--- a/services/core/java/com/android/server/notification/ManagedServices.java
+++ b/services/core/java/com/android/server/notification/ManagedServices.java
@@ -1554,7 +1554,7 @@
if (!isEnabledForCurrentProfiles()) {
return false;
}
- return this.userid == userId;
+ return userId == USER_ALL || userId == this.userid;
}
public boolean enabledAndUserMatches(int nid) {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 0465855..12419a9 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -262,7 +262,6 @@
import com.android.server.IoThread;
import com.android.server.LocalServices;
import com.android.server.SystemService;
-import com.android.server.SystemService.TargetUser;
import com.android.server.UiThread;
import com.android.server.lights.LightsManager;
import com.android.server.lights.LogicalLight;
@@ -966,8 +965,7 @@
nv.recycle();
}
reportUserInteraction(r);
- mAssistants.notifyAssistantActionClicked(
- r.getSbn(), actionIndex, action, generatedByAssistant);
+ mAssistants.notifyAssistantActionClicked(r.getSbn(), action, generatedByAssistant);
}
}
@@ -8629,12 +8627,25 @@
ServiceManager.getService(Context.COMPANION_DEVICE_SERVICE));
}
- private boolean isVisibleToListener(StatusBarNotification sbn, ManagedServiceInfo listener) {
+ @VisibleForTesting
+ boolean isVisibleToListener(StatusBarNotification sbn, ManagedServiceInfo listener) {
if (!listener.enabledAndUserMatches(sbn.getUserId())) {
return false;
}
- // TODO: remove this for older listeners.
- return true;
+ return isInteractionVisibleToListener(listener, sbn.getUserId());
+ }
+
+ /**
+ * Returns whether the given assistant should be informed about interactions on the given user.
+ *
+ * Normally an assistant would be able to see all interactions on the current user and any
+ * associated profiles because they are notification listeners, but since NASes have one
+ * instance per user, we want to filter out interactions that are not for the user that the
+ * given NAS is bound in.
+ */
+ private boolean isInteractionVisibleToListener(ManagedServiceInfo info, int userId) {
+ boolean isAssistantService = mAssistants.isServiceTokenValidLocked(info.service);
+ return !isAssistantService || info.isSameUser(userId);
}
private boolean isPackageSuspendedForUser(String pkg, int uid) {
@@ -8856,8 +8867,6 @@
}
protected void onNotificationsSeenLocked(ArrayList<NotificationRecord> records) {
- // There should be only one, but it's a list, so while we enforce
- // singularity elsewhere, we keep it general here, to avoid surprises.
for (final ManagedServiceInfo info : NotificationAssistants.this.getServices()) {
ArrayList<String> keys = new ArrayList<>(records.size());
for (NotificationRecord r : records) {
@@ -8875,6 +8884,8 @@
}
protected void onPanelRevealed(int items) {
+ // send to all currently bounds NASes since notifications from both users will appear in
+ // the panel
for (final ManagedServiceInfo info : NotificationAssistants.this.getServices()) {
mHandler.post(() -> {
final INotificationListener assistant = (INotificationListener) info.service;
@@ -8888,6 +8899,8 @@
}
protected void onPanelHidden() {
+ // send to all currently bounds NASes since notifications from both users will appear in
+ // the panel
for (final ManagedServiceInfo info : NotificationAssistants.this.getServices()) {
mHandler.post(() -> {
final INotificationListener assistant = (INotificationListener) info.service;
@@ -8976,7 +8989,7 @@
}
notifyAssistantLocked(
sbn,
- false /* sameUserOnly */,
+ true /* sameUserOnly */,
(assistant, sbnHolder) -> {
try {
assistant.onNotificationVisibilityChanged(key, isVisible);
@@ -8994,7 +9007,7 @@
final String key = sbn.getKey();
notifyAssistantLocked(
sbn,
- false /* sameUserOnly */,
+ true /* sameUserOnly */,
(assistant, sbnHolder) -> {
try {
assistant.onNotificationExpansionChanged(key, isUserAction, isExpanded);
@@ -9010,7 +9023,7 @@
final String key = sbn.getKey();
notifyAssistantLocked(
sbn,
- false /* sameUserOnly */,
+ true /* sameUserOnly */,
(assistant, sbnHolder) -> {
try {
assistant.onNotificationDirectReply(key);
@@ -9026,7 +9039,7 @@
final String key = sbn.getKey();
notifyAssistantLocked(
sbn,
- false /* sameUserOnly */,
+ true /* sameUserOnly */,
(assistant, sbnHolder) -> {
try {
assistant.onSuggestedReplySent(
@@ -9043,12 +9056,12 @@
@GuardedBy("mNotificationLock")
void notifyAssistantActionClicked(
- final StatusBarNotification sbn, int actionIndex, Notification.Action action,
+ final StatusBarNotification sbn, Notification.Action action,
boolean generatedByAssistant) {
final String key = sbn.getKey();
notifyAssistantLocked(
sbn,
- false /* sameUserOnly */,
+ true /* sameUserOnly */,
(assistant, sbnHolder) -> {
try {
assistant.onActionClicked(
@@ -9072,7 +9085,7 @@
final StatusBarNotification sbn, final String snoozeCriterionId) {
notifyAssistantLocked(
sbn,
- false /* sameUserOnly */,
+ true /* sameUserOnly */,
(assistant, sbnHolder) -> {
try {
assistant.onNotificationSnoozedUntilContext(
@@ -9129,7 +9142,7 @@
}
protected void resetDefaultAssistantsIfNecessary() {
- final List<UserInfo> activeUsers = mUm.getUsers(true);
+ final List<UserInfo> activeUsers = mUm.getAliveUsers();
for (UserInfo userInfo : activeUsers) {
int userId = userInfo.getUserHandle().getIdentifier();
if (!hasUserSet(userId)) {
@@ -9293,10 +9306,12 @@
}
public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) {
+ // send to all currently bounds NASes since notifications from both users will appear in
+ // the status bar
for (final ManagedServiceInfo info : getServices()) {
mHandler.post(() -> {
final INotificationListener listener = (INotificationListener) info.service;
- try {
+ try {
listener.onStatusBarIconsBehaviorChanged(hideSilentStatusIcons);
} catch (RemoteException ex) {
Slog.e(TAG, "unable to notify listener "
@@ -9470,7 +9485,8 @@
&& changedHiddenNotifications.size() > 0;
for (final ManagedServiceInfo serviceInfo : getServices()) {
- if (!serviceInfo.isEnabledForCurrentProfiles()) {
+ if (!serviceInfo.isEnabledForCurrentProfiles() || !isInteractionVisibleToListener(
+ serviceInfo, ActivityManager.getCurrentUser())) {
continue;
}
@@ -9489,12 +9505,7 @@
final NotificationRankingUpdate update = makeRankingUpdateLocked(
serviceInfo);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyRankingUpdate(serviceInfo, update);
- }
- });
+ mHandler.post(() -> notifyRankingUpdate(serviceInfo, update));
}
}
}
@@ -9502,15 +9513,11 @@
@GuardedBy("mNotificationLock")
public void notifyListenerHintsChangedLocked(final int hints) {
for (final ManagedServiceInfo serviceInfo : getServices()) {
- if (!serviceInfo.isEnabledForCurrentProfiles()) {
+ if (!serviceInfo.isEnabledForCurrentProfiles() || !isInteractionVisibleToListener(
+ serviceInfo, ActivityManager.getCurrentUser())) {
continue;
}
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyListenerHintsChanged(serviceInfo, hints);
- }
- });
+ mHandler.post(() -> notifyListenerHintsChanged(serviceInfo, hints));
}
}
@@ -9562,15 +9569,12 @@
public void notifyInterruptionFilterChanged(final int interruptionFilter) {
for (final ManagedServiceInfo serviceInfo : getServices()) {
- if (!serviceInfo.isEnabledForCurrentProfiles()) {
+ if (!serviceInfo.isEnabledForCurrentProfiles() || !isInteractionVisibleToListener(
+ serviceInfo, ActivityManager.getCurrentUser())) {
continue;
}
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyInterruptionFilterChanged(serviceInfo, interruptionFilter);
- }
- });
+ mHandler.post(
+ () -> notifyInterruptionFilterChanged(serviceInfo, interruptionFilter));
}
}
@@ -9579,15 +9583,16 @@
if (channel == null) {
return;
}
- for (final ManagedServiceInfo serviceInfo : getServices()) {
- if (!serviceInfo.enabledAndUserMatches(UserHandle.getCallingUserId())) {
+ for (final ManagedServiceInfo info : getServices()) {
+ if (!info.enabledAndUserMatches(UserHandle.getCallingUserId())
+ || !isInteractionVisibleToListener(info, UserHandle.getCallingUserId())) {
continue;
}
BackgroundThread.getHandler().post(() -> {
- if (serviceInfo.isSystem || hasCompanionDevice(serviceInfo)) {
+ if (info.isSystem || hasCompanionDevice(info)) {
notifyNotificationChannelChanged(
- serviceInfo, pkg, user, channel, modificationType);
+ info, pkg, user, channel, modificationType);
}
});
}
@@ -9599,15 +9604,16 @@
if (group == null) {
return;
}
- for (final ManagedServiceInfo serviceInfo : getServices()) {
- if (!serviceInfo.enabledAndUserMatches(UserHandle.getCallingUserId())) {
+ for (final ManagedServiceInfo info : getServices()) {
+ if (!info.enabledAndUserMatches(UserHandle.getCallingUserId())
+ || !isInteractionVisibleToListener(info, UserHandle.getCallingUserId())) {
continue;
}
BackgroundThread.getHandler().post(() -> {
- if (serviceInfo.isSystem || hasCompanionDevice(serviceInfo)) {
+ if (info.isSystem || hasCompanionDevice(info)) {
notifyNotificationChannelGroupChanged(
- serviceInfo, pkg, user, group, modificationType);
+ info, pkg, user, group, modificationType);
}
});
}
@@ -9626,9 +9632,6 @@
private void notifyRemoved(ManagedServiceInfo info, StatusBarNotification sbn,
NotificationRankingUpdate rankingUpdate, NotificationStats stats, int reason) {
- if (!info.enabledAndUserMatches(sbn.getUserId())) {
- return;
- }
final INotificationListener listener = (INotificationListener) info.service;
StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
try {
diff --git a/services/core/java/com/android/server/om/OverlayManagerService.java b/services/core/java/com/android/server/om/OverlayManagerService.java
index a4debc1..d7a1ba2 100644
--- a/services/core/java/com/android/server/om/OverlayManagerService.java
+++ b/services/core/java/com/android/server/om/OverlayManagerService.java
@@ -288,7 +288,7 @@
private void initIfNeeded() {
final UserManager um = getContext().getSystemService(UserManager.class);
- final List<UserInfo> users = um.getUsers(true /*excludeDying*/);
+ final List<UserInfo> users = um.getAliveUsers();
synchronized (mLock) {
final int userCount = users.size();
for (int i = 0; i < userCount; i++) {
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index d137fd0..e44c8ab 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -760,6 +760,8 @@
return null;
}
+ // TODO(b/157921703): replace by getAliveUsers() or remove (so callers
+ // explicitly call the 3-booleans version)
public @NonNull List<UserInfo> getUsers(boolean excludeDying) {
return getUsers(/*excludePartial= */ true, excludeDying, /* excludePreCreated= */
true);
diff --git a/services/core/java/com/android/server/slice/SliceFullAccessList.java b/services/core/java/com/android/server/slice/SliceFullAccessList.java
index 6f5afa2..d25ddf8 100644
--- a/services/core/java/com/android/server/slice/SliceFullAccessList.java
+++ b/services/core/java/com/android/server/slice/SliceFullAccessList.java
@@ -101,7 +101,7 @@
public void readXml(XmlPullParser parser) throws XmlPullParserException, IOException {
// upgrade xml
int xmlVersion = XmlUtils.readIntAttribute(parser, ATT_VERSION, 0);
- final List<UserInfo> activeUsers = UserManager.get(mContext).getUsers(true);
+ final List<UserInfo> activeUsers = UserManager.get(mContext).getAliveUsers();
for (UserInfo userInfo : activeUsers) {
upgradeXml(xmlVersion, userInfo.getUserHandle().getIdentifier());
}
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index 0c85387..386f390 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -379,7 +379,7 @@
}
private void updateTrustAll() {
- List<UserInfo> userInfos = mUserManager.getUsers(true /* excludeDying */);
+ List<UserInfo> userInfos = mUserManager.getAliveUsers();
for (UserInfo userInfo : userInfos) {
updateTrust(userInfo.id, 0);
}
@@ -485,7 +485,7 @@
List<UserInfo> userInfos;
if (userIdOrAll == UserHandle.USER_ALL) {
- userInfos = mUserManager.getUsers(true /* excludeDying */);
+ userInfos = mUserManager.getAliveUsers();
} else {
userInfos = new ArrayList<>();
userInfos.add(mUserManager.getUserInfo(userIdOrAll));
@@ -644,7 +644,7 @@
}
List<UserInfo> userInfos;
if (userId == UserHandle.USER_ALL) {
- userInfos = mUserManager.getUsers(true /* excludeDying */);
+ userInfos = mUserManager.getAliveUsers();
} else {
userInfos = new ArrayList<>();
userInfos.add(mUserManager.getUserInfo(userId));
@@ -1171,7 +1171,7 @@
fout.println("disabled because the third-party apps can't run yet.");
return;
}
- final List<UserInfo> userInfos = mUserManager.getUsers(true /* excludeDying */);
+ final List<UserInfo> userInfos = mUserManager.getAliveUsers();
mHandler.runWithScissors(new Runnable() {
@Override
public void run() {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 277218d..c359b19 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -9438,8 +9438,7 @@
Preconditions.checkCallAuthorization(isDeviceOwner(identity));
return mInjector.binderWithCleanCallingIdentity(() -> {
- final List<UserInfo> userInfos = mInjector.getUserManager().getUsers(true
- /*excludeDying*/);
+ final List<UserInfo> userInfos = mInjector.getUserManager().getAliveUsers();
final List<UserHandle> userHandles = new ArrayList<>();
for (UserInfo userInfo : userInfos) {
UserHandle userHandle = userInfo.getUserHandle();
@@ -10362,7 +10361,7 @@
private void maybeClearLockTaskPolicyLocked() {
mInjector.binderWithCleanCallingIdentity(() -> {
- final List<UserInfo> userInfos = mUserManager.getUsers(/*excludeDying=*/ true);
+ final List<UserInfo> userInfos = mUserManager.getAliveUsers();
for (int i = userInfos.size() - 1; i >= 0; i--) {
int userId = userInfos.get(i).id;
if (canUserUseLockTaskLocked(userId)) {
@@ -10849,7 +10848,7 @@
* them.
*/
void updateUserSetupCompleteAndPaired() {
- List<UserInfo> users = mUserManager.getUsers(true);
+ List<UserInfo> users = mUserManager.getAliveUsers();
final int N = users.size();
for (int i = 0; i < N; i++) {
int userHandle = users.get(i).id;
@@ -12571,7 +12570,7 @@
private boolean areAllUsersAffiliatedWithDeviceLocked() {
return mInjector.binderWithCleanCallingIdentity(() -> {
- final List<UserInfo> userInfos = mUserManager.getUsers(/*excludeDying=*/ true);
+ final List<UserInfo> userInfos = mUserManager.getAliveUsers();
for (int i = 0; i < userInfos.size(); i++) {
int userId = userInfos.get(i).id;
if (!isUserAffiliatedWithDeviceLocked(userId)) {
@@ -13040,7 +13039,7 @@
}
} else {
// Caller is the device owner: Look for profile owners that it can bind to.
- final List<UserInfo> userInfos = mUserManager.getUsers(/*excludeDying=*/ true);
+ final List<UserInfo> userInfos = mUserManager.getAliveUsers();
for (int i = 0; i < userInfos.size(); i++) {
final int userId = userInfos.get(i).id;
if (userId != callingUserId && canUserBindToDeviceOwnerLocked(userId)) {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
index 3cdd482..7649af4 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
@@ -169,7 +169,7 @@
// First, try to read from the legacy file.
final File legacy = getLegacyConfigFile();
- final List<UserInfo> users = mUserManager.getUsers(true);
+ final List<UserInfo> users = mUserManager.getAliveUsers();
if (readLegacyOwnerFileLocked(legacy)) {
if (DEBUG) {
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
index b306ff0..431cc27 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
@@ -16,7 +16,6 @@
package com.android.server.devicepolicy;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -236,7 +235,7 @@
}
mUserInfos.add(uh);
when(userManager.getUsers()).thenReturn(mUserInfos);
- when(userManager.getUsers(anyBoolean())).thenReturn(mUserInfos);
+ when(userManager.getAliveUsers()).thenReturn(mUserInfos);
when(userManager.isUserRunning(eq(new UserHandle(userId)))).thenReturn(true);
when(userManager.getProfileParent(anyInt())).thenAnswer(
invocation -> {
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
index 99433a6..d7e431f 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
@@ -978,6 +978,7 @@
assertFalse(services.isSameUser(service, 0));
assertTrue(services.isSameUser(service, 10));
+ assertTrue(services.isSameUser(service, UserHandle.USER_ALL));
}
@Test
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
index ab4dc47..5796e84 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
@@ -103,7 +103,7 @@
when(mUm.getUserInfo(eq(user.id))).thenReturn(user);
}
when(mUm.getUsers()).thenReturn(users);
- when(mUm.getUsers(anyBoolean())).thenReturn(users);
+ when(mUm.getAliveUsers()).thenReturn(users);
IntArray profileIds = new IntArray();
profileIds.add(0);
profileIds.add(11);
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 9319bea..86447192 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -5058,7 +5058,7 @@
10, 10, r.getKey(), actionIndex, action, notificationVisibility,
generatedByAssistant);
verify(mAssistants).notifyAssistantActionClicked(
- eq(r.getSbn()), eq(actionIndex), eq(action), eq(generatedByAssistant));
+ eq(r.getSbn()), eq(action), eq(generatedByAssistant));
assertEquals(1, mNotificationRecordLogger.numCalls());
assertEquals(
@@ -5082,7 +5082,7 @@
10, 10, r.getKey(), actionIndex, action, notificationVisibility,
generatedByAssistant);
verify(mAssistants).notifyAssistantActionClicked(
- eq(r.getSbn()), eq(actionIndex), eq(action), eq(generatedByAssistant));
+ eq(r.getSbn()), eq(action), eq(generatedByAssistant));
assertEquals(1, mNotificationRecordLogger.numCalls());
assertEquals(
@@ -6948,4 +6948,63 @@
assertEquals(NotificationManagerService.MAX_PACKAGE_NOTIFICATIONS + 1,
mService.getNotificationRecordCount());
}
+
+ @Test
+ public void testIsVisibleToListener_notEnabled() {
+ StatusBarNotification sbn = mock(StatusBarNotification.class);
+ when(sbn.getUserId()).thenReturn(10);
+ ManagedServices.ManagedServiceInfo info = mock(ManagedServices.ManagedServiceInfo.class);
+ ManagedServices.ManagedServiceInfo assistant = mock(ManagedServices.ManagedServiceInfo.class);
+ info.userid = 10;
+ when(info.isSameUser(anyInt())).thenReturn(true);
+ when(assistant.isSameUser(anyInt())).thenReturn(true);
+ when(info.enabledAndUserMatches(info.userid)).thenReturn(false);
+ when(mAssistants.checkServiceTokenLocked(any())).thenReturn(assistant);
+
+ assertFalse(mService.isVisibleToListener(sbn, info));
+ }
+
+ @Test
+ public void testIsVisibleToListener_noAssistant() {
+ StatusBarNotification sbn = mock(StatusBarNotification.class);
+ when(sbn.getUserId()).thenReturn(10);
+ ManagedServices.ManagedServiceInfo info = mock(ManagedServices.ManagedServiceInfo.class);
+ info.userid = 10;
+ when(info.isSameUser(anyInt())).thenReturn(true);
+ when(info.enabledAndUserMatches(info.userid)).thenReturn(true);
+ when(mAssistants.checkServiceTokenLocked(any())).thenReturn(null);
+
+ assertTrue(mService.isVisibleToListener(sbn, info));
+ }
+
+ @Test
+ public void testIsVisibleToListener_assistant_differentUser() {
+ StatusBarNotification sbn = mock(StatusBarNotification.class);
+ when(sbn.getUserId()).thenReturn(10);
+ ManagedServices.ManagedServiceInfo info = mock(ManagedServices.ManagedServiceInfo.class);
+ ManagedServices.ManagedServiceInfo assistant = mock(ManagedServices.ManagedServiceInfo.class);
+ info.userid = 0;
+ when(info.isSameUser(anyInt())).thenReturn(true);
+ when(assistant.isSameUser(anyInt())).thenReturn(true);
+ when(info.enabledAndUserMatches(info.userid)).thenReturn(true);
+ when(mAssistants.checkServiceTokenLocked(any())).thenReturn(assistant);
+
+ assertFalse(mService.isVisibleToListener(sbn, info));
+ }
+
+ @Test
+ public void testIsVisibleToListener_assistant_sameUser() {
+ StatusBarNotification sbn = mock(StatusBarNotification.class);
+ when(sbn.getUserId()).thenReturn(10);
+ ManagedServices.ManagedServiceInfo info = mock(ManagedServices.ManagedServiceInfo.class);
+ ManagedServices.ManagedServiceInfo assistant = mock(ManagedServices.ManagedServiceInfo.class);
+ info.userid = 10;
+ when(info.isSameUser(anyInt())).thenReturn(true);
+ when(assistant.isSameUser(anyInt())).thenReturn(true);
+ when(info.enabledAndUserMatches(info.userid)).thenReturn(true);
+ when(mAssistants.checkServiceTokenLocked(any())).thenReturn(assistant);
+
+ assertTrue(mService.isVisibleToListener(sbn, info));
+ }
+
}