Merge "Convert enableGwpAsan to @IntDef and rename to gwpAsanMode." into rvc-dev

This commit is contained in:
Evgenii Stepanov
2020-03-19 22:47:05 +00:00
committed by Android (Google) Code Review
15 changed files with 117 additions and 100 deletions

View File

@@ -573,7 +573,6 @@ package android {
field public static final int elevation = 16843840; // 0x1010440 field public static final int elevation = 16843840; // 0x1010440
field public static final int ellipsize = 16842923; // 0x10100ab field public static final int ellipsize = 16842923; // 0x10100ab
field public static final int ems = 16843096; // 0x1010158 field public static final int ems = 16843096; // 0x1010158
field public static final int enableGwpAsan = 16844312; // 0x1010618
field public static final int enableVrMode = 16844069; // 0x1010525 field public static final int enableVrMode = 16844069; // 0x1010525
field public static final int enabled = 16842766; // 0x101000e field public static final int enabled = 16842766; // 0x101000e
field public static final int end = 16843996; // 0x10104dc field public static final int end = 16843996; // 0x10104dc
@@ -710,6 +709,7 @@ package android {
field public static final int gravity = 16842927; // 0x10100af field public static final int gravity = 16842927; // 0x10100af
field public static final int gridViewStyle = 16842865; // 0x1010071 field public static final int gridViewStyle = 16842865; // 0x1010071
field public static final int groupIndicator = 16843019; // 0x101010b field public static final int groupIndicator = 16843019; // 0x101010b
field public static final int gwpAsanMode = 16844312; // 0x1010618
field public static final int hand_hour = 16843011; // 0x1010103 field public static final int hand_hour = 16843011; // 0x1010103
field public static final int hand_minute = 16843012; // 0x1010104 field public static final int hand_minute = 16843012; // 0x1010104
field public static final int handle = 16843354; // 0x101025a field public static final int handle = 16843354; // 0x101025a
@@ -11443,7 +11443,7 @@ package android.content.pm {
method public int describeContents(); method public int describeContents();
method public void dump(android.util.Printer, String); method public void dump(android.util.Printer, String);
method public static CharSequence getCategoryTitle(android.content.Context, int); method public static CharSequence getCategoryTitle(android.content.Context, int);
method @Nullable public Boolean isGwpAsanEnabled(); method public int getGwpAsanMode();
method public boolean isProfileableByShell(); method public boolean isProfileableByShell();
method public boolean isResourceOverlay(); method public boolean isResourceOverlay();
method public boolean isVirtualPreload(); method public boolean isVirtualPreload();
@@ -11490,6 +11490,9 @@ package android.content.pm {
field public static final int FLAG_UPDATED_SYSTEM_APP = 128; // 0x80 field public static final int FLAG_UPDATED_SYSTEM_APP = 128; // 0x80
field public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 134217728; // 0x8000000 field public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 134217728; // 0x8000000
field public static final int FLAG_VM_SAFE_MODE = 16384; // 0x4000 field public static final int FLAG_VM_SAFE_MODE = 16384; // 0x4000
field public static final int GWP_ASAN_ALWAYS = 1; // 0x1
field public static final int GWP_ASAN_DEFAULT = -1; // 0xffffffff
field public static final int GWP_ASAN_NEVER = 0; // 0x0
field public String appComponentFactory; field public String appComponentFactory;
field public String backupAgentName; field public String backupAgentName;
field public int category; field public int category;

View File

@@ -59,8 +59,6 @@ import java.util.UUID;
* <application> tag. * <application> tag.
*/ */
public class ApplicationInfo extends PackageItemInfo implements Parcelable { public class ApplicationInfo extends PackageItemInfo implements Parcelable {
private static ForBoolean sForBoolean = Parcelling.Cache.getOrCreate(ForBoolean.class);
/** /**
* Default task affinity of all activities in this application. See * Default task affinity of all activities in this application. See
* {@link ActivityInfo#taskAffinity} for more information. This comes * {@link ActivityInfo#taskAffinity} for more information. This comes
@@ -1277,12 +1275,37 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
public String zygotePreloadName; public String zygotePreloadName;
/** /**
* Indicates if the application has requested GWP-ASan to be enabled, disabled, or left * Default (unspecified) setting of GWP-ASan.
* unspecified. Processes can override this setting. */
public static final int GWP_ASAN_DEFAULT = -1;
/**
* Never enable GWP-ASan in this application or process.
*/
public static final int GWP_ASAN_NEVER = 0;
/**
* Always enable GWP-ASan in this application or process.
*/
public static final int GWP_ASAN_ALWAYS = 1;
/**
* These constants need to match the values of gwpAsanMode in application manifest.
* @hide * @hide
*/ */
@Nullable @IntDef(prefix = {"GWP_ASAN_"}, value = {
public Boolean enableGwpAsan; GWP_ASAN_DEFAULT,
GWP_ASAN_NEVER,
GWP_ASAN_ALWAYS,
})
@Retention(RetentionPolicy.SOURCE)
public @interface GwpAsanMode {}
/**
* Indicates if the application has requested GWP-ASan to be enabled, disabled, or left
* unspecified. Processes can override this setting.
*/
private @GwpAsanMode int gwpAsanMode;
/** /**
* Represents the default policy. The actual policy used will depend on other properties of * Represents the default policy. The actual policy used will depend on other properties of
@@ -1425,8 +1448,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
pw.println(prefix + "usesNonSdkApi=" + usesNonSdkApi()); pw.println(prefix + "usesNonSdkApi=" + usesNonSdkApi());
pw.println(prefix + "allowsPlaybackCapture=" pw.println(prefix + "allowsPlaybackCapture="
+ (isAudioPlaybackCaptureAllowed() ? "true" : "false")); + (isAudioPlaybackCaptureAllowed() ? "true" : "false"));
if (enableGwpAsan != null) { if (gwpAsanMode != GWP_ASAN_DEFAULT) {
pw.println(prefix + "enableGwpAsan=" + enableGwpAsan); pw.println(prefix + "gwpAsanMode=" + gwpAsanMode);
} }
} }
super.dumpBack(pw, prefix); super.dumpBack(pw, prefix);
@@ -1526,8 +1549,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
if (category != CATEGORY_UNDEFINED) { if (category != CATEGORY_UNDEFINED) {
proto.write(ApplicationInfoProto.Detail.CATEGORY, category); proto.write(ApplicationInfoProto.Detail.CATEGORY, category);
} }
if (enableGwpAsan != null) { if (gwpAsanMode != GWP_ASAN_DEFAULT) {
proto.write(ApplicationInfoProto.Detail.ENABLE_GWP_ASAN, enableGwpAsan); proto.write(ApplicationInfoProto.Detail.ENABLE_GWP_ASAN, gwpAsanMode);
} }
proto.end(detailToken); proto.end(detailToken);
} }
@@ -1638,7 +1661,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
mHiddenApiPolicy = orig.mHiddenApiPolicy; mHiddenApiPolicy = orig.mHiddenApiPolicy;
hiddenUntilInstalled = orig.hiddenUntilInstalled; hiddenUntilInstalled = orig.hiddenUntilInstalled;
zygotePreloadName = orig.zygotePreloadName; zygotePreloadName = orig.zygotePreloadName;
enableGwpAsan = orig.enableGwpAsan; gwpAsanMode = orig.gwpAsanMode;
} }
public String toString() { public String toString() {
@@ -1722,7 +1745,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
dest.writeInt(mHiddenApiPolicy); dest.writeInt(mHiddenApiPolicy);
dest.writeInt(hiddenUntilInstalled ? 1 : 0); dest.writeInt(hiddenUntilInstalled ? 1 : 0);
dest.writeString(zygotePreloadName); dest.writeString(zygotePreloadName);
sForBoolean.parcel(enableGwpAsan, dest, parcelableFlags); dest.writeInt(gwpAsanMode);
} }
public static final @android.annotation.NonNull Parcelable.Creator<ApplicationInfo> CREATOR public static final @android.annotation.NonNull Parcelable.Creator<ApplicationInfo> CREATOR
@@ -1803,7 +1826,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
mHiddenApiPolicy = source.readInt(); mHiddenApiPolicy = source.readInt();
hiddenUntilInstalled = source.readInt() != 0; hiddenUntilInstalled = source.readInt() != 0;
zygotePreloadName = source.readString(); zygotePreloadName = source.readString();
enableGwpAsan = sForBoolean.unparcel(source); gwpAsanMode = source.readInt();
} }
/** /**
@@ -2182,7 +2205,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
/** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; } /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
/** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; } /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
/** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; } /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
/** {@hide} */ public void setGwpAsanEnabled(@Nullable Boolean value) { enableGwpAsan = value; } /** {@hide} */ public void setGwpAsanMode(@GwpAsanMode int value) { gwpAsanMode = value; }
/** {@hide} */ /** {@hide} */
@UnsupportedAppUsage @UnsupportedAppUsage
@@ -2194,6 +2217,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
@UnsupportedAppUsage @UnsupportedAppUsage
public String getBaseResourcePath() { return publicSourceDir; } public String getBaseResourcePath() { return publicSourceDir; }
/** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; } /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
@Nullable @GwpAsanMode
public Boolean isGwpAsanEnabled() { return enableGwpAsan; } public int getGwpAsanMode() { return gwpAsanMode; }
} }

View File

@@ -18,6 +18,7 @@ package android.content.pm;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.content.pm.ApplicationInfo;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.text.TextUtils; import android.text.TextUtils;
@@ -50,14 +51,13 @@ public class ProcessInfo implements Parcelable {
/** /**
* Indicates if the process has requested GWP-ASan to be enabled, disabled, or left unspecified. * Indicates if the process has requested GWP-ASan to be enabled, disabled, or left unspecified.
*/ */
@Nullable public @ApplicationInfo.GwpAsanMode int gwpAsanMode;
public Boolean enableGwpAsan;
@Deprecated @Deprecated
public ProcessInfo(@NonNull ProcessInfo orig) { public ProcessInfo(@NonNull ProcessInfo orig) {
this.name = orig.name; this.name = orig.name;
this.deniedPermissions = orig.deniedPermissions; this.deniedPermissions = orig.deniedPermissions;
this.enableGwpAsan = orig.enableGwpAsan; this.gwpAsanMode = orig.gwpAsanMode;
} }
@@ -82,19 +82,21 @@ public class ProcessInfo implements Parcelable {
* The name of the process, fully-qualified based on the app's package name. * The name of the process, fully-qualified based on the app's package name.
* @param deniedPermissions * @param deniedPermissions
* If non-null, these are permissions that are not allowed in this process. * If non-null, these are permissions that are not allowed in this process.
* @param enableGwpAsan * @param gwpAsanMode
* Indicates if the process has requested GWP-ASan to be enabled, disabled, or left unspecified. * Indicates if the process has requested GWP-ASan to be enabled, disabled, or left unspecified.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public ProcessInfo( public ProcessInfo(
@NonNull String name, @NonNull String name,
@Nullable ArraySet<String> deniedPermissions, @Nullable ArraySet<String> deniedPermissions,
@Nullable Boolean enableGwpAsan) { @ApplicationInfo.GwpAsanMode int gwpAsanMode) {
this.name = name; this.name = name;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, name); NonNull.class, null, name);
this.deniedPermissions = deniedPermissions; this.deniedPermissions = deniedPermissions;
this.enableGwpAsan = enableGwpAsan; this.gwpAsanMode = gwpAsanMode;
com.android.internal.util.AnnotationValidations.validate(
ApplicationInfo.GwpAsanMode.class, null, gwpAsanMode);
// onConstructed(); // You can define this method to get a callback // onConstructed(); // You can define this method to get a callback
} }
@@ -118,11 +120,10 @@ public class ProcessInfo implements Parcelable {
byte flg = 0; byte flg = 0;
if (deniedPermissions != null) flg |= 0x2; if (deniedPermissions != null) flg |= 0x2;
if (enableGwpAsan != null) flg |= 0x4;
dest.writeByte(flg); dest.writeByte(flg);
dest.writeString(name); dest.writeString(name);
sParcellingForDeniedPermissions.parcel(deniedPermissions, dest, flags); sParcellingForDeniedPermissions.parcel(deniedPermissions, dest, flags);
if (enableGwpAsan != null) dest.writeBoolean(enableGwpAsan); dest.writeInt(gwpAsanMode);
} }
@Override @Override
@@ -139,13 +140,15 @@ public class ProcessInfo implements Parcelable {
byte flg = in.readByte(); byte flg = in.readByte();
String _name = in.readString(); String _name = in.readString();
ArraySet<String> _deniedPermissions = sParcellingForDeniedPermissions.unparcel(in); ArraySet<String> _deniedPermissions = sParcellingForDeniedPermissions.unparcel(in);
Boolean _enableGwpAsan = (flg & 0x4) == 0 ? null : (Boolean) in.readBoolean(); int _gwpAsanMode = in.readInt();
this.name = _name; this.name = _name;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, name); NonNull.class, null, name);
this.deniedPermissions = _deniedPermissions; this.deniedPermissions = _deniedPermissions;
this.enableGwpAsan = _enableGwpAsan; this.gwpAsanMode = _gwpAsanMode;
com.android.internal.util.AnnotationValidations.validate(
ApplicationInfo.GwpAsanMode.class, null, gwpAsanMode);
// onConstructed(); // You can define this method to get a callback // onConstructed(); // You can define this method to get a callback
} }
@@ -165,10 +168,10 @@ public class ProcessInfo implements Parcelable {
}; };
@DataClass.Generated( @DataClass.Generated(
time = 1582840056156L, time = 1584555730519L,
codegenVersion = "1.0.15", codegenVersion = "1.0.15",
sourceFile = "frameworks/base/core/java/android/content/pm/ProcessInfo.java", sourceFile = "frameworks/base/core/java/android/content/pm/ProcessInfo.java",
inputSignatures = "public @android.annotation.NonNull java.lang.String name\npublic @android.annotation.Nullable @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedStringArraySet.class) android.util.ArraySet<java.lang.String> deniedPermissions\npublic @android.annotation.Nullable java.lang.Boolean enableGwpAsan\nclass ProcessInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genSetters=false, genParcelable=true, genAidl=false, genBuilder=false)") inputSignatures = "public @android.annotation.NonNull java.lang.String name\npublic @android.annotation.Nullable @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedStringArraySet.class) android.util.ArraySet<java.lang.String> deniedPermissions\npublic @android.content.pm.ApplicationInfo.GwpAsanMode int gwpAsanMode\nclass ProcessInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genSetters=false, genParcelable=true, genAidl=false, genBuilder=false)")
@Deprecated @Deprecated
private void __metadata() {} private void __metadata() {}

View File

@@ -240,7 +240,7 @@ public interface ParsingPackage extends ParsingPackageRead {
ParsingPackage setEnabled(boolean enabled); ParsingPackage setEnabled(boolean enabled);
ParsingPackage setGwpAsanEnabled(Boolean enableGwpAsan); ParsingPackage setGwpAsanMode(int gwpAsanMode);
ParsingPackage setCrossProfile(boolean crossProfile); ParsingPackage setCrossProfile(boolean crossProfile);

View File

@@ -409,9 +409,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
private boolean allowDontAutoRevokePermissions; private boolean allowDontAutoRevokePermissions;
private boolean preserveLegacyExternalStorage; private boolean preserveLegacyExternalStorage;
@Nullable protected int gwpAsanMode;
@DataClass.ParcelWith(ForBoolean.class)
protected Boolean enableGwpAsan = null;
// TODO(chiuwinson): Non-null // TODO(chiuwinson): Non-null
@Nullable @Nullable
@@ -911,7 +909,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
appInfo.volumeUuid = volumeUuid; appInfo.volumeUuid = volumeUuid;
appInfo.zygotePreloadName = zygotePreloadName; appInfo.zygotePreloadName = zygotePreloadName;
appInfo.crossProfile = isCrossProfile(); appInfo.crossProfile = isCrossProfile();
appInfo.setGwpAsanEnabled(enableGwpAsan); appInfo.setGwpAsanMode(gwpAsanMode);
appInfo.setBaseCodePath(baseCodePath); appInfo.setBaseCodePath(baseCodePath);
appInfo.setBaseResourcePath(baseCodePath); appInfo.setBaseResourcePath(baseCodePath);
appInfo.setCodePath(codePath); appInfo.setCodePath(codePath);
@@ -1095,7 +1093,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
dest.writeBoolean(this.allowDontAutoRevokePermissions); dest.writeBoolean(this.allowDontAutoRevokePermissions);
dest.writeBoolean(this.preserveLegacyExternalStorage); dest.writeBoolean(this.preserveLegacyExternalStorage);
dest.writeArraySet(this.mimeGroups); dest.writeArraySet(this.mimeGroups);
sForBoolean.parcel(this.enableGwpAsan, dest, flags); dest.writeInt(this.gwpAsanMode);
} }
public ParsingPackageImpl(Parcel in) { public ParsingPackageImpl(Parcel in) {
@@ -1255,7 +1253,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
this.allowDontAutoRevokePermissions = in.readBoolean(); this.allowDontAutoRevokePermissions = in.readBoolean();
this.preserveLegacyExternalStorage = in.readBoolean(); this.preserveLegacyExternalStorage = in.readBoolean();
this.mimeGroups = (ArraySet<String>) in.readArraySet(boot); this.mimeGroups = (ArraySet<String>) in.readArraySet(boot);
this.enableGwpAsan = sForBoolean.unparcel(in); this.gwpAsanMode = in.readInt();
} }
public static final Parcelable.Creator<ParsingPackageImpl> CREATOR = public static final Parcelable.Creator<ParsingPackageImpl> CREATOR =
@@ -1978,9 +1976,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
} }
@Override @Override
@Nullable public int getGwpAsanMode() {
public Boolean isGwpAsanEnabled() { return gwpAsanMode;
return enableGwpAsan;
} }
@Override @Override
@@ -2449,8 +2446,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
} }
@Override @Override
public ParsingPackageImpl setGwpAsanEnabled(@Nullable Boolean value) { public ParsingPackageImpl setGwpAsanMode(int value) {
enableGwpAsan = value; gwpAsanMode = value;
return this; return this;
} }

View File

@@ -847,11 +847,10 @@ public interface ParsingPackageRead extends Parcelable {
Set<String> getMimeGroups(); Set<String> getMimeGroups();
/** /**
* @see ApplicationInfo#enableGwpAsan * @see ApplicationInfo#gwpAsanMode
* @see R.styleable#AndroidManifest_enableGwpAsan * @see R.styleable#AndroidManifest_gwpAsanMode
*/ */
@Nullable public int getGwpAsanMode();
public Boolean isGwpAsanEnabled();
// TODO(b/135203078): Hide and enforce going through PackageInfoUtils // TODO(b/135203078): Hide and enforce going through PackageInfoUtils
ApplicationInfo toAppInfoWithoutState(); ApplicationInfo toAppInfoWithoutState();

View File

@@ -1677,10 +1677,7 @@ public class ParsingPackageUtils {
return input.error("Invalid class loader name: " + classLoaderName); return input.error("Invalid class loader name: " + classLoaderName);
} }
if (sa.hasValue(R.styleable.AndroidManifestApplication_enableGwpAsan)) { pkg.setGwpAsanMode(sa.getInt(R.styleable.AndroidManifestApplication_gwpAsanMode, -1));
pkg.setGwpAsanEnabled(
sa.getBoolean(R.styleable.AndroidManifestApplication_enableGwpAsan, false));
}
} finally { } finally {
sa.recycle(); sa.recycle();
} }

View File

@@ -41,8 +41,7 @@ public class ParsedProcess implements Parcelable {
@DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringSet.class) @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringSet.class)
protected Set<String> deniedPermissions = emptySet(); protected Set<String> deniedPermissions = emptySet();
@Nullable protected int gwpAsanMode = -1;
protected Boolean enableGwpAsan = null;
public ParsedProcess() { public ParsedProcess() {
} }
@@ -58,7 +57,7 @@ public class ParsedProcess implements Parcelable {
// Code below generated by codegen v1.0.14. // Code below generated by codegen v1.0.15.
// //
// DO NOT MODIFY! // DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code // CHECKSTYLE:OFF Generated code
@@ -75,14 +74,14 @@ public class ParsedProcess implements Parcelable {
public ParsedProcess( public ParsedProcess(
@NonNull String name, @NonNull String name,
@NonNull Set<String> deniedPermissions, @NonNull Set<String> deniedPermissions,
@Nullable Boolean enableGwpAsan) { int gwpAsanMode) {
this.name = name; this.name = name;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, name); NonNull.class, null, name);
this.deniedPermissions = deniedPermissions; this.deniedPermissions = deniedPermissions;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, deniedPermissions); NonNull.class, null, deniedPermissions);
this.enableGwpAsan = enableGwpAsan; this.gwpAsanMode = gwpAsanMode;
// onConstructed(); // You can define this method to get a callback // onConstructed(); // You can define this method to get a callback
} }
@@ -98,8 +97,8 @@ public class ParsedProcess implements Parcelable {
} }
@DataClass.Generated.Member @DataClass.Generated.Member
public @Nullable Boolean getEnableGwpAsan() { public int getGwpAsanMode() {
return enableGwpAsan; return gwpAsanMode;
} }
@DataClass.Generated.Member @DataClass.Generated.Member
@@ -119,12 +118,9 @@ public class ParsedProcess implements Parcelable {
// You can override field parcelling by defining methods like: // You can override field parcelling by defining methods like:
// void parcelFieldName(Parcel dest, int flags) { ... } // void parcelFieldName(Parcel dest, int flags) { ... }
byte flg = 0;
if (enableGwpAsan != null) flg |= 0x4;
dest.writeByte(flg);
dest.writeString(name); dest.writeString(name);
sParcellingForDeniedPermissions.parcel(deniedPermissions, dest, flags); sParcellingForDeniedPermissions.parcel(deniedPermissions, dest, flags);
if (enableGwpAsan != null) dest.writeBoolean(enableGwpAsan); dest.writeInt(gwpAsanMode);
} }
@Override @Override
@@ -138,10 +134,9 @@ public class ParsedProcess implements Parcelable {
// You can override field unparcelling by defining methods like: // You can override field unparcelling by defining methods like:
// static FieldType unparcelFieldName(Parcel in) { ... } // static FieldType unparcelFieldName(Parcel in) { ... }
byte flg = in.readByte();
String _name = in.readString(); String _name = in.readString();
Set<String> _deniedPermissions = sParcellingForDeniedPermissions.unparcel(in); Set<String> _deniedPermissions = sParcellingForDeniedPermissions.unparcel(in);
Boolean _enableGwpAsan = (flg & 0x4) == 0 ? null : (Boolean) in.readBoolean(); int _gwpAsanMode = in.readInt();
this.name = _name; this.name = _name;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
@@ -149,7 +144,7 @@ public class ParsedProcess implements Parcelable {
this.deniedPermissions = _deniedPermissions; this.deniedPermissions = _deniedPermissions;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, deniedPermissions); NonNull.class, null, deniedPermissions);
this.enableGwpAsan = _enableGwpAsan; this.gwpAsanMode = _gwpAsanMode;
// onConstructed(); // You can define this method to get a callback // onConstructed(); // You can define this method to get a callback
} }
@@ -169,10 +164,10 @@ public class ParsedProcess implements Parcelable {
}; };
@DataClass.Generated( @DataClass.Generated(
time = 1582589960479L, time = 1584557524776L,
codegenVersion = "1.0.14", codegenVersion = "1.0.15",
sourceFile = "frameworks/base/core/java/android/content/pm/parsing/component/ParsedProcess.java", sourceFile = "frameworks/base/core/java/android/content/pm/parsing/component/ParsedProcess.java",
inputSignatures = "protected @android.annotation.NonNull java.lang.String name\nprotected @android.annotation.NonNull @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedStringSet.class) java.util.Set<java.lang.String> deniedPermissions\nprotected @android.annotation.Nullable java.lang.Boolean enableGwpAsan\npublic void addStateFrom(android.content.pm.parsing.component.ParsedProcess)\nclass ParsedProcess extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genSetters=false, genParcelable=true, genAidl=false, genBuilder=false)") inputSignatures = "protected @android.annotation.NonNull java.lang.String name\nprotected @android.annotation.NonNull @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedStringSet.class) java.util.Set<java.lang.String> deniedPermissions\nprotected int gwpAsanMode\npublic void addStateFrom(android.content.pm.parsing.component.ParsedProcess)\nclass ParsedProcess extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genSetters=false, genParcelable=true, genAidl=false, genBuilder=false)")
@Deprecated @Deprecated
private void __metadata() {} private void __metadata() {}

View File

@@ -104,10 +104,7 @@ public class ParsedProcessUtils {
return input.error("<process> does not specify android:process"); return input.error("<process> does not specify android:process");
} }
if (sa.hasValue(R.styleable.AndroidManifestProcess_enableGwpAsan)) { proc.gwpAsanMode = sa.getInt(R.styleable.AndroidManifestProcess_gwpAsanMode, -1);
proc.enableGwpAsan =
sa.getBoolean(R.styleable.AndroidManifestProcess_enableGwpAsan, false);
}
} finally { } finally {
sa.recycle(); sa.recycle();
} }

View File

@@ -109,7 +109,7 @@ message ApplicationInfoProto {
} }
optional int32 network_security_config_res = 17; optional int32 network_security_config_res = 17;
optional int32 category = 18; optional int32 category = 18;
optional bool enable_gwp_asan = 19; optional int32 enable_gwp_asan = 19;
} }
optional Detail detail = 17; optional Detail detail = 17;
} }

View File

@@ -1547,19 +1547,18 @@
See the <a href="http://llvm.org/docs/GwpAsan.html">LLVM documentation</a> See the <a href="http://llvm.org/docs/GwpAsan.html">LLVM documentation</a>
for more information about this feature. for more information about this feature.
<p>This tag can be applied to any tag that allows <p>This attribute can be applied to a
{@link android.R.styleable#AndroidManifestProcess process} tag: {@link android.R.styleable#AndroidManifestProcess process} tag, or to an
{@link android.R.styleable#AndroidManifestApplication application} tag (to supply {@link android.R.styleable#AndroidManifestApplication application} tag (to supply
a default setting for all application components), or with the a default setting for all application components). -->
{@link android.R.styleable#AndroidManifestProvider provider}, <attr name="gwpAsanMode">
{@link android.R.styleable#AndroidManifestService service}, <!-- Default behavior: GwpAsan is disabled in user apps, randomly enabled in system apps. -->
{@link android.R.styleable#AndroidManifestReceiver receiver}, <enum name="default" value="-1" />
{@link android.R.styleable#AndroidManifestActivity activity} tag. <!-- Never enable GwpAsan. -->
When multiple components run in the same process, <enum name="never" value="0" />
the first component to start determines the behavior of the entire process. <!-- Always enable GwpAsan. -->
<enum name="always" value="1" />
The default value is {@code false}. --> </attr>
<attr name="enableGwpAsan" format="boolean" />
<!-- The <code>manifest</code> tag is the root of an <!-- The <code>manifest</code> tag is the root of an
<code>AndroidManifest.xml</code> file, <code>AndroidManifest.xml</code> file,
@@ -1826,7 +1825,7 @@
The default value is {@code true}. --> The default value is {@code true}. -->
<attr name="allowNativeHeapPointerTagging" format="boolean" /> <attr name="allowNativeHeapPointerTagging" format="boolean" />
<attr name="enableGwpAsan" /> <attr name="gwpAsanMode" />
<!-- If {@code true} allow requesting that its permissions don't get automatically <!-- If {@code true} allow requesting that its permissions don't get automatically
revoked when the app is unused for an extended amount of time. revoked when the app is unused for an extended amount of time.
@@ -2351,7 +2350,7 @@
<declare-styleable name="AndroidManifestProcess" parent="AndroidManifestProcesses"> <declare-styleable name="AndroidManifestProcess" parent="AndroidManifestProcesses">
<!-- Required name of the process that is allowed --> <!-- Required name of the process that is allowed -->
<attr name="process" /> <attr name="process" />
<attr name="enableGwpAsan" /> <attr name="gwpAsanMode" />
</declare-styleable> </declare-styleable>
<!-- The <code>deny-permission</code> tag specifies that a permission is to be denied <!-- The <code>deny-permission</code> tag specifies that a permission is to be denied

View File

@@ -3018,7 +3018,7 @@
<public name="allowAutoRevokePermissionsExemption" /> <public name="allowAutoRevokePermissionsExemption" />
<public name="preserveLegacyExternalStorage" /> <public name="preserveLegacyExternalStorage" />
<public name="mimeGroup" /> <public name="mimeGroup" />
<public name="enableGwpAsan" /> <public name="gwpAsanMode" />
</public-group> </public-group>
<public-group type="drawable" first-id="0x010800b5"> <public-group type="drawable" first-id="0x010800b5">

View File

@@ -1665,16 +1665,19 @@ public final class ProcessList {
private int decideGwpAsanLevel(ProcessRecord app) { private int decideGwpAsanLevel(ProcessRecord app) {
// Look at the process attribute first. // Look at the process attribute first.
if (app.processInfo != null && app.processInfo.enableGwpAsan != null) { if (app.processInfo != null
return app.processInfo.enableGwpAsan ? Zygote.GWP_ASAN_LEVEL_ALWAYS && app.processInfo.gwpAsanMode != ApplicationInfo.GWP_ASAN_DEFAULT) {
return app.processInfo.gwpAsanMode == ApplicationInfo.GWP_ASAN_ALWAYS
? Zygote.GWP_ASAN_LEVEL_ALWAYS
: Zygote.GWP_ASAN_LEVEL_NEVER; : Zygote.GWP_ASAN_LEVEL_NEVER;
} }
// Then at the applicaton attribute. // Then at the applicaton attribute.
if (app.info.isGwpAsanEnabled() != null) { if (app.info.getGwpAsanMode() != ApplicationInfo.GWP_ASAN_DEFAULT) {
return app.info.isGwpAsanEnabled() ? Zygote.GWP_ASAN_LEVEL_ALWAYS return app.info.getGwpAsanMode() == ApplicationInfo.GWP_ASAN_ALWAYS
? Zygote.GWP_ASAN_LEVEL_ALWAYS
: Zygote.GWP_ASAN_LEVEL_NEVER; : Zygote.GWP_ASAN_LEVEL_NEVER;
} }
// If the app does not specify enableGwpAsan, the default behavior is lottery among the // If the app does not specify gwpAsanMode, the default behavior is lottery among the
// system apps, and disabled for user apps, unless overwritten by the compat feature. // system apps, and disabled for user apps, unless overwritten by the compat feature.
if (mPlatformCompat.isChangeEnabled(GWP_ASAN, app.info)) { if (mPlatformCompat.isChangeEnabled(GWP_ASAN, app.info)) {
return Zygote.GWP_ASAN_LEVEL_ALWAYS; return Zygote.GWP_ASAN_LEVEL_ALWAYS;

View File

@@ -385,8 +385,8 @@ class ProcessRecord implements WindowProcessListener {
pw.println(processInfo.deniedPermissions.valueAt(i)); pw.println(processInfo.deniedPermissions.valueAt(i));
} }
} }
if (processInfo.enableGwpAsan != null) { if (processInfo.gwpAsanMode != ApplicationInfo.GWP_ASAN_DEFAULT) {
pw.print(prefix); pw.println(" enableGwpAsan=" + processInfo.enableGwpAsan); pw.print(prefix); pw.println(" gwpAsanMode=" + processInfo.gwpAsanMode);
} }
} }
pw.print(prefix); pw.print("mRequiredAbi="); pw.print(mRequiredAbi); pw.print(prefix); pw.print("mRequiredAbi="); pw.print(mRequiredAbi);
@@ -640,9 +640,10 @@ class ProcessRecord implements WindowProcessListener {
_service.mPackageManagerInt.getProcessesForUid(_uid); _service.mPackageManagerInt.getProcessesForUid(_uid);
if (processes != null) { if (processes != null) {
procInfo = processes.get(_processName); procInfo = processes.get(_processName);
if (procInfo != null && procInfo.deniedPermissions == null) { if (procInfo != null && procInfo.deniedPermissions == null
// If this process hasn't asked for permissions to be denied, then && procInfo.gwpAsanMode == ApplicationInfo.GWP_ASAN_DEFAULT) {
// we don't care about it. // If this process hasn't asked for permissions to be denied, or for a
// non-default GwpAsan mode, then we don't care about it.
procInfo = null; procInfo = null;
} }
} }

View File

@@ -393,7 +393,7 @@ public class PackageInfoUtils {
ParsedProcess proc = procs.get(key); ParsedProcess proc = procs.get(key);
retProcs.put(proc.getName(), retProcs.put(proc.getName(),
new ProcessInfo(proc.getName(), new ArraySet<>(proc.getDeniedPermissions()), new ProcessInfo(proc.getName(), new ArraySet<>(proc.getDeniedPermissions()),
proc.getEnableGwpAsan())); proc.getGwpAsanMode()));
} }
return retProcs; return retProcs;
} }