Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26b7e030 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Added AudioManager.isMusicActive() to CSS" into main

parents a9fe2c0b 0c32cdf3
Loading
Loading
Loading
Loading
+32 −7
Original line number Diff line number Diff line
@@ -48,7 +48,9 @@ public final class ContextualSearchManager {

    /**
     * Key to get the entrypoint from the extras of the activity launched by contextual search.
     * Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     */
    public static final String EXTRA_ENTRYPOINT =
            "android.app.contextualsearch.extra.ENTRYPOINT";
@@ -56,14 +58,18 @@ public final class ContextualSearchManager {
    /**
     * Key to get the flag_secure value from the extras of the activity launched by contextual
     * search. The value will be true if flag_secure is found in any of the visible activities.
     * Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     */
    public static final String EXTRA_FLAG_SECURE_FOUND =
            "android.app.contextualsearch.extra.FLAG_SECURE_FOUND";

    /**
     * Key to get the screenshot from the extras of the activity launched by contextual search.
     * Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     */
    public static final String EXTRA_SCREENSHOT =
            "android.app.contextualsearch.extra.SCREENSHOT";
@@ -71,7 +77,9 @@ public final class ContextualSearchManager {
    /**
     * Key to check whether managed profile is visible from the extras of the activity launched by
     * contextual search. The value will be true if any one of the visible apps is managed.
     * Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     */
    public static final String EXTRA_IS_MANAGED_PROFILE_VISIBLE =
            "android.app.contextualsearch.extra.IS_MANAGED_PROFILE_VISIBLE";
@@ -79,7 +87,9 @@ public final class ContextualSearchManager {
    /**
     * Key to get the list of visible packages from the extras of the activity launched by
     * contextual search.
     * Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     */
    public static final String EXTRA_VISIBLE_PACKAGE_NAMES =
            "android.app.contextualsearch.extra.VISIBLE_PACKAGE_NAMES";
@@ -87,7 +97,9 @@ public final class ContextualSearchManager {
    /**
     * Key to get the time the user made the invocation request, based on
     * {@link SystemClock#uptimeMillis()}.
     * Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     *
     * TODO: un-hide in W
     *
@@ -99,10 +111,23 @@ public final class ContextualSearchManager {
    /**
     * Key to get the binder token from the extras of the activity launched by contextual search.
     * This token is needed to invoke {@link CallbackToken#getContextualSearchState} method.
     * Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     */
    public static final String EXTRA_TOKEN = "android.app.contextualsearch.extra.TOKEN";

    /**
     * Key to check whether audio is playing when contextual search is invoked.
     * Only supposed to be used with ACTION_LAUNCH_CONTEXTUAL_SEARCH.
     *
     * @see #ACTION_LAUNCH_CONTEXTUAL_SEARCH
     *
     * @hide
     */
    public static final String EXTRA_IS_AUDIO_PLAYING =
            "android.app.contextualsearch.extra.IS_AUDIO_PLAYING";

    /**
     * Intent action for contextual search invocation. The app providing the contextual search
     * experience must add this intent filter action to the activity it wants to be launched.
+8 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ flag {
  bug: "309689654"
  is_exported: true
}

flag {
  name: "enable_token_refresh"
  namespace: "machine_learning"
@@ -28,3 +29,10 @@ flag {
    description: "Identify live contextual search UI to exclude from contextual search screenshot."
    bug: "372510690"
}

flag {
    name: "include_audio_playing_status"
    namespace: "sysui_integrations"
    description: "Add audio playing status to the contextual search invocation intent."
    bug: "372935419"
}
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.content.Intent;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -102,6 +103,7 @@ public class ContextualSearchManagerService extends SystemService {
    private final PackageManagerInternal mPackageManager;
    private final WindowManagerInternal mWmInternal;
    private final DevicePolicyManagerInternal mDpmInternal;
    private final AudioManager mAudioManager;
    private final Object mLock = new Object();
    private final AssistDataRequester mAssistDataRequester;

@@ -163,6 +165,8 @@ public class ContextualSearchManagerService extends SystemService {
        mAtmInternal = Objects.requireNonNull(
                LocalServices.getService(ActivityTaskManagerInternal.class));
        mPackageManager = LocalServices.getService(PackageManagerInternal.class);
        mAudioManager = context.getSystemService(AudioManager.class);

        mWmInternal = Objects.requireNonNull(LocalServices.getService(WindowManagerInternal.class));
        mDpmInternal = LocalServices.getService(DevicePolicyManagerInternal.class);
        mAssistDataRequester = new AssistDataRequester(
@@ -306,6 +310,10 @@ public class ContextualSearchManagerService extends SystemService {
                SystemClock.uptimeMillis());
        launchIntent.putExtra(ContextualSearchManager.EXTRA_ENTRYPOINT, entrypoint);
        launchIntent.putExtra(ContextualSearchManager.EXTRA_TOKEN, mToken);
        if (Flags.includeAudioPlayingStatus()) {
            launchIntent.putExtra(ContextualSearchManager.EXTRA_IS_AUDIO_PLAYING,
                    mAudioManager.isMusicActive());
        }
        boolean isAssistDataAllowed = mAtmInternal.isAssistDataAllowed();
        final List<ActivityAssistInfo> records = mAtmInternal.getTopVisibleActivities();
        final List<IBinder> activityTokens = new ArrayList<>(records.size());