Loading core/api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -939,6 +939,7 @@ package android.companion { method @NonNull public android.companion.AssociationInfo.Builder setSelfManaged(boolean); method @NonNull public android.companion.AssociationInfo.Builder setSystemDataSyncFlags(int); method @NonNull public android.companion.AssociationInfo.Builder setTimeApproved(long); method @NonNull public android.companion.AssociationInfo.Builder setTransportFlags(int); } public final class AssociationRequest implements android.os.Parcelable { Loading core/java/android/companion/AssociationInfo.java +30 −3 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ public final class AssociationInfo implements Parcelable { */ private final long mLastTimeConnectedMs; private final int mSystemDataSyncFlags; private final int mTransportFlags; @Nullable private final DeviceId mDeviceId; @Nullable Loading @@ -104,7 +105,7 @@ public final class AssociationInfo implements Parcelable { @Nullable String deviceProfile, @Nullable AssociatedDevice associatedDevice, boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked, boolean pending, long timeApprovedMs, long lastTimeConnectedMs, int systemDataSyncFlags, @Nullable Icon deviceIcon, @Nullable DeviceId deviceId, int transportFlags, @Nullable Icon deviceIcon, @Nullable DeviceId deviceId, @Nullable List<String> packagesToNotify) { if (id <= 0) { throw new IllegalArgumentException("Association ID should be greater than 0"); Loading @@ -128,6 +129,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = timeApprovedMs; mLastTimeConnectedMs = lastTimeConnectedMs; mSystemDataSyncFlags = systemDataSyncFlags; mTransportFlags = transportFlags; mDeviceIcon = deviceIcon; mDeviceId = deviceId; mPackagesToNotify = packagesToNotify; Loading Loading @@ -288,6 +290,14 @@ public final class AssociationInfo implements Parcelable { return mSystemDataSyncFlags; } /** * @return Flags to be used when attaching a new transport for this association. * @hide */ public int getTransportFlags() { return mTransportFlags; } /** * Get the device icon of the associated device. The device icon represents the device type. * Loading Loading @@ -382,6 +392,7 @@ public final class AssociationInfo implements Parcelable { mLastTimeConnectedMs == Long.MAX_VALUE ? LAST_TIME_CONNECTED_NONE : new Date(mLastTimeConnectedMs)) + ", mSystemDataSyncFlags=" + mSystemDataSyncFlags + ", mTransportFlags=" + mTransportFlags + ", mDeviceId=" + mDeviceId + ", mPackagesToNotify=" + mPackagesToNotify + '}'; Loading @@ -407,6 +418,7 @@ public final class AssociationInfo implements Parcelable { && Objects.equals(mDeviceProfile, that.mDeviceProfile) && Objects.equals(mAssociatedDevice, that.mAssociatedDevice) && mSystemDataSyncFlags == that.mSystemDataSyncFlags && mTransportFlags == that.mTransportFlags && isSameIcon(mDeviceIcon, that.mDeviceIcon) && Objects.equals(mDeviceId, that.mDeviceId) && Objects.equals(mPackagesToNotify, that.mPackagesToNotify); Loading @@ -423,8 +435,8 @@ public final class AssociationInfo implements Parcelable { public int hashCode() { return Objects.hash(mId, mUserId, mPackageName, mDeviceMacAddress, mDisplayName, mDeviceProfile, mAssociatedDevice, mSelfManaged, mNotifyOnDeviceNearby, mRevoked, mPending, mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags, mDeviceIcon, mDeviceId, mPackagesToNotify); mPending, mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags, mTransportFlags, mDeviceIcon, mDeviceId, mPackagesToNotify); } @Override Loading @@ -448,6 +460,7 @@ public final class AssociationInfo implements Parcelable { dest.writeLong(mTimeApprovedMs); dest.writeLong(mLastTimeConnectedMs); dest.writeInt(mSystemDataSyncFlags); dest.writeInt(mTransportFlags); if (Flags.associationDeviceIcon() && mDeviceIcon != null) { dest.writeInt(1); mDeviceIcon.writeToParcel(dest, flags); Loading Loading @@ -480,6 +493,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = in.readLong(); mLastTimeConnectedMs = in.readLong(); mSystemDataSyncFlags = in.readInt(); mTransportFlags = in.readInt(); int deviceIcon = in.readInt(); if (Flags.associationDeviceIcon() && deviceIcon == 1) { mDeviceIcon = Icon.CREATOR.createFromParcel(in); Loading Loading @@ -531,6 +545,7 @@ public final class AssociationInfo implements Parcelable { 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 int mTransportFlags; private Icon mDeviceIcon; private DeviceId mDeviceId; private List<String> mPackagesToNotify; Loading Loading @@ -560,6 +575,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = info.mTimeApprovedMs; mLastTimeConnectedMs = info.mLastTimeConnectedMs; mSystemDataSyncFlags = info.mSystemDataSyncFlags; mTransportFlags = info.mTransportFlags; mDeviceIcon = info.mDeviceIcon; mDeviceId = info.mDeviceId; mPackagesToNotify = info.mPackagesToNotify; Loading @@ -586,6 +602,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = info.mTimeApprovedMs; mLastTimeConnectedMs = info.mLastTimeConnectedMs; mSystemDataSyncFlags = info.mSystemDataSyncFlags; mTransportFlags = info.mTransportFlags; mDeviceIcon = info.mDeviceIcon; mDeviceId = info.mDeviceId; mPackagesToNotify = info.mPackagesToNotify; Loading Loading @@ -700,6 +717,15 @@ public final class AssociationInfo implements Parcelable { return this; } /** @hide */ @TestApi @NonNull @SuppressLint("MissingGetterMatchingBuilder") public Builder setTransportFlags(int flags) { mTransportFlags = flags; return this; } /** @hide */ @TestApi @NonNull Loading Loading @@ -745,6 +771,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags, mTransportFlags, mDeviceIcon, mDeviceId, mPackagesToNotify Loading core/java/android/companion/CompanionDeviceManager.java +2 −70 Original line number Diff line number Diff line Loading @@ -286,23 +286,6 @@ public final class CompanionDeviceManager { */ public static final int MESSAGE_ONEWAY_TO_WEARABLE = 0x43847987; // +TOW /** @hide */ @IntDef(flag = true, prefix = { "TRANSPORT_FLAG_" }, value = { TRANSPORT_FLAG_EXTEND_PATCH_DIFF, }) @Retention(RetentionPolicy.SOURCE) public @interface TransportFlags {} /** * A security flag that allows transports to be attached to devices that may be more vulnerable * due to infrequent updates. Can only be used for associations with * {@link AssociationRequest#DEVICE_PROFILE_WEARABLE_SENSING} device profile. * * @hide */ public static final int TRANSPORT_FLAG_EXTEND_PATCH_DIFF = 1; /** * Callback for applications to receive updates about and the outcome of * {@link AssociationRequest} issued via {@code associate()} call. Loading Loading @@ -1511,52 +1494,7 @@ public final class CompanionDeviceManager { } try { final Transport transport = new Transport(associationId, in, out, 0); mTransports.put(associationId, transport); transport.start(); } catch (IOException e) { throw new RuntimeException("Failed to attach transport", e); } } } /** * Attach a bidirectional communication stream to be used as a transport channel for * transporting system data between associated devices. Flags can be provided to further * customize the behavior of the transport. * * @param associationId id of the associated device. * @param in Already connected stream of data incoming from remote * associated device. * @param out Already connected stream of data outgoing to remote associated * device. * @param flags Flags to customize transport behavior. * @throws DeviceNotAssociatedException Thrown if the associationId was not previously * associated with this app. * * @see #buildPermissionTransferUserConsentIntent(int) * @see #startSystemDataTransfer(int, Executor, OutcomeReceiver) * @see #detachSystemDataTransport(int) * * @hide */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public void attachSystemDataTransport(int associationId, @NonNull InputStream in, @NonNull OutputStream out, @TransportFlags int flags) throws DeviceNotAssociatedException { if (mService == null) { Log.w(TAG, "CompanionDeviceManager service is not available."); return; } synchronized (mTransports) { if (mTransports.contains(associationId)) { detachSystemDataTransport(associationId); } try { final Transport transport = new Transport(associationId, in, out, flags); final Transport transport = new Transport(associationId, in, out); mTransports.put(associationId, transport); transport.start(); } catch (IOException e) { Loading Loading @@ -2098,7 +2036,6 @@ public final class CompanionDeviceManager { private final int mAssociationId; private final InputStream mRemoteIn; private final OutputStream mRemoteOut; private final int mFlags; private InputStream mLocalIn; private OutputStream mLocalOut; Loading @@ -2106,14 +2043,9 @@ public final class CompanionDeviceManager { private volatile boolean mStopped; Transport(int associationId, InputStream remoteIn, OutputStream remoteOut) { this(associationId, remoteIn, remoteOut, 0); } Transport(int associationId, InputStream remoteIn, OutputStream remoteOut, int flags) { mAssociationId = associationId; mRemoteIn = remoteIn; mRemoteOut = remoteOut; mFlags = flags; } public void start() throws IOException { Loading @@ -2130,7 +2062,7 @@ public final class CompanionDeviceManager { try { mService.attachSystemDataTransport(mContext.getOpPackageName(), mContext.getUserId(), mAssociationId, remoteFd, mFlags); mContext.getUserId(), mAssociationId, remoteFd); } catch (RemoteException e) { throw new IOException("Failed to configure transport", e); } Loading core/java/android/companion/ICompanionDeviceManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ interface ICompanionDeviceManager { in ISystemDataTransferCallback callback); @EnforcePermission("DELIVER_COMPANION_MESSAGES") void attachSystemDataTransport(String packageName, int userId, int associationId, in ParcelFileDescriptor fd, int flags); void attachSystemDataTransport(String packageName, int userId, int associationId, in ParcelFileDescriptor fd); @EnforcePermission("DELIVER_COMPANION_MESSAGES") void detachSystemDataTransport(String packageName, int userId, int associationId); Loading services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -594,10 +594,10 @@ public class CompanionDeviceManagerService extends SystemService { @Override @EnforcePermission(DELIVER_COMPANION_MESSAGES) public void attachSystemDataTransport(String packageName, int userId, int associationId, ParcelFileDescriptor fd, int flags) { ParcelFileDescriptor fd) { attachSystemDataTransport_enforcePermission(); mTransportManager.attachSystemDataTransport(associationId, fd, flags); mTransportManager.attachSystemDataTransport(associationId, fd); } @Override Loading Loading
core/api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -939,6 +939,7 @@ package android.companion { method @NonNull public android.companion.AssociationInfo.Builder setSelfManaged(boolean); method @NonNull public android.companion.AssociationInfo.Builder setSystemDataSyncFlags(int); method @NonNull public android.companion.AssociationInfo.Builder setTimeApproved(long); method @NonNull public android.companion.AssociationInfo.Builder setTransportFlags(int); } public final class AssociationRequest implements android.os.Parcelable { Loading
core/java/android/companion/AssociationInfo.java +30 −3 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ public final class AssociationInfo implements Parcelable { */ private final long mLastTimeConnectedMs; private final int mSystemDataSyncFlags; private final int mTransportFlags; @Nullable private final DeviceId mDeviceId; @Nullable Loading @@ -104,7 +105,7 @@ public final class AssociationInfo implements Parcelable { @Nullable String deviceProfile, @Nullable AssociatedDevice associatedDevice, boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked, boolean pending, long timeApprovedMs, long lastTimeConnectedMs, int systemDataSyncFlags, @Nullable Icon deviceIcon, @Nullable DeviceId deviceId, int transportFlags, @Nullable Icon deviceIcon, @Nullable DeviceId deviceId, @Nullable List<String> packagesToNotify) { if (id <= 0) { throw new IllegalArgumentException("Association ID should be greater than 0"); Loading @@ -128,6 +129,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = timeApprovedMs; mLastTimeConnectedMs = lastTimeConnectedMs; mSystemDataSyncFlags = systemDataSyncFlags; mTransportFlags = transportFlags; mDeviceIcon = deviceIcon; mDeviceId = deviceId; mPackagesToNotify = packagesToNotify; Loading Loading @@ -288,6 +290,14 @@ public final class AssociationInfo implements Parcelable { return mSystemDataSyncFlags; } /** * @return Flags to be used when attaching a new transport for this association. * @hide */ public int getTransportFlags() { return mTransportFlags; } /** * Get the device icon of the associated device. The device icon represents the device type. * Loading Loading @@ -382,6 +392,7 @@ public final class AssociationInfo implements Parcelable { mLastTimeConnectedMs == Long.MAX_VALUE ? LAST_TIME_CONNECTED_NONE : new Date(mLastTimeConnectedMs)) + ", mSystemDataSyncFlags=" + mSystemDataSyncFlags + ", mTransportFlags=" + mTransportFlags + ", mDeviceId=" + mDeviceId + ", mPackagesToNotify=" + mPackagesToNotify + '}'; Loading @@ -407,6 +418,7 @@ public final class AssociationInfo implements Parcelable { && Objects.equals(mDeviceProfile, that.mDeviceProfile) && Objects.equals(mAssociatedDevice, that.mAssociatedDevice) && mSystemDataSyncFlags == that.mSystemDataSyncFlags && mTransportFlags == that.mTransportFlags && isSameIcon(mDeviceIcon, that.mDeviceIcon) && Objects.equals(mDeviceId, that.mDeviceId) && Objects.equals(mPackagesToNotify, that.mPackagesToNotify); Loading @@ -423,8 +435,8 @@ public final class AssociationInfo implements Parcelable { public int hashCode() { return Objects.hash(mId, mUserId, mPackageName, mDeviceMacAddress, mDisplayName, mDeviceProfile, mAssociatedDevice, mSelfManaged, mNotifyOnDeviceNearby, mRevoked, mPending, mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags, mDeviceIcon, mDeviceId, mPackagesToNotify); mPending, mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags, mTransportFlags, mDeviceIcon, mDeviceId, mPackagesToNotify); } @Override Loading @@ -448,6 +460,7 @@ public final class AssociationInfo implements Parcelable { dest.writeLong(mTimeApprovedMs); dest.writeLong(mLastTimeConnectedMs); dest.writeInt(mSystemDataSyncFlags); dest.writeInt(mTransportFlags); if (Flags.associationDeviceIcon() && mDeviceIcon != null) { dest.writeInt(1); mDeviceIcon.writeToParcel(dest, flags); Loading Loading @@ -480,6 +493,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = in.readLong(); mLastTimeConnectedMs = in.readLong(); mSystemDataSyncFlags = in.readInt(); mTransportFlags = in.readInt(); int deviceIcon = in.readInt(); if (Flags.associationDeviceIcon() && deviceIcon == 1) { mDeviceIcon = Icon.CREATOR.createFromParcel(in); Loading Loading @@ -531,6 +545,7 @@ public final class AssociationInfo implements Parcelable { 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 int mTransportFlags; private Icon mDeviceIcon; private DeviceId mDeviceId; private List<String> mPackagesToNotify; Loading Loading @@ -560,6 +575,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = info.mTimeApprovedMs; mLastTimeConnectedMs = info.mLastTimeConnectedMs; mSystemDataSyncFlags = info.mSystemDataSyncFlags; mTransportFlags = info.mTransportFlags; mDeviceIcon = info.mDeviceIcon; mDeviceId = info.mDeviceId; mPackagesToNotify = info.mPackagesToNotify; Loading @@ -586,6 +602,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs = info.mTimeApprovedMs; mLastTimeConnectedMs = info.mLastTimeConnectedMs; mSystemDataSyncFlags = info.mSystemDataSyncFlags; mTransportFlags = info.mTransportFlags; mDeviceIcon = info.mDeviceIcon; mDeviceId = info.mDeviceId; mPackagesToNotify = info.mPackagesToNotify; Loading Loading @@ -700,6 +717,15 @@ public final class AssociationInfo implements Parcelable { return this; } /** @hide */ @TestApi @NonNull @SuppressLint("MissingGetterMatchingBuilder") public Builder setTransportFlags(int flags) { mTransportFlags = flags; return this; } /** @hide */ @TestApi @NonNull Loading Loading @@ -745,6 +771,7 @@ public final class AssociationInfo implements Parcelable { mTimeApprovedMs, mLastTimeConnectedMs, mSystemDataSyncFlags, mTransportFlags, mDeviceIcon, mDeviceId, mPackagesToNotify Loading
core/java/android/companion/CompanionDeviceManager.java +2 −70 Original line number Diff line number Diff line Loading @@ -286,23 +286,6 @@ public final class CompanionDeviceManager { */ public static final int MESSAGE_ONEWAY_TO_WEARABLE = 0x43847987; // +TOW /** @hide */ @IntDef(flag = true, prefix = { "TRANSPORT_FLAG_" }, value = { TRANSPORT_FLAG_EXTEND_PATCH_DIFF, }) @Retention(RetentionPolicy.SOURCE) public @interface TransportFlags {} /** * A security flag that allows transports to be attached to devices that may be more vulnerable * due to infrequent updates. Can only be used for associations with * {@link AssociationRequest#DEVICE_PROFILE_WEARABLE_SENSING} device profile. * * @hide */ public static final int TRANSPORT_FLAG_EXTEND_PATCH_DIFF = 1; /** * Callback for applications to receive updates about and the outcome of * {@link AssociationRequest} issued via {@code associate()} call. Loading Loading @@ -1511,52 +1494,7 @@ public final class CompanionDeviceManager { } try { final Transport transport = new Transport(associationId, in, out, 0); mTransports.put(associationId, transport); transport.start(); } catch (IOException e) { throw new RuntimeException("Failed to attach transport", e); } } } /** * Attach a bidirectional communication stream to be used as a transport channel for * transporting system data between associated devices. Flags can be provided to further * customize the behavior of the transport. * * @param associationId id of the associated device. * @param in Already connected stream of data incoming from remote * associated device. * @param out Already connected stream of data outgoing to remote associated * device. * @param flags Flags to customize transport behavior. * @throws DeviceNotAssociatedException Thrown if the associationId was not previously * associated with this app. * * @see #buildPermissionTransferUserConsentIntent(int) * @see #startSystemDataTransfer(int, Executor, OutcomeReceiver) * @see #detachSystemDataTransport(int) * * @hide */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public void attachSystemDataTransport(int associationId, @NonNull InputStream in, @NonNull OutputStream out, @TransportFlags int flags) throws DeviceNotAssociatedException { if (mService == null) { Log.w(TAG, "CompanionDeviceManager service is not available."); return; } synchronized (mTransports) { if (mTransports.contains(associationId)) { detachSystemDataTransport(associationId); } try { final Transport transport = new Transport(associationId, in, out, flags); final Transport transport = new Transport(associationId, in, out); mTransports.put(associationId, transport); transport.start(); } catch (IOException e) { Loading Loading @@ -2098,7 +2036,6 @@ public final class CompanionDeviceManager { private final int mAssociationId; private final InputStream mRemoteIn; private final OutputStream mRemoteOut; private final int mFlags; private InputStream mLocalIn; private OutputStream mLocalOut; Loading @@ -2106,14 +2043,9 @@ public final class CompanionDeviceManager { private volatile boolean mStopped; Transport(int associationId, InputStream remoteIn, OutputStream remoteOut) { this(associationId, remoteIn, remoteOut, 0); } Transport(int associationId, InputStream remoteIn, OutputStream remoteOut, int flags) { mAssociationId = associationId; mRemoteIn = remoteIn; mRemoteOut = remoteOut; mFlags = flags; } public void start() throws IOException { Loading @@ -2130,7 +2062,7 @@ public final class CompanionDeviceManager { try { mService.attachSystemDataTransport(mContext.getOpPackageName(), mContext.getUserId(), mAssociationId, remoteFd, mFlags); mContext.getUserId(), mAssociationId, remoteFd); } catch (RemoteException e) { throw new IOException("Failed to configure transport", e); } Loading
core/java/android/companion/ICompanionDeviceManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ interface ICompanionDeviceManager { in ISystemDataTransferCallback callback); @EnforcePermission("DELIVER_COMPANION_MESSAGES") void attachSystemDataTransport(String packageName, int userId, int associationId, in ParcelFileDescriptor fd, int flags); void attachSystemDataTransport(String packageName, int userId, int associationId, in ParcelFileDescriptor fd); @EnforcePermission("DELIVER_COMPANION_MESSAGES") void detachSystemDataTransport(String packageName, int userId, int associationId); Loading
services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -594,10 +594,10 @@ public class CompanionDeviceManagerService extends SystemService { @Override @EnforcePermission(DELIVER_COMPANION_MESSAGES) public void attachSystemDataTransport(String packageName, int userId, int associationId, ParcelFileDescriptor fd, int flags) { ParcelFileDescriptor fd) { attachSystemDataTransport_enforcePermission(); mTransportManager.attachSystemDataTransport(associationId, fd, flags); mTransportManager.attachSystemDataTransport(associationId, fd); } @Override Loading