diff options
12 files changed, 151 insertions, 108 deletions
diff --git a/core/java/com/android/internal/compat/CompatibilityChangeInfo.java b/core/java/com/android/internal/compat/CompatibilityChangeInfo.java index 9ba025988126..670ca9f6091e 100644 --- a/core/java/com/android/internal/compat/CompatibilityChangeInfo.java +++ b/core/java/com/android/internal/compat/CompatibilityChangeInfo.java @@ -28,7 +28,7 @@ import android.os.Parcelable; public class CompatibilityChangeInfo implements Parcelable { private final long mChangeId; private final @Nullable String mName; - private final int mEnableAfterTargetSdk; + private final int mEnableSinceTargetSdk; private final boolean mDisabled; private final boolean mLoggingOnly; private final @Nullable String mDescription; @@ -42,8 +42,8 @@ public class CompatibilityChangeInfo implements Parcelable { return mName; } - public int getEnableAfterTargetSdk() { - return mEnableAfterTargetSdk; + public int getEnableSinceTargetSdk() { + return mEnableSinceTargetSdk; } public boolean getDisabled() { @@ -59,20 +59,37 @@ public class CompatibilityChangeInfo implements Parcelable { } public CompatibilityChangeInfo( - Long changeId, String name, int enableAfterTargetSdk, boolean disabled, - boolean loggingOnly, String description) { + Long changeId, String name, int enableAfterTargetSdk, int enableSinceTargetSdk, + boolean disabled, boolean loggingOnly, String description) { this.mChangeId = changeId; this.mName = name; - this.mEnableAfterTargetSdk = enableAfterTargetSdk; + if (enableAfterTargetSdk > 0) { + // Need to maintain support for @EnabledAfter(X), but make it equivalent to + // @EnabledSince(X+1) + this.mEnableSinceTargetSdk = enableAfterTargetSdk + 1; + } else if (enableSinceTargetSdk > 0) { + this.mEnableSinceTargetSdk = enableSinceTargetSdk; + } else { + this.mEnableSinceTargetSdk = -1; + } this.mDisabled = disabled; this.mLoggingOnly = loggingOnly; this.mDescription = description; } + public CompatibilityChangeInfo(CompatibilityChangeInfo other) { + this.mChangeId = other.mChangeId; + this.mName = other.mName; + this.mEnableSinceTargetSdk = other.mEnableSinceTargetSdk; + this.mDisabled = other.mDisabled; + this.mLoggingOnly = other.mLoggingOnly; + this.mDescription = other.mDescription; + } + private CompatibilityChangeInfo(Parcel in) { mChangeId = in.readLong(); mName = in.readString(); - mEnableAfterTargetSdk = in.readInt(); + mEnableSinceTargetSdk = in.readInt(); mDisabled = in.readBoolean(); mLoggingOnly = in.readBoolean(); mDescription = in.readString(); @@ -87,7 +104,7 @@ public class CompatibilityChangeInfo implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeLong(mChangeId); dest.writeString(mName); - dest.writeInt(mEnableAfterTargetSdk); + dest.writeInt(mEnableSinceTargetSdk); dest.writeBoolean(mDisabled); dest.writeBoolean(mLoggingOnly); dest.writeString(mDescription); @@ -100,8 +117,8 @@ public class CompatibilityChangeInfo implements Parcelable { if (getName() != null) { sb.append("; name=").append(getName()); } - if (getEnableAfterTargetSdk() != -1) { - sb.append("; enableAfterTargetSdk=").append(getEnableAfterTargetSdk()); + if (getEnableSinceTargetSdk() != -1) { + sb.append("; enableSinceTargetSdk=").append(getEnableSinceTargetSdk()); } if (getDisabled()) { sb.append("; disabled"); @@ -123,7 +140,7 @@ public class CompatibilityChangeInfo implements Parcelable { CompatibilityChangeInfo that = (CompatibilityChangeInfo) o; return this.mChangeId == that.mChangeId && this.mName.equals(that.mName) - && this.mEnableAfterTargetSdk == that.mEnableAfterTargetSdk + && this.mEnableSinceTargetSdk == that.mEnableSinceTargetSdk && this.mDisabled == that.mDisabled && this.mLoggingOnly == that.mLoggingOnly && this.mDescription.equals(that.mDescription); diff --git a/core/java/com/android/internal/compat/IPlatformCompat.aidl b/core/java/com/android/internal/compat/IPlatformCompat.aidl index 6408def7eeac..cc266d60465e 100644 --- a/core/java/com/android/internal/compat/IPlatformCompat.aidl +++ b/core/java/com/android/internal/compat/IPlatformCompat.aidl @@ -164,7 +164,7 @@ interface IPlatformCompat boolean clearOverride(long changeId, String packageName); /** - * Enable all compatibility changes which have enabledAfterTargetSdk == + * Enable all compatibility changes which have enabledSinceTargetSdk == * {@param targetSdkVersion} for an app, subject to the policy. Kills the app to allow the * changes to take effect. * diff --git a/services/core/java/com/android/server/compat/CompatChange.java b/services/core/java/com/android/server/compat/CompatChange.java index 2e9818d15963..bc3bff1b966f 100644 --- a/services/core/java/com/android/server/compat/CompatChange.java +++ b/services/core/java/com/android/server/compat/CompatChange.java @@ -63,7 +63,7 @@ public final class CompatChange extends CompatibilityChangeInfo { private Map<String, Boolean> mPackageOverrides; public CompatChange(long changeId) { - this(changeId, null, -1, false, false, null); + this(changeId, null, -1, -1, false, false, null); } /** @@ -71,11 +71,14 @@ public final class CompatChange extends CompatibilityChangeInfo { * @param name Short descriptive name. * @param enableAfterTargetSdk {@code targetSdkVersion} restriction. See {@link EnabledAfter}; * -1 if the change is always enabled. + * @param enableSinceTargetSdk {@code targetSdkVersion} restriction. See {@link EnabledSince}; + * -1 if the change is always enabled. * @param disabled If {@code true}, overrides any {@code enableAfterTargetSdk} set. */ public CompatChange(long changeId, @Nullable String name, int enableAfterTargetSdk, - boolean disabled, boolean loggingOnly, String description) { - super(changeId, name, enableAfterTargetSdk, disabled, loggingOnly, description); + int enableSinceTargetSdk, boolean disabled, boolean loggingOnly, String description) { + super(changeId, name, enableAfterTargetSdk, enableSinceTargetSdk, disabled, loggingOnly, + description); } /** @@ -83,7 +86,8 @@ public final class CompatChange extends CompatibilityChangeInfo { */ public CompatChange(Change change) { super(change.getId(), change.getName(), change.getEnableAfterTargetSdk(), - change.getDisabled(), change.getLoggingOnly(), change.getDescription()); + change.getEnableSinceTargetSdk(), change.getDisabled(), change.getLoggingOnly(), + change.getDescription()); } void registerListener(ChangeListener listener) { @@ -145,8 +149,8 @@ public final class CompatChange extends CompatibilityChangeInfo { if (getDisabled()) { return false; } - if (getEnableAfterTargetSdk() != -1) { - return app.targetSdkVersion > getEnableAfterTargetSdk(); + if (getEnableSinceTargetSdk() != -1) { + return app.targetSdkVersion >= getEnableSinceTargetSdk(); } return true; } @@ -167,8 +171,8 @@ public final class CompatChange extends CompatibilityChangeInfo { if (getName() != null) { sb.append("; name=").append(getName()); } - if (getEnableAfterTargetSdk() != -1) { - sb.append("; enableAfterTargetSdk=").append(getEnableAfterTargetSdk()); + if (getEnableSinceTargetSdk() != -1) { + sb.append("; enableSinceTargetSdk=").append(getEnableSinceTargetSdk()); } if (getDisabled()) { sb.append("; disabled"); diff --git a/services/core/java/com/android/server/compat/CompatConfig.java b/services/core/java/com/android/server/compat/CompatConfig.java index aeaa1fedf9e3..d80c58b39768 100644 --- a/services/core/java/com/android/server/compat/CompatConfig.java +++ b/services/core/java/com/android/server/compat/CompatConfig.java @@ -192,16 +192,19 @@ final class CompatConfig { } /** - * Returns the minimum sdk version for which this change should be enabled (or 0 if it is not + * Returns the maximum sdk version for which this change can be opted in (or -1 if it is not * target sdk gated). */ - int minTargetSdkForChangeId(long changeId) { + int maxTargetSdkForChangeIdOptIn(long changeId) { synchronized (mChanges) { CompatChange c = mChanges.get(changeId); if (c == null) { - return 0; + return -1; } - return c.getEnableAfterTargetSdk(); + if (c.getEnableSinceTargetSdk() != -1) { + return c.getEnableSinceTargetSdk() - 1; + } + return -1; } } @@ -318,7 +321,7 @@ final class CompatConfig { } } - private long[] getAllowedChangesAfterTargetSdkForPackage(String packageName, + private long[] getAllowedChangesSinceTargetSdkForPackage(String packageName, int targetSdkVersion) throws RemoteException { LongArray allowed = new LongArray(); @@ -326,7 +329,7 @@ final class CompatConfig { for (int i = 0; i < mChanges.size(); ++i) { try { CompatChange change = mChanges.valueAt(i); - if (change.getEnableAfterTargetSdk() != targetSdkVersion) { + if (change.getEnableSinceTargetSdk() != targetSdkVersion) { continue; } OverrideAllowedState allowedState = @@ -345,14 +348,14 @@ final class CompatConfig { } /** - * Enables all changes with enabledAfterTargetSdk == {@param targetSdkVersion} for + * Enables all changes with enabledSinceTargetSdk == {@param targetSdkVersion} for * {@param packageName}. * * @return The number of changes that were toggled. */ int enableTargetSdkChangesForPackage(String packageName, int targetSdkVersion) throws RemoteException { - long[] changes = getAllowedChangesAfterTargetSdkForPackage(packageName, targetSdkVersion); + long[] changes = getAllowedChangesSinceTargetSdkForPackage(packageName, targetSdkVersion); for (long changeId : changes) { addOverride(changeId, packageName, true); } @@ -361,14 +364,14 @@ final class CompatConfig { /** - * Disables all changes with enabledAfterTargetSdk == {@param targetSdkVersion} for + * Disables all changes with enabledSinceTargetSdk == {@param targetSdkVersion} for * {@param packageName}. * * @return The number of changes that were toggled. */ int disableTargetSdkChangesForPackage(String packageName, int targetSdkVersion) throws RemoteException { - long[] changes = getAllowedChangesAfterTargetSdkForPackage(packageName, targetSdkVersion); + long[] changes = getAllowedChangesSinceTargetSdkForPackage(packageName, targetSdkVersion); for (long changeId : changes) { addOverride(changeId, packageName, false); } @@ -448,12 +451,7 @@ final class CompatConfig { CompatibilityChangeInfo[] changeInfos = new CompatibilityChangeInfo[mChanges.size()]; for (int i = 0; i < mChanges.size(); ++i) { CompatChange change = mChanges.valueAt(i); - changeInfos[i] = new CompatibilityChangeInfo(change.getId(), - change.getName(), - change.getEnableAfterTargetSdk(), - change.getDisabled(), - change.getLoggingOnly(), - change.getDescription()); + changeInfos[i] = new CompatibilityChangeInfo(change); } return changeInfos; } diff --git a/services/core/java/com/android/server/compat/OverrideValidatorImpl.java b/services/core/java/com/android/server/compat/OverrideValidatorImpl.java index 08d266478f4b..79a13ca242c1 100644 --- a/services/core/java/com/android/server/compat/OverrideValidatorImpl.java +++ b/services/core/java/com/android/server/compat/OverrideValidatorImpl.java @@ -58,7 +58,7 @@ public class OverrideValidatorImpl extends IOverrideValidator.Stub { boolean debuggableBuild = mAndroidBuildClassifier.isDebuggableBuild(); boolean finalBuild = mAndroidBuildClassifier.isFinalBuild(); - int minTargetSdk = mCompatConfig.minTargetSdkForChangeId(changeId); + int maxTargetSdk = mCompatConfig.maxTargetSdkForChangeIdOptIn(changeId); boolean disabled = mCompatConfig.isDisabled(changeId); // Allow any override for userdebug or eng builds. @@ -82,16 +82,16 @@ public class OverrideValidatorImpl extends IOverrideValidator.Stub { } // Allow overriding any change for debuggable apps on non-final builds. if (!finalBuild) { - return new OverrideAllowedState(ALLOWED, appTargetSdk, minTargetSdk); + return new OverrideAllowedState(ALLOWED, appTargetSdk, maxTargetSdk); } // Do not allow overriding default enabled changes on user builds - if (minTargetSdk == -1 && !disabled) { - return new OverrideAllowedState(DISABLED_NON_TARGET_SDK, appTargetSdk, minTargetSdk); + if (maxTargetSdk == -1 && !disabled) { + return new OverrideAllowedState(DISABLED_NON_TARGET_SDK, appTargetSdk, maxTargetSdk); } // Only allow to opt-in for a targetSdk gated change. - if (disabled || appTargetSdk <= minTargetSdk) { - return new OverrideAllowedState(ALLOWED, appTargetSdk, minTargetSdk); + if (disabled || appTargetSdk <= maxTargetSdk) { + return new OverrideAllowedState(ALLOWED, appTargetSdk, maxTargetSdk); } - return new OverrideAllowedState(DISABLED_TARGET_SDK_TOO_HIGH, appTargetSdk, minTargetSdk); + return new OverrideAllowedState(DISABLED_TARGET_SDK_TOO_HIGH, appTargetSdk, maxTargetSdk); } } diff --git a/services/core/java/com/android/server/compat/PlatformCompat.java b/services/core/java/com/android/server/compat/PlatformCompat.java index 92fce8a22937..38664fe09044 100644 --- a/services/core/java/com/android/server/compat/PlatformCompat.java +++ b/services/core/java/com/android/server/compat/PlatformCompat.java @@ -59,8 +59,8 @@ public class PlatformCompat extends IPlatformCompat.Stub { private final ChangeReporter mChangeReporter; private final CompatConfig mCompatConfig; - private static int sMinTargetSdk = Build.VERSION_CODES.P; - private static int sMaxTargetSdk = Build.VERSION_CODES.Q; + private static int sMinTargetSdk = Build.VERSION_CODES.Q; + private static int sMaxTargetSdk = Build.VERSION_CODES.R; public PlatformCompat(Context context) { mContext = context; @@ -375,9 +375,9 @@ public class PlatformCompat extends IPlatformCompat.Stub { if (change.getLoggingOnly()) { return false; } - if (change.getEnableAfterTargetSdk() > 0) { - if (change.getEnableAfterTargetSdk() < sMinTargetSdk - || change.getEnableAfterTargetSdk() > sMaxTargetSdk) { + if (change.getEnableSinceTargetSdk() > 0) { + if (change.getEnableSinceTargetSdk() < sMinTargetSdk + || change.getEnableSinceTargetSdk() > sMaxTargetSdk) { return false; } } diff --git a/services/core/xsd/platform-compat-config.xsd b/services/core/xsd/platform-compat-config.xsd index 5a4c682f52eb..992470816068 100644 --- a/services/core/xsd/platform-compat-config.xsd +++ b/services/core/xsd/platform-compat-config.xsd @@ -29,6 +29,7 @@ <xs:attribute type="xs:boolean" name="disabled"/> <xs:attribute type="xs:boolean" name="loggingOnly"/> <xs:attribute type="xs:int" name="enableAfterTargetSdk"/> + <xs:attribute type="xs:int" name="enableSinceTargetSdk"/> <xs:attribute type="xs:string" name="description"/> </xs:extension> </xs:simpleContent> diff --git a/services/core/xsd/platform-compat-schema/current.txt b/services/core/xsd/platform-compat-schema/current.txt index 7def58d56a26..e3640edd0201 100644 --- a/services/core/xsd/platform-compat-schema/current.txt +++ b/services/core/xsd/platform-compat-schema/current.txt @@ -6,6 +6,7 @@ package com.android.server.compat.config { method public String getDescription(); method public boolean getDisabled(); method public int getEnableAfterTargetSdk(); + method public int getEnableSinceTargetSdk(); method public long getId(); method public boolean getLoggingOnly(); method public String getName(); @@ -13,6 +14,7 @@ package com.android.server.compat.config { method public void setDescription(String); method public void setDisabled(boolean); method public void setEnableAfterTargetSdk(int); + method public void setEnableSinceTargetSdk(int); method public void setId(long); method public void setLoggingOnly(boolean); method public void setName(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 2cbe7be8ac33..870fe4a0837e 100644 --- a/services/tests/servicestests/src/com/android/server/compat/CompatConfigBuilder.java +++ b/services/tests/servicestests/src/com/android/server/compat/CompatConfigBuilder.java @@ -39,58 +39,79 @@ class CompatConfigBuilder { return new CompatConfigBuilder(buildClassifier, context); } - CompatConfigBuilder addTargetSdkChangeWithId(int sdk, long id) { - mChanges.add(new CompatChange(id, "", sdk, false, false, "")); + CompatConfigBuilder addEnableAfterSdkChangeWithId(int sdk, long id) { + mChanges.add(new CompatChange(id, "", sdk, -1, false, false, "")); return this; } - CompatConfigBuilder addTargetSdkDisabledChangeWithId(int sdk, long id) { - mChanges.add(new CompatChange(id, "", sdk, true, false, "")); + CompatConfigBuilder addEnableAfterSdkChangeWithIdAndName(int sdk, long id, String name) { + mChanges.add(new CompatChange(id, name, sdk, -1, false, false, "")); return this; } - CompatConfigBuilder addTargetSdkChangeWithIdAndName(int sdk, long id, String name) { - mChanges.add(new CompatChange(id, name, sdk, false, false, "")); + CompatConfigBuilder addEnableAfterSdkChangeWithIdDefaultDisabled(int sdk, long id) { + mChanges.add(new CompatChange(id, "", sdk, -1, true, false, "")); return this; } - CompatConfigBuilder addTargetSdkChangeWithIdAndDescription(int sdk, long id, + CompatConfigBuilder addEnableAfterSdkChangeWithIdAndDescription(int sdk, long id, String description) { - mChanges.add(new CompatChange(id, "", sdk, false, false, description)); + mChanges.add(new CompatChange(id, "", sdk, -1, false, false, description)); + return this; + } + + CompatConfigBuilder addEnableSinceSdkChangeWithId(int sdk, long id) { + mChanges.add(new CompatChange(id, "", -1, sdk, false, false, "")); + return this; + } + + CompatConfigBuilder addEnableSinceSdkChangeWithIdAndName(int sdk, long id, String name) { + mChanges.add(new CompatChange(id, name, -1, sdk, false, false, "")); + return this; + } + + CompatConfigBuilder addEnableSinceSdkChangeWithIdDefaultDisabled(int sdk, long id) { + mChanges.add(new CompatChange(id, "", -1, sdk, true, false, "")); + return this; + } + + CompatConfigBuilder addEnableSinceSdkChangeWithIdAndDescription(int sdk, long id, + String description) { + mChanges.add(new CompatChange(id, "", -1, sdk, false, false, description)); return this; } CompatConfigBuilder addEnabledChangeWithId(long id) { - mChanges.add(new CompatChange(id, "", -1, false, false, "")); + mChanges.add(new CompatChange(id, "", -1, -1, false, false, "")); return this; } CompatConfigBuilder addEnabledChangeWithIdAndName(long id, String name) { - mChanges.add(new CompatChange(id, name, -1, false, false, "")); + mChanges.add(new CompatChange(id, name, -1, -1, false, false, "")); return this; } CompatConfigBuilder addEnabledChangeWithIdAndDescription(long id, String description) { - mChanges.add(new CompatChange(id, "", -1, false, false, description)); + mChanges.add(new CompatChange(id, "", -1, -1, false, false, description)); return this; } CompatConfigBuilder addDisabledChangeWithId(long id) { - mChanges.add(new CompatChange(id, "", -1, true, false, "")); + mChanges.add(new CompatChange(id, "", -1, -1, true, false, "")); return this; } CompatConfigBuilder addDisabledChangeWithIdAndName(long id, String name) { - mChanges.add(new CompatChange(id, name, -1, true, false, "")); + mChanges.add(new CompatChange(id, name, -1, -1, true, false, "")); return this; } CompatConfigBuilder addDisabledChangeWithIdAndDescription(long id, String description) { - mChanges.add(new CompatChange(id, "", -1, true, false, description)); + mChanges.add(new CompatChange(id, "", -1, -1, true, false, description)); return this; } CompatConfigBuilder addLoggingOnlyChangeWithId(long id) { - mChanges.add(new CompatChange(id, "", -1, false, true, "")); + mChanges.add(new CompatChange(id, "", -1, -1, false, true, "")); return this; } diff --git a/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java b/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java index 8be9213fd925..e5883708e921 100644 --- a/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java +++ b/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java @@ -98,7 +98,7 @@ public class CompatConfigTest { @Test public void testTargetSdkChangeDisabled() throws Exception { CompatConfig compatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext) - .addTargetSdkChangeWithId(2, 1234L) + .addEnableAfterSdkChangeWithId(2, 1234L) .build(); assertThat(compatConfig.isChangeEnabled(1234L, @@ -109,7 +109,7 @@ public class CompatConfigTest { @Test public void testTargetSdkChangeEnabled() throws Exception { CompatConfig compatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext) - .addTargetSdkChangeWithId(2, 1234L) + .addEnableAfterSdkChangeWithId(2, 1234L) .build(); assertThat(compatConfig.isChangeEnabled(1234L, @@ -119,7 +119,7 @@ public class CompatConfigTest { @Test public void testDisabledOverrideTargetSdkChange() throws Exception { CompatConfig compatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext) - .addTargetSdkDisabledChangeWithId(2, 1234L) + .addEnableAfterSdkChangeWithIdDefaultDisabled(2, 1234L) .build(); assertThat(compatConfig.isChangeEnabled(1234L, @@ -293,8 +293,8 @@ public class CompatConfigTest { CompatConfig compatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext) .addEnabledChangeWithId(1L) .addDisabledChangeWithId(2L) - .addTargetSdkChangeWithId(3, 3L) - .addTargetSdkChangeWithId(4, 4L) + .addEnableSinceSdkChangeWithId(3, 3L) + .addEnableSinceSdkChangeWithId(4, 4L) .build(); ApplicationInfo applicationInfo = ApplicationInfoBuilder.create() .withPackageName("foo.bar") @@ -314,8 +314,8 @@ public class CompatConfigTest { CompatConfig compatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext) .addEnabledChangeWithId(1L) .addDisabledChangeWithId(2L) - .addTargetSdkChangeWithId(3, 3L) - .addTargetSdkChangeWithId(4, 4L) + .addEnableSinceSdkChangeWithId(3, 3L) + .addEnableSinceSdkChangeWithId(4, 4L) .build(); ApplicationInfo applicationInfo = ApplicationInfoBuilder.create() .withPackageName("foo.bar") diff --git a/services/tests/servicestests/src/com/android/server/compat/OverrideValidatorImplTest.java b/services/tests/servicestests/src/com/android/server/compat/OverrideValidatorImplTest.java index d45589d90ce3..c53b29a08a4a 100644 --- a/services/tests/servicestests/src/com/android/server/compat/OverrideValidatorImplTest.java +++ b/services/tests/servicestests/src/com/android/server/compat/OverrideValidatorImplTest.java @@ -87,9 +87,9 @@ public class OverrideValidatorImplTest { public void getOverrideAllowedState_debugBuildAnyChangeDebugApp_allowOverride() throws Exception { CompatConfig config = CompatConfigBuilder.create(debuggableBuild(), mContext) - .addTargetSdkChangeWithId(TARGET_SDK_BEFORE, 1) - .addTargetSdkChangeWithId(TARGET_SDK, 2) - .addTargetSdkChangeWithId(TARGET_SDK_AFTER, 3) + .addEnableAfterSdkChangeWithId(TARGET_SDK_BEFORE, 1) + .addEnableAfterSdkChangeWithId(TARGET_SDK, 2) + .addEnableAfterSdkChangeWithId(TARGET_SDK_AFTER, 3) .addEnabledChangeWithId(4) .addDisabledChangeWithId(5) .addLoggingOnlyChangeWithId(6).build(); @@ -131,9 +131,9 @@ public class OverrideValidatorImplTest { public void getOverrideAllowedState_debugBuildAnyChangeReleaseApp_allowOverride() throws Exception { CompatConfig config = CompatConfigBuilder.create(debuggableBuild(), mContext) - .addTargetSdkChangeWithId(TARGET_SDK_BEFORE, 1) - .addTargetSdkChangeWithId(TARGET_SDK, 2) - .addTargetSdkChangeWithId(TARGET_SDK_AFTER, 3) + .addEnableAfterSdkChangeWithId(TARGET_SDK_BEFORE, 1) + .addEnableAfterSdkChangeWithId(TARGET_SDK, 2) + .addEnableAfterSdkChangeWithId(TARGET_SDK_AFTER, 3) .addEnabledChangeWithId(4) .addDisabledChangeWithId(5) .addLoggingOnlyChangeWithId(6).build(); @@ -174,9 +174,9 @@ public class OverrideValidatorImplTest { public void getOverrideAllowedState_betaBuildTargetSdkChangeDebugApp_allowOverride() throws Exception { CompatConfig config = CompatConfigBuilder.create(betaBuild(), mContext) - .addTargetSdkChangeWithId(TARGET_SDK_BEFORE, 1) - .addTargetSdkChangeWithId(TARGET_SDK, 2) - .addTargetSdkChangeWithId(TARGET_SDK_AFTER, 3) + .addEnableAfterSdkChangeWithId(TARGET_SDK_BEFORE, 1) + .addEnableAfterSdkChangeWithId(TARGET_SDK, 2) + .addEnableAfterSdkChangeWithId(TARGET_SDK_AFTER, 3) .addDisabledChangeWithId(4).build(); IOverrideValidator overrideValidator = config.getOverrideValidator(); when(mPackageManager.getApplicationInfo(eq(PACKAGE_NAME), anyInt())) @@ -245,9 +245,9 @@ public class OverrideValidatorImplTest { public void getOverrideAllowedState_betaBuildAnyChangeReleaseApp_rejectOverride() throws Exception { CompatConfig config = CompatConfigBuilder.create(betaBuild(), mContext) - .addTargetSdkChangeWithId(TARGET_SDK_BEFORE, 1) - .addTargetSdkChangeWithId(TARGET_SDK, 2) - .addTargetSdkChangeWithId(TARGET_SDK_AFTER, 3) + .addEnableAfterSdkChangeWithId(TARGET_SDK_BEFORE, 1) + .addEnableAfterSdkChangeWithId(TARGET_SDK, 2) + .addEnableAfterSdkChangeWithId(TARGET_SDK_AFTER, 3) .addEnabledChangeWithId(4) .addDisabledChangeWithId(5) .addLoggingOnlyChangeWithId(6).build(); @@ -288,8 +288,8 @@ public class OverrideValidatorImplTest { public void getOverrideAllowedState_finalBuildTargetSdkChangeDebugAppOptin_allowOverride() throws Exception { CompatConfig config = CompatConfigBuilder.create(finalBuild(), mContext) - .addTargetSdkChangeWithId(TARGET_SDK_AFTER, 1) - .addTargetSdkChangeWithId(TARGET_SDK, 2).build(); + .addEnableAfterSdkChangeWithId(TARGET_SDK_AFTER, 1) + .addEnableAfterSdkChangeWithId(TARGET_SDK, 2).build(); IOverrideValidator overrideValidator = config.getOverrideValidator(); when(mPackageManager.getApplicationInfo(eq(PACKAGE_NAME), anyInt())) .thenReturn(ApplicationInfoBuilder.create() @@ -313,7 +313,7 @@ public class OverrideValidatorImplTest { public void getOverrideAllowedState_finalBuildTargetSdkChangeDebugAppOptout_rejectOverride() throws Exception { CompatConfig config = CompatConfigBuilder.create(finalBuild(), mContext) - .addTargetSdkChangeWithId(TARGET_SDK_BEFORE, 1).build(); + .addEnableAfterSdkChangeWithId(TARGET_SDK_BEFORE, 1).build(); IOverrideValidator overrideValidator = config.getOverrideValidator(); when(mPackageManager.getApplicationInfo(eq(PACKAGE_NAME), anyInt())) .thenReturn(ApplicationInfoBuilder.create() @@ -371,9 +371,9 @@ public class OverrideValidatorImplTest { public void getOverrideAllowedState_finalBuildAnyChangeReleaseApp_rejectOverride() throws Exception { CompatConfig config = CompatConfigBuilder.create(finalBuild(), mContext) - .addTargetSdkChangeWithId(TARGET_SDK_BEFORE, 1) - .addTargetSdkChangeWithId(TARGET_SDK, 2) - .addTargetSdkChangeWithId(TARGET_SDK_AFTER, 3) + .addEnableAfterSdkChangeWithId(TARGET_SDK_BEFORE, 1) + .addEnableAfterSdkChangeWithId(TARGET_SDK, 2) + .addEnableAfterSdkChangeWithId(TARGET_SDK_AFTER, 3) .addEnabledChangeWithId(4) .addDisabledChangeWithId(5) .addLoggingOnlyChangeWithId(6).build(); 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 cef02ffc3831..64014ba182d2 100644 --- a/services/tests/servicestests/src/com/android/server/compat/PlatformCompatTest.java +++ b/services/tests/servicestests/src/com/android/server/compat/PlatformCompatTest.java @@ -84,22 +84,22 @@ public class PlatformCompatTest { mCompatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext) .addEnabledChangeWithId(1L) .addDisabledChangeWithIdAndName(2L, "change2") - .addTargetSdkChangeWithIdAndDescription(Build.VERSION_CODES.O, 3L, "description") - .addTargetSdkChangeWithId(Build.VERSION_CODES.P, 4L) - .addTargetSdkChangeWithId(Build.VERSION_CODES.Q, 5L) - .addTargetSdkChangeWithId(Build.VERSION_CODES.R, 6L) + .addEnableAfterSdkChangeWithIdAndDescription(Build.VERSION_CODES.O, 3L, "desc") + .addEnableAfterSdkChangeWithId(Build.VERSION_CODES.P, 4L) + .addEnableAfterSdkChangeWithId(Build.VERSION_CODES.Q, 5L) + .addEnableAfterSdkChangeWithId(Build.VERSION_CODES.R, 6L) .addLoggingOnlyChangeWithId(7L) .build(); mPlatformCompat = new PlatformCompat(mContext, mCompatConfig); assertThat(mPlatformCompat.listAllChanges()).asList().containsExactly( - new CompatibilityChangeInfo(1L, "", -1, false, false, ""), - new CompatibilityChangeInfo(2L, "change2", -1, true, false, ""), - new CompatibilityChangeInfo(3L, "", Build.VERSION_CODES.O, false, false, - "description"), - new CompatibilityChangeInfo(4L, "", Build.VERSION_CODES.P, false, false, ""), - new CompatibilityChangeInfo(5L, "", Build.VERSION_CODES.Q, false, false, ""), - new CompatibilityChangeInfo(6L, "", Build.VERSION_CODES.R, false, false, ""), - new CompatibilityChangeInfo(7L, "", -1, false, true, "")); + new CompatibilityChangeInfo(1L, "", -1, -1, false, false, ""), + new CompatibilityChangeInfo(2L, "change2", -1, -1, true, 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, "")); } @Test @@ -107,18 +107,18 @@ public class PlatformCompatTest { mCompatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext) .addEnabledChangeWithId(1L) .addDisabledChangeWithIdAndName(2L, "change2") - .addTargetSdkChangeWithIdAndDescription(Build.VERSION_CODES.O, 3L, "description") - .addTargetSdkChangeWithId(Build.VERSION_CODES.P, 4L) - .addTargetSdkChangeWithId(Build.VERSION_CODES.Q, 5L) - .addTargetSdkChangeWithId(Build.VERSION_CODES.R, 6L) + .addEnableAfterSdkChangeWithIdAndDescription(Build.VERSION_CODES.O, 3L, "desc") + .addEnableAfterSdkChangeWithId(Build.VERSION_CODES.P, 4L) + .addEnableAfterSdkChangeWithId(Build.VERSION_CODES.Q, 5L) + .addEnableAfterSdkChangeWithId(Build.VERSION_CODES.R, 6L) .addLoggingOnlyChangeWithId(7L) .build(); mPlatformCompat = new PlatformCompat(mContext, mCompatConfig); assertThat(mPlatformCompat.listUIChanges()).asList().containsExactly( - new CompatibilityChangeInfo(1L, "", -1, false, false, ""), - new CompatibilityChangeInfo(2L, "change2", -1, true, false, ""), - new CompatibilityChangeInfo(4L, "", Build.VERSION_CODES.P, false, false, ""), - new CompatibilityChangeInfo(5L, "", Build.VERSION_CODES.Q, false, false, "")); + new CompatibilityChangeInfo(1L, "", -1, -1, false, false, ""), + new CompatibilityChangeInfo(2L, "change2", -1, -1, true, false, ""), + new CompatibilityChangeInfo(4L, "", Build.VERSION_CODES.P, -1, false, false, ""), + new CompatibilityChangeInfo(5L, "", Build.VERSION_CODES.Q, -1, false, false, "")); } @Test |