From: jiayuzhou Date: Mon, 15 Apr 2019 20:36:06 +0000 (-0700) Subject: make onGetSupportedVoiceActions return @NonNull and return empty set by default X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5422f30c144777fa9b8c7f1c8ed7ef1a1ecc2925;p=android-x86%2Fframeworks-base.git make onGetSupportedVoiceActions return @NonNull and return empty set by default Test: make Fix: 124302147 Change-Id: Ie91184310a1709cd62cd7d89911beda5c4e2d513 --- diff --git a/api/current.txt b/api/current.txt index 3f28dfc69912..05c54f89614a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -41776,7 +41776,7 @@ package android.service.voice { method public int getDisabledShowContext(); method public static boolean isActiveService(android.content.Context, android.content.ComponentName); method public android.os.IBinder onBind(android.content.Intent); - method @Nullable public java.util.Set onGetSupportedVoiceActions(@NonNull java.util.Set); + method @NonNull public java.util.Set onGetSupportedVoiceActions(@NonNull java.util.Set); method public void onLaunchVoiceAssistFromKeyguard(); method public void onReady(); method public void onShutdown(); diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java index e3e63e539591..0de17ca3b960 100644 --- a/core/java/android/service/voice/VoiceInteractionService.java +++ b/core/java/android/service/voice/VoiceInteractionService.java @@ -17,7 +17,6 @@ package android.service.voice; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.SdkConstant; import android.annotation.UnsupportedAppUsage; import android.app.Service; @@ -41,6 +40,7 @@ import com.android.internal.util.function.pooled.PooledLambda; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Set; @@ -211,11 +211,11 @@ public class VoiceInteractionService extends Service { * * @param voiceActions A set of checked voice actions. * @return Returns a subset of checked voice actions. Additional voice actions in the - * returned set will be ignored. Returns null or empty set if no actions are supported. + * returned set will be ignored. Returns empty set if no actions are supported. */ - @Nullable + @NonNull public Set onGetSupportedVoiceActions(@NonNull Set voiceActions) { - return null; + return Collections.emptySet(); } @Override @@ -272,7 +272,7 @@ public class VoiceInteractionService extends Service { try { Set voiceActionsSet = new ArraySet<>(voiceActions); Set resultSet = onGetSupportedVoiceActions(voiceActionsSet); - callback.onComplete(resultSet == null ? null : new ArrayList<>(resultSet)); + callback.onComplete(new ArrayList<>(resultSet)); } catch (RemoteException e) { } }