Store CDM device profile and apply role when device is connected

Test: manual - ensure role privileges are granted/revoked when device is connected/disconnected
Bug: 165951651
Change-Id: Id24a4b3a3510781d9105763b1722f44583a7fd7c
This commit is contained in:
Eugene Susla
2020-12-02 12:21:36 -08:00
parent 9c3ddc9cbd
commit 151da5b2bc
4 changed files with 220 additions and 45 deletions

View File

@@ -37,6 +37,8 @@ public final class Association implements Parcelable {
private final @UserIdInt int mUserId;
private final @NonNull String mDeviceMacAddress;
private final @NonNull String mPackageName;
private final @Nullable String mDeviceProfile;
private final boolean mKeepProfilePrivilegesWhenDeviceAway;
/** @hide */
public int getUserId() {
@@ -45,7 +47,7 @@ public final class Association implements Parcelable {
// Code below generated by codegen v1.0.15.
// Code below generated by codegen v1.0.21.
//
// DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code
@@ -67,7 +69,9 @@ public final class Association implements Parcelable {
public Association(
@UserIdInt int userId,
@NonNull String deviceMacAddress,
@NonNull String packageName) {
@NonNull String packageName,
@Nullable String deviceProfile,
boolean keepProfilePrivilegesWhenDeviceAway) {
this.mUserId = userId;
com.android.internal.util.AnnotationValidations.validate(
UserIdInt.class, null, mUserId);
@@ -77,6 +81,8 @@ public final class Association implements Parcelable {
this.mPackageName = packageName;
com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, mPackageName);
this.mDeviceProfile = deviceProfile;
this.mKeepProfilePrivilegesWhenDeviceAway = keepProfilePrivilegesWhenDeviceAway;
// onConstructed(); // You can define this method to get a callback
}
@@ -91,6 +97,16 @@ public final class Association implements Parcelable {
return mPackageName;
}
@DataClass.Generated.Member
public @Nullable String getDeviceProfile() {
return mDeviceProfile;
}
@DataClass.Generated.Member
public boolean isKeepProfilePrivilegesWhenDeviceAway() {
return mKeepProfilePrivilegesWhenDeviceAway;
}
@Override
@DataClass.Generated.Member
public String toString() {
@@ -100,7 +116,9 @@ public final class Association implements Parcelable {
return "Association { " +
"userId = " + mUserId + ", " +
"deviceMacAddress = " + mDeviceMacAddress + ", " +
"packageName = " + mPackageName +
"packageName = " + mPackageName + ", " +
"deviceProfile = " + mDeviceProfile + ", " +
"keepProfilePrivilegesWhenDeviceAway = " + mKeepProfilePrivilegesWhenDeviceAway +
" }";
}
@@ -119,7 +137,9 @@ public final class Association implements Parcelable {
return true
&& mUserId == that.mUserId
&& Objects.equals(mDeviceMacAddress, that.mDeviceMacAddress)
&& Objects.equals(mPackageName, that.mPackageName);
&& Objects.equals(mPackageName, that.mPackageName)
&& Objects.equals(mDeviceProfile, that.mDeviceProfile)
&& mKeepProfilePrivilegesWhenDeviceAway == that.mKeepProfilePrivilegesWhenDeviceAway;
}
@Override
@@ -132,6 +152,8 @@ public final class Association implements Parcelable {
_hash = 31 * _hash + mUserId;
_hash = 31 * _hash + Objects.hashCode(mDeviceMacAddress);
_hash = 31 * _hash + Objects.hashCode(mPackageName);
_hash = 31 * _hash + Objects.hashCode(mDeviceProfile);
_hash = 31 * _hash + Boolean.hashCode(mKeepProfilePrivilegesWhenDeviceAway);
return _hash;
}
@@ -141,9 +163,14 @@ public final class Association implements Parcelable {
// You can override field parcelling by defining methods like:
// void parcelFieldName(Parcel dest, int flags) { ... }
byte flg = 0;
if (mKeepProfilePrivilegesWhenDeviceAway) flg |= 0x10;
if (mDeviceProfile != null) flg |= 0x8;
dest.writeByte(flg);
dest.writeInt(mUserId);
dest.writeString(mDeviceMacAddress);
dest.writeString(mPackageName);
if (mDeviceProfile != null) dest.writeString(mDeviceProfile);
}
@Override
@@ -157,9 +184,12 @@ public final class Association implements Parcelable {
// You can override field unparcelling by defining methods like:
// static FieldType unparcelFieldName(Parcel in) { ... }
byte flg = in.readByte();
boolean keepProfilePrivilegesWhenDeviceAway = (flg & 0x10) != 0;
int userId = in.readInt();
String deviceMacAddress = in.readString();
String packageName = in.readString();
String deviceProfile = (flg & 0x8) == 0 ? null : in.readString();
this.mUserId = userId;
com.android.internal.util.AnnotationValidations.validate(
@@ -170,6 +200,8 @@ public final class Association implements Parcelable {
this.mPackageName = packageName;
com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, mPackageName);
this.mDeviceProfile = deviceProfile;
this.mKeepProfilePrivilegesWhenDeviceAway = keepProfilePrivilegesWhenDeviceAway;
// onConstructed(); // You can define this method to get a callback
}
@@ -189,10 +221,10 @@ public final class Association implements Parcelable {
};
@DataClass.Generated(
time = 1599083149942L,
codegenVersion = "1.0.15",
time = 1606940835778L,
codegenVersion = "1.0.21",
sourceFile = "frameworks/base/core/java/android/companion/Association.java",
inputSignatures = "private final @android.annotation.UserIdInt int mUserId\nprivate final @android.annotation.NonNull java.lang.String mDeviceMacAddress\nprivate final @android.annotation.NonNull java.lang.String mPackageName\npublic int getUserId()\nclass Association extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstructor=true)")
inputSignatures = "private final @android.annotation.UserIdInt int mUserId\nprivate final @android.annotation.NonNull java.lang.String mDeviceMacAddress\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.Nullable java.lang.String mDeviceProfile\nprivate final boolean mKeepProfilePrivilegesWhenDeviceAway\npublic int getUserId()\nclass Association extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstructor=true)")
@Deprecated
private void __metadata() {}