summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Benjamin Franz <bfranz@google.com> 2021-01-12 16:22:18 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-01-12 16:22:18 +0000
commit899cd8920b4ded09e7c623ef2076ade54ffab24c (patch)
tree30bc278a832cdf07453770739a42f1906c360d04
parent88f04b79bdb32a91cf0cd67799ef5e0d9fefbdeb (diff)
parent458515e464b1fcd61338076f294c9c4752d60053 (diff)
Merge "Add new overridable annotation to platform compat" am: 458515e464
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1540124 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Icdb84460fab8ec12e185a6f78afa0efd8de2d3b5
-rw-r--r--core/java/com/android/internal/compat/CompatibilityChangeInfo.java18
-rw-r--r--services/core/java/com/android/server/compat/CompatChange.java12
-rw-r--r--services/core/xsd/platform-compat-config.xsd5
-rw-r--r--services/core/xsd/platform-compat-schema/current.txt2
-rw-r--r--services/tests/servicestests/src/com/android/server/compat/CompatConfigBuilder.java35
-rw-r--r--services/tests/servicestests/src/com/android/server/compat/PlatformCompatTest.java31
6 files changed, 64 insertions, 39 deletions
diff --git a/core/java/com/android/internal/compat/CompatibilityChangeInfo.java b/core/java/com/android/internal/compat/CompatibilityChangeInfo.java
index 670ca9f6091e..03fe4551c249 100644
--- a/core/java/com/android/internal/compat/CompatibilityChangeInfo.java
+++ b/core/java/com/android/internal/compat/CompatibilityChangeInfo.java
@@ -32,6 +32,7 @@ public class CompatibilityChangeInfo implements Parcelable {
private final boolean mDisabled;
private final boolean mLoggingOnly;
private final @Nullable String mDescription;
+ private final boolean mOverridable;
public long getId() {
return mChangeId;
@@ -58,9 +59,13 @@ public class CompatibilityChangeInfo implements Parcelable {
return mDescription;
}
+ public boolean getOverridable() {
+ return mOverridable;
+ }
+
public CompatibilityChangeInfo(
Long changeId, String name, int enableAfterTargetSdk, int enableSinceTargetSdk,
- boolean disabled, boolean loggingOnly, String description) {
+ boolean disabled, boolean loggingOnly, String description, boolean overridable) {
this.mChangeId = changeId;
this.mName = name;
if (enableAfterTargetSdk > 0) {
@@ -75,6 +80,7 @@ public class CompatibilityChangeInfo implements Parcelable {
this.mDisabled = disabled;
this.mLoggingOnly = loggingOnly;
this.mDescription = description;
+ this.mOverridable = overridable;
}
public CompatibilityChangeInfo(CompatibilityChangeInfo other) {
@@ -84,6 +90,7 @@ public class CompatibilityChangeInfo implements Parcelable {
this.mDisabled = other.mDisabled;
this.mLoggingOnly = other.mLoggingOnly;
this.mDescription = other.mDescription;
+ this.mOverridable = other.mOverridable;
}
private CompatibilityChangeInfo(Parcel in) {
@@ -93,6 +100,7 @@ public class CompatibilityChangeInfo implements Parcelable {
mDisabled = in.readBoolean();
mLoggingOnly = in.readBoolean();
mDescription = in.readString();
+ mOverridable = in.readBoolean();
}
@Override
@@ -108,6 +116,7 @@ public class CompatibilityChangeInfo implements Parcelable {
dest.writeBoolean(mDisabled);
dest.writeBoolean(mLoggingOnly);
dest.writeString(mDescription);
+ dest.writeBoolean(mOverridable);
}
@Override
@@ -126,6 +135,9 @@ public class CompatibilityChangeInfo implements Parcelable {
if (getLoggingOnly()) {
sb.append("; loggingOnly");
}
+ if (getOverridable()) {
+ sb.append("; overridable");
+ }
return sb.append(")").toString();
}
@@ -143,8 +155,8 @@ public class CompatibilityChangeInfo implements Parcelable {
&& this.mEnableSinceTargetSdk == that.mEnableSinceTargetSdk
&& this.mDisabled == that.mDisabled
&& this.mLoggingOnly == that.mLoggingOnly
- && this.mDescription.equals(that.mDescription);
-
+ && this.mDescription.equals(that.mDescription)
+ && this.mOverridable == that.mOverridable;
}
public static final Parcelable.Creator<CompatibilityChangeInfo> CREATOR =
diff --git a/services/core/java/com/android/server/compat/CompatChange.java b/services/core/java/com/android/server/compat/CompatChange.java
index 18907a19f96d..9ba957ef27ae 100644
--- a/services/core/java/com/android/server/compat/CompatChange.java
+++ b/services/core/java/com/android/server/compat/CompatChange.java
@@ -64,7 +64,7 @@ public final class CompatChange extends CompatibilityChangeInfo {
private Map<String, Boolean> mDeferredOverrides;
public CompatChange(long changeId) {
- this(changeId, null, -1, -1, false, false, null);
+ this(changeId, null, -1, -1, false, false, null, false);
}
/**
@@ -77,9 +77,10 @@ public final class CompatChange extends CompatibilityChangeInfo {
* @param disabled If {@code true}, overrides any {@code enableAfterTargetSdk} set.
*/
public CompatChange(long changeId, @Nullable String name, int enableAfterTargetSdk,
- int enableSinceTargetSdk, boolean disabled, boolean loggingOnly, String description) {
+ int enableSinceTargetSdk, boolean disabled, boolean loggingOnly, String description,
+ boolean overridable) {
super(changeId, name, enableAfterTargetSdk, enableSinceTargetSdk, disabled, loggingOnly,
- description);
+ description, overridable);
}
/**
@@ -88,7 +89,7 @@ public final class CompatChange extends CompatibilityChangeInfo {
public CompatChange(Change change) {
super(change.getId(), change.getName(), change.getEnableAfterTargetSdk(),
change.getEnableSinceTargetSdk(), change.getDisabled(), change.getLoggingOnly(),
- change.getDescription());
+ change.getDescription(), change.getOverridable());
}
void registerListener(ChangeListener listener) {
@@ -274,6 +275,9 @@ public final class CompatChange extends CompatibilityChangeInfo {
if (mDeferredOverrides != null && mDeferredOverrides.size() > 0) {
sb.append("; deferredOverrides=").append(mDeferredOverrides);
}
+ if (getOverridable()) {
+ sb.append("; overridable");
+ }
return sb.append(")").toString();
}
diff --git a/services/core/xsd/platform-compat-config.xsd b/services/core/xsd/platform-compat-config.xsd
index 992470816068..a62e2c385766 100644
--- a/services/core/xsd/platform-compat-config.xsd
+++ b/services/core/xsd/platform-compat-config.xsd
@@ -31,6 +31,7 @@
<xs:attribute type="xs:int" name="enableAfterTargetSdk"/>
<xs:attribute type="xs:int" name="enableSinceTargetSdk"/>
<xs:attribute type="xs:string" name="description"/>
+ <xs:attribute type="xs:boolean" name="overridable"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
@@ -48,7 +49,3 @@
</xs:unique>
</xs:element>
</xs:schema>
-
-
-
-
diff --git a/services/core/xsd/platform-compat-schema/current.txt b/services/core/xsd/platform-compat-schema/current.txt
index e3640edd0201..fb8bbefd8374 100644
--- a/services/core/xsd/platform-compat-schema/current.txt
+++ b/services/core/xsd/platform-compat-schema/current.txt
@@ -10,6 +10,7 @@ package com.android.server.compat.config {
method public long getId();
method public boolean getLoggingOnly();
method public String getName();
+ method public boolean getOverridable();
method public String getValue();
method public void setDescription(String);
method public void setDisabled(boolean);
@@ -18,6 +19,7 @@ package com.android.server.compat.config {
method public void setId(long);
method public void setLoggingOnly(boolean);
method public void setName(String);
+ method public void setOverridable(boolean);
method public void setValue(String);
}
diff --git a/services/tests/servicestests/src/com/android/server/compat/CompatConfigBuilder.java b/services/tests/servicestests/src/com/android/server/compat/CompatConfigBuilder.java
index 4f4aa3f16f09..f00edcc85404 100644
--- a/services/tests/servicestests/src/com/android/server/compat/CompatConfigBuilder.java
+++ b/services/tests/servicestests/src/com/android/server/compat/CompatConfigBuilder.java
@@ -40,78 +40,83 @@ class CompatConfigBuilder {
}
CompatConfigBuilder addEnableAfterSdkChangeWithId(int sdk, long id) {
- mChanges.add(new CompatChange(id, "", sdk, -1, false, false, ""));
+ mChanges.add(new CompatChange(id, "", sdk, -1, false, false, "", false));
return this;
}
CompatConfigBuilder addEnableAfterSdkChangeWithIdAndName(int sdk, long id, String name) {
- mChanges.add(new CompatChange(id, name, sdk, -1, false, false, ""));
+ mChanges.add(new CompatChange(id, name, sdk, -1, false, false, "", false));
return this;
}
CompatConfigBuilder addEnableAfterSdkChangeWithIdDefaultDisabled(int sdk, long id) {
- mChanges.add(new CompatChange(id, "", sdk, -1, true, false, ""));
+ mChanges.add(new CompatChange(id, "", sdk, -1, true, false, "", false));
return this;
}
CompatConfigBuilder addEnableAfterSdkChangeWithIdAndDescription(int sdk, long id,
String description) {
- mChanges.add(new CompatChange(id, "", sdk, -1, false, false, description));
+ mChanges.add(new CompatChange(id, "", sdk, -1, false, false, description, false));
return this;
}
CompatConfigBuilder addEnableSinceSdkChangeWithId(int sdk, long id) {
- mChanges.add(new CompatChange(id, "", -1, sdk, false, false, ""));
+ mChanges.add(new CompatChange(id, "", -1, sdk, false, false, "", false));
return this;
}
CompatConfigBuilder addEnableSinceSdkChangeWithIdAndName(int sdk, long id, String name) {
- mChanges.add(new CompatChange(id, name, -1, sdk, false, false, ""));
+ mChanges.add(new CompatChange(id, name, -1, sdk, false, false, "", false));
return this;
}
CompatConfigBuilder addEnableSinceSdkChangeWithIdDefaultDisabled(int sdk, long id) {
- mChanges.add(new CompatChange(id, "", -1, sdk, true, false, ""));
+ mChanges.add(new CompatChange(id, "", -1, sdk, true, false, "", false));
return this;
}
CompatConfigBuilder addEnableSinceSdkChangeWithIdAndDescription(int sdk, long id,
String description) {
- mChanges.add(new CompatChange(id, "", -1, sdk, false, false, description));
+ mChanges.add(new CompatChange(id, "", -1, sdk, false, false, description, false));
return this;
}
CompatConfigBuilder addEnabledChangeWithId(long id) {
- mChanges.add(new CompatChange(id, "", -1, -1, false, false, ""));
+ mChanges.add(new CompatChange(id, "", -1, -1, false, false, "", false));
return this;
}
CompatConfigBuilder addEnabledChangeWithIdAndName(long id, String name) {
- mChanges.add(new CompatChange(id, name, -1, -1, false, false, ""));
+ mChanges.add(new CompatChange(id, name, -1, -1, false, false, "", false));
return this;
}
CompatConfigBuilder addEnabledChangeWithIdAndDescription(long id, String description) {
- mChanges.add(new CompatChange(id, "", -1, -1, false, false, description));
+ mChanges.add(new CompatChange(id, "", -1, -1, false, false, description, false));
return this;
}
CompatConfigBuilder addDisabledChangeWithId(long id) {
- mChanges.add(new CompatChange(id, "", -1, -1, true, false, ""));
+ mChanges.add(new CompatChange(id, "", -1, -1, true, false, "", false));
return this;
}
CompatConfigBuilder addDisabledChangeWithIdAndName(long id, String name) {
- mChanges.add(new CompatChange(id, name, -1, -1, true, false, ""));
+ mChanges.add(new CompatChange(id, name, -1, -1, true, false, "", false));
return this;
}
CompatConfigBuilder addDisabledChangeWithIdAndDescription(long id, String description) {
- mChanges.add(new CompatChange(id, "", -1, -1, true, false, description));
+ mChanges.add(new CompatChange(id, "", -1, -1, true, false, description, false));
return this;
}
CompatConfigBuilder addLoggingOnlyChangeWithId(long id) {
- mChanges.add(new CompatChange(id, "", -1, -1, false, true, ""));
+ mChanges.add(new CompatChange(id, "", -1, -1, false, true, "", false));
+ return this;
+ }
+
+ CompatConfigBuilder addOverridableChangeWithId(long id) {
+ mChanges.add(new CompatChange(id, "", -1, -1, false, true, "", true));
return this;
}
diff --git a/services/tests/servicestests/src/com/android/server/compat/PlatformCompatTest.java b/services/tests/servicestests/src/com/android/server/compat/PlatformCompatTest.java
index a70c51045340..a1b2dc8bd82d 100644
--- a/services/tests/servicestests/src/com/android/server/compat/PlatformCompatTest.java
+++ b/services/tests/servicestests/src/com/android/server/compat/PlatformCompatTest.java
@@ -97,17 +97,22 @@ public class PlatformCompatTest {
.addEnableAfterSdkChangeWithId(Build.VERSION_CODES.Q, 5L)
.addEnableAfterSdkChangeWithId(Build.VERSION_CODES.R, 6L)
.addLoggingOnlyChangeWithId(7L)
+ .addOverridableChangeWithId(8L)
.build();
mPlatformCompat = new PlatformCompat(mContext, mCompatConfig);
assertThat(mPlatformCompat.listAllChanges()).asList().containsExactly(
- new CompatibilityChangeInfo(1L, "", -1, -1, false, false, ""),
- new CompatibilityChangeInfo(2L, "change2", -1, -1, true, false, ""),
+ new CompatibilityChangeInfo(1L, "", -1, -1, false, false, "", false),
+ new CompatibilityChangeInfo(2L, "change2", -1, -1, true, false, "", false),
new CompatibilityChangeInfo(3L, "", Build.VERSION_CODES.O, -1, false, false,
- "desc"),
- new CompatibilityChangeInfo(4L, "", Build.VERSION_CODES.P, -1, false, false, ""),
- new CompatibilityChangeInfo(5L, "", Build.VERSION_CODES.Q, -1, false, false, ""),
- new CompatibilityChangeInfo(6L, "", Build.VERSION_CODES.R, -1, false, false, ""),
- new CompatibilityChangeInfo(7L, "", -1, -1, false, true, ""));
+ "desc", false),
+ new CompatibilityChangeInfo(
+ 4L, "", Build.VERSION_CODES.P, -1, false, false, "", false),
+ new CompatibilityChangeInfo(
+ 5L, "", Build.VERSION_CODES.Q, -1, false, false, "", false),
+ new CompatibilityChangeInfo(
+ 6L, "", Build.VERSION_CODES.R, -1, false, false, "", false),
+ new CompatibilityChangeInfo(7L, "", -1, -1, false, true, "", false),
+ new CompatibilityChangeInfo(8L, "", -1, -1, false, true, "", true));
}
@Test
@@ -123,12 +128,12 @@ public class PlatformCompatTest {
.build();
mPlatformCompat = new PlatformCompat(mContext, mCompatConfig);
assertThat(mPlatformCompat.listUIChanges()).asList().containsExactly(
- new CompatibilityChangeInfo(1L, "", -1, -1, false, false, ""),
- new CompatibilityChangeInfo(2L, "change2", -1, -1, true, false, ""),
- new CompatibilityChangeInfo(5L, "", /*enableAfter*/ -1,
- /*enableSince*/ Build.VERSION_CODES.Q, false, false, ""),
- new CompatibilityChangeInfo(6L, "", /*enableAfter*/ -1,
- /*enableSince*/ Build.VERSION_CODES.R, false, false, ""));
+ new CompatibilityChangeInfo(1L, "", -1, -1, false, false, "", false),
+ new CompatibilityChangeInfo(2L, "change2", -1, -1, true, false, "", false),
+ new CompatibilityChangeInfo(
+ 5L, "", Build.VERSION_CODES.P, -1, false, false, "", false),
+ new CompatibilityChangeInfo(
+ 6L, "", Build.VERSION_CODES.Q, -1, false, false, "", false));
}
@Test