summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eghosa Ewansiha-Vlachavas <eevlachavas@google.com> 2022-08-19 14:47:55 +0000
committer Eghosa Ewansiha-Vlachavas <eevlachavas@google.com> 2022-08-23 09:59:15 +0000
commit2ab0e95a6a4b50987eef57e1c00d46a4a6fd92cc (patch)
tree99974a9859ddde0c5832252a11cf4ec839a617b4
parenta61c60e9ca44c19604ab7baa616f3659e430f322 (diff)
Remove OwnersInfo.name field
Owner name no longer used so remove field from ownerInfo. Modify owner setters to not take owner name as a parameter and remove owner getters which retrieve owner name. Bug: 240562947 Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest Change-Id: I6967eccff5fc8545160a65d78cac939874016023
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java8
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/Owners.java27
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/OwnersData.java12
3 files changed, 14 insertions, 33 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index c1c7bceaebd9..0018a523a34a 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -8363,6 +8363,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
+ PackageManager.FEATURE_DEVICE_ADMIN + " feature.");
}
+ // TODO(b/240562946): Remove owner name from API parameters.
@Override
public boolean setDeviceOwner(ComponentName admin, String ownerName, int userId,
boolean setProfileOwnerOnCurrentUserIfNecessary) {
@@ -8397,7 +8398,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
.write();
}
- mOwners.setDeviceOwner(admin, ownerName, userId);
+ mOwners.setDeviceOwner(admin, userId);
mOwners.writeDeviceOwner();
setDeviceOwnershipSystemPropertyLocked();
@@ -8649,6 +8650,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
}
+ // TODO(b/240562946): Remove api as owner name is not used.
/**
* Returns the "name" of the device owner. It'll work for non-DO users too, but requires
* MANAGE_USERS.
@@ -8819,6 +8821,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
});
}
+ // TODO(b/240562946): Remove owner name from API parameters.
@Override
public boolean setProfileOwner(ComponentName who, String ownerName, int userHandle) {
if (!mHasFeature) {
@@ -8866,7 +8869,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
// Shutting down backup manager service permanently.
toggleBackupServiceActive(userHandle, /* makeActive= */ false);
- mOwners.setProfileOwner(who, ownerName, userHandle);
+ mOwners.setProfileOwner(who, userHandle);
mOwners.writeProfileOwner(userHandle);
Slogf.i(LOG_TAG, "Profile owner set: " + who + " on user " + userHandle);
@@ -9337,6 +9340,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return who.getPackageName().equals(configPackage);
}
+ // TODO(b/240562946): Remove api as owner name is not used.
@Override
public String getProfileOwnerName(int userHandle) {
if (!mHasFeature) {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
index 08bd3e4c7c47..3b46d5238e6a 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
@@ -193,12 +193,6 @@ class Owners {
}
}
- String getDeviceOwnerName() {
- synchronized (mData) {
- return mData.mDeviceOwner != null ? mData.mDeviceOwner.name : null;
- }
- }
-
ComponentName getDeviceOwnerComponent() {
synchronized (mData) {
return mData.mDeviceOwner != null ? mData.mDeviceOwner.admin : null;
@@ -217,7 +211,7 @@ class Owners {
}
}
- void setDeviceOwner(ComponentName admin, String ownerName, int userId) {
+ void setDeviceOwner(ComponentName admin, int userId) {
if (userId < 0) {
Slog.e(TAG, "Invalid user id for device owner user: " + userId);
return;
@@ -226,7 +220,7 @@ class Owners {
// A device owner is allowed to access device identifiers. Even though this flag
// is not currently checked for device owner, it is set to true here so that it is
// semantically compatible with the meaning of this flag.
- mData.mDeviceOwner = new OwnerInfo(ownerName, admin, /* remoteBugreportUri =*/ null,
+ mData.mDeviceOwner = new OwnerInfo(admin, /* remoteBugreportUri =*/ null,
/* remoteBugreportHash =*/ null, /* isOrganizationOwnedDevice =*/ true);
mData.mDeviceOwnerUserId = userId;
@@ -248,10 +242,10 @@ class Owners {
}
}
- void setProfileOwner(ComponentName admin, String ownerName, int userId) {
+ void setProfileOwner(ComponentName admin, int userId) {
synchronized (mData) {
// For a newly set PO, there's no need for migration.
- mData.mProfileOwners.put(userId, new OwnerInfo(ownerName, admin,
+ mData.mProfileOwners.put(userId, new OwnerInfo(admin,
/* remoteBugreportUri =*/ null, /* remoteBugreportHash =*/ null,
/* isOrganizationOwnedDevice =*/ false));
mUserManagerInternal.setUserManaged(userId, true);
@@ -270,7 +264,7 @@ class Owners {
void transferProfileOwner(ComponentName target, int userId) {
synchronized (mData) {
final OwnerInfo ownerInfo = mData.mProfileOwners.get(userId);
- final OwnerInfo newOwnerInfo = new OwnerInfo(target.getPackageName(), target,
+ final OwnerInfo newOwnerInfo = new OwnerInfo(target,
ownerInfo.remoteBugreportUri, ownerInfo.remoteBugreportHash,
ownerInfo.isOrganizationOwnedDevice);
mData.mProfileOwners.put(userId, newOwnerInfo);
@@ -282,9 +276,7 @@ class Owners {
synchronized (mData) {
Integer previousDeviceOwnerType = mData.mDeviceOwnerTypes.remove(
mData.mDeviceOwner.packageName);
- // We don't set a name because it's not used anyway.
- // See DevicePolicyManagerService#getDeviceOwnerName
- mData.mDeviceOwner = new OwnerInfo(null, target,
+ mData.mDeviceOwner = new OwnerInfo(target,
mData.mDeviceOwner.remoteBugreportUri,
mData.mDeviceOwner.remoteBugreportHash,
mData.mDeviceOwner.isOrganizationOwnedDevice);
@@ -305,13 +297,6 @@ class Owners {
}
}
- String getProfileOwnerName(int userId) {
- synchronized (mData) {
- OwnerInfo profileOwner = mData.mProfileOwners.get(userId);
- return profileOwner != null ? profileOwner.name : null;
- }
- }
-
String getProfileOwnerPackage(int userId) {
synchronized (mData) {
OwnerInfo profileOwner = mData.mProfileOwners.get(userId);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/OwnersData.java b/services/devicepolicy/java/com/android/server/devicepolicy/OwnersData.java
index 694842034d1f..2ab54644fd18 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/OwnersData.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/OwnersData.java
@@ -493,16 +493,14 @@ class OwnersData {
}
static class OwnerInfo {
- public final String name;
public final String packageName;
public final ComponentName admin;
public String remoteBugreportUri;
public String remoteBugreportHash;
public boolean isOrganizationOwnedDevice;
- OwnerInfo(String name, ComponentName admin, String remoteBugreportUri,
+ OwnerInfo(ComponentName admin, String remoteBugreportUri,
String remoteBugreportHash, boolean isOrganizationOwnedDevice) {
- this.name = name;
this.admin = admin;
this.packageName = admin.getPackageName();
this.remoteBugreportUri = remoteBugreportUri;
@@ -512,9 +510,6 @@ class OwnersData {
public void writeToXml(TypedXmlSerializer out, String tag) throws IOException {
out.startTag(null, tag);
- if (name != null) {
- out.attribute(null, ATTR_NAME, name);
- }
if (admin != null) {
out.attribute(null, ATTR_COMPONENT_NAME, admin.flattenToString());
}
@@ -532,7 +527,6 @@ class OwnersData {
}
public static OwnerInfo readFromXml(TypedXmlPullParser parser) {
- final String name = parser.getAttributeValue(null, ATTR_NAME);
final String componentName = parser.getAttributeValue(null, ATTR_COMPONENT_NAME);
final String remoteBugreportUri =
parser.getAttributeValue(null, ATTR_REMOTE_BUGREPORT_URI);
@@ -556,13 +550,11 @@ class OwnersData {
return null;
}
- return new OwnerInfo(
- name, admin, remoteBugreportUri, remoteBugreportHash, isOrgOwnedDevice);
+ return new OwnerInfo(admin, remoteBugreportUri, remoteBugreportHash, isOrgOwnedDevice);
}
public void dump(IndentingPrintWriter pw) {
pw.println("admin=" + admin);
- pw.println("name=" + name);
pw.println("package=" + packageName);
pw.println("isOrganizationOwnedDevice=" + isOrganizationOwnedDevice);
}