Merge changes I91a61b38,Ia7e4e035
* changes: Convert Integer/Float/Boolean to primitive types Using float instead of Float in ParsedActivity
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.content.pm;
|
||||
|
||||
import android.annotation.FloatRange;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.TestApi;
|
||||
import android.app.Activity;
|
||||
@@ -1368,8 +1369,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void setMaxAspectRatio(float maxAspectRatio) {
|
||||
this.mMaxAspectRatio = maxAspectRatio;
|
||||
public void setMaxAspectRatio(@FloatRange(from = 0f) float maxAspectRatio) {
|
||||
this.mMaxAspectRatio = maxAspectRatio >= 0f ? maxAspectRatio : 0f;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -1378,8 +1379,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void setMinAspectRatio(float minAspectRatio) {
|
||||
this.mMinAspectRatio = minAspectRatio;
|
||||
public void setMinAspectRatio(@FloatRange(from = 0f) float minAspectRatio) {
|
||||
this.mMinAspectRatio = minAspectRatio >= 0f ? minAspectRatio : 0f;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -531,10 +531,8 @@ public class PackageInfoWithoutStateUtils {
|
||||
ai.lockTaskLaunchMode = a.getLockTaskLaunchMode();
|
||||
ai.screenOrientation = a.getScreenOrientation();
|
||||
ai.resizeMode = a.getResizeMode();
|
||||
Float maxAspectRatio = a.getMaxAspectRatio();
|
||||
ai.setMaxAspectRatio(maxAspectRatio != null ? maxAspectRatio : 0f);
|
||||
Float minAspectRatio = a.getMinAspectRatio();
|
||||
ai.setMinAspectRatio(minAspectRatio != null ? minAspectRatio : 0f);
|
||||
ai.setMaxAspectRatio(a.getMaxAspectRatio());
|
||||
ai.setMinAspectRatio(a.getMinAspectRatio());
|
||||
ai.supportsSizeChanges = a.isSupportsSizeChanges();
|
||||
ai.requestedVrComponent = a.getRequestedVrComponent();
|
||||
ai.rotationAnimation = a.getRotationAnimation();
|
||||
|
||||
@@ -150,6 +150,7 @@ public class ParsingPackageUtils {
|
||||
public static final boolean DEBUG_JAR = false;
|
||||
public static final boolean DEBUG_BACKUP = false;
|
||||
public static final float DEFAULT_PRE_O_MAX_ASPECT_RATIO = 1.86f;
|
||||
public static final float ASPECT_RATIO_NOT_SET = -1f;
|
||||
|
||||
/** File name in an APK for the Android manifest. */
|
||||
public static final String ANDROID_MANIFEST_FILENAME = "AndroidManifest.xml";
|
||||
@@ -2096,7 +2097,7 @@ public class ParsingPackageUtils {
|
||||
pkg.setGwpAsanMode(sa.getInt(R.styleable.AndroidManifestApplication_gwpAsanMode, -1));
|
||||
pkg.setMemtagMode(sa.getInt(R.styleable.AndroidManifestApplication_memtagMode, -1));
|
||||
if (sa.hasValue(R.styleable.AndroidManifestApplication_nativeHeapZeroInitialized)) {
|
||||
Boolean v = sa.getBoolean(
|
||||
final boolean v = sa.getBoolean(
|
||||
R.styleable.AndroidManifestApplication_nativeHeapZeroInitialized, false);
|
||||
pkg.setNativeHeapZeroInitialized(
|
||||
v ? ApplicationInfo.ZEROINIT_ENABLED : ApplicationInfo.ZEROINIT_DISABLED);
|
||||
@@ -2677,7 +2678,7 @@ public class ParsingPackageUtils {
|
||||
for (int index = 0; index < activitiesSize; index++) {
|
||||
ParsedActivity activity = activities.get(index);
|
||||
// If the max aspect ratio for the activity has already been set, skip.
|
||||
if (activity.getMaxAspectRatio() != null) {
|
||||
if (activity.getMaxAspectRatio() != ASPECT_RATIO_NOT_SET) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2706,7 +2707,7 @@ public class ParsingPackageUtils {
|
||||
int activitiesSize = activities.size();
|
||||
for (int index = 0; index < activitiesSize; index++) {
|
||||
ParsedActivity activity = activities.get(index);
|
||||
if (activity.getMinAspectRatio() == null) {
|
||||
if (activity.getMinAspectRatio() == ASPECT_RATIO_NOT_SET) {
|
||||
activity.setMinAspectRatio(activity.getResizeMode(), minAspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public class ParsingUtils {
|
||||
public static final int DEFAULT_MIN_SDK_VERSION = 1;
|
||||
public static final int DEFAULT_TARGET_SDK_VERSION = 0;
|
||||
|
||||
public static final int NOT_SET = -1;
|
||||
|
||||
@Nullable
|
||||
public static String buildClassName(String pkg, CharSequence clsSeq) {
|
||||
if (clsSeq == null || clsSeq.length() <= 0) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
|
||||
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
import static android.content.pm.parsing.ParsingPackageImpl.sForInternedString;
|
||||
import static android.content.pm.parsing.ParsingPackageUtils.ASPECT_RATIO_NOT_SET;
|
||||
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
@@ -67,11 +68,8 @@ public class ParsedActivity extends ParsedMainComponent {
|
||||
private int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
private int resizeMode = ActivityInfo.RESIZE_MODE_RESIZEABLE;
|
||||
|
||||
@Nullable
|
||||
private Float maxAspectRatio;
|
||||
|
||||
@Nullable
|
||||
private Float minAspectRatio;
|
||||
private float maxAspectRatio = ASPECT_RATIO_NOT_SET;
|
||||
private float minAspectRatio = ASPECT_RATIO_NOT_SET;
|
||||
|
||||
private boolean supportsSizeChanges;
|
||||
|
||||
@@ -234,7 +232,7 @@ public class ParsedActivity extends ParsedMainComponent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParsedActivity setMaxAspectRatio(Float maxAspectRatio) {
|
||||
public ParsedActivity setMaxAspectRatio(float maxAspectRatio) {
|
||||
this.maxAspectRatio = maxAspectRatio;
|
||||
return this;
|
||||
}
|
||||
@@ -260,7 +258,7 @@ public class ParsedActivity extends ParsedMainComponent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParsedActivity setMinAspectRatio(Float minAspectRatio) {
|
||||
public ParsedActivity setMinAspectRatio(float minAspectRatio) {
|
||||
this.minAspectRatio = minAspectRatio;
|
||||
return this;
|
||||
}
|
||||
@@ -375,8 +373,8 @@ public class ParsedActivity extends ParsedMainComponent {
|
||||
dest.writeInt(this.lockTaskLaunchMode);
|
||||
dest.writeInt(this.screenOrientation);
|
||||
dest.writeInt(this.resizeMode);
|
||||
dest.writeValue(this.maxAspectRatio);
|
||||
dest.writeValue(this.minAspectRatio);
|
||||
dest.writeFloat(this.maxAspectRatio);
|
||||
dest.writeFloat(this.minAspectRatio);
|
||||
dest.writeBoolean(this.supportsSizeChanges);
|
||||
dest.writeString(this.requestedVrComponent);
|
||||
dest.writeInt(this.rotationAnimation);
|
||||
@@ -412,8 +410,8 @@ public class ParsedActivity extends ParsedMainComponent {
|
||||
this.lockTaskLaunchMode = in.readInt();
|
||||
this.screenOrientation = in.readInt();
|
||||
this.resizeMode = in.readInt();
|
||||
this.maxAspectRatio = (Float) in.readValue(Float.class.getClassLoader());
|
||||
this.minAspectRatio = (Float) in.readValue(Float.class.getClassLoader());
|
||||
this.maxAspectRatio = in.readFloat();
|
||||
this.minAspectRatio = in.readFloat();
|
||||
this.supportsSizeChanges = in.readBoolean();
|
||||
this.requestedVrComponent = in.readString();
|
||||
this.rotationAnimation = in.readInt();
|
||||
@@ -505,13 +503,11 @@ public class ParsedActivity extends ParsedMainComponent {
|
||||
return resizeMode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Float getMaxAspectRatio() {
|
||||
public float getMaxAspectRatio() {
|
||||
return maxAspectRatio;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Float getMinAspectRatio() {
|
||||
public float getMinAspectRatio() {
|
||||
return minAspectRatio;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.content.pm.parsing.component;
|
||||
|
||||
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE_PER_TASK;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
import static android.content.pm.parsing.ParsingUtils.NOT_SET;
|
||||
import static android.content.pm.parsing.component.ComponentParseUtils.flag;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
@@ -269,15 +270,15 @@ public class ParsedActivityUtils {
|
||||
activity, tag, null, pkg, sa, 0, useRoundIcon, input,
|
||||
R.styleable.AndroidManifestActivityAlias_banner,
|
||||
R.styleable.AndroidManifestActivityAlias_description,
|
||||
null /*directBootAwareAttr*/,
|
||||
NOT_SET /*directBootAwareAttr*/,
|
||||
R.styleable.AndroidManifestActivityAlias_enabled,
|
||||
R.styleable.AndroidManifestActivityAlias_icon,
|
||||
R.styleable.AndroidManifestActivityAlias_label,
|
||||
R.styleable.AndroidManifestActivityAlias_logo,
|
||||
R.styleable.AndroidManifestActivityAlias_name,
|
||||
null /*processAttr*/,
|
||||
NOT_SET /*processAttr*/,
|
||||
R.styleable.AndroidManifestActivityAlias_roundIcon,
|
||||
null /*splitNameAttr*/,
|
||||
NOT_SET /*splitNameAttr*/,
|
||||
R.styleable.AndroidManifestActivityAlias_attributionTags);
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
package android.content.pm.parsing.component;
|
||||
|
||||
import static android.content.pm.parsing.ParsingUtils.NOT_SET;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.Property;
|
||||
import android.content.pm.parsing.ParsingPackage;
|
||||
@@ -41,9 +42,8 @@ class ParsedComponentUtils {
|
||||
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
|
||||
static <Component extends ParsedComponent> ParseResult<Component> parseComponent(
|
||||
Component component, String tag, ParsingPackage pkg, TypedArray array,
|
||||
boolean useRoundIcon, ParseInput input, int bannerAttr,
|
||||
@Nullable Integer descriptionAttr, int iconAttr, int labelAttr, int logoAttr,
|
||||
int nameAttr, int roundIconAttr) {
|
||||
boolean useRoundIcon, ParseInput input, int bannerAttr, int descriptionAttr,
|
||||
int iconAttr, int labelAttr, int logoAttr, int nameAttr, int roundIconAttr) {
|
||||
String name = array.getNonConfigurationString(nameAttr, 0);
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
return input.error(tag + " does not specify android:name");
|
||||
@@ -81,7 +81,7 @@ class ParsedComponentUtils {
|
||||
component.setBanner(bannerVal);
|
||||
}
|
||||
|
||||
if (descriptionAttr != null) {
|
||||
if (descriptionAttr != NOT_SET) {
|
||||
component.setDescriptionRes(array.getResourceId(descriptionAttr, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,17 @@
|
||||
|
||||
package android.content.pm.parsing.component;
|
||||
|
||||
import static android.content.pm.parsing.ParsingUtils.NOT_SET;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.pm.parsing.ParsingPackage;
|
||||
import android.content.pm.parsing.result.ParseInput;
|
||||
import android.content.pm.parsing.result.ParseResult;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
|
||||
import com.android.internal.R;
|
||||
import android.content.pm.parsing.result.ParseInput;
|
||||
import android.content.pm.parsing.result.ParseResult;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
@@ -46,7 +48,7 @@ public class ParsedInstrumentationUtils {
|
||||
ParseResult<ParsedInstrumentation> result = ParsedComponentUtils.parseComponent(
|
||||
instrumentation, tag, pkg, sa, useRoundIcon, input,
|
||||
R.styleable.AndroidManifestInstrumentation_banner,
|
||||
null /*descriptionAttr*/,
|
||||
NOT_SET /*descriptionAttr*/,
|
||||
R.styleable.AndroidManifestInstrumentation_icon,
|
||||
R.styleable.AndroidManifestInstrumentation_label,
|
||||
R.styleable.AndroidManifestInstrumentation_logo,
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
package android.content.pm.parsing.component;
|
||||
|
||||
import static android.content.pm.parsing.ParsingUtils.NOT_SET;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.parsing.ParsingPackage;
|
||||
import android.content.pm.parsing.ParsingUtils;
|
||||
@@ -45,11 +46,10 @@ class ParsedMainComponentUtils {
|
||||
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
|
||||
static <Component extends ParsedMainComponent> ParseResult<Component> parseMainComponent(
|
||||
Component component, String tag, String[] separateProcesses, ParsingPackage pkg,
|
||||
TypedArray array, int flags, boolean useRoundIcon, ParseInput input,
|
||||
int bannerAttr, int descriptionAttr, @Nullable Integer directBootAwareAttr,
|
||||
@Nullable Integer enabledAttr, int iconAttr, int labelAttr, int logoAttr, int nameAttr,
|
||||
@Nullable Integer processAttr, int roundIconAttr, @Nullable Integer splitNameAttr,
|
||||
@Nullable Integer attributionTagsAttr) {
|
||||
TypedArray array, int flags, boolean useRoundIcon, ParseInput input, int bannerAttr,
|
||||
int descriptionAttr, int directBootAwareAttr, int enabledAttr, int iconAttr,
|
||||
int labelAttr, int logoAttr, int nameAttr, int processAttr, int roundIconAttr,
|
||||
int splitNameAttr, int attributionTagsAttr) {
|
||||
ParseResult<Component> result = ParsedComponentUtils.parseComponent(component, tag, pkg,
|
||||
array, useRoundIcon, input, bannerAttr, descriptionAttr, iconAttr, labelAttr,
|
||||
logoAttr, nameAttr, roundIconAttr);
|
||||
@@ -57,18 +57,18 @@ class ParsedMainComponentUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (directBootAwareAttr != null) {
|
||||
if (directBootAwareAttr != NOT_SET) {
|
||||
component.setDirectBootAware(array.getBoolean(directBootAwareAttr, false));
|
||||
if (component.isDirectBootAware()) {
|
||||
pkg.setPartiallyDirectBootAware(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (enabledAttr != null) {
|
||||
if (enabledAttr != NOT_SET) {
|
||||
component.setEnabled(array.getBoolean(enabledAttr, true));
|
||||
}
|
||||
|
||||
if (processAttr != null) {
|
||||
if (processAttr != NOT_SET) {
|
||||
CharSequence processName;
|
||||
if (pkg.getTargetSdkVersion() >= Build.VERSION_CODES.FROYO) {
|
||||
processName = array.getNonConfigurationString(processAttr,
|
||||
@@ -91,11 +91,11 @@ class ParsedMainComponentUtils {
|
||||
component.setProcessName(processNameResult.getResult());
|
||||
}
|
||||
|
||||
if (splitNameAttr != null) {
|
||||
if (splitNameAttr != NOT_SET) {
|
||||
component.setSplitName(array.getNonConfigurationString(splitNameAttr, 0));
|
||||
}
|
||||
|
||||
if (attributionTagsAttr != null) {
|
||||
if (attributionTagsAttr != NOT_SET) {
|
||||
final String attributionTags = array.getNonConfigurationString(attributionTagsAttr, 0);
|
||||
if (attributionTags != null) {
|
||||
component.setAttributionTags(attributionTags.split("\\|"));
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.content.pm.parsing.component;
|
||||
|
||||
import static android.content.pm.parsing.ParsingUtils.NOT_SET;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.pm.PermissionInfo;
|
||||
import android.content.pm.parsing.ParsingPackage;
|
||||
@@ -163,7 +165,7 @@ public class ParsedPermissionUtils {
|
||||
result = ParsedComponentUtils.parseComponent(
|
||||
permission, tag, pkg, sa, useRoundIcon, input,
|
||||
R.styleable.AndroidManifestPermissionTree_banner,
|
||||
null /*descriptionAttr*/,
|
||||
NOT_SET /*descriptionAttr*/,
|
||||
R.styleable.AndroidManifestPermissionTree_icon,
|
||||
R.styleable.AndroidManifestPermissionTree_label,
|
||||
R.styleable.AndroidManifestPermissionTree_logo,
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ParsedProcessUtils {
|
||||
proc.setGwpAsanMode(sa.getInt(R.styleable.AndroidManifestProcess_gwpAsanMode, -1));
|
||||
proc.setMemtagMode(sa.getInt(R.styleable.AndroidManifestProcess_memtagMode, -1));
|
||||
if (sa.hasValue(R.styleable.AndroidManifestProcess_nativeHeapZeroInitialized)) {
|
||||
Boolean v = sa.getBoolean(
|
||||
final boolean v = sa.getBoolean(
|
||||
R.styleable.AndroidManifestProcess_nativeHeapZeroInitialized, false);
|
||||
proc.setNativeHeapZeroInitialized(
|
||||
v ? ApplicationInfo.ZEROINIT_ENABLED : ApplicationInfo.ZEROINIT_DISABLED);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.content.pm.parsing.result;
|
||||
|
||||
import static android.content.pm.parsing.ParsingUtils.NOT_SET;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
@@ -62,7 +64,7 @@ public class ParseTypeImpl implements ParseInput, ParseResult<Object> {
|
||||
private ArrayMap<Long, String> mDeferredErrors = null;
|
||||
|
||||
private String mPackageName;
|
||||
private Integer mTargetSdkVersion;
|
||||
private int mTargetSdkVersion = NOT_SET;
|
||||
|
||||
/**
|
||||
* Specifically for {@link PackageManager#getPackageArchiveInfo(String, int)} where
|
||||
@@ -119,7 +121,7 @@ public class ParseTypeImpl implements ParseInput, ParseResult<Object> {
|
||||
// how many APKs they're going through.
|
||||
mDeferredErrors.erase();
|
||||
}
|
||||
mTargetSdkVersion = null;
|
||||
mTargetSdkVersion = NOT_SET;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@ public class ParseTypeImpl implements ParseInput, ParseResult<Object> {
|
||||
if (DEBUG_THROW_ALL_ERRORS) {
|
||||
return error(parseError);
|
||||
}
|
||||
if (mTargetSdkVersion != null) {
|
||||
if (mTargetSdkVersion != NOT_SET) {
|
||||
if (mDeferredErrors != null && mDeferredErrors.containsKey(deferredError)) {
|
||||
// If the map already contains the key, that means it's already been checked and
|
||||
// found to be disabled. Otherwise it would've failed when mTargetSdkVersion was
|
||||
|
||||
Reference in New Issue
Block a user