UserProperties 'getIs' is just 'is'

Rename the UserProperties that start with 'getIs' to just start with
'is'. Likewise, 'setIs' becomes 'set'.

Bug: 237399048
Test: atest android.multiuser.cts.UserManagerTest
Test: atest com.android.server.pm.UserManagerTest
Test: atest UserManagerServiceUserTypeTest
Test: atest UserManagerServiceUserPropertiesTest
Test: atest AppCloningHostTest
Change-Id: I87eb58160c82ac25ef0fe595e9456029a1213e6a
This commit is contained in:
Adam Bookatz
2023-01-20 11:44:00 -08:00
parent 3a71dcc71f
commit c33092e4cd
10 changed files with 83 additions and 81 deletions

View File

@@ -3910,8 +3910,8 @@ package android.content.pm {
public final class UserProperties implements android.os.Parcelable {
method public int describeContents();
method public boolean getIsCredentialSharableWithParent();
method public boolean getIsMediaSharedWithParent();
method public boolean isCredentialShareableWithParent();
method public boolean isMediaSharedWithParent();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.UserProperties> CREATOR;
}

View File

@@ -59,8 +59,8 @@ public final class UserProperties implements Parcelable {
"crossProfileIntentResolutionStrategy";
private static final String ATTR_MEDIA_SHARED_WITH_PARENT =
"mediaSharedWithParent";
private static final String ATTR_CREDENTIAL_SHARABLE_WITH_PARENT =
"credentialSharableWithParent";
private static final String ATTR_CREDENTIAL_SHAREABLE_WITH_PARENT =
"credentialShareableWithParent";
/** Index values of each property (to indicate whether they are present in this object). */
@IntDef(prefix = "INDEX_", value = {
@@ -73,7 +73,7 @@ public final class UserProperties implements Parcelable {
INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL,
INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY,
INDEX_MEDIA_SHARED_WITH_PARENT,
INDEX_CREDENTIAL_SHARABLE_WITH_PARENT
INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT
})
@Retention(RetentionPolicy.SOURCE)
private @interface PropertyIndex {
@@ -87,7 +87,7 @@ public final class UserProperties implements Parcelable {
private static final int INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL = 6;
private static final int INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY = 7;
private static final int INDEX_MEDIA_SHARED_WITH_PARENT = 8;
private static final int INDEX_CREDENTIAL_SHARABLE_WITH_PARENT = 9;
private static final int INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT = 9;
/** A bit set, mapping each PropertyIndex to whether it is present (1) or absent (0). */
private long mPropertiesPresent = 0;
@@ -323,8 +323,8 @@ public final class UserProperties implements Parcelable {
}
// Add items that have no permission requirements at all.
setShowInLauncher(orig.getShowInLauncher());
setIsMediaSharedWithParent(orig.getIsMediaSharedWithParent());
setIsCredentialSharableWithParent(orig.getIsCredentialSharableWithParent());
setMediaSharedWithParent(orig.isMediaSharedWithParent());
setCredentialShareableWithParent(orig.isCredentialShareableWithParent());
}
/**
@@ -496,13 +496,13 @@ public final class UserProperties implements Parcelable {
* Returns whether a profile shares media with its parent user.
* This only applies for users that have parents (i.e. for profiles).
*/
public boolean getIsMediaSharedWithParent() {
public boolean isMediaSharedWithParent() {
if (isPresent(INDEX_MEDIA_SHARED_WITH_PARENT)) return mMediaSharedWithParent;
if (mDefaultProperties != null) return mDefaultProperties.mMediaSharedWithParent;
throw new SecurityException("You don't have permission to query isMediaSharedWithParent");
throw new SecurityException("You don't have permission to query mediaSharedWithParent");
}
/** @hide */
public void setIsMediaSharedWithParent(boolean val) {
public void setMediaSharedWithParent(boolean val) {
this.mMediaSharedWithParent = val;
setPresent(INDEX_MEDIA_SHARED_WITH_PARENT);
}
@@ -512,18 +512,20 @@ public final class UserProperties implements Parcelable {
* Returns whether a profile can have shared lockscreen credential with its parent user.
* This only applies for users that have parents (i.e. for profiles).
*/
public boolean getIsCredentialSharableWithParent() {
if (isPresent(INDEX_CREDENTIAL_SHARABLE_WITH_PARENT)) return mCredentialSharableWithParent;
if (mDefaultProperties != null) return mDefaultProperties.mCredentialSharableWithParent;
public boolean isCredentialShareableWithParent() {
if (isPresent(INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT)) {
return mCredentialShareableWithParent;
}
if (mDefaultProperties != null) return mDefaultProperties.mCredentialShareableWithParent;
throw new SecurityException(
"You don't have permission to query isCredentialSharableWithParent");
"You don't have permission to query credentialShareableWithParent");
}
/** @hide */
public void setIsCredentialSharableWithParent(boolean val) {
this.mCredentialSharableWithParent = val;
setPresent(INDEX_CREDENTIAL_SHARABLE_WITH_PARENT);
public void setCredentialShareableWithParent(boolean val) {
this.mCredentialShareableWithParent = val;
setPresent(INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT);
}
private boolean mCredentialSharableWithParent;
private boolean mCredentialShareableWithParent;
/*
Indicate if {@link com.android.server.pm.CrossProfileIntentFilter}s need to be updated during
@@ -605,8 +607,8 @@ public final class UserProperties implements Parcelable {
+ getCrossProfileIntentFilterAccessControl()
+ ", mCrossProfileIntentResolutionStrategy="
+ getCrossProfileIntentResolutionStrategy()
+ ", mMediaSharedWithParent=" + getIsMediaSharedWithParent()
+ ", mCredentialSharableWithParent=" + getIsCredentialSharableWithParent()
+ ", mMediaSharedWithParent=" + isMediaSharedWithParent()
+ ", mCredentialShareableWithParent=" + isCredentialShareableWithParent()
+ "}";
}
@@ -629,9 +631,9 @@ public final class UserProperties implements Parcelable {
+ getCrossProfileIntentFilterAccessControl());
pw.println(prefix + " mCrossProfileIntentResolutionStrategy="
+ getCrossProfileIntentResolutionStrategy());
pw.println(prefix + " mMediaSharedWithParent=" + getIsMediaSharedWithParent());
pw.println(prefix + " mCredentialSharableWithParent="
+ getIsCredentialSharableWithParent());
pw.println(prefix + " mMediaSharedWithParent=" + isMediaSharedWithParent());
pw.println(prefix + " mCredentialShareableWithParent="
+ isCredentialShareableWithParent());
}
/**
@@ -690,10 +692,10 @@ public final class UserProperties implements Parcelable {
setCrossProfileIntentResolutionStrategy(parser.getAttributeInt(i));
break;
case ATTR_MEDIA_SHARED_WITH_PARENT:
setIsMediaSharedWithParent(parser.getAttributeBoolean(i));
setMediaSharedWithParent(parser.getAttributeBoolean(i));
break;
case ATTR_CREDENTIAL_SHARABLE_WITH_PARENT:
setIsCredentialSharableWithParent(parser.getAttributeBoolean(i));
case ATTR_CREDENTIAL_SHAREABLE_WITH_PARENT:
setCredentialShareableWithParent(parser.getAttributeBoolean(i));
break;
default:
Slog.w(LOG_TAG, "Skipping unknown property " + attributeName);
@@ -746,9 +748,9 @@ public final class UserProperties implements Parcelable {
serializer.attributeBoolean(null, ATTR_MEDIA_SHARED_WITH_PARENT,
mMediaSharedWithParent);
}
if (isPresent(INDEX_CREDENTIAL_SHARABLE_WITH_PARENT)) {
serializer.attributeBoolean(null, ATTR_CREDENTIAL_SHARABLE_WITH_PARENT,
mCredentialSharableWithParent);
if (isPresent(INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT)) {
serializer.attributeBoolean(null, ATTR_CREDENTIAL_SHAREABLE_WITH_PARENT,
mCredentialShareableWithParent);
}
}
@@ -765,7 +767,7 @@ public final class UserProperties implements Parcelable {
dest.writeInt(mCrossProfileIntentFilterAccessControl);
dest.writeInt(mCrossProfileIntentResolutionStrategy);
dest.writeBoolean(mMediaSharedWithParent);
dest.writeBoolean(mCredentialSharableWithParent);
dest.writeBoolean(mCredentialShareableWithParent);
}
/**
@@ -785,7 +787,7 @@ public final class UserProperties implements Parcelable {
mCrossProfileIntentFilterAccessControl = source.readInt();
mCrossProfileIntentResolutionStrategy = source.readInt();
mMediaSharedWithParent = source.readBoolean();
mCredentialSharableWithParent = source.readBoolean();
mCredentialShareableWithParent = source.readBoolean();
}
@Override
@@ -822,7 +824,7 @@ public final class UserProperties implements Parcelable {
private @CrossProfileIntentResolutionStrategy int mCrossProfileIntentResolutionStrategy =
CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_DEFAULT;
private boolean mMediaSharedWithParent = false;
private boolean mCredentialSharableWithParent = false;
private boolean mCredentialShareableWithParent = false;
public Builder setShowInLauncher(@ShowInLauncher int showInLauncher) {
mShowInLauncher = showInLauncher;
@@ -874,13 +876,13 @@ public final class UserProperties implements Parcelable {
return this;
}
public Builder setIsMediaSharedWithParent(boolean mediaSharedWithParent) {
public Builder setMediaSharedWithParent(boolean mediaSharedWithParent) {
mMediaSharedWithParent = mediaSharedWithParent;
return this;
}
public Builder setIsCredentialSharableWithParent(boolean credentialSharableWithParent) {
mCredentialSharableWithParent = credentialSharableWithParent;
public Builder setCredentialShareableWithParent(boolean credentialShareableWithParent) {
mCredentialShareableWithParent = credentialShareableWithParent;
return this;
}
@@ -896,7 +898,7 @@ public final class UserProperties implements Parcelable {
mCrossProfileIntentFilterAccessControl,
mCrossProfileIntentResolutionStrategy,
mMediaSharedWithParent,
mCredentialSharableWithParent);
mCredentialShareableWithParent);
}
} // end Builder
@@ -910,7 +912,7 @@ public final class UserProperties implements Parcelable {
@CrossProfileIntentFilterAccessControlLevel int crossProfileIntentFilterAccessControl,
@CrossProfileIntentResolutionStrategy int crossProfileIntentResolutionStrategy,
boolean mediaSharedWithParent,
boolean credentialSharableWithParent) {
boolean credentialShareableWithParent) {
mDefaultProperties = null;
setShowInLauncher(showInLauncher);
@@ -921,7 +923,7 @@ public final class UserProperties implements Parcelable {
setUpdateCrossProfileIntentFiltersOnOTA(updateCrossProfileIntentFiltersOnOTA);
setCrossProfileIntentFilterAccessControl(crossProfileIntentFilterAccessControl);
setCrossProfileIntentResolutionStrategy(crossProfileIntentResolutionStrategy);
setIsMediaSharedWithParent(mediaSharedWithParent);
setIsCredentialSharableWithParent(credentialSharableWithParent);
setMediaSharedWithParent(mediaSharedWithParent);
setCredentialShareableWithParent(credentialShareableWithParent);
}
}

View File

@@ -5170,7 +5170,7 @@ public class UserManager {
* @return true if the user shares media with its parent user, false otherwise.
*
* @deprecated use {@link #getUserProperties(UserHandle)} with
* {@link UserProperties#getIsMediaSharedWithParent()} instead.
* {@link UserProperties#isMediaSharedWithParent()} instead.
* @hide
*/
@SystemApi
@@ -5183,7 +5183,7 @@ public class UserManager {
@SuppressAutoDoc
public boolean isMediaSharedWithParent() {
try {
return getUserProperties(UserHandle.of(mUserId)).getIsMediaSharedWithParent();
return getUserProperties(UserHandle.of(mUserId)).isMediaSharedWithParent();
} catch (IllegalArgumentException e) {
// If the user doesn't exist, return false (for historical reasons)
return false;
@@ -5197,7 +5197,7 @@ public class UserManager {
* and will always return false for any other user type.
*
* @deprecated use {@link #getUserProperties(UserHandle)} with
* {@link UserProperties#getIsMediaSharedWithParent()} instead.
* {@link UserProperties#isCredentialShareableWithParent()} instead.
* @hide
*/
@SystemApi
@@ -5210,7 +5210,7 @@ public class UserManager {
@SuppressAutoDoc
public boolean isCredentialSharableWithParent() {
try {
return getUserProperties(UserHandle.of(mUserId)).getIsCredentialSharableWithParent();
return getUserProperties(UserHandle.of(mUserId)).isCredentialShareableWithParent();
} catch (IllegalArgumentException e) {
// If the user doesn't exist, return false (for historical reasons)
return false;

View File

@@ -198,7 +198,7 @@ public class ContentProviderHelper {
//todo(b/236121588) MediaProvider should not be installed in clone profile.
final UserProperties userProps = umInternal.getUserProperties(userId);
final boolean isMediaSharedWithParent =
userProps != null && userProps.getIsMediaSharedWithParent();
userProps != null && userProps.isMediaSharedWithParent();
if (!isAuthorityRedirectedForCloneProfile(name) || !isMediaSharedWithParent) {
// First check if this content provider has been published...
cpr = mProviderMap.getProviderByName(name, userId);

View File

@@ -2907,7 +2907,7 @@ class UserController implements Handler.Callback {
return false;
}
final UserProperties properties = getUserProperties(userId);
if (properties == null || !properties.getIsCredentialSharableWithParent()) {
if (properties == null || !properties.isCredentialShareableWithParent()) {
return false;
}
if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {

View File

@@ -134,8 +134,8 @@ public final class UserTypeFactory {
UserProperties.CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM)
.setCrossProfileIntentResolutionStrategy(UserProperties
.CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_NO_FILTERING)
.setIsMediaSharedWithParent(true)
.setIsCredentialSharableWithParent(true)
.setMediaSharedWithParent(true)
.setCredentialShareableWithParent(true)
);
}
@@ -172,7 +172,7 @@ public final class UserTypeFactory {
.setStartWithParent(true)
.setShowInLauncher(UserProperties.SHOW_IN_LAUNCHER_SEPARATE)
.setShowInSettings(UserProperties.SHOW_IN_SETTINGS_SEPARATE)
.setIsCredentialSharableWithParent(true));
.setCredentialShareableWithParent(true));
}
/**

View File

@@ -37,7 +37,7 @@
crossProfileIntentFilterAccessControl='20'
crossProfileIntentResolutionStrategy='0'
mediaSharedWithParent='true'
credentialSharableWithParent='false'
credentialShareableWithParent='false'
/>
</profile-type>
<profile-type name='custom.test.1' max-allowed-per-parent='14' />

View File

@@ -64,8 +64,8 @@ public class UserManagerServiceUserPropertiesTest {
.setUseParentsContacts(false)
.setCrossProfileIntentFilterAccessControl(10)
.setCrossProfileIntentResolutionStrategy(0)
.setIsMediaSharedWithParent(false)
.setIsCredentialSharableWithParent(true)
.setMediaSharedWithParent(false)
.setCredentialShareableWithParent(true)
.build();
final UserProperties actualProps = new UserProperties(defaultProps);
actualProps.setShowInLauncher(14);
@@ -74,8 +74,8 @@ public class UserManagerServiceUserPropertiesTest {
actualProps.setUseParentsContacts(true);
actualProps.setCrossProfileIntentFilterAccessControl(20);
actualProps.setCrossProfileIntentResolutionStrategy(1);
actualProps.setIsMediaSharedWithParent(true);
actualProps.setIsCredentialSharableWithParent(false);
actualProps.setMediaSharedWithParent(true);
actualProps.setCredentialShareableWithParent(false);
// Write the properties to xml.
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -115,7 +115,7 @@ public class UserManagerServiceUserPropertiesTest {
.setStartWithParent(true)
.setShowInSettings(3452)
.setInheritDevicePolicy(1732)
.setIsMediaSharedWithParent(true)
.setMediaSharedWithParent(true)
.build();
final UserProperties orig = new UserProperties(defaultProps);
orig.setShowInLauncher(2841);
@@ -174,10 +174,10 @@ public class UserManagerServiceUserPropertiesTest {
// Items with no permission requirements.
assertEqualGetterOrThrows(orig::getShowInLauncher, copy::getShowInLauncher, true);
assertEqualGetterOrThrows(orig::getIsMediaSharedWithParent,
copy::getIsMediaSharedWithParent, true);
assertEqualGetterOrThrows(orig::getIsCredentialSharableWithParent,
copy::getIsCredentialSharableWithParent, true);
assertEqualGetterOrThrows(orig::isMediaSharedWithParent,
copy::isMediaSharedWithParent, true);
assertEqualGetterOrThrows(orig::isCredentialShareableWithParent,
copy::isCredentialShareableWithParent, true);
}
/**
@@ -223,9 +223,9 @@ public class UserManagerServiceUserPropertiesTest {
.isEqualTo(actual.getCrossProfileIntentFilterAccessControl());
assertThat(expected.getCrossProfileIntentResolutionStrategy())
.isEqualTo(actual.getCrossProfileIntentResolutionStrategy());
assertThat(expected.getIsMediaSharedWithParent())
.isEqualTo(actual.getIsMediaSharedWithParent());
assertThat(expected.getIsCredentialSharableWithParent())
.isEqualTo(actual.getIsCredentialSharableWithParent());
assertThat(expected.isMediaSharedWithParent())
.isEqualTo(actual.isMediaSharedWithParent());
assertThat(expected.isCredentialShareableWithParent())
.isEqualTo(actual.isCredentialShareableWithParent());
}
}

View File

@@ -87,8 +87,8 @@ public class UserManagerServiceUserTypeTest {
.setUseParentsContacts(true)
.setCrossProfileIntentFilterAccessControl(10)
.setCrossProfileIntentResolutionStrategy(1)
.setIsMediaSharedWithParent(true)
.setIsCredentialSharableWithParent(false);
.setMediaSharedWithParent(true)
.setCredentialShareableWithParent(false);
final UserTypeDetails type = new UserTypeDetails.Builder()
.setName("a.name")
.setEnabled(1)
@@ -150,8 +150,8 @@ public class UserManagerServiceUserTypeTest {
.getCrossProfileIntentFilterAccessControl());
assertEquals(1, type.getDefaultUserPropertiesReference()
.getCrossProfileIntentResolutionStrategy());
assertTrue(type.getDefaultUserPropertiesReference().getIsMediaSharedWithParent());
assertFalse(type.getDefaultUserPropertiesReference().getIsCredentialSharableWithParent());
assertTrue(type.getDefaultUserPropertiesReference().isMediaSharedWithParent());
assertFalse(type.getDefaultUserPropertiesReference().isCredentialShareableWithParent());
assertEquals(23, type.getBadgeLabel(0));
assertEquals(24, type.getBadgeLabel(1));
@@ -200,8 +200,8 @@ public class UserManagerServiceUserTypeTest {
assertEquals(UserProperties.SHOW_IN_LAUNCHER_WITH_PARENT, props.getShowInLauncher());
assertEquals(UserProperties.CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_DEFAULT,
props.getCrossProfileIntentResolutionStrategy());
assertFalse(props.getIsMediaSharedWithParent());
assertFalse(props.getIsCredentialSharableWithParent());
assertFalse(props.isMediaSharedWithParent());
assertFalse(props.isCredentialShareableWithParent());
assertFalse(type.hasBadge());
}
@@ -286,8 +286,8 @@ public class UserManagerServiceUserTypeTest {
.setUseParentsContacts(true)
.setCrossProfileIntentFilterAccessControl(10)
.setCrossProfileIntentResolutionStrategy(1)
.setIsMediaSharedWithParent(false)
.setIsCredentialSharableWithParent(true);
.setMediaSharedWithParent(false)
.setCredentialShareableWithParent(true);
final ArrayMap<String, UserTypeDetails.Builder> builders = new ArrayMap<>();
builders.put(userTypeAosp1, new UserTypeDetails.Builder()
.setName(userTypeAosp1)
@@ -320,9 +320,9 @@ public class UserManagerServiceUserTypeTest {
assertTrue(aospType.getDefaultUserPropertiesReference().getStartWithParent());
assertTrue(aospType.getDefaultUserPropertiesReference()
.getUseParentsContacts());
assertFalse(aospType.getDefaultUserPropertiesReference().getIsMediaSharedWithParent());
assertFalse(aospType.getDefaultUserPropertiesReference().isMediaSharedWithParent());
assertTrue(aospType.getDefaultUserPropertiesReference()
.getIsCredentialSharableWithParent());
.isCredentialShareableWithParent());
// userTypeAosp2 should be modified.
aospType = builders.get(userTypeAosp2).createUserTypeDetails();
@@ -359,9 +359,9 @@ public class UserManagerServiceUserTypeTest {
assertFalse(aospType.getDefaultUserPropertiesReference().getStartWithParent());
assertFalse(aospType.getDefaultUserPropertiesReference()
.getUseParentsContacts());
assertTrue(aospType.getDefaultUserPropertiesReference().getIsMediaSharedWithParent());
assertTrue(aospType.getDefaultUserPropertiesReference().isMediaSharedWithParent());
assertFalse(aospType.getDefaultUserPropertiesReference()
.getIsCredentialSharableWithParent());
.isCredentialShareableWithParent());
// userTypeOem1 should be created.
UserTypeDetails.Builder customType = builders.get(userTypeOem1);

View File

@@ -188,10 +188,10 @@ public final class UserManagerTest {
cloneUserProperties::getCrossProfileIntentFilterAccessControl);
assertThrows(SecurityException.class,
cloneUserProperties::getCrossProfileIntentResolutionStrategy);
assertThat(typeProps.getIsMediaSharedWithParent())
.isEqualTo(cloneUserProperties.getIsMediaSharedWithParent());
assertThat(typeProps.getIsCredentialSharableWithParent())
.isEqualTo(cloneUserProperties.getIsCredentialSharableWithParent());
assertThat(typeProps.isMediaSharedWithParent())
.isEqualTo(cloneUserProperties.isMediaSharedWithParent());
assertThat(typeProps.isCredentialShareableWithParent())
.isEqualTo(cloneUserProperties.isCredentialShareableWithParent());
// Verify clone user parent
assertThat(mUserManager.getProfileParent(mainUserId)).isNull();
@@ -842,8 +842,8 @@ public final class UserManagerTest {
assertThrows(SecurityException.class, userProps::getCrossProfileIntentResolutionStrategy);
assertThrows(SecurityException.class, userProps::getStartWithParent);
assertThrows(SecurityException.class, userProps::getInheritDevicePolicy);
assertThat(userProps.getIsMediaSharedWithParent()).isFalse();
assertThat(userProps.getIsCredentialSharableWithParent()).isTrue();
assertThat(userProps.isMediaSharedWithParent()).isFalse();
assertThat(userProps.isCredentialShareableWithParent()).isTrue();
}
// Make sure only max managed profiles can be created