summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evan Chen <evanxinchen@google.com> 2024-10-10 17:26:12 +0000
committer Evan Chen <evanxinchen@google.com> 2024-10-10 17:26:12 +0000
commit5b9bdecf083676902dd3236bd44059fb35a1138d (patch)
tree49893cee3c0df6687bcc113529a8759d5366d3ab
parentcd85368b03979aec9d87809ad108021b94fc2196 (diff)
Change the association revoke importance
Change the imprtance to IMPORTANCE_FOREGROUND, so that the role will be reovked if the app currently is not at the top of the screen that the user is interacting with. fix: 372495062 Test: CtsCompanionDeviceManagerUiAutomationTestCases:AssociationRevokedTest Flag: EXEMPT bugfix Change-Id: I56047a21980f346ca0eb656b09f9389387a00851
-rw-r--r--services/companion/java/com/android/server/companion/association/DisassociationProcessor.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java b/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java
index 6f0baef019b3..150e8da5f614 100644
--- a/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java
+++ b/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java
@@ -16,7 +16,7 @@
package com.android.server.companion.association;
-import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
+import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION;
import static com.android.internal.util.CollectionUtils.any;
@@ -107,7 +107,7 @@ public class DisassociationProcessor {
it -> deviceProfile.equals(it.getDeviceProfile()) && id != it.getId());
final int packageProcessImportance = getPackageProcessImportance(userId, packageName);
- if (packageProcessImportance <= IMPORTANCE_VISIBLE && deviceProfile != null
+ if (packageProcessImportance <= IMPORTANCE_FOREGROUND && deviceProfile != null
&& !isRoleInUseByOtherAssociations) {
// Need to remove the app from the list of role holders, but the process is visible
// to the user at the moment, so we'll need to do it later.
@@ -238,12 +238,16 @@ public class DisassociationProcessor {
*/
private class OnPackageVisibilityChangeListener implements
ActivityManager.OnUidImportanceListener {
-
+ // This method is called when the importance of a uid (app) changes.
+ // We only care about changes where the app is moving to the background.
+ // (e.g., the app currently is not at the top of the screen that the user
+ // is interacting with.)
@Override
public void onUidImportance(int uid, int importance) {
- if (importance <= ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE) {
- // The lower the importance value the more "important" the process is.
- // We are only interested when the process ceases to be visible.
+ // Higher importance values indicate the app is less important.
+ // We are only interested when the process importance level
+ // is greater than IMPORTANCE_FOREGROUND.
+ if (importance <= IMPORTANCE_FOREGROUND) {
return;
}