Merge "Switch auto-revoke manifest flag to a tri-state" into rvc-dev am: 2f54a864d5
Change-Id: If829d3cee8c03c4e18b1ba58e4f90a798c6d9d97
This commit is contained in:
@@ -278,7 +278,7 @@ package android {
|
||||
field public static final int activityCloseExitAnimation = 16842939; // 0x10100bb
|
||||
field public static final int activityOpenEnterAnimation = 16842936; // 0x10100b8
|
||||
field public static final int activityOpenExitAnimation = 16842937; // 0x10100b9
|
||||
field public static final int actor = 16844313; // 0x1010619
|
||||
field public static final int actor = 16844312; // 0x1010618
|
||||
field public static final int addPrintersActivity = 16843750; // 0x10103e6
|
||||
field public static final int addStatesFromChildren = 16842992; // 0x10100f0
|
||||
field public static final int adjustViewBounds = 16843038; // 0x101011e
|
||||
@@ -289,7 +289,6 @@ package android {
|
||||
field public static final int alignmentMode = 16843642; // 0x101037a
|
||||
field public static final int allContactsName = 16843468; // 0x10102cc
|
||||
field public static final int allowAudioPlaybackCapture = 16844289; // 0x1010601
|
||||
field public static final int allowAutoRevokePermissionsExemption = 16844309; // 0x1010615
|
||||
field public static final int allowBackup = 16843392; // 0x1010280
|
||||
field public static final int allowClearUserData = 16842757; // 0x1010005
|
||||
field public static final int allowEmbedded = 16843765; // 0x10103f5
|
||||
@@ -329,6 +328,7 @@ package android {
|
||||
field public static final int autoLink = 16842928; // 0x10100b0
|
||||
field public static final int autoMirrored = 16843754; // 0x10103ea
|
||||
field public static final int autoRemoveFromRecents = 16843847; // 0x1010447
|
||||
field public static final int autoRevokePermissions = 16844308; // 0x1010614
|
||||
field public static final int autoSizeMaxTextSize = 16844102; // 0x1010546
|
||||
field public static final int autoSizeMinTextSize = 16844088; // 0x1010538
|
||||
field public static final int autoSizePresetSizes = 16844087; // 0x1010537
|
||||
@@ -710,7 +710,7 @@ package android {
|
||||
field public static final int gravity = 16842927; // 0x10100af
|
||||
field public static final int gridViewStyle = 16842865; // 0x1010071
|
||||
field public static final int groupIndicator = 16843019; // 0x101010b
|
||||
field public static final int gwpAsanMode = 16844312; // 0x1010618
|
||||
field public static final int gwpAsanMode = 16844311; // 0x1010617
|
||||
field public static final int hand_hour = 16843011; // 0x1010103
|
||||
field public static final int hand_minute = 16843012; // 0x1010104
|
||||
field public static final int handle = 16843354; // 0x101025a
|
||||
@@ -955,7 +955,7 @@ package android {
|
||||
field public static final int mediaRouteButtonStyle = 16843693; // 0x10103ad
|
||||
field public static final int mediaRouteTypes = 16843694; // 0x10103ae
|
||||
field public static final int menuCategory = 16843230; // 0x10101de
|
||||
field public static final int mimeGroup = 16844311; // 0x1010617
|
||||
field public static final int mimeGroup = 16844310; // 0x1010616
|
||||
field public static final int mimeType = 16842790; // 0x1010026
|
||||
field public static final int min = 16844089; // 0x1010539
|
||||
field public static final int minAspectRatio = 16844187; // 0x101059b
|
||||
@@ -1084,7 +1084,7 @@ package android {
|
||||
field public static final int preferenceScreenStyle = 16842891; // 0x101008b
|
||||
field public static final int preferenceStyle = 16842894; // 0x101008e
|
||||
field public static final int presentationTheme = 16843712; // 0x10103c0
|
||||
field public static final int preserveLegacyExternalStorage = 16844310; // 0x1010616
|
||||
field public static final int preserveLegacyExternalStorage = 16844309; // 0x1010615
|
||||
field public static final int previewImage = 16843482; // 0x10102da
|
||||
field public static final int primaryContentAlpha = 16844114; // 0x1010552
|
||||
field public static final int priority = 16842780; // 0x101001c
|
||||
@@ -1141,7 +1141,6 @@ package android {
|
||||
field public static final int reqKeyboardType = 16843304; // 0x1010228
|
||||
field public static final int reqNavigation = 16843306; // 0x101022a
|
||||
field public static final int reqTouchScreen = 16843303; // 0x1010227
|
||||
field public static final int requestAutoRevokePermissionsExemption = 16844308; // 0x1010614
|
||||
field public static final int requestLegacyExternalStorage = 16844291; // 0x1010603
|
||||
field public static final int requireDeviceUnlock = 16843756; // 0x10103ec
|
||||
field public static final int required = 16843406; // 0x101028e
|
||||
|
||||
@@ -751,6 +751,30 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ApplicationInfoPrivateFlags {}
|
||||
|
||||
/**
|
||||
* Constant corresponding to <code>allowed</code> in the
|
||||
* {@link android.R.attr#autoRevokePermissions} attribute.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int AUTO_REVOKE_ALLOWED = 0;
|
||||
|
||||
/**
|
||||
* Constant corresponding to <code>discouraged</code> in the
|
||||
* {@link android.R.attr#autoRevokePermissions} attribute.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int AUTO_REVOKE_DISCOURAGED = 1;
|
||||
|
||||
/**
|
||||
* Constant corresponding to <code>disallowed</code> in the
|
||||
* {@link android.R.attr#autoRevokePermissions} attribute.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int AUTO_REVOKE_DISALLOWED = 2;
|
||||
|
||||
/**
|
||||
* Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
|
||||
* @hide
|
||||
|
||||
@@ -192,9 +192,7 @@ public interface ParsingPackage extends ParsingPackageRead {
|
||||
|
||||
ParsingPackage setAllowNativeHeapPointerTagging(boolean allowNativeHeapPointerTagging);
|
||||
|
||||
ParsingPackage setDontAutoRevokePermissions(boolean dontAutoRevokePermissions);
|
||||
|
||||
ParsingPackage setAllowDontAutoRevokePermissions(boolean allowDontAutoRevokePermissions);
|
||||
ParsingPackage setAutoRevokePermissions(int autoRevokePermissions);
|
||||
|
||||
ParsingPackage setPreserveLegacyExternalStorage(boolean preserveLegacyExternalStorage);
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.content.pm.FeatureGroupInfo;
|
||||
import android.content.pm.FeatureInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.ProcessInfo;
|
||||
import android.content.pm.parsing.component.ParsedActivity;
|
||||
import android.content.pm.parsing.component.ParsedAttribution;
|
||||
import android.content.pm.parsing.component.ParsedComponent;
|
||||
@@ -405,8 +404,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
private boolean hasFragileUserData;
|
||||
private boolean cantSaveState;
|
||||
private boolean allowNativeHeapPointerTagging;
|
||||
private boolean dontAutoRevokePermissions;
|
||||
private boolean allowDontAutoRevokePermissions;
|
||||
private int autoRevokePermissions;
|
||||
private boolean preserveLegacyExternalStorage;
|
||||
|
||||
protected int gwpAsanMode;
|
||||
@@ -1089,8 +1087,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
dest.writeBoolean(this.hasFragileUserData);
|
||||
dest.writeBoolean(this.cantSaveState);
|
||||
dest.writeBoolean(this.allowNativeHeapPointerTagging);
|
||||
dest.writeBoolean(this.dontAutoRevokePermissions);
|
||||
dest.writeBoolean(this.allowDontAutoRevokePermissions);
|
||||
dest.writeInt(this.autoRevokePermissions);
|
||||
dest.writeBoolean(this.preserveLegacyExternalStorage);
|
||||
dest.writeArraySet(this.mimeGroups);
|
||||
dest.writeInt(this.gwpAsanMode);
|
||||
@@ -1249,8 +1246,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
this.hasFragileUserData = in.readBoolean();
|
||||
this.cantSaveState = in.readBoolean();
|
||||
this.allowNativeHeapPointerTagging = in.readBoolean();
|
||||
this.dontAutoRevokePermissions = in.readBoolean();
|
||||
this.allowDontAutoRevokePermissions = in.readBoolean();
|
||||
this.autoRevokePermissions = in.readInt();
|
||||
this.preserveLegacyExternalStorage = in.readBoolean();
|
||||
this.mimeGroups = (ArraySet<String>) in.readArraySet(boot);
|
||||
this.gwpAsanMode = in.readInt();
|
||||
@@ -2026,13 +2022,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDontAutoRevokePermmissions() {
|
||||
return dontAutoRevokePermissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowDontAutoRevokePermmissions() {
|
||||
return allowDontAutoRevokePermissions;
|
||||
public int getAutoRevokePermissions() {
|
||||
return autoRevokePermissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2506,14 +2497,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsingPackageImpl setDontAutoRevokePermissions(boolean value) {
|
||||
dontAutoRevokePermissions = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsingPackageImpl setAllowDontAutoRevokePermissions(boolean value) {
|
||||
allowDontAutoRevokePermissions = value;
|
||||
public ParsingPackageImpl setAutoRevokePermissions(int value) {
|
||||
autoRevokePermissions = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -771,11 +771,7 @@ public interface ParsingPackageRead extends Parcelable {
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING */
|
||||
boolean isAllowNativeHeapPointerTagging();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG2_DONT_AUTO_REVOKE_PERMISSIONS */
|
||||
boolean isDontAutoRevokePermmissions();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG2_ALLOW_DONT_AUTO_REVOKE_PERMISSIONS */
|
||||
boolean isAllowDontAutoRevokePermmissions();
|
||||
int getAutoRevokePermissions();
|
||||
|
||||
boolean hasPreserveLegacyExternalStorage();
|
||||
|
||||
|
||||
@@ -1829,8 +1829,7 @@ public class ParsingPackageUtils {
|
||||
.setUseEmbeddedDex(bool(false, R.styleable.AndroidManifestApplication_useEmbeddedDex, sa))
|
||||
.setUsesNonSdkApi(bool(false, R.styleable.AndroidManifestApplication_usesNonSdkApi, sa))
|
||||
.setVmSafeMode(bool(false, R.styleable.AndroidManifestApplication_vmSafeMode, sa))
|
||||
.setDontAutoRevokePermissions(bool(false, R.styleable.AndroidManifestApplication_requestAutoRevokePermissionsExemption, sa))
|
||||
.setAllowDontAutoRevokePermissions(bool(false, R.styleable.AndroidManifestApplication_allowAutoRevokePermissionsExemption, sa))
|
||||
.setAutoRevokePermissions(anInt(R.styleable.AndroidManifestApplication_autoRevokePermissions, sa))
|
||||
// targetSdkVersion gated
|
||||
.setAllowAudioPlaybackCapture(bool(targetSdk >= Build.VERSION_CODES.Q, R.styleable.AndroidManifestApplication_allowAudioPlaybackCapture, sa))
|
||||
.setBaseHardwareAccelerated(bool(targetSdk >= Build.VERSION_CODES.ICE_CREAM_SANDWICH, R.styleable.AndroidManifestApplication_hardwareAccelerated, sa))
|
||||
|
||||
@@ -1827,19 +1827,11 @@
|
||||
|
||||
<attr name="gwpAsanMode" />
|
||||
|
||||
<!-- If {@code true} allow requesting that its permissions don't get automatically
|
||||
revoked when the app is unused for an extended amount of time.
|
||||
|
||||
The default value is {@code false}. -->
|
||||
<attr name="requestAutoRevokePermissionsExemption" format="boolean" />
|
||||
|
||||
<!-- If {@code true} its permissions shouldn't get automatically
|
||||
revoked when the app is unused for an extended amount of time.
|
||||
|
||||
This implies {@code requestDontAutoRevokePermissions=true}
|
||||
|
||||
The default value is {@code false}. -->
|
||||
<attr name="allowAutoRevokePermissionsExemption" format="boolean" />
|
||||
<attr name="autoRevokePermissions">
|
||||
<enum name="allowed" value="0" />
|
||||
<enum name="discouraged" value="1" />
|
||||
<enum name="disallowed" value="2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- An attribution is a logical part of an app and is identified by a tag.
|
||||
|
||||
@@ -3014,8 +3014,7 @@
|
||||
<!-- @hide @SystemApi -->
|
||||
<public name="minExtensionVersion" />
|
||||
<public name="allowNativeHeapPointerTagging" />
|
||||
<public name="requestAutoRevokePermissionsExemption" />
|
||||
<public name="allowAutoRevokePermissionsExemption" />
|
||||
<public name="autoRevokePermissions" />
|
||||
<public name="preserveLegacyExternalStorage" />
|
||||
<public name="mimeGroup" />
|
||||
<public name="gwpAsanMode" />
|
||||
|
||||
@@ -24487,7 +24487,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
} else {
|
||||
synchronized (mLock) {
|
||||
boolean manifestWhitelisted =
|
||||
mPackages.get(packageName).isAllowDontAutoRevokePermmissions();
|
||||
mPackages.get(packageName).getAutoRevokePermissions()
|
||||
== ApplicationInfo.AUTO_REVOKE_DISALLOWED;
|
||||
return manifestWhitelisted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
import static android.app.AppOpsManager.MODE_ALLOWED;
|
||||
import static android.app.AppOpsManager.MODE_IGNORED;
|
||||
import static android.content.pm.ApplicationInfo.AUTO_REVOKE_DISALLOWED;
|
||||
import static android.content.pm.ApplicationInfo.AUTO_REVOKE_DISCOURAGED;
|
||||
import static android.content.pm.PackageManager.FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT;
|
||||
import static android.content.pm.PackageManager.FLAG_PERMISSION_APPLY_RESTRICTION;
|
||||
import static android.content.pm.PackageManager.FLAG_PERMISSION_GRANTED_BY_DEFAULT;
|
||||
@@ -3238,31 +3240,25 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
|
||||
@Override
|
||||
public List<String> getAutoRevokeExemptionRequestedPackages(int userId) {
|
||||
mContext.enforceCallingPermission(Manifest.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY,
|
||||
"Must hold " + Manifest.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY);
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
mPackageManagerInt.forEachInstalledPackage(pkg -> {
|
||||
if (pkg.isDontAutoRevokePermmissions()) {
|
||||
result.add(pkg.getPackageName());
|
||||
}
|
||||
}, userId);
|
||||
|
||||
return result;
|
||||
return getPackagesWithAutoRevokePolicy(AUTO_REVOKE_DISCOURAGED, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAutoRevokeExemptionGrantedPackages(int userId) {
|
||||
return getPackagesWithAutoRevokePolicy(AUTO_REVOKE_DISALLOWED, userId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private List<String> getPackagesWithAutoRevokePolicy(int autoRevokePolicy, int userId) {
|
||||
mContext.enforceCallingPermission(Manifest.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY,
|
||||
"Must hold " + Manifest.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY);
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
mPackageManagerInt.forEachInstalledPackage(pkg -> {
|
||||
if (pkg.isAllowDontAutoRevokePermmissions()) {
|
||||
if (pkg.getAutoRevokePermissions() == autoRevokePolicy) {
|
||||
result.add(pkg.getPackageName());
|
||||
}
|
||||
}, userId);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user