summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/role/model/RoleBehavior.java
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2019-01-17 10:31:14 -0800
committerPhilip P. Moltmann <moltmann@google.com>2019-01-17 22:04:29 +0000
commit4895be22c1e51941590a5c6164a9eb5d8280cb4f (patch)
tree1074feca95fae5513a4ceae3df8e7853f4bcf2b7 /src/com/android/packageinstaller/role/model/RoleBehavior.java
parentab313f29afc54d0f39f5fcb290056e4c87bfbfc0 (diff)
downloadandroid_packages_apps_PackageInstaller-4895be22c1e51941590a5c6164a9eb5d8280cb4f.tar.gz
android_packages_apps_PackageInstaller-4895be22c1e51941590a5c6164a9eb5d8280cb4f.tar.bz2
android_packages_apps_PackageInstaller-4895be22c1e51941590a5c6164a9eb5d8280cb4f.zip
Allow to find qualified packages via RoleBehavior
Sometimes finding qualified packages is to complex to be described in the roles.xml. Hence allow the RoleBehavior to override the logic if needed. Bug: 110557011 Test: Created a role with custom behavior. Looked at old and new roles. Change-Id: I5c8f6875504cb7e84bc45762227d0649fee0d6b7
Diffstat (limited to 'src/com/android/packageinstaller/role/model/RoleBehavior.java')
-rw-r--r--src/com/android/packageinstaller/role/model/RoleBehavior.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/packageinstaller/role/model/RoleBehavior.java b/src/com/android/packageinstaller/role/model/RoleBehavior.java
index 3b1c2ccf..ec8d6c31 100644
--- a/src/com/android/packageinstaller/role/model/RoleBehavior.java
+++ b/src/com/android/packageinstaller/role/model/RoleBehavior.java
@@ -62,4 +62,34 @@ public interface RoleBehavior {
@NonNull Context context) {
return null;
}
+
+ /**
+ * Gets the packages that qualify to hold the role.
+ *
+ * @param user The user the package belong to
+ * @param context A context to use
+ *
+ * @return the list of qualifying packages (might be empty) or {@code null} if the role
+ * description is enough to find the qualified packages
+ */
+ @Nullable
+ default List<String> getQualifyingPackagesAsUser(@NonNull UserHandle user,
+ @NonNull Context context) {
+ return null;
+ }
+
+ /**
+ * Check whether a package is qualified for this role, i.e. whether it contains all the required
+ * components (plus meeting some other general restrictions).
+ *
+ * @param packageName the package name to check for
+ * @param context the {@code Context} to retrieve system services
+ *
+ * @return whether the package is qualified for a role of {@code null} if the role description
+ * is enough to find the qualified packages
+ */
+ @Nullable
+ default Boolean isPackageQualified(@NonNull String packageName, @NonNull Context context) {
+ return null;
+ }
}