Loading core/api/current.txt +0 −7 Original line number Diff line number Diff line Loading @@ -9010,8 +9010,6 @@ package android.companion { method @Deprecated public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); method @RequiresPermission(android.Manifest.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE) public void startObservingDevicePresence(@NonNull String) throws android.companion.DeviceNotAssociatedException; method @Deprecated public void startSystemDataTransfer(int) throws android.companion.DeviceNotAssociatedException; method public void startSystemDataTransfer(int, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.companion.CompanionException>) throws android.companion.DeviceNotAssociatedException; 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"; Loading @@ -9027,19 +9025,14 @@ package android.companion { public abstract class CompanionDeviceService extends android.app.Service { ctor public CompanionDeviceService(); method @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void dispatchMessageToSystem(int, int, @NonNull byte[]) throws android.companion.DeviceNotAssociatedException; method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); method @Deprecated @MainThread public void onDeviceAppeared(@NonNull String); method @MainThread public void onDeviceAppeared(@NonNull android.companion.AssociationInfo); method @Deprecated @MainThread public void onDeviceDisappeared(@NonNull String); method @MainThread public void onDeviceDisappeared(@NonNull android.companion.AssociationInfo); method public void onMessageDispatchedFromSystem(int, int, @NonNull byte[]); field public static final String SERVICE_INTERFACE = "android.companion.CompanionDeviceService"; } public class CompanionException extends java.lang.RuntimeException { } public interface DeviceFilter<D extends android.os.Parcelable> extends android.os.Parcelable { } core/java/android/companion/CompanionDeviceManager.java +12 −11 Original line number Diff line number Diff line Loading @@ -800,18 +800,15 @@ public final class CompanionDeviceManager { * * @hide */ @Deprecated @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public void dispatchMessage(int messageId, int associationId, @NonNull byte[] message) throws DeviceNotAssociatedException { try { mService.dispatchMessage(messageId, associationId, message); } catch (RemoteException e) { ExceptionUtils.propagateIfInstanceOf(e.getCause(), DeviceNotAssociatedException.class); throw e.rethrowFromSystemServer(); } Log.w(LOG_TAG, "dispatchMessage replaced by attachSystemDataTransport"); } /** {@hide} */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void attachSystemDataTransport(int associationId, @NonNull InputStream in, @NonNull OutputStream out) throws DeviceNotAssociatedException { synchronized (mTransports) { Loading @@ -830,6 +827,7 @@ public final class CompanionDeviceManager { } /** {@hide} */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void detachSystemDataTransport(int associationId) throws DeviceNotAssociatedException { synchronized (mTransports) { Loading Loading @@ -927,7 +925,7 @@ public final class CompanionDeviceManager { * * <p>The permission transfer doesn't happen immediately after the call or user consented. * The app needs to trigger the system data transfer manually by calling * {@link #startSystemDataTransfer(int)}, when it confirms the communication channel between * {@code #startSystemDataTransfer(int)}, when it confirms the communication channel between * the two devices is established.</p> * * @param associationId The unique {@link AssociationInfo#getId ID} assigned to the association Loading Loading @@ -965,8 +963,8 @@ public final class CompanionDeviceManager { * @param associationId The unique {@link AssociationInfo#getId ID} assigned to the Association * of the companion device recorded by CompanionDeviceManager * @throws DeviceNotAssociatedException Exception if the companion device is not associated * * @deprecated Use {@link #startSystemDataTransfer(int, Executor, OutcomeReceiver)} instead. * @hide */ @Deprecated @UserHandleAware Loading @@ -993,6 +991,7 @@ public final class CompanionDeviceManager { * @param executor The executor which will be used to invoke the result callback. * @param result The callback to notify the app of the result of the system data transfer. * @throws DeviceNotAssociatedException Exception if the companion device is not associated * @hide */ @UserHandleAware public void startSystemDataTransfer( Loading Loading @@ -1125,12 +1124,14 @@ public final class CompanionDeviceManager { public void start() throws IOException { final ParcelFileDescriptor[] pair = ParcelFileDescriptor.createSocketPair(); mLocalIn = new ParcelFileDescriptor.AutoCloseInputStream(pair[0]); mLocalOut = new ParcelFileDescriptor.AutoCloseOutputStream(pair[0]); final ParcelFileDescriptor localFd = pair[0]; final ParcelFileDescriptor remoteFd = pair[1]; mLocalIn = new ParcelFileDescriptor.AutoCloseInputStream(localFd); mLocalOut = new ParcelFileDescriptor.AutoCloseOutputStream(localFd); try { mService.attachSystemDataTransport(mContext.getPackageName(), mContext.getUserId(), mAssociationId, pair[1]); mContext.getUserId(), mAssociationId, remoteFd); } catch (RemoteException e) { throw new IOException("Failed to configure transport", e); } Loading core/java/android/companion/CompanionDeviceService.java +11 −20 Original line number Diff line number Diff line Loading @@ -156,9 +156,12 @@ public abstract class CompanionDeviceService extends Service { * @param messageId system assigned id of the message to be sent * @param associationId association id of the associated device * @param message message to be sent * @hide */ @Deprecated public void onMessageDispatchedFromSystem(int messageId, int associationId, @NonNull byte[] message) { Log.w(LOG_TAG, "Replaced by attachSystemDataTransport"); // do nothing. Companion apps can override this function for system to send messages. } Loading @@ -185,22 +188,14 @@ public abstract class CompanionDeviceService extends Service { * @param messageId id of the message * @param associationId id of the associated device * @param message message received from the associated device * @hide */ @Deprecated @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void dispatchMessageToSystem(int messageId, int associationId, @NonNull byte[] message) throws DeviceNotAssociatedException { if (getBaseContext() == null) { Log.e(LOG_TAG, "Dispatch failed. Start your service before calling this method."); return; } CompanionDeviceManager companionDeviceManager = getSystemService(CompanionDeviceManager.class); if (companionDeviceManager != null) { companionDeviceManager.dispatchMessage(messageId, associationId, message); } else { Log.e(LOG_TAG, "CompanionDeviceManager is null. Can't dispatch messages."); } Log.w(LOG_TAG, "Replaced by attachSystemDataTransport"); } /** Loading @@ -223,10 +218,13 @@ public abstract class CompanionDeviceService extends Service { * device * @hide */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void attachSystemDataTransport(int associationId, @NonNull InputStream in, @NonNull OutputStream out) throws DeviceNotAssociatedException { getSystemService(CompanionDeviceManager.class) .attachSystemDataTransport(associationId, in, out); .attachSystemDataTransport(associationId, Objects.requireNonNull(in), Objects.requireNonNull(out)); } /** Loading @@ -236,6 +234,7 @@ public abstract class CompanionDeviceService extends Service { * @param associationId id of the associated device * @hide */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void detachSystemDataTransport(int associationId) throws DeviceNotAssociatedException { getSystemService(CompanionDeviceManager.class) Loading Loading @@ -299,13 +298,5 @@ public abstract class CompanionDeviceService extends Service { public void onDeviceDisappeared(AssociationInfo associationInfo) { mMainHandler.postAtFrontOfQueue(() -> mService.onDeviceDisappeared(associationInfo)); } @Override public void onMessageDispatchedFromSystem(int messageId, int associationId, @NonNull byte[] message) { mMainHandler.postAtFrontOfQueue( () -> mService.onMessageDispatchedFromSystem(messageId, associationId, message)); } } } core/java/android/companion/CompanionException.java +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ package android.companion; import android.annotation.NonNull; /** * {@code CompanionException} can be thrown during the companion system data transfer process. * {@code CompanionException} can be thrown during the companion system data * transfer process. * * @hide */ public class CompanionException extends RuntimeException { /** @hide */ Loading core/java/android/companion/ICompanionDeviceManager.aidl +0 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,6 @@ interface ICompanionDeviceManager { void createAssociation(in String packageName, in String macAddress, int userId, in byte[] certificate); void dispatchMessage(int messageId, int associationId, in byte[] message); void addOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId); void removeOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId); Loading Loading
core/api/current.txt +0 −7 Original line number Diff line number Diff line Loading @@ -9010,8 +9010,6 @@ package android.companion { method @Deprecated public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); method @RequiresPermission(android.Manifest.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE) public void startObservingDevicePresence(@NonNull String) throws android.companion.DeviceNotAssociatedException; method @Deprecated public void startSystemDataTransfer(int) throws android.companion.DeviceNotAssociatedException; method public void startSystemDataTransfer(int, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.companion.CompanionException>) throws android.companion.DeviceNotAssociatedException; 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"; Loading @@ -9027,19 +9025,14 @@ package android.companion { public abstract class CompanionDeviceService extends android.app.Service { ctor public CompanionDeviceService(); method @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void dispatchMessageToSystem(int, int, @NonNull byte[]) throws android.companion.DeviceNotAssociatedException; method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); method @Deprecated @MainThread public void onDeviceAppeared(@NonNull String); method @MainThread public void onDeviceAppeared(@NonNull android.companion.AssociationInfo); method @Deprecated @MainThread public void onDeviceDisappeared(@NonNull String); method @MainThread public void onDeviceDisappeared(@NonNull android.companion.AssociationInfo); method public void onMessageDispatchedFromSystem(int, int, @NonNull byte[]); field public static final String SERVICE_INTERFACE = "android.companion.CompanionDeviceService"; } public class CompanionException extends java.lang.RuntimeException { } public interface DeviceFilter<D extends android.os.Parcelable> extends android.os.Parcelable { }
core/java/android/companion/CompanionDeviceManager.java +12 −11 Original line number Diff line number Diff line Loading @@ -800,18 +800,15 @@ public final class CompanionDeviceManager { * * @hide */ @Deprecated @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public void dispatchMessage(int messageId, int associationId, @NonNull byte[] message) throws DeviceNotAssociatedException { try { mService.dispatchMessage(messageId, associationId, message); } catch (RemoteException e) { ExceptionUtils.propagateIfInstanceOf(e.getCause(), DeviceNotAssociatedException.class); throw e.rethrowFromSystemServer(); } Log.w(LOG_TAG, "dispatchMessage replaced by attachSystemDataTransport"); } /** {@hide} */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void attachSystemDataTransport(int associationId, @NonNull InputStream in, @NonNull OutputStream out) throws DeviceNotAssociatedException { synchronized (mTransports) { Loading @@ -830,6 +827,7 @@ public final class CompanionDeviceManager { } /** {@hide} */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void detachSystemDataTransport(int associationId) throws DeviceNotAssociatedException { synchronized (mTransports) { Loading Loading @@ -927,7 +925,7 @@ public final class CompanionDeviceManager { * * <p>The permission transfer doesn't happen immediately after the call or user consented. * The app needs to trigger the system data transfer manually by calling * {@link #startSystemDataTransfer(int)}, when it confirms the communication channel between * {@code #startSystemDataTransfer(int)}, when it confirms the communication channel between * the two devices is established.</p> * * @param associationId The unique {@link AssociationInfo#getId ID} assigned to the association Loading Loading @@ -965,8 +963,8 @@ public final class CompanionDeviceManager { * @param associationId The unique {@link AssociationInfo#getId ID} assigned to the Association * of the companion device recorded by CompanionDeviceManager * @throws DeviceNotAssociatedException Exception if the companion device is not associated * * @deprecated Use {@link #startSystemDataTransfer(int, Executor, OutcomeReceiver)} instead. * @hide */ @Deprecated @UserHandleAware Loading @@ -993,6 +991,7 @@ public final class CompanionDeviceManager { * @param executor The executor which will be used to invoke the result callback. * @param result The callback to notify the app of the result of the system data transfer. * @throws DeviceNotAssociatedException Exception if the companion device is not associated * @hide */ @UserHandleAware public void startSystemDataTransfer( Loading Loading @@ -1125,12 +1124,14 @@ public final class CompanionDeviceManager { public void start() throws IOException { final ParcelFileDescriptor[] pair = ParcelFileDescriptor.createSocketPair(); mLocalIn = new ParcelFileDescriptor.AutoCloseInputStream(pair[0]); mLocalOut = new ParcelFileDescriptor.AutoCloseOutputStream(pair[0]); final ParcelFileDescriptor localFd = pair[0]; final ParcelFileDescriptor remoteFd = pair[1]; mLocalIn = new ParcelFileDescriptor.AutoCloseInputStream(localFd); mLocalOut = new ParcelFileDescriptor.AutoCloseOutputStream(localFd); try { mService.attachSystemDataTransport(mContext.getPackageName(), mContext.getUserId(), mAssociationId, pair[1]); mContext.getUserId(), mAssociationId, remoteFd); } catch (RemoteException e) { throw new IOException("Failed to configure transport", e); } Loading
core/java/android/companion/CompanionDeviceService.java +11 −20 Original line number Diff line number Diff line Loading @@ -156,9 +156,12 @@ public abstract class CompanionDeviceService extends Service { * @param messageId system assigned id of the message to be sent * @param associationId association id of the associated device * @param message message to be sent * @hide */ @Deprecated public void onMessageDispatchedFromSystem(int messageId, int associationId, @NonNull byte[] message) { Log.w(LOG_TAG, "Replaced by attachSystemDataTransport"); // do nothing. Companion apps can override this function for system to send messages. } Loading @@ -185,22 +188,14 @@ public abstract class CompanionDeviceService extends Service { * @param messageId id of the message * @param associationId id of the associated device * @param message message received from the associated device * @hide */ @Deprecated @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void dispatchMessageToSystem(int messageId, int associationId, @NonNull byte[] message) throws DeviceNotAssociatedException { if (getBaseContext() == null) { Log.e(LOG_TAG, "Dispatch failed. Start your service before calling this method."); return; } CompanionDeviceManager companionDeviceManager = getSystemService(CompanionDeviceManager.class); if (companionDeviceManager != null) { companionDeviceManager.dispatchMessage(messageId, associationId, message); } else { Log.e(LOG_TAG, "CompanionDeviceManager is null. Can't dispatch messages."); } Log.w(LOG_TAG, "Replaced by attachSystemDataTransport"); } /** Loading @@ -223,10 +218,13 @@ public abstract class CompanionDeviceService extends Service { * device * @hide */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void attachSystemDataTransport(int associationId, @NonNull InputStream in, @NonNull OutputStream out) throws DeviceNotAssociatedException { getSystemService(CompanionDeviceManager.class) .attachSystemDataTransport(associationId, in, out); .attachSystemDataTransport(associationId, Objects.requireNonNull(in), Objects.requireNonNull(out)); } /** Loading @@ -236,6 +234,7 @@ public abstract class CompanionDeviceService extends Service { * @param associationId id of the associated device * @hide */ @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void detachSystemDataTransport(int associationId) throws DeviceNotAssociatedException { getSystemService(CompanionDeviceManager.class) Loading Loading @@ -299,13 +298,5 @@ public abstract class CompanionDeviceService extends Service { public void onDeviceDisappeared(AssociationInfo associationInfo) { mMainHandler.postAtFrontOfQueue(() -> mService.onDeviceDisappeared(associationInfo)); } @Override public void onMessageDispatchedFromSystem(int messageId, int associationId, @NonNull byte[] message) { mMainHandler.postAtFrontOfQueue( () -> mService.onMessageDispatchedFromSystem(messageId, associationId, message)); } } }
core/java/android/companion/CompanionException.java +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ package android.companion; import android.annotation.NonNull; /** * {@code CompanionException} can be thrown during the companion system data transfer process. * {@code CompanionException} can be thrown during the companion system data * transfer process. * * @hide */ public class CompanionException extends RuntimeException { /** @hide */ Loading
core/java/android/companion/ICompanionDeviceManager.aidl +0 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,6 @@ interface ICompanionDeviceManager { void createAssociation(in String packageName, in String macAddress, int userId, in byte[] certificate); void dispatchMessage(int messageId, int associationId, in byte[] message); void addOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId); void removeOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId); Loading