Merge "Rename CDM receiveMessage to dispatchMessage"
This commit is contained in:
committed by
Android (Google) Code Review
commit
b049086aa5
@@ -9895,11 +9895,11 @@ 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 dispatchMessage(int, int, @NonNull byte[]);
|
||||
method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent);
|
||||
method @MainThread public abstract void onDeviceAppeared(@NonNull String);
|
||||
method @MainThread public abstract void onDeviceDisappeared(@NonNull String);
|
||||
method @MainThread public void onSendMessage(int, int, @NonNull byte[]);
|
||||
method @RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES) public final void receiveMessage(int, int, @NonNull byte[]);
|
||||
method @MainThread public void onDispatchMessage(int, int, @NonNull byte[]);
|
||||
field public static final String SERVICE_INTERFACE = "android.companion.CompanionDeviceService";
|
||||
}
|
||||
|
||||
|
||||
@@ -445,10 +445,7 @@ public final class CompanionDeviceManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch received message to system for processing.
|
||||
*
|
||||
* <p>Messages received from {@link CompanionDeviceService#onSendMessage}, which is implemented
|
||||
* on another device, need to be dispatched to system for processing.</p>
|
||||
* Dispatch a message to system for processing.
|
||||
*
|
||||
* <p>Calling app must declare uses-permission
|
||||
* {@link android.Manifest.permission#DELIVER_COMPANION_MESSAGES}</p>
|
||||
@@ -463,10 +460,10 @@ public final class CompanionDeviceManager {
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES)
|
||||
public void receiveMessage(int messageId, int associationId, @NonNull byte[] message)
|
||||
public void dispatchMessage(int messageId, int associationId, @NonNull byte[] message)
|
||||
throws DeviceNotAssociatedException {
|
||||
try {
|
||||
mService.receiveMessage(messageId, associationId, message);
|
||||
mService.dispatchMessage(messageId, associationId, message);
|
||||
} catch (RemoteException e) {
|
||||
ExceptionUtils.propagateIfInstanceOf(e.getCause(), DeviceNotAssociatedException.class);
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
@@ -88,20 +88,21 @@ public abstract class CompanionDeviceService extends Service {
|
||||
public abstract void onDeviceDisappeared(@NonNull String address);
|
||||
|
||||
/**
|
||||
* Called by system whenever the system tries to send a message to an associated device.
|
||||
* Called by system whenever the system dispatches a message to the app to send it to
|
||||
* an associated device.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@MainThread
|
||||
public void onSendMessage(int messageId, int associationId, @NonNull byte[] message) {
|
||||
public void onDispatchMessage(int messageId, int associationId, @NonNull byte[] message) {
|
||||
// do nothing. Companion apps can override this function for system to send messages.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when there's message received from an associated device, which needs to be dispatched
|
||||
* to system for processing.
|
||||
* App calls this method when there's a message received from an associated device,
|
||||
* which needs to be dispatched to system for processing.
|
||||
*
|
||||
* <p>Calling app must declare uses-permission
|
||||
* {@link android.Manifest.permission#DELIVER_COMPANION_MESSAGES}</p>
|
||||
@@ -111,10 +112,10 @@ public abstract class CompanionDeviceService extends Service {
|
||||
* @param message messaged received from the associated device
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.DELIVER_COMPANION_MESSAGES)
|
||||
public final void receiveMessage(int messageId, int associationId, @NonNull byte[] message) {
|
||||
public final void dispatchMessage(int messageId, int associationId, @NonNull byte[] message) {
|
||||
CompanionDeviceManager companionDeviceManager =
|
||||
getSystemService(CompanionDeviceManager.class);
|
||||
companionDeviceManager.receiveMessage(messageId, associationId, message);
|
||||
companionDeviceManager.dispatchMessage(messageId, associationId, message);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -144,16 +145,16 @@ public abstract class CompanionDeviceService extends Service {
|
||||
CompanionDeviceService.this, address));
|
||||
}
|
||||
|
||||
public void onSendMessage(int messageId, int associationId, @NonNull byte[] message) {
|
||||
public void onDispatchMessage(int messageId, int associationId, @NonNull byte[] message) {
|
||||
Handler.getMain().sendMessage(PooledLambda.obtainMessage(
|
||||
CompanionDeviceService::onSendMessage,
|
||||
CompanionDeviceService::onDispatchMessage,
|
||||
CompanionDeviceService.this, messageId, associationId, message));
|
||||
}
|
||||
|
||||
public final void receiveMessage(int messageId, int associationId,
|
||||
public final void dispatchMessage(int messageId, int associationId,
|
||||
@NonNull byte[] message) {
|
||||
Handler.getMain().sendMessage(PooledLambda.obtainMessage(
|
||||
CompanionDeviceService::receiveMessage,
|
||||
CompanionDeviceService::dispatchMessage,
|
||||
CompanionDeviceService.this, messageId, associationId, message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,5 +55,5 @@ interface ICompanionDeviceManager {
|
||||
void createAssociation(in String packageName, in String macAddress, int userId,
|
||||
in byte[] certificate);
|
||||
|
||||
void receiveMessage(in int messageId, in int associationId, in byte[] message);
|
||||
void dispatchMessage(in int messageId, in int associationId, in byte[] message);
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ package android.companion;
|
||||
oneway interface ICompanionDeviceService {
|
||||
void onDeviceAppeared(in String address);
|
||||
void onDeviceDisappeared(in String address);
|
||||
void onSendMessage(in int messageId, in int associationId, in byte[] message);
|
||||
void onDispatchMessage(in int messageId, in int associationId, in byte[] message);
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveMessage(int messageId, int associationId, byte[] message)
|
||||
public void dispatchMessage(int messageId, int associationId, byte[] message)
|
||||
throws RemoteException {
|
||||
//TODO: b/199427116
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user