Merge "Add AR intent to ingest exempt attribution tags" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ae4d48ebec
@@ -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";
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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,25 +238,31 @@ 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) {
|
||||
return;
|
||||
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 = resolvedService.serviceInfo.metaData.getString(
|
||||
ACTIVITY_RECOGNITION_TAGS);
|
||||
if (tagsList != null) {
|
||||
final String[] tags = tagsList.split(ACTIVITY_RECOGNITION_TAGS_SEPARATOR);
|
||||
synchronized (mLock) {
|
||||
updateAllowListedTagsForPackageLocked(
|
||||
resolvedService.serviceInfo.applicationInfo.uid,
|
||||
resolvedService.serviceInfo.packageName, new ArraySet<>(tags),
|
||||
mActivityRecognitionTags);
|
||||
}
|
||||
final String tagsList = recognizerAppInfo.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),
|
||||
mActivityRecognitionTags);
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Slog.wtf(LOG_TAG, "Missing " + RoleManager.ROLE_SYSTEM_ACTIVITY_RECOGNIZER
|
||||
+ " role holder package " + activityRecognizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user