Loading core/api/current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -9187,6 +9187,7 @@ package android.companion { method @Nullable public String getDeviceProfile(); method @Nullable public CharSequence getDisplayName(); method public int getId(); method public int getSystemDataSyncFlags(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.companion.AssociationInfo> CREATOR; } Loading Loading @@ -9256,8 +9257,10 @@ package android.companion { method @RequiresPermission(anyOf={android.Manifest.permission.REQUEST_COMPANION_PROFILE_WATCH, android.Manifest.permission.REQUEST_COMPANION_PROFILE_COMPUTER, android.Manifest.permission.REQUEST_COMPANION_PROFILE_APP_STREAMING, android.Manifest.permission.REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION}, conditional=true) public void associate(@NonNull android.companion.AssociationRequest, @NonNull java.util.concurrent.Executor, @NonNull android.companion.CompanionDeviceManager.Callback); method @Nullable public android.content.IntentSender buildAssociationCancellationIntent(); method @Nullable public android.content.IntentSender buildPermissionTransferUserConsentIntent(int) throws android.companion.DeviceNotAssociatedException; method public void disableSystemDataSync(int, int); method @Deprecated public void disassociate(@NonNull String); method public void disassociate(int); method public void enableSystemDataSync(int, int); method @NonNull @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") public java.util.List<android.companion.AssociationInfo> getAllAssociations(); method @Deprecated @NonNull public java.util.List<java.lang.String> getAssociations(); method @NonNull public java.util.List<android.companion.AssociationInfo> getMyAssociations(); Loading @@ -9268,6 +9271,7 @@ package android.companion { method @RequiresPermission(android.Manifest.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE) public void stopObservingDevicePresence(@NonNull String) throws android.companion.DeviceNotAssociatedException; field public static final String EXTRA_ASSOCIATION = "android.companion.extra.ASSOCIATION"; field @Deprecated public static final String EXTRA_DEVICE = "android.companion.extra.DEVICE"; field public static final int FLAG_CALL_METADATA = 1; // 0x1 field public static final int RESULT_CANCELED = 0; // 0x0 field public static final int RESULT_DISCOVERY_TIMEOUT = 2; // 0x2 field public static final int RESULT_INTERNAL_ERROR = 3; // 0x3 core/java/android/companion/AssociationInfo.java +43 −35 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public final class AssociationInfo implements Parcelable { private final boolean mSelfManaged; private final boolean mNotifyOnDeviceNearby; private final int mSystemDataSyncFlags; /** * Indicates that the association has been revoked (removed), but we keep the association Loading @@ -73,7 +74,6 @@ public final class AssociationInfo implements Parcelable { /** * Creates a new Association. * Only to be used by the CompanionDeviceManagerService. * * @hide */ Loading @@ -81,7 +81,7 @@ public final class AssociationInfo implements Parcelable { @Nullable MacAddress macAddress, @Nullable CharSequence displayName, @Nullable String deviceProfile, @Nullable AssociatedDevice associatedDevice, boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked, long timeApprovedMs, long lastTimeConnectedMs) { long timeApprovedMs, long lastTimeConnectedMs, int systemDataSyncFlags) { if (id <= 0) { throw new IllegalArgumentException("Association ID should be greater than 0"); } Loading @@ -105,6 +105,7 @@ public final class AssociationInfo implements Parcelable { mRevoked = revoked; mTimeApprovedMs = timeApprovedMs; mLastTimeConnectedMs = lastTimeConnectedMs; mSystemDataSyncFlags = systemDataSyncFlags; } /** Loading Loading @@ -220,6 +221,16 @@ public final class AssociationInfo implements Parcelable { return mLastTimeConnectedMs; } /** * @return Enabled system data sync flags set via * {@link CompanionDeviceManager#enableSystemDataSync(int, int)} and * {@link CompanionDeviceManager#disableSystemDataSync(int, int)}. * Or by default all flags are 1 (enabled). */ public int getSystemDataSyncFlags() { return mSystemDataSyncFlags; } /** * Utility method for checking if the association represents a device with the given MAC * address. Loading Loading @@ -287,6 +298,7 @@ public final class AssociationInfo implements Parcelable { + ", mLastTimeConnectedMs=" + ( mLastTimeConnectedMs == Long.MAX_VALUE ? LAST_TIME_CONNECTED_NONE : new Date(mLastTimeConnectedMs)) + ", mSystemDataSyncFlags=" + mSystemDataSyncFlags + '}'; } Loading @@ -306,14 +318,15 @@ public final class AssociationInfo implements Parcelable { && Objects.equals(mDeviceMacAddress, that.mDeviceMacAddress) && Objects.equals(mDisplayName, that.mDisplayName) && Objects.equals(mDeviceProfile, that.mDeviceProfile) && Objects.equals(mAssociatedDevice, that.mAssociatedDevice); && Objects.equals(mAssociatedDevice, that.mAssociatedDevice) && mSystemDataSyncFlags == that.mSystemDataSyncFlags; } @Override public int hashCode() { return Objects.hash(mId, mUserId, mPackageName, mDeviceMacAddress, mDisplayName, mDeviceProfile, mAssociatedDevice, mSelfManaged, mNotifyOnDeviceNearby, mRevoked, mTimeApprovedMs, mLastTimeConnectedMs); mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags); } @Override Loading @@ -338,6 +351,7 @@ public final class AssociationInfo implements Parcelable { dest.writeBoolean(mRevoked); dest.writeLong(mTimeApprovedMs); dest.writeLong(mLastTimeConnectedMs); dest.writeInt(mSystemDataSyncFlags); } private AssociationInfo(@NonNull Parcel in) { Loading @@ -356,6 +370,7 @@ public final class AssociationInfo implements Parcelable { mRevoked = in.readBoolean(); mTimeApprovedMs = in.readLong(); mLastTimeConnectedMs = in.readLong(); mSystemDataSyncFlags = in.readInt(); } @NonNull Loading Loading @@ -390,27 +405,24 @@ public final class AssociationInfo implements Parcelable { return new Builder(info); } /** * @hide */ /** @hide */ public static final class Builder implements NonActionableBuilder { @NonNull private final AssociationInfo mOriginalInfo; private boolean mNotifyOnDeviceNearby; private boolean mRevoked; private long mLastTimeConnectedMs; private int mSystemDataSyncFlags; private Builder(@NonNull AssociationInfo info) { mOriginalInfo = info; mNotifyOnDeviceNearby = info.mNotifyOnDeviceNearby; mRevoked = info.mRevoked; mLastTimeConnectedMs = info.mLastTimeConnectedMs; mSystemDataSyncFlags = info.mSystemDataSyncFlags; } /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @Override @NonNull public Builder setLastTimeConnected(long lastTimeConnectedMs) { Loading @@ -423,10 +435,7 @@ public final class AssociationInfo implements Parcelable { return this; } /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @Override @NonNull public Builder setNotifyOnDeviceNearby(boolean notifyOnDeviceNearby) { Loading @@ -434,10 +443,7 @@ public final class AssociationInfo implements Parcelable { return this; } /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @Override @NonNull public Builder setRevoked(boolean revoked) { Loading @@ -445,9 +451,15 @@ public final class AssociationInfo implements Parcelable { return this; } /** * @hide */ /** @hide */ @Override @NonNull public Builder setSystemDataSyncFlags(int flags) { mSystemDataSyncFlags = flags; return this; } /** @hide */ @NonNull public AssociationInfo build() { return new AssociationInfo( Loading @@ -462,7 +474,8 @@ public final class AssociationInfo implements Parcelable { mNotifyOnDeviceNearby, mRevoked, mOriginalInfo.mTimeApprovedMs, mLastTimeConnectedMs mLastTimeConnectedMs, mSystemDataSyncFlags ); } } Loading @@ -480,25 +493,20 @@ public final class AssociationInfo implements Parcelable { * @hide */ public interface NonActionableBuilder { /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @NonNull Builder setNotifyOnDeviceNearby(boolean notifyOnDeviceNearby); /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @NonNull Builder setLastTimeConnected(long lastTimeConnectedMs); /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @NonNull Builder setRevoked(boolean revoked); /** @hide */ @NonNull Builder setSystemDataSyncFlags(int flags); } } core/java/android/companion/CompanionDeviceManager.java +56 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,19 @@ public final class CompanionDeviceManager { */ public static final String REASON_CANCELED = "canceled"; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { FLAG_CALL_METADATA, }) @Retention(RetentionPolicy.SOURCE) public @interface DataSyncTypes {} /** * Used by {@link #enableSystemDataSync(int, int)}}. * Sync call metadata like muting, ending and silencing a call. * */ public static final int FLAG_CALL_METADATA = 1; /** * A device, returned in the activity result of the {@link IntentSender} received in Loading Loading @@ -468,6 +481,49 @@ public final class CompanionDeviceManager { } } /** * <p>Enable system data sync (it only supports call metadata sync for now). * By default all supported system data types are enabled.</p> * * <p>Calling this API requires a uses-feature * {@link PackageManager#FEATURE_COMPANION_DEVICE_SETUP} declaration in the manifest</p> * * @param associationId id of the device association. * @param flags system data types to be enabled. */ public void enableSystemDataSync(int associationId, @DataSyncTypes int flags) { if (!checkFeaturePresent()) { return; } try { mService.enableSystemDataSync(associationId, flags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * <p>Disable system data sync (it only supports call metadata sync for now). * By default all supported system data types are enabled.</p> * * <p>Calling this API requires a uses-feature * {@link PackageManager#FEATURE_COMPANION_DEVICE_SETUP} declaration in the manifest</p> * * @param associationId id of the device association. * @param flags system data types to be disabled. */ public void disableSystemDataSync(int associationId, @DataSyncTypes int flags) { if (!checkFeaturePresent()) { return; } try { mService.disableSystemDataSync(associationId, flags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * <p>Calling this API requires a uses-feature Loading core/java/android/companion/ICompanionDeviceManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,8 @@ interface ICompanionDeviceManager { boolean isCompanionApplicationBound(String packageName, int userId); PendingIntent buildAssociationCancellationIntent(in String callingPackage, int userId); void enableSystemDataSync(int associationId, int flags); void disableSystemDataSync(int associationId, int flags); } services/companion/java/com/android/server/companion/AssociationRequestsProcessor.java +19 −4 Original line number Diff line number Diff line Loading @@ -268,9 +268,9 @@ class AssociationRequestsProcessor { @NonNull ResultReceiver resultReceiver) { final long callingIdentity = Binder.clearCallingIdentity(); try { createAssociation(userId, packageName, macAddress, request.getDisplayName(), request.getDeviceProfile(), request.getAssociatedDevice(), request.isSelfManaged(), createAssociation(userId, packageName, macAddress, request.getDisplayName(), request.getDeviceProfile(), request.getAssociatedDevice(), request.isSelfManaged(), callback, resultReceiver); } finally { Binder.restoreCallingIdentity(callingIdentity); Loading @@ -287,7 +287,8 @@ class AssociationRequestsProcessor { final AssociationInfo association = new AssociationInfo(id, userId, packageName, macAddress, displayName, deviceProfile, associatedDevice, selfManaged, /* notifyOnDeviceNearby */ false, /* revoked */ false, timestamp, Long.MAX_VALUE); /* notifyOnDeviceNearby */ false, /* revoked */ false, timestamp, Long.MAX_VALUE, /* systemDataSyncFlags */ ~0); if (deviceProfile != null) { // If the "Device Profile" is specified, make the companion application a holder of the Loading Loading @@ -315,6 +316,20 @@ class AssociationRequestsProcessor { // that there are other devices with the same profile, so the role holder won't be removed. } public void enableSystemDataSync(int associationId, int flags) { AssociationInfo association = mAssociationStore.getAssociationById(associationId); AssociationInfo updated = AssociationInfo.builder(association) .setSystemDataSyncFlags(association.getSystemDataSyncFlags() | flags).build(); mAssociationStore.updateAssociation(updated); } public void disableSystemDataSync(int associationId, int flags) { AssociationInfo association = mAssociationStore.getAssociationById(associationId); AssociationInfo updated = AssociationInfo.builder(association) .setSystemDataSyncFlags(association.getSystemDataSyncFlags() & (~flags)).build(); mAssociationStore.updateAssociation(updated); } private void addAssociationToStore(@NonNull AssociationInfo association, @Nullable String deviceProfile) { Slog.i(TAG, "New CDM association created=" + association); Loading Loading
core/api/current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -9187,6 +9187,7 @@ package android.companion { method @Nullable public String getDeviceProfile(); method @Nullable public CharSequence getDisplayName(); method public int getId(); method public int getSystemDataSyncFlags(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.companion.AssociationInfo> CREATOR; } Loading Loading @@ -9256,8 +9257,10 @@ package android.companion { method @RequiresPermission(anyOf={android.Manifest.permission.REQUEST_COMPANION_PROFILE_WATCH, android.Manifest.permission.REQUEST_COMPANION_PROFILE_COMPUTER, android.Manifest.permission.REQUEST_COMPANION_PROFILE_APP_STREAMING, android.Manifest.permission.REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION}, conditional=true) public void associate(@NonNull android.companion.AssociationRequest, @NonNull java.util.concurrent.Executor, @NonNull android.companion.CompanionDeviceManager.Callback); method @Nullable public android.content.IntentSender buildAssociationCancellationIntent(); method @Nullable public android.content.IntentSender buildPermissionTransferUserConsentIntent(int) throws android.companion.DeviceNotAssociatedException; method public void disableSystemDataSync(int, int); method @Deprecated public void disassociate(@NonNull String); method public void disassociate(int); method public void enableSystemDataSync(int, int); method @NonNull @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") public java.util.List<android.companion.AssociationInfo> getAllAssociations(); method @Deprecated @NonNull public java.util.List<java.lang.String> getAssociations(); method @NonNull public java.util.List<android.companion.AssociationInfo> getMyAssociations(); Loading @@ -9268,6 +9271,7 @@ package android.companion { method @RequiresPermission(android.Manifest.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE) public void stopObservingDevicePresence(@NonNull String) throws android.companion.DeviceNotAssociatedException; field public static final String EXTRA_ASSOCIATION = "android.companion.extra.ASSOCIATION"; field @Deprecated public static final String EXTRA_DEVICE = "android.companion.extra.DEVICE"; field public static final int FLAG_CALL_METADATA = 1; // 0x1 field public static final int RESULT_CANCELED = 0; // 0x0 field public static final int RESULT_DISCOVERY_TIMEOUT = 2; // 0x2 field public static final int RESULT_INTERNAL_ERROR = 3; // 0x3
core/java/android/companion/AssociationInfo.java +43 −35 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public final class AssociationInfo implements Parcelable { private final boolean mSelfManaged; private final boolean mNotifyOnDeviceNearby; private final int mSystemDataSyncFlags; /** * Indicates that the association has been revoked (removed), but we keep the association Loading @@ -73,7 +74,6 @@ public final class AssociationInfo implements Parcelable { /** * Creates a new Association. * Only to be used by the CompanionDeviceManagerService. * * @hide */ Loading @@ -81,7 +81,7 @@ public final class AssociationInfo implements Parcelable { @Nullable MacAddress macAddress, @Nullable CharSequence displayName, @Nullable String deviceProfile, @Nullable AssociatedDevice associatedDevice, boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked, long timeApprovedMs, long lastTimeConnectedMs) { long timeApprovedMs, long lastTimeConnectedMs, int systemDataSyncFlags) { if (id <= 0) { throw new IllegalArgumentException("Association ID should be greater than 0"); } Loading @@ -105,6 +105,7 @@ public final class AssociationInfo implements Parcelable { mRevoked = revoked; mTimeApprovedMs = timeApprovedMs; mLastTimeConnectedMs = lastTimeConnectedMs; mSystemDataSyncFlags = systemDataSyncFlags; } /** Loading Loading @@ -220,6 +221,16 @@ public final class AssociationInfo implements Parcelable { return mLastTimeConnectedMs; } /** * @return Enabled system data sync flags set via * {@link CompanionDeviceManager#enableSystemDataSync(int, int)} and * {@link CompanionDeviceManager#disableSystemDataSync(int, int)}. * Or by default all flags are 1 (enabled). */ public int getSystemDataSyncFlags() { return mSystemDataSyncFlags; } /** * Utility method for checking if the association represents a device with the given MAC * address. Loading Loading @@ -287,6 +298,7 @@ public final class AssociationInfo implements Parcelable { + ", mLastTimeConnectedMs=" + ( mLastTimeConnectedMs == Long.MAX_VALUE ? LAST_TIME_CONNECTED_NONE : new Date(mLastTimeConnectedMs)) + ", mSystemDataSyncFlags=" + mSystemDataSyncFlags + '}'; } Loading @@ -306,14 +318,15 @@ public final class AssociationInfo implements Parcelable { && Objects.equals(mDeviceMacAddress, that.mDeviceMacAddress) && Objects.equals(mDisplayName, that.mDisplayName) && Objects.equals(mDeviceProfile, that.mDeviceProfile) && Objects.equals(mAssociatedDevice, that.mAssociatedDevice); && Objects.equals(mAssociatedDevice, that.mAssociatedDevice) && mSystemDataSyncFlags == that.mSystemDataSyncFlags; } @Override public int hashCode() { return Objects.hash(mId, mUserId, mPackageName, mDeviceMacAddress, mDisplayName, mDeviceProfile, mAssociatedDevice, mSelfManaged, mNotifyOnDeviceNearby, mRevoked, mTimeApprovedMs, mLastTimeConnectedMs); mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags); } @Override Loading @@ -338,6 +351,7 @@ public final class AssociationInfo implements Parcelable { dest.writeBoolean(mRevoked); dest.writeLong(mTimeApprovedMs); dest.writeLong(mLastTimeConnectedMs); dest.writeInt(mSystemDataSyncFlags); } private AssociationInfo(@NonNull Parcel in) { Loading @@ -356,6 +370,7 @@ public final class AssociationInfo implements Parcelable { mRevoked = in.readBoolean(); mTimeApprovedMs = in.readLong(); mLastTimeConnectedMs = in.readLong(); mSystemDataSyncFlags = in.readInt(); } @NonNull Loading Loading @@ -390,27 +405,24 @@ public final class AssociationInfo implements Parcelable { return new Builder(info); } /** * @hide */ /** @hide */ public static final class Builder implements NonActionableBuilder { @NonNull private final AssociationInfo mOriginalInfo; private boolean mNotifyOnDeviceNearby; private boolean mRevoked; private long mLastTimeConnectedMs; private int mSystemDataSyncFlags; private Builder(@NonNull AssociationInfo info) { mOriginalInfo = info; mNotifyOnDeviceNearby = info.mNotifyOnDeviceNearby; mRevoked = info.mRevoked; mLastTimeConnectedMs = info.mLastTimeConnectedMs; mSystemDataSyncFlags = info.mSystemDataSyncFlags; } /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @Override @NonNull public Builder setLastTimeConnected(long lastTimeConnectedMs) { Loading @@ -423,10 +435,7 @@ public final class AssociationInfo implements Parcelable { return this; } /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @Override @NonNull public Builder setNotifyOnDeviceNearby(boolean notifyOnDeviceNearby) { Loading @@ -434,10 +443,7 @@ public final class AssociationInfo implements Parcelable { return this; } /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @Override @NonNull public Builder setRevoked(boolean revoked) { Loading @@ -445,9 +451,15 @@ public final class AssociationInfo implements Parcelable { return this; } /** * @hide */ /** @hide */ @Override @NonNull public Builder setSystemDataSyncFlags(int flags) { mSystemDataSyncFlags = flags; return this; } /** @hide */ @NonNull public AssociationInfo build() { return new AssociationInfo( Loading @@ -462,7 +474,8 @@ public final class AssociationInfo implements Parcelable { mNotifyOnDeviceNearby, mRevoked, mOriginalInfo.mTimeApprovedMs, mLastTimeConnectedMs mLastTimeConnectedMs, mSystemDataSyncFlags ); } } Loading @@ -480,25 +493,20 @@ public final class AssociationInfo implements Parcelable { * @hide */ public interface NonActionableBuilder { /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @NonNull Builder setNotifyOnDeviceNearby(boolean notifyOnDeviceNearby); /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @NonNull Builder setLastTimeConnected(long lastTimeConnectedMs); /** * Should only be used by the CompanionDeviceManagerService. * @hide */ /** @hide */ @NonNull Builder setRevoked(boolean revoked); /** @hide */ @NonNull Builder setSystemDataSyncFlags(int flags); } }
core/java/android/companion/CompanionDeviceManager.java +56 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,19 @@ public final class CompanionDeviceManager { */ public static final String REASON_CANCELED = "canceled"; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { FLAG_CALL_METADATA, }) @Retention(RetentionPolicy.SOURCE) public @interface DataSyncTypes {} /** * Used by {@link #enableSystemDataSync(int, int)}}. * Sync call metadata like muting, ending and silencing a call. * */ public static final int FLAG_CALL_METADATA = 1; /** * A device, returned in the activity result of the {@link IntentSender} received in Loading Loading @@ -468,6 +481,49 @@ public final class CompanionDeviceManager { } } /** * <p>Enable system data sync (it only supports call metadata sync for now). * By default all supported system data types are enabled.</p> * * <p>Calling this API requires a uses-feature * {@link PackageManager#FEATURE_COMPANION_DEVICE_SETUP} declaration in the manifest</p> * * @param associationId id of the device association. * @param flags system data types to be enabled. */ public void enableSystemDataSync(int associationId, @DataSyncTypes int flags) { if (!checkFeaturePresent()) { return; } try { mService.enableSystemDataSync(associationId, flags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * <p>Disable system data sync (it only supports call metadata sync for now). * By default all supported system data types are enabled.</p> * * <p>Calling this API requires a uses-feature * {@link PackageManager#FEATURE_COMPANION_DEVICE_SETUP} declaration in the manifest</p> * * @param associationId id of the device association. * @param flags system data types to be disabled. */ public void disableSystemDataSync(int associationId, @DataSyncTypes int flags) { if (!checkFeaturePresent()) { return; } try { mService.disableSystemDataSync(associationId, flags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * <p>Calling this API requires a uses-feature Loading
core/java/android/companion/ICompanionDeviceManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,8 @@ interface ICompanionDeviceManager { boolean isCompanionApplicationBound(String packageName, int userId); PendingIntent buildAssociationCancellationIntent(in String callingPackage, int userId); void enableSystemDataSync(int associationId, int flags); void disableSystemDataSync(int associationId, int flags); }
services/companion/java/com/android/server/companion/AssociationRequestsProcessor.java +19 −4 Original line number Diff line number Diff line Loading @@ -268,9 +268,9 @@ class AssociationRequestsProcessor { @NonNull ResultReceiver resultReceiver) { final long callingIdentity = Binder.clearCallingIdentity(); try { createAssociation(userId, packageName, macAddress, request.getDisplayName(), request.getDeviceProfile(), request.getAssociatedDevice(), request.isSelfManaged(), createAssociation(userId, packageName, macAddress, request.getDisplayName(), request.getDeviceProfile(), request.getAssociatedDevice(), request.isSelfManaged(), callback, resultReceiver); } finally { Binder.restoreCallingIdentity(callingIdentity); Loading @@ -287,7 +287,8 @@ class AssociationRequestsProcessor { final AssociationInfo association = new AssociationInfo(id, userId, packageName, macAddress, displayName, deviceProfile, associatedDevice, selfManaged, /* notifyOnDeviceNearby */ false, /* revoked */ false, timestamp, Long.MAX_VALUE); /* notifyOnDeviceNearby */ false, /* revoked */ false, timestamp, Long.MAX_VALUE, /* systemDataSyncFlags */ ~0); if (deviceProfile != null) { // If the "Device Profile" is specified, make the companion application a holder of the Loading Loading @@ -315,6 +316,20 @@ class AssociationRequestsProcessor { // that there are other devices with the same profile, so the role holder won't be removed. } public void enableSystemDataSync(int associationId, int flags) { AssociationInfo association = mAssociationStore.getAssociationById(associationId); AssociationInfo updated = AssociationInfo.builder(association) .setSystemDataSyncFlags(association.getSystemDataSyncFlags() | flags).build(); mAssociationStore.updateAssociation(updated); } public void disableSystemDataSync(int associationId, int flags) { AssociationInfo association = mAssociationStore.getAssociationById(associationId); AssociationInfo updated = AssociationInfo.builder(association) .setSystemDataSyncFlags(association.getSystemDataSyncFlags() & (~flags)).build(); mAssociationStore.updateAssociation(updated); } private void addAssociationToStore(@NonNull AssociationInfo association, @Nullable String deviceProfile) { Slog.i(TAG, "New CDM association created=" + association); Loading