Loading core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -9433,6 +9433,7 @@ package android.app.blob { package android.app.contextualsearch { @FlaggedApi("android.app.contextualsearch.flags.self_invocation") public final class ContextualSearchManager { method @FlaggedApi("android.app.contextualsearch.flags.self_invocation") public boolean isContextualSearchAvailable(); method @FlaggedApi("android.app.contextualsearch.flags.self_invocation") public void startContextualSearch(); } core/java/android/app/contextualsearch/ContextualSearchManager.java +32 −2 Original line number Diff line number Diff line Loading @@ -253,6 +253,26 @@ public final class ContextualSearchManager { mService = IContextualSearchManager.Stub.asInterface(b); } /** * Used to check whether contextual search is available on the device. This method should be * called before calling {@link #startContextualSearch()} or adding any UI related to it to * ensure that the device is configured to support contextual search. * * @see #startContextualSearch() * @return true if contextual search is available on the device, false otherwise. */ @FlaggedApi(Flags.FLAG_SELF_INVOCATION) public boolean isContextualSearchAvailable() { if (DEBUG) Log.d(TAG, "isContextualSearchAvailable"); try { return mService.isContextualSearchAvailable(); } catch (RemoteException e) { if (DEBUG) Log.e(TAG, "Failed to determine isContextualSearchAvailable", e); e.rethrowFromSystemServer(); } return false; } /** * Used to start contextual search for a given system entrypoint. * <p> Loading @@ -267,6 +287,8 @@ public final class ContextualSearchManager { * </ul> * </p> * * <p>This method will fail silently if Contextual Search is not available on the device. * * @param entrypoint the invocation entrypoint * * @hide Loading @@ -287,10 +309,18 @@ public final class ContextualSearchManager { } /** * Used to start contextual search from within an app. * Used to start Contextual Search from within an app. This will send a screenshot to the * Contextual Search app designated by the device manufacturer. The user can then select content * on the screenshot to get a search result or take an action such as calling a phone number or * translating the text. * * <p>Prior to calling this method or showing any UI related to it, you should verify that * Contextual Search is available on the device by using {@link #isContextualSearchAvailable()}. * Otherwise, this method will fail silently. * * <p>System apps should use the available System APIs rather than this method. * <p>This method should only be called from an app that has a foreground Activity. * * @see #isContextualSearchAvailable() * @throws SecurityException if the caller does not have a foreground Activity. */ @FlaggedApi(Flags.FLAG_SELF_INVOCATION) Loading core/java/android/app/contextualsearch/IContextualSearchManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import android.app.contextualsearch.IContextualSearchCallback; * @hide */ interface IContextualSearchManager { boolean isContextualSearchAvailable(); void startContextualSearchForForegroundApp(); oneway void startContextualSearch(int entrypoint); oneway void getContextualSearchState(in IBinder token, in IContextualSearchCallback callback); Loading services/contextualsearch/java/com/android/server/contextualsearch/ContextualSearchManagerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.Manifest.permission.ACCESS_CONTEXTUAL_SEARCH; import static android.app.AppOpsManager.OP_ASSIST_SCREENSHOT; import static android.app.AppOpsManager.OP_ASSIST_STRUCTURE; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.contextualsearch.ContextualSearchManager.FEATURE_CONTEXTUAL_SEARCH; import static android.content.Context.CONTEXTUAL_SEARCH_SERVICE; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; Loading Loading @@ -515,6 +516,13 @@ public class ContextualSearchManagerService extends SystemService { } } @Override public boolean isContextualSearchAvailable() { return mContext.getPackageManager().hasSystemFeature(FEATURE_CONTEXTUAL_SEARCH) && getResolvedLaunchIntent(Binder.getCallingUserHandle().getIdentifier()) != null; } @Override public void startContextualSearchForForegroundApp() { synchronized (this) { Loading Loading
core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -9433,6 +9433,7 @@ package android.app.blob { package android.app.contextualsearch { @FlaggedApi("android.app.contextualsearch.flags.self_invocation") public final class ContextualSearchManager { method @FlaggedApi("android.app.contextualsearch.flags.self_invocation") public boolean isContextualSearchAvailable(); method @FlaggedApi("android.app.contextualsearch.flags.self_invocation") public void startContextualSearch(); }
core/java/android/app/contextualsearch/ContextualSearchManager.java +32 −2 Original line number Diff line number Diff line Loading @@ -253,6 +253,26 @@ public final class ContextualSearchManager { mService = IContextualSearchManager.Stub.asInterface(b); } /** * Used to check whether contextual search is available on the device. This method should be * called before calling {@link #startContextualSearch()} or adding any UI related to it to * ensure that the device is configured to support contextual search. * * @see #startContextualSearch() * @return true if contextual search is available on the device, false otherwise. */ @FlaggedApi(Flags.FLAG_SELF_INVOCATION) public boolean isContextualSearchAvailable() { if (DEBUG) Log.d(TAG, "isContextualSearchAvailable"); try { return mService.isContextualSearchAvailable(); } catch (RemoteException e) { if (DEBUG) Log.e(TAG, "Failed to determine isContextualSearchAvailable", e); e.rethrowFromSystemServer(); } return false; } /** * Used to start contextual search for a given system entrypoint. * <p> Loading @@ -267,6 +287,8 @@ public final class ContextualSearchManager { * </ul> * </p> * * <p>This method will fail silently if Contextual Search is not available on the device. * * @param entrypoint the invocation entrypoint * * @hide Loading @@ -287,10 +309,18 @@ public final class ContextualSearchManager { } /** * Used to start contextual search from within an app. * Used to start Contextual Search from within an app. This will send a screenshot to the * Contextual Search app designated by the device manufacturer. The user can then select content * on the screenshot to get a search result or take an action such as calling a phone number or * translating the text. * * <p>Prior to calling this method or showing any UI related to it, you should verify that * Contextual Search is available on the device by using {@link #isContextualSearchAvailable()}. * Otherwise, this method will fail silently. * * <p>System apps should use the available System APIs rather than this method. * <p>This method should only be called from an app that has a foreground Activity. * * @see #isContextualSearchAvailable() * @throws SecurityException if the caller does not have a foreground Activity. */ @FlaggedApi(Flags.FLAG_SELF_INVOCATION) Loading
core/java/android/app/contextualsearch/IContextualSearchManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import android.app.contextualsearch.IContextualSearchCallback; * @hide */ interface IContextualSearchManager { boolean isContextualSearchAvailable(); void startContextualSearchForForegroundApp(); oneway void startContextualSearch(int entrypoint); oneway void getContextualSearchState(in IBinder token, in IContextualSearchCallback callback); Loading
services/contextualsearch/java/com/android/server/contextualsearch/ContextualSearchManagerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.Manifest.permission.ACCESS_CONTEXTUAL_SEARCH; import static android.app.AppOpsManager.OP_ASSIST_SCREENSHOT; import static android.app.AppOpsManager.OP_ASSIST_STRUCTURE; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.contextualsearch.ContextualSearchManager.FEATURE_CONTEXTUAL_SEARCH; import static android.content.Context.CONTEXTUAL_SEARCH_SERVICE; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; Loading Loading @@ -515,6 +516,13 @@ public class ContextualSearchManagerService extends SystemService { } } @Override public boolean isContextualSearchAvailable() { return mContext.getPackageManager().hasSystemFeature(FEATURE_CONTEXTUAL_SEARCH) && getResolvedLaunchIntent(Binder.getCallingUserHandle().getIdentifier()) != null; } @Override public void startContextualSearchForForegroundApp() { synchronized (this) { Loading