summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wentao Wang <wwtbuaa@google.com> 2023-07-07 06:42:56 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-07-07 06:42:56 +0000
commitafed24e208891ac195d583a4351832008cdf1d6e (patch)
treeef3d82d10b94591cb13045ab230b110839266962
parent0e513fb0733720791af1d0d49323db9b3bdeff8d (diff)
parent0a6779ab974263abdb6855180cac3c88f4b04a7e (diff)
Merge "Add additional arguments to PackagesHash." into main
-rw-r--r--services/core/java/com/android/server/policy/role/RoleServicePlatformHelperImpl.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/policy/role/RoleServicePlatformHelperImpl.java b/services/core/java/com/android/server/policy/role/RoleServicePlatformHelperImpl.java
index 6cc4258194d1..5c4b6f1ad76b 100644
--- a/services/core/java/com/android/server/policy/role/RoleServicePlatformHelperImpl.java
+++ b/services/core/java/com/android/server/policy/role/RoleServicePlatformHelperImpl.java
@@ -19,6 +19,7 @@ package com.android.server.policy.role;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
+import android.app.admin.DevicePolicyManagerInternal;
import android.app.role.RoleManager;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -303,6 +304,8 @@ public class RoleServicePlatformHelperImpl implements RoleServicePlatformHelper
public String computePackageStateHash(@UserIdInt int userId) {
PackageManagerInternal packageManagerInternal = LocalServices.getService(
PackageManagerInternal.class);
+ DevicePolicyManagerInternal devicePolicyManagerInternal = LocalServices.getService(
+ DevicePolicyManagerInternal.class);
final MessageDigestOutputStream mdos = new MessageDigestOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(new BufferedOutputStream(mdos));
@@ -342,6 +345,30 @@ public class RoleServicePlatformHelperImpl implements RoleServicePlatformHelper
throw new AssertionError(e);
}
}, userId);
+ try {
+ String deviceOwner= "";
+ if (devicePolicyManagerInternal.getDeviceOwnerUserId() == userId) {
+ ComponentName deviceOwnerComponent =
+ devicePolicyManagerInternal.getDeviceOwnerComponent(false);
+ if (deviceOwnerComponent != null) {
+ deviceOwner = deviceOwnerComponent.getPackageName();
+ }
+ }
+ dataOutputStream.writeUTF(deviceOwner);
+ String profileOwner = "";
+ ComponentName profileOwnerComponent =
+ devicePolicyManagerInternal.getProfileOwnerAsUser(userId);
+ if (profileOwnerComponent != null) {
+ profileOwner = profileOwnerComponent.getPackageName();
+ }
+ dataOutputStream.writeUTF(profileOwner);
+ dataOutputStream.writeInt(Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.DEVICE_DEMO_MODE, 0));
+ dataOutputStream.flush();
+ } catch (IOException e) {
+ // Never happens for MessageDigestOutputStream and DataOutputStream.
+ throw new AssertionError(e);
+ }
return mdos.getDigestAsString();
}