Loading core/java/android/companion/AssociationInfo.java +4 −4 Original line number Diff line number Diff line Loading @@ -99,7 +99,7 @@ public final class AssociationInfo implements Parcelable { * * @hide */ public AssociationInfo(int id, @UserIdInt int userId, @NonNull String packageName, private AssociationInfo(int id, @UserIdInt int userId, @NonNull String packageName, @Nullable MacAddress macAddress, @Nullable CharSequence displayName, @Nullable String deviceProfile, @Nullable AssociatedDevice associatedDevice, boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked, boolean pending, Loading Loading @@ -528,9 +528,9 @@ public final class AssociationInfo implements Parcelable { private boolean mNotifyOnDeviceNearby; private boolean mRevoked; private boolean mPending; private long mTimeApprovedMs; private long mLastTimeConnectedMs; private int mSystemDataSyncFlags; private long mTimeApprovedMs = System.currentTimeMillis(); private long mLastTimeConnectedMs = Long.MAX_VALUE; // Never connected. private int mSystemDataSyncFlags = -1; // By default, all system data sync is enabled. private Icon mDeviceIcon; private DeviceId mDeviceId; private List<String> mPackagesToNotify; Loading services/companion/java/com/android/server/companion/association/AssociationDiskStore.java +22 −8 Original line number Diff line number Diff line Loading @@ -477,11 +477,13 @@ public final class AssociationDiskStore { final boolean notify = readBooleanAttribute(parser, XML_ATTR_NOTIFY_DEVICE_NEARBY); final long timeApproved = readLongAttribute(parser, XML_ATTR_TIME_APPROVED, 0L); return new AssociationInfo(associationId, userId, appPackage, MacAddress.fromString(deviceAddress), null, profile, null, /* managedByCompanionApp */ false, notify, /* revoked */ false, /* pending */ false, timeApproved, Long.MAX_VALUE, /* systemDataSyncFlags */ 0, /* deviceIcon */ null, /* deviceId */ null, /* packagesToNotify */ null); return new AssociationInfo.Builder(associationId, userId, appPackage) .setDeviceMacAddress(MacAddress.fromString(deviceAddress)) .setDeviceProfile(profile) .setNotifyOnDeviceNearby(notify) .setTimeApproved(timeApproved) .setSystemDataSyncFlags(0) .build(); } private static Associations readAssociationsV1(@NonNull TypedXmlPullParser parser, Loading Loading @@ -558,9 +560,21 @@ public final class AssociationDiskStore { } } return new AssociationInfo(associationId, userId, appPackage, macAddress, displayName, profile, null, selfManaged, notify, revoked, pending, timeApproved, lastTimeConnected, systemDataSyncFlags, deviceIcon, deviceId, packagesToNotify); return new AssociationInfo.Builder(associationId, userId, appPackage) .setDeviceMacAddress(macAddress) .setDisplayName(displayName) .setDeviceProfile(profile) .setSelfManaged(selfManaged) .setNotifyOnDeviceNearby(notify) .setRevoked(revoked) .setPending(pending) .setTimeApproved(timeApproved) .setLastTimeConnected(lastTimeConnected) .setSystemDataSyncFlags(systemDataSyncFlags) .setDeviceIcon(deviceIcon) .setDeviceId(deviceId) .setPackagesToNotify(packagesToNotify) .build(); } private static List<String> readPackagesToNotify(@NonNull TypedXmlPullParser parser) Loading services/companion/java/com/android/server/companion/association/AssociationRequestsProcessor.java +17 −5 Original line number Diff line number Diff line Loading @@ -314,11 +314,23 @@ public class AssociationRequestsProcessor { final int id = mAssociationStore.getNextId(); final long timestamp = System.currentTimeMillis(); final AssociationInfo association = new AssociationInfo(id, userId, packageName, macAddress, displayName, deviceProfile, associatedDevice, selfManaged, /* notifyOnDeviceNearby */ false, /* revoked */ false, /* pending */ false, timestamp, Long.MAX_VALUE, /* systemDataSyncFlags */ 0, deviceIcon, /* deviceId */ null, /* packagesToNotify */ null); final AssociationInfo association = new AssociationInfo.Builder(id, userId, packageName) .setDeviceMacAddress(macAddress) .setDisplayName(displayName) .setDeviceProfile(deviceProfile) .setAssociatedDevice(associatedDevice) .setSelfManaged(selfManaged) .setNotifyOnDeviceNearby(false) .setRevoked(false) .setPending(false) .setTimeApproved(timestamp) .setLastTimeConnected(Long.MAX_VALUE) .setSystemDataSyncFlags(0) .setDeviceIcon(deviceIcon) .setDeviceId(null) .setPackagesToNotify(null) .build(); if (skipRoleGrant) { Slog.i(TAG, "Created association for " + association.getDeviceProfile() + " and userId=" Loading services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java +10 −9 Original line number Diff line number Diff line Loading @@ -1561,14 +1561,15 @@ public class VirtualDeviceManagerServiceTest { associationId, deviceProfile, /* displayName= */ deviceProfile); } private AssociationInfo createAssociationInfo(int associationId, String deviceProfile, CharSequence displayName) { return new AssociationInfo(associationId, /* userId= */ 0, /* packageName= */ null, MacAddress.BROADCAST_ADDRESS, displayName, deviceProfile, /* associatedDevice= */ null, /* selfManaged= */ true, /* notifyOnDeviceNearby= */ false, /* revoked= */ false, /* pending= */ false, /* timeApprovedMs= */0, /* lastTimeConnectedMs= */0, /* systemDataSyncFlags= */ -1, /* deviceIcon= */ null, /* deviceId= */ null, /* packageToNotify= */ null); private AssociationInfo createAssociationInfo( int associationId, String deviceProfile, CharSequence displayName) { return new AssociationInfo.Builder(associationId, /* userId= */ 0, /* packageName= */ null) .setDeviceMacAddress(MacAddress.BROADCAST_ADDRESS) .setDisplayName(displayName) .setDeviceProfile(deviceProfile) .setSelfManaged(true) .setTimeApproved(0) .setLastTimeConnected(0) .build(); } } Loading
core/java/android/companion/AssociationInfo.java +4 −4 Original line number Diff line number Diff line Loading @@ -99,7 +99,7 @@ public final class AssociationInfo implements Parcelable { * * @hide */ public AssociationInfo(int id, @UserIdInt int userId, @NonNull String packageName, private AssociationInfo(int id, @UserIdInt int userId, @NonNull String packageName, @Nullable MacAddress macAddress, @Nullable CharSequence displayName, @Nullable String deviceProfile, @Nullable AssociatedDevice associatedDevice, boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked, boolean pending, Loading Loading @@ -528,9 +528,9 @@ public final class AssociationInfo implements Parcelable { private boolean mNotifyOnDeviceNearby; private boolean mRevoked; private boolean mPending; private long mTimeApprovedMs; private long mLastTimeConnectedMs; private int mSystemDataSyncFlags; private long mTimeApprovedMs = System.currentTimeMillis(); private long mLastTimeConnectedMs = Long.MAX_VALUE; // Never connected. private int mSystemDataSyncFlags = -1; // By default, all system data sync is enabled. private Icon mDeviceIcon; private DeviceId mDeviceId; private List<String> mPackagesToNotify; Loading
services/companion/java/com/android/server/companion/association/AssociationDiskStore.java +22 −8 Original line number Diff line number Diff line Loading @@ -477,11 +477,13 @@ public final class AssociationDiskStore { final boolean notify = readBooleanAttribute(parser, XML_ATTR_NOTIFY_DEVICE_NEARBY); final long timeApproved = readLongAttribute(parser, XML_ATTR_TIME_APPROVED, 0L); return new AssociationInfo(associationId, userId, appPackage, MacAddress.fromString(deviceAddress), null, profile, null, /* managedByCompanionApp */ false, notify, /* revoked */ false, /* pending */ false, timeApproved, Long.MAX_VALUE, /* systemDataSyncFlags */ 0, /* deviceIcon */ null, /* deviceId */ null, /* packagesToNotify */ null); return new AssociationInfo.Builder(associationId, userId, appPackage) .setDeviceMacAddress(MacAddress.fromString(deviceAddress)) .setDeviceProfile(profile) .setNotifyOnDeviceNearby(notify) .setTimeApproved(timeApproved) .setSystemDataSyncFlags(0) .build(); } private static Associations readAssociationsV1(@NonNull TypedXmlPullParser parser, Loading Loading @@ -558,9 +560,21 @@ public final class AssociationDiskStore { } } return new AssociationInfo(associationId, userId, appPackage, macAddress, displayName, profile, null, selfManaged, notify, revoked, pending, timeApproved, lastTimeConnected, systemDataSyncFlags, deviceIcon, deviceId, packagesToNotify); return new AssociationInfo.Builder(associationId, userId, appPackage) .setDeviceMacAddress(macAddress) .setDisplayName(displayName) .setDeviceProfile(profile) .setSelfManaged(selfManaged) .setNotifyOnDeviceNearby(notify) .setRevoked(revoked) .setPending(pending) .setTimeApproved(timeApproved) .setLastTimeConnected(lastTimeConnected) .setSystemDataSyncFlags(systemDataSyncFlags) .setDeviceIcon(deviceIcon) .setDeviceId(deviceId) .setPackagesToNotify(packagesToNotify) .build(); } private static List<String> readPackagesToNotify(@NonNull TypedXmlPullParser parser) Loading
services/companion/java/com/android/server/companion/association/AssociationRequestsProcessor.java +17 −5 Original line number Diff line number Diff line Loading @@ -314,11 +314,23 @@ public class AssociationRequestsProcessor { final int id = mAssociationStore.getNextId(); final long timestamp = System.currentTimeMillis(); final AssociationInfo association = new AssociationInfo(id, userId, packageName, macAddress, displayName, deviceProfile, associatedDevice, selfManaged, /* notifyOnDeviceNearby */ false, /* revoked */ false, /* pending */ false, timestamp, Long.MAX_VALUE, /* systemDataSyncFlags */ 0, deviceIcon, /* deviceId */ null, /* packagesToNotify */ null); final AssociationInfo association = new AssociationInfo.Builder(id, userId, packageName) .setDeviceMacAddress(macAddress) .setDisplayName(displayName) .setDeviceProfile(deviceProfile) .setAssociatedDevice(associatedDevice) .setSelfManaged(selfManaged) .setNotifyOnDeviceNearby(false) .setRevoked(false) .setPending(false) .setTimeApproved(timestamp) .setLastTimeConnected(Long.MAX_VALUE) .setSystemDataSyncFlags(0) .setDeviceIcon(deviceIcon) .setDeviceId(null) .setPackagesToNotify(null) .build(); if (skipRoleGrant) { Slog.i(TAG, "Created association for " + association.getDeviceProfile() + " and userId=" Loading
services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java +10 −9 Original line number Diff line number Diff line Loading @@ -1561,14 +1561,15 @@ public class VirtualDeviceManagerServiceTest { associationId, deviceProfile, /* displayName= */ deviceProfile); } private AssociationInfo createAssociationInfo(int associationId, String deviceProfile, CharSequence displayName) { return new AssociationInfo(associationId, /* userId= */ 0, /* packageName= */ null, MacAddress.BROADCAST_ADDRESS, displayName, deviceProfile, /* associatedDevice= */ null, /* selfManaged= */ true, /* notifyOnDeviceNearby= */ false, /* revoked= */ false, /* pending= */ false, /* timeApprovedMs= */0, /* lastTimeConnectedMs= */0, /* systemDataSyncFlags= */ -1, /* deviceIcon= */ null, /* deviceId= */ null, /* packageToNotify= */ null); private AssociationInfo createAssociationInfo( int associationId, String deviceProfile, CharSequence displayName) { return new AssociationInfo.Builder(associationId, /* userId= */ 0, /* packageName= */ null) .setDeviceMacAddress(MacAddress.BROADCAST_ADDRESS) .setDisplayName(displayName) .setDeviceProfile(deviceProfile) .setSelfManaged(true) .setTimeApproved(0) .setLastTimeConnected(0) .build(); } }