From 7d26552f23aa25bcee14f45afc090accf447f754 Mon Sep 17 00:00:00 2001 From: Shashwat Razdan Date: Tue, 1 Oct 2024 15:47:01 -0700 Subject: AppFunctionRuntimeMetadata enabled changes Replacing the AppFunctionRuntimeMetadata.getEnabled() and the corresponding Builder.setEnabled() signature from a tristate boolean to an integer. Flag: android.app.appfunctions.flags.enable_app_function_manager Test: Pre-existing tests (like setAppFunctionEnabled_functionDefaultEnabled) already test this change. Bug: 369683073 Change-Id: I6c62e8e4f802d47ee2a648ee334ec44616f3ee0a --- .../AppFunctionManagerServiceImpl.java | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'services/appfunctions/java') diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java index ab9cc20763a8..517d3afbc2d5 100644 --- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java @@ -16,8 +16,6 @@ package com.android.server.appfunctions; -import static android.app.appfunctions.AppFunctionManager.APP_FUNCTION_STATE_DISABLED; -import static android.app.appfunctions.AppFunctionManager.APP_FUNCTION_STATE_ENABLED; import static android.app.appfunctions.AppFunctionRuntimeMetadata.APP_FUNCTION_RUNTIME_METADATA_DB; import static android.app.appfunctions.AppFunctionRuntimeMetadata.APP_FUNCTION_RUNTIME_NAMESPACE; @@ -363,26 +361,14 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { callingPackage, functionIdentifier, runtimeMetadataSearchSession)); - AppFunctionRuntimeMetadata.Builder newMetadata = - new AppFunctionRuntimeMetadata.Builder(existingMetadata); - switch (enabledState) { - case AppFunctionManager.APP_FUNCTION_STATE_DEFAULT -> { - newMetadata.setEnabled(null); - } - case APP_FUNCTION_STATE_ENABLED -> { - newMetadata.setEnabled(true); - } - case APP_FUNCTION_STATE_DISABLED -> { - newMetadata.setEnabled(false); - } - default -> - throw new IllegalArgumentException("Value of EnabledState is unsupported."); - } + AppFunctionRuntimeMetadata newMetadata = + new AppFunctionRuntimeMetadata.Builder(existingMetadata) + .setEnabled(enabledState).build(); AppSearchBatchResult putDocumentBatchResult = runtimeMetadataSearchSession .put( new PutDocumentsRequest.Builder() - .addGenericDocuments(newMetadata.build()) + .addGenericDocuments(newMetadata) .build()) .get(); if (!putDocumentBatchResult.isSuccess()) { -- cgit v1.2.3-59-g8ed1b