diff options
| author | 2024-10-23 19:39:26 +0000 | |
|---|---|---|
| committer | 2024-10-23 19:39:26 +0000 | |
| commit | a51eb6c7228143c3526807d8c40ca637249d1f15 (patch) | |
| tree | 039b21626d0487246487791bead6fcb2aef41ace | |
| parent | 8c3891147e08c2150c4f7e6142ba4b58f152988f (diff) | |
| parent | 1d3827d255e9e1e14ccdbbec8d1bca301fb47a2b (diff) | |
Merge "[Service] Cleanup CHRE 24Q3 flags" into main
12 files changed, 58 insertions, 93 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index f04df2f5e3fb..41732fe6ef63 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -6054,7 +6054,7 @@ package android.hardware.location { method @NonNull public android.hardware.location.ContextHubInfo getAttachedHub(); method @IntRange(from=0, to=65535) public int getId(); method @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public int sendMessageToNanoApp(@NonNull android.hardware.location.NanoAppMessage); - method @FlaggedApi("android.chre.flags.reliable_message") @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public android.hardware.location.ContextHubTransaction<java.lang.Void> sendReliableMessageToNanoApp(@NonNull android.hardware.location.NanoAppMessage); + method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public android.hardware.location.ContextHubTransaction<java.lang.Void> sendReliableMessageToNanoApp(@NonNull android.hardware.location.NanoAppMessage); } public class ContextHubClientCallback { @@ -6090,7 +6090,7 @@ package android.hardware.location { method public String getToolchain(); method public int getToolchainVersion(); method public String getVendor(); - method @FlaggedApi("android.chre.flags.reliable_message") public boolean supportsReliableMessages(); + method public boolean supportsReliableMessages(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.hardware.location.ContextHubInfo> CREATOR; } @@ -6174,7 +6174,7 @@ package android.hardware.location { field public static final int RESULT_FAILED_BAD_PARAMS = 2; // 0x2 field public static final int RESULT_FAILED_BUSY = 4; // 0x4 field public static final int RESULT_FAILED_HAL_UNAVAILABLE = 8; // 0x8 - field @FlaggedApi("android.chre.flags.reliable_message") public static final int RESULT_FAILED_NOT_SUPPORTED = 9; // 0x9 + field public static final int RESULT_FAILED_NOT_SUPPORTED = 9; // 0x9 field public static final int RESULT_FAILED_SERVICE_INTERNAL_FAILURE = 7; // 0x7 field public static final int RESULT_FAILED_TIMEOUT = 6; // 0x6 field public static final int RESULT_FAILED_UNINITIALIZED = 3; // 0x3 @@ -6184,7 +6184,7 @@ package android.hardware.location { field public static final int TYPE_ENABLE_NANOAPP = 2; // 0x2 field public static final int TYPE_LOAD_NANOAPP = 0; // 0x0 field public static final int TYPE_QUERY_NANOAPPS = 4; // 0x4 - field @FlaggedApi("android.chre.flags.reliable_message") public static final int TYPE_RELIABLE_MESSAGE = 5; // 0x5 + field public static final int TYPE_RELIABLE_MESSAGE = 5; // 0x5 field public static final int TYPE_UNLOAD_NANOAPP = 1; // 0x1 } @@ -6367,15 +6367,15 @@ package android.hardware.location { public final class NanoAppMessage implements android.os.Parcelable { method public static android.hardware.location.NanoAppMessage createMessageFromNanoApp(long, int, byte[], boolean); - method @FlaggedApi("android.chre.flags.reliable_message") @NonNull public static android.hardware.location.NanoAppMessage createMessageFromNanoApp(long, int, @NonNull byte[], boolean, boolean, int); + method @NonNull public static android.hardware.location.NanoAppMessage createMessageFromNanoApp(long, int, @NonNull byte[], boolean, boolean, int); method public static android.hardware.location.NanoAppMessage createMessageToNanoApp(long, int, byte[]); method public int describeContents(); method public byte[] getMessageBody(); - method @FlaggedApi("android.chre.flags.reliable_message") public int getMessageSequenceNumber(); + method public int getMessageSequenceNumber(); method public int getMessageType(); method public long getNanoAppId(); method public boolean isBroadcastMessage(); - method @FlaggedApi("android.chre.flags.reliable_message") public boolean isReliable(); + method public boolean isReliable(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.hardware.location.NanoAppMessage> CREATOR; } diff --git a/core/java/android/hardware/location/ContextHubClient.java b/core/java/android/hardware/location/ContextHubClient.java index 953086de2d15..538e2fb7fe3e 100644 --- a/core/java/android/hardware/location/ContextHubClient.java +++ b/core/java/android/hardware/location/ContextHubClient.java @@ -194,23 +194,20 @@ public class ContextHubClient implements Closeable { /** * Sends a reliable message to a nanoapp. * - * This method is similar to {@link ContextHubClient#sendMessageToNanoApp} with the + * <p>This method is similar to {@link ContextHubClient#sendMessageToNanoApp} with the * difference that it expects the message to be acknowledged by CHRE. * - * The transaction succeeds after we received an ACK from CHRE without error. - * In all other cases the transaction will fail. + * <p>The transaction succeeds after we received an ACK from CHRE without error. In all other + * cases the transaction will fail. */ @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) @NonNull - @FlaggedApi(Flags.FLAG_RELIABLE_MESSAGE) public ContextHubTransaction<Void> sendReliableMessageToNanoApp( @NonNull NanoAppMessage message) { ContextHubTransaction<Void> transaction = new ContextHubTransaction<>(ContextHubTransaction.TYPE_RELIABLE_MESSAGE); - if (!Flags.reliableMessageImplementation() || - !mAttachedHub.supportsReliableMessages() || - message.isBroadcastMessage()) { + if (!mAttachedHub.supportsReliableMessages() || message.isBroadcastMessage()) { transaction.setResponse(new ContextHubTransaction.Response<Void>( ContextHubTransaction.RESULT_FAILED_NOT_SUPPORTED, null)); return transaction; diff --git a/core/java/android/hardware/location/ContextHubInfo.java b/core/java/android/hardware/location/ContextHubInfo.java index d9349701bf7d..858ec23ebed8 100644 --- a/core/java/android/hardware/location/ContextHubInfo.java +++ b/core/java/android/hardware/location/ContextHubInfo.java @@ -99,8 +99,7 @@ public class ContextHubInfo implements Parcelable { mSleepPowerDrawMw = 0; mPeakPowerDrawMw = 0; mMaxPacketLengthBytes = contextHub.maxSupportedMessageLengthBytes; - mSupportsReliableMessages = Flags.reliableMessageImplementation() - && contextHub.supportsReliableMessages; + mSupportsReliableMessages = contextHub.supportsReliableMessages; mChrePlatformId = contextHub.chrePlatformId; mChreApiMajorVersion = contextHub.chreApiMajorVersion; mChreApiMinorVersion = contextHub.chreApiMinorVersion; @@ -124,7 +123,6 @@ public class ContextHubInfo implements Parcelable { * * @return whether reliable messages are supported. */ - @FlaggedApi(Flags.FLAG_RELIABLE_MESSAGE) public boolean supportsReliableMessages() { return mSupportsReliableMessages; } @@ -364,22 +362,22 @@ public class ContextHubInfo implements Parcelable { boolean isEqual = false; if (object instanceof ContextHubInfo) { ContextHubInfo other = (ContextHubInfo) object; - isEqual = (other.getId() == mId) - && other.getName().equals(mName) - && other.getVendor().equals(mVendor) - && other.getToolchain().equals(mToolchain) - && (other.getToolchainVersion() == mToolchainVersion) - && (other.getStaticSwVersion() == getStaticSwVersion()) - && (other.getChrePlatformId() == mChrePlatformId) - && (other.getPeakMips() == mPeakMips) - && (other.getStoppedPowerDrawMw() == mStoppedPowerDrawMw) - && (other.getSleepPowerDrawMw() == mSleepPowerDrawMw) - && (other.getPeakPowerDrawMw() == mPeakPowerDrawMw) - && (other.getMaxPacketLengthBytes() == mMaxPacketLengthBytes) - && (!Flags.reliableMessage() - || (other.supportsReliableMessages() == mSupportsReliableMessages)) - && Arrays.equals(other.getSupportedSensors(), mSupportedSensors) - && Arrays.equals(other.getMemoryRegions(), mMemoryRegions); + isEqual = + (other.getId() == mId) + && other.getName().equals(mName) + && other.getVendor().equals(mVendor) + && other.getToolchain().equals(mToolchain) + && (other.getToolchainVersion() == mToolchainVersion) + && (other.getStaticSwVersion() == getStaticSwVersion()) + && (other.getChrePlatformId() == mChrePlatformId) + && (other.getPeakMips() == mPeakMips) + && (other.getStoppedPowerDrawMw() == mStoppedPowerDrawMw) + && (other.getSleepPowerDrawMw() == mSleepPowerDrawMw) + && (other.getPeakPowerDrawMw() == mPeakPowerDrawMw) + && (other.getMaxPacketLengthBytes() == mMaxPacketLengthBytes) + && (other.supportsReliableMessages() == mSupportsReliableMessages) + && Arrays.equals(other.getSupportedSensors(), mSupportedSensors) + && Arrays.equals(other.getMemoryRegions(), mMemoryRegions); } return isEqual; diff --git a/core/java/android/hardware/location/ContextHubManager.java b/core/java/android/hardware/location/ContextHubManager.java index 218b02315fc8..6284e7061b88 100644 --- a/core/java/android/hardware/location/ContextHubManager.java +++ b/core/java/android/hardware/location/ContextHubManager.java @@ -750,9 +750,7 @@ public final class ContextHubManager { executor.execute( () -> { callback.onMessageFromNanoApp(client, message); - if (Flags.reliableMessage() - && Flags.reliableMessageImplementation() - && message.isReliable()) { + if (message.isReliable()) { client.reliableMessageCallbackFinished( message.getMessageSequenceNumber(), ErrorCode.OK); } else { diff --git a/core/java/android/hardware/location/ContextHubTransaction.java b/core/java/android/hardware/location/ContextHubTransaction.java index 4060f4c1b462..bd87b5cb6d54 100644 --- a/core/java/android/hardware/location/ContextHubTransaction.java +++ b/core/java/android/hardware/location/ContextHubTransaction.java @@ -69,7 +69,6 @@ public class ContextHubTransaction<T> { public static final int TYPE_ENABLE_NANOAPP = 2; public static final int TYPE_DISABLE_NANOAPP = 3; public static final int TYPE_QUERY_NANOAPPS = 4; - @FlaggedApi(Flags.FLAG_RELIABLE_MESSAGE) public static final int TYPE_RELIABLE_MESSAGE = 5; /** @@ -123,10 +122,8 @@ public class ContextHubTransaction<T> { * Failure mode when the Context Hub HAL was not available. */ public static final int RESULT_FAILED_HAL_UNAVAILABLE = 8; - /** - * Failure mode when the operation is not supported. - */ - @FlaggedApi(Flags.FLAG_RELIABLE_MESSAGE) + + /** Failure mode when the operation is not supported. */ public static final int RESULT_FAILED_NOT_SUPPORTED = 9; /** @@ -232,11 +229,8 @@ public class ContextHubTransaction<T> { return upperCase ? "Disable" : "disable"; case ContextHubTransaction.TYPE_QUERY_NANOAPPS: return upperCase ? "Query" : "query"; - case ContextHubTransaction.TYPE_RELIABLE_MESSAGE: { - if (Flags.reliableMessage()) { - return upperCase ? "Reliable Message" : "reliable message"; - } - } + case ContextHubTransaction.TYPE_RELIABLE_MESSAGE: + return upperCase ? "Reliable Message" : "reliable message"; default: return upperCase ? "Unknown" : "unknown"; } diff --git a/core/java/android/hardware/location/NanoAppMessage.java b/core/java/android/hardware/location/NanoAppMessage.java index ec0adda38d10..32b9283ecd2e 100644 --- a/core/java/android/hardware/location/NanoAppMessage.java +++ b/core/java/android/hardware/location/NanoAppMessage.java @@ -97,7 +97,7 @@ public final class NanoAppMessage implements Parcelable { /** * Creates a NanoAppMessage object sent from a nanoapp. * - * This factory method is intended only to be used by the Context Hub Service when delivering + * <p>This factory method is intended only to be used by the Context Hub Service when delivering * messages from a nanoapp to clients. * * @param sourceNanoAppId the ID of the nanoapp that the message was sent from @@ -106,12 +106,14 @@ public final class NanoAppMessage implements Parcelable { * @param broadcasted {@code true} if the message was broadcasted, {@code false} otherwise * @param isReliable if the NanoAppMessage is reliable * @param messageSequenceNumber the message sequence number of the NanoAppMessage - * * @return the NanoAppMessage object */ - @FlaggedApi(Flags.FLAG_RELIABLE_MESSAGE) - public static @NonNull NanoAppMessage createMessageFromNanoApp(long sourceNanoAppId, - int messageType, @NonNull byte[] messageBody, boolean broadcasted, boolean isReliable, + public static @NonNull NanoAppMessage createMessageFromNanoApp( + long sourceNanoAppId, + int messageType, + @NonNull byte[] messageBody, + boolean broadcasted, + boolean isReliable, int messageSequenceNumber) { return new NanoAppMessage(sourceNanoAppId, messageType, messageBody, broadcasted, isReliable, messageSequenceNumber); @@ -147,18 +149,18 @@ public final class NanoAppMessage implements Parcelable { /** * Returns if the message is reliable. The default value is {@code false} + * * @return {@code true} if the message is reliable, {@code false} otherwise */ - @FlaggedApi(Flags.FLAG_RELIABLE_MESSAGE) public boolean isReliable() { return mIsReliable; } /** * Returns the message sequence number. The default value is 0 + * * @return the message sequence number of the message */ - @FlaggedApi(Flags.FLAG_RELIABLE_MESSAGE) public int getMessageSequenceNumber() { return mMessageSequenceNumber; } diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java index 598901e33305..556cc03b3abd 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java @@ -500,7 +500,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub checkNanoappPermsAsync(); } - if (!Flags.reliableMessageImplementation() || transactionCallback == null) { + if (transactionCallback == null) { try { result = mContextHubProxy.sendMessageToContextHub(mHostEndPointId, mAttachedContextHubInfo.getId(), message); @@ -671,10 +671,8 @@ public class ContextHubClientBroker extends IContextHubClient.Stub .putExtra(ContextHubManager.EXTRA_MESSAGE, message); Consumer<Byte> onFinishedCallback = (Byte error) -> sendMessageDeliveryStatusToContextHub(message.getMessageSequenceNumber(), error); - return sendPendingIntent(supplier, nanoAppId, - Flags.reliableMessageImplementation() && message.isReliable() - ? onFinishedCallback - : null); + return sendPendingIntent( + supplier, nanoAppId, message.isReliable() ? onFinishedCallback : null); } /** @@ -1284,10 +1282,6 @@ public class ContextHubClientBroker extends IContextHubClient.Stub } private void sendMessageDeliveryStatusToContextHub(int messageSequenceNumber, byte errorCode) { - if (!Flags.reliableMessageImplementation()) { - return; - } - MessageDeliveryStatus status = new MessageDeliveryStatus(); status.messageSequenceNumber = messageSequenceNumber; status.errorCode = errorCode; diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubClientManager.java b/services/core/java/com/android/server/location/contexthub/ContextHubClientManager.java index 7285151ee598..0fdd0ae641df 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubClientManager.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubClientManager.java @@ -236,7 +236,7 @@ import java.util.function.Consumer; } if (message.isBroadcastMessage()) { - if (Flags.reliableMessageImplementation() && message.isReliable()) { + if (message.isReliable()) { Log.e(TAG, "Received reliable broadcast message from " + message.getNanoAppId()); return ErrorCode.PERMANENT_ERROR; } diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java b/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java index e1b1416169cd..53a02cd1b677 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java @@ -333,10 +333,6 @@ public class ContextHubEventLogger { */ public synchronized void logReliableMessageToNanoappStatus( int messageSequenceNumber, byte errorCode) { - if (!Flags.reliableMessage()) { - return; - } - for (NanoappMessageEvent event : mMessageToNanoappQueue) { if (event.message.isReliable() && event.message.getMessageSequenceNumber() diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubService.java b/services/core/java/com/android/server/location/contexthub/ContextHubService.java index ed69f7ad32f6..acc8f6634f5c 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubService.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubService.java @@ -228,9 +228,8 @@ public class ContextHubService extends IContextHubService.Stub { // Only process the message normally if not using test mode manager or if // the test mode manager call returned false as this indicates it did not // process the message. - boolean useTestModeManager = Flags.reliableMessageImplementation() - && Flags.reliableMessageTestModeBehavior() - && mIsTestModeEnabled.get(); + boolean useTestModeManager = + Flags.reliableMessageTestModeBehavior() && mIsTestModeEnabled.get(); if (!useTestModeManager || !mTestModeManager.handleNanoappMessage(() -> { handleClientMessageCallback(mContextHubId, hostEndpointId, @@ -945,8 +944,7 @@ public class ContextHubService extends IContextHubService.Stub { private void handleClientMessageCallback(int contextHubId, short hostEndpointId, NanoAppMessage message, List<String> nanoappPermissions, List<String> messagePermissions) { - if (!Flags.reliableMessageImplementation() - || !Flags.reliableMessageDuplicateDetectionService()) { + if (!Flags.reliableMessageDuplicateDetectionService()) { byte errorCode = mClientManager.onMessageFromNanoApp(contextHubId, hostEndpointId, message, nanoappPermissions, messagePermissions); if (message.isReliable() && errorCode != ErrorCode.OK) { @@ -1040,12 +1038,8 @@ public class ContextHubService extends IContextHubService.Stub { * @param messageSequenceNumber the message sequence number * @param errorCode the error code, one of the enum ErrorCode */ - private void sendMessageDeliveryStatusToContextHub(int contextHubId, - int messageSequenceNumber, byte errorCode) { - if (!Flags.reliableMessageImplementation()) { - return; - } - + private void sendMessageDeliveryStatusToContextHub( + int contextHubId, int messageSequenceNumber, byte errorCode) { MessageDeliveryStatus status = new MessageDeliveryStatus(); status.messageSequenceNumber = messageSequenceNumber; status.errorCode = errorCode; diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java index a8ad41853d34..5e9277ac0faf 100644 --- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java @@ -494,16 +494,11 @@ public abstract class IContextHubWrapper { } public void handleMessageDeliveryStatus( - char hostEndpointId, - MessageDeliveryStatus messageDeliveryStatus) { - if (Flags.reliableMessageImplementation()) { - mHandler.post(() -> { - mCallback.handleMessageDeliveryStatus(messageDeliveryStatus); - }); - } else { - Log.w(TAG, "handleMessageDeliveryStatus called when the " - + "reliableMessageImplementation flag is disabled"); - } + char hostEndpointId, MessageDeliveryStatus messageDeliveryStatus) { + mHandler.post( + () -> { + mCallback.handleMessageDeliveryStatus(messageDeliveryStatus); + }); } public byte[] getUuid() { @@ -682,9 +677,8 @@ public abstract class IContextHubWrapper { // Only process the message normally if not using test mode manager or if // the test mode manager call returned false as this indicates it did not // process the message. - boolean useTestModeManager = Flags.reliableMessageImplementation() - && Flags.reliableMessageTestModeBehavior() - && mIsTestModeEnabled.get(); + boolean useTestModeManager = + Flags.reliableMessageTestModeBehavior() && mIsTestModeEnabled.get(); if (!useTestModeManager || !mTestModeManager.sendMessageToContextHub( sendMessage, message)) { try { diff --git a/services/tests/servicestests/src/com/android/server/location/contexthub/ContextHubEventLoggerTest.java b/services/tests/servicestests/src/com/android/server/location/contexthub/ContextHubEventLoggerTest.java index 41cb6fd99d9b..e1dcc99d3851 100644 --- a/services/tests/servicestests/src/com/android/server/location/contexthub/ContextHubEventLoggerTest.java +++ b/services/tests/servicestests/src/com/android/server/location/contexthub/ContextHubEventLoggerTest.java @@ -128,8 +128,6 @@ public class ContextHubEventLoggerTest { } @Test - @EnableFlags({Flags.FLAG_RELIABLE_MESSAGE, - Flags.FLAG_RELIABLE_MESSAGE_IMPLEMENTATION}) public void testLogReliableMessageToNanoappStatus() { NanoAppMessage message1 = NanoAppMessage.createMessageToNanoApp(1, 0, new byte[] {0x00, 0x11, 0x22, 0x33}); |