Merge "Merge "[wm] Introduce meta-data tag (android.supports_size_changes)" into rvc-dev am: 247144d4a2 am: 925463ba53 am: e9f14eeb22" into rvc-qpr-dev-plus-aosp

This commit is contained in:
Automerger Merge Worker
2020-06-01 22:06:48 +00:00
committed by Android (Google) Code Review
6 changed files with 68 additions and 0 deletions

View File

@@ -244,6 +244,13 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
*/
public float minAspectRatio;
/**
* Indicates that the activity works well with size changes like display changing size.
*
* @hide
*/
public boolean supportsSizeChanges;
/**
* Name of the VrListenerService component to run for this activity.
* @see android.R.attr#enableVrMode
@@ -1013,6 +1020,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
colorMode = orig.colorMode;
maxAspectRatio = orig.maxAspectRatio;
minAspectRatio = orig.minAspectRatio;
supportsSizeChanges = orig.supportsSizeChanges;
}
/**
@@ -1188,6 +1196,9 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
if (minAspectRatio != 0) {
pw.println(prefix + "minAspectRatio=" + minAspectRatio);
}
if (supportsSizeChanges) {
pw.println(prefix + "supportsSizeChanges=true");
}
super.dumpBack(pw, prefix, dumpFlags);
}
@@ -1232,6 +1243,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
dest.writeInt(colorMode);
dest.writeFloat(maxAspectRatio);
dest.writeFloat(minAspectRatio);
dest.writeBoolean(supportsSizeChanges);
}
/**
@@ -1350,6 +1362,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
colorMode = source.readInt();
maxAspectRatio = source.readFloat();
minAspectRatio = source.readFloat();
supportsSizeChanges = source.readBoolean();
}
/**

View File

@@ -207,6 +207,7 @@ public class PackageParser {
public static final String TAG_USES_SPLIT = "uses-split";
public static final String METADATA_MAX_ASPECT_RATIO = "android.max_aspect";
public static final String METADATA_SUPPORTS_SIZE_CHANGES = "android.supports_size_changes";
public static final String METADATA_ACTIVITY_WINDOW_LAYOUT_AFFINITY =
"android.activity_window_layout_affinity";
@@ -3897,6 +3898,7 @@ public class PackageParser {
// every activity info has had a chance to set it from its attributes.
setMaxAspectRatio(owner);
setMinAspectRatio(owner);
setSupportsSizeChanges(owner);
if (hasDomainURLs(owner)) {
owner.applicationInfo.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS;
@@ -4694,6 +4696,18 @@ public class PackageParser {
}
}
private void setSupportsSizeChanges(Package owner) {
final boolean supportsSizeChanges = owner.mAppMetaData != null
&& owner.mAppMetaData.getBoolean(METADATA_SUPPORTS_SIZE_CHANGES, false);
for (Activity activity : owner.activities) {
if (supportsSizeChanges || (activity.metaData != null
&& activity.metaData.getBoolean(METADATA_SUPPORTS_SIZE_CHANGES, false))) {
activity.info.supportsSizeChanges = true;
}
}
}
/**
* @param configChanges The bit mask of configChanges fetched from AndroidManifest.xml.
* @param recreateOnConfigChanges The bit mask recreateOnConfigChanges fetched from
@@ -4863,6 +4877,7 @@ public class PackageParser {
info.resizeMode = target.info.resizeMode;
info.maxAspectRatio = target.info.maxAspectRatio;
info.minAspectRatio = target.info.minAspectRatio;
info.supportsSizeChanges = target.info.supportsSizeChanges;
info.requestedVrComponent = target.info.requestedVrComponent;
info.directBootAware = target.info.directBootAware;

View File

@@ -445,6 +445,7 @@ public class PackageInfoWithoutStateUtils {
ai.maxAspectRatio = maxAspectRatio != null ? maxAspectRatio : 0f;
Float minAspectRatio = a.getMinAspectRatio();
ai.minAspectRatio = minAspectRatio != null ? minAspectRatio : 0f;
ai.supportsSizeChanges = a.getSupportsSizeChanges();
ai.requestedVrComponent = a.getRequestedVrComponent();
ai.rotationAnimation = a.getRotationAnimation();
ai.colorMode = a.getColorMode();

View File

@@ -1912,6 +1912,7 @@ public class ParsingPackageUtils {
// every activity info has had a chance to set it from its attributes.
setMaxAspectRatio(pkg);
setMinAspectRatio(pkg);
setSupportsSizeChanges(pkg);
pkg.setHasDomainUrls(hasDomainURLs(pkg));
@@ -2366,6 +2367,23 @@ public class ParsingPackageUtils {
}
}
private void setSupportsSizeChanges(ParsingPackage pkg) {
final Bundle appMetaData = pkg.getMetaData();
final boolean supportsSizeChanges = appMetaData != null
&& appMetaData.getBoolean(PackageParser.METADATA_SUPPORTS_SIZE_CHANGES, false);
List<ParsedActivity> activities = pkg.getActivities();
int activitiesSize = activities.size();
for (int index = 0; index < activitiesSize; index++) {
ParsedActivity activity = activities.get(index);
if (supportsSizeChanges || (activity.getMetaData() != null
&& activity.getMetaData().getBoolean(
PackageParser.METADATA_SUPPORTS_SIZE_CHANGES, false))) {
activity.setSupportsSizeChanges(true);
}
}
}
private static ParseResult<ParsingPackage> parseOverlay(ParseInput input, ParsingPackage pkg,
Resources res, XmlResourceParser parser) {
TypedArray sa = res.obtainAttributes(parser, R.styleable.AndroidManifestResourceOverlay);

View File

@@ -73,6 +73,8 @@ public class ParsedActivity extends ParsedMainComponent {
@Nullable
private Float minAspectRatio;
private boolean supportsSizeChanges;
@Nullable
String requestedVrComponent;
int rotationAnimation = -1;
@@ -101,6 +103,7 @@ public class ParsedActivity extends ParsedMainComponent {
this.resizeMode = other.resizeMode;
this.maxAspectRatio = other.maxAspectRatio;
this.minAspectRatio = other.minAspectRatio;
this.supportsSizeChanges = other.supportsSizeChanges;
this.requestedVrComponent = other.requestedVrComponent;
this.rotationAnimation = other.rotationAnimation;
this.colorMode = other.colorMode;
@@ -165,6 +168,7 @@ public class ParsedActivity extends ParsedMainComponent {
alias.resizeMode = target.resizeMode;
alias.maxAspectRatio = target.maxAspectRatio;
alias.minAspectRatio = target.minAspectRatio;
alias.supportsSizeChanges = target.supportsSizeChanges;
alias.requestedVrComponent = target.requestedVrComponent;
alias.directBootAware = target.directBootAware;
alias.setProcessName(target.getProcessName());
@@ -217,6 +221,11 @@ public class ParsedActivity extends ParsedMainComponent {
return this;
}
public ParsedActivity setSupportsSizeChanges(boolean supportsSizeChanges) {
this.supportsSizeChanges = supportsSizeChanges;
return this;
}
public ParsedActivity setFlags(int flags) {
this.flags = flags;
return this;
@@ -279,6 +288,7 @@ public class ParsedActivity extends ParsedMainComponent {
dest.writeInt(this.resizeMode);
dest.writeValue(this.maxAspectRatio);
dest.writeValue(this.minAspectRatio);
dest.writeBoolean(this.supportsSizeChanges);
dest.writeString(this.requestedVrComponent);
dest.writeInt(this.rotationAnimation);
dest.writeInt(this.colorMode);
@@ -315,6 +325,7 @@ public class ParsedActivity extends ParsedMainComponent {
this.resizeMode = in.readInt();
this.maxAspectRatio = (Float) in.readValue(Float.class.getClassLoader());
this.minAspectRatio = (Float) in.readValue(Float.class.getClassLoader());
this.supportsSizeChanges = in.readBoolean();
this.requestedVrComponent = in.readString();
this.rotationAnimation = in.readInt();
this.colorMode = in.readInt();
@@ -414,6 +425,10 @@ public class ParsedActivity extends ParsedMainComponent {
return minAspectRatio;
}
public boolean getSupportsSizeChanges() {
return supportsSizeChanges;
}
@Nullable
public String getRequestedVrComponent() {
return requestedVrComponent;

View File

@@ -1001,6 +1001,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (info.minAspectRatio != 0) {
pw.println(prefix + "minAspectRatio=" + info.minAspectRatio);
}
if (info.supportsSizeChanges) {
pw.println(prefix + "supportsSizeChanges=true");
}
}
}
@@ -6376,6 +6379,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
* aspect ratio.
*/
boolean shouldUseSizeCompatMode() {
if (info.supportsSizeChanges) {
return false;
}
if (inMultiWindowMode() || getWindowConfiguration().hasWindowDecorCaption()) {
final ActivityRecord root = task != null ? task.getRootActivity() : null;
if (root != null && root != this && !root.shouldUseSizeCompatMode()) {