Merge "Remove OwnersInfo.name field"
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index c1c7bce..0018a52 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 @@
+ 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 @@
.write();
}
- mOwners.setDeviceOwner(admin, ownerName, userId);
+ mOwners.setDeviceOwner(admin, userId);
mOwners.writeDeviceOwner();
setDeviceOwnershipSystemPropertyLocked();
@@ -8649,6 +8650,7 @@
}
}
+ // 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 @@
});
}
+ // 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 @@
// 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 @@
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 08bd3e4..3b46d52 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 @@
}
}
- 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 @@
}
}
- 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 @@
// 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 @@
}
}
- 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 @@
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 @@
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 @@
}
}
- 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 6948420..2ab5464 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 @@
}
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 @@
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 @@
}
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 @@
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);
}