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

Commit d096e0e1 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Automerger Merge Worker
Browse files

Merge "Add AR intent to ingest exempt attribution tags" into sc-dev am: ae4d48eb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14128312

Change-Id: Ie914b0c20790149ed3abbb6a4ecf25cb123d6b09
parents c855d65d ae4d48eb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2344,6 +2344,7 @@ package android.content {
  }
  public class Intent implements java.lang.Cloneable android.os.Parcelable {
    field public static final String ACTION_ACTIVITY_RECOGNIZER = "android.intent.action.ACTIVITY_RECOGNIZER";
    field public static final String ACTION_BATTERY_LEVEL_CHANGED = "android.intent.action.BATTERY_LEVEL_CHANGED";
    field public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
    field public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
+15 −0
Original line number Diff line number Diff line
@@ -848,6 +848,21 @@ public class Intent implements Parcelable, Cloneable {
    public static final String ACTION_SHOW_APP_INFO
            = "android.intent.action.SHOW_APP_INFO";

    /**
     * Activity Action: Placeholder that the component handling it can do activity
     * recognition. Can be placed on a service. Only one service per package is
     * supported.
     *
     * <p>Input: Nothing.</p>
     * <p>Output: Nothing </p>
     *
     * @hide
     */
    @SystemApi
    @SdkConstant(SdkConstantType.SERVICE_ACTION)
    public static final String ACTION_ACTIVITY_RECOGNIZER =
            "android.intent.action.ACTIVITY_RECOGNIZER";

    /**
     * Represents a shortcut/live folder icon resource.
     *
+26 −19
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.location.LocationManagerInternal;
import android.net.Uri;
import android.os.IBinder;
@@ -36,6 +36,7 @@ import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
@@ -237,26 +238,32 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
    }

    private void updateActivityRecognizerTags(@NonNull String activityRecognizer) {
        try {
            final ApplicationInfo recognizerAppInfo = mContext.getPackageManager()
                    .getApplicationInfoAsUser(activityRecognizer, PackageManager.GET_META_DATA,
                            UserHandle.USER_SYSTEM);
            if (recognizerAppInfo.metaData == null) {
        final int flags = PackageManager.GET_SERVICES
                | PackageManager.GET_META_DATA
                | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
                | PackageManager.MATCH_DIRECT_BOOT_AWARE
                | PackageManager.MATCH_DIRECT_BOOT_UNAWARE;

        final Intent intent = new Intent(Intent.ACTION_ACTIVITY_RECOGNIZER);
        intent.setPackage(activityRecognizer);
        final ResolveInfo resolvedService = mContext.getPackageManager()
                .resolveServiceAsUser(intent, flags, UserHandle.USER_SYSTEM);
        if (resolvedService == null || resolvedService.serviceInfo == null) {
            Log.w(LOG_TAG, "Service recognizer doesn't handle "
                    + Intent.ACTION_ACTIVITY_RECOGNIZER +  ", ignoring!");
            return;
        }
            final String tagsList = recognizerAppInfo.metaData.getString(ACTIVITY_RECOGNITION_TAGS);
        final String tagsList = resolvedService.serviceInfo.metaData.getString(
                ACTIVITY_RECOGNITION_TAGS);
        if (tagsList != null) {
            final String[] tags = tagsList.split(ACTIVITY_RECOGNITION_TAGS_SEPARATOR);
            synchronized (mLock) {
                    updateAllowListedTagsForPackageLocked(recognizerAppInfo.uid,
                            recognizerAppInfo.packageName, new ArraySet<>(tags),
                updateAllowListedTagsForPackageLocked(
                        resolvedService.serviceInfo.applicationInfo.uid,
                        resolvedService.serviceInfo.packageName, new ArraySet<>(tags),
                        mActivityRecognitionTags);
            }
        }
        } catch (PackageManager.NameNotFoundException e) {
            Slog.wtf(LOG_TAG, "Missing " + RoleManager.ROLE_SYSTEM_ACTIVITY_RECOGNIZER
                    + " role holder package " + activityRecognizer);
        }
    }

    private static void updateAllowListedTagsForPackageLocked(int uid, String packageName,