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

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

Merge "Adds Contextual Search calling package name." into main

parents f87544e6 1fc2a17b
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -313,7 +313,8 @@ public class ContextualSearchManagerService extends SystemService {
            android.Manifest.permission.CREATE_USERS,
            android.Manifest.permission.CREATE_USERS,
            android.Manifest.permission.QUERY_USERS
            android.Manifest.permission.QUERY_USERS
    })
    })
    private Intent getContextualSearchIntent(int entrypoint, int userId, CallbackToken mToken) {
    private Intent getContextualSearchIntent(int entrypoint, int userId, String callingPackage,
            CallbackToken mToken) {
        final Intent launchIntent = getResolvedLaunchIntent(userId);
        final Intent launchIntent = getResolvedLaunchIntent(userId);
        if (launchIntent == null) {
        if (launchIntent == null) {
            if (DEBUG) Log.w(TAG, "Failed getContextualSearchIntent: launchIntent is null");
            if (DEBUG) Log.w(TAG, "Failed getContextualSearchIntent: launchIntent is null");
@@ -332,6 +333,9 @@ public class ContextualSearchManagerService extends SystemService {
            launchIntent.putExtra(ContextualSearchManager.EXTRA_IS_AUDIO_PLAYING,
            launchIntent.putExtra(ContextualSearchManager.EXTRA_IS_AUDIO_PLAYING,
                    mAudioManager.isMusicActive());
                    mAudioManager.isMusicActive());
        }
        }
        if (Flags.selfInvocation()) {
            launchIntent.putExtra(Intent.EXTRA_CALLING_PACKAGE, callingPackage);
        }
        boolean isAssistDataAllowed = mAtmInternal.isAssistDataAllowed();
        boolean isAssistDataAllowed = mAtmInternal.isAssistDataAllowed();
        final List<ActivityAssistInfo> records = mAtmInternal.getTopVisibleActivities();
        final List<ActivityAssistInfo> records = mAtmInternal.getTopVisibleActivities();
        final List<IBinder> activityTokens = new ArrayList<>(records.size());
        final List<IBinder> activityTokens = new ArrayList<>(records.size());
@@ -500,6 +504,7 @@ public class ContextualSearchManagerService extends SystemService {
        }
        }


        private void startContextualSearchInternal(int entrypoint) {
        private void startContextualSearchInternal(int entrypoint) {
            final String callingPackage = mPackageManager.getNameForUid(Binder.getCallingUid());
            final int callingUserId = Binder.getCallingUserHandle().getIdentifier();
            final int callingUserId = Binder.getCallingUserHandle().getIdentifier();
            mAssistDataRequester.cancel();
            mAssistDataRequester.cancel();
            // Creates a new CallbackToken at mToken and an expiration handler.
            // Creates a new CallbackToken at mToken and an expiration handler.
@@ -508,7 +513,8 @@ public class ContextualSearchManagerService extends SystemService {
            // server has READ_FRAME_BUFFER permission to get the screenshot and because only
            // server has READ_FRAME_BUFFER permission to get the screenshot and because only
            // the system server can invoke non-exported activities.
            // the system server can invoke non-exported activities.
            Binder.withCleanCallingIdentity(() -> {
            Binder.withCleanCallingIdentity(() -> {
                Intent launchIntent = getContextualSearchIntent(entrypoint, callingUserId, mToken);
                Intent launchIntent = getContextualSearchIntent(entrypoint, callingUserId,
                            callingPackage, mToken);
                if (launchIntent != null) {
                if (launchIntent != null) {
                    int result = invokeContextualSearchIntent(launchIntent, callingUserId);
                    int result = invokeContextualSearchIntent(launchIntent, callingUserId);
                    if (DEBUG) {
                    if (DEBUG) {