Loading core/api/system-current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -1124,10 +1124,11 @@ package android.app.backup { package android.app.compat { public final class CompatChanges { method @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void addPackageOverrides(@NonNull String, @NonNull java.util.Map<java.lang.Long,android.app.compat.PackageOverride>); method public static boolean isChangeEnabled(long); method @RequiresPermission(allOf={"android.permission.READ_COMPAT_CHANGE_CONFIG", "android.permission.LOG_COMPAT_CHANGE"}) public static boolean isChangeEnabled(long, @NonNull String, @NonNull android.os.UserHandle); method @RequiresPermission(allOf={"android.permission.READ_COMPAT_CHANGE_CONFIG", "android.permission.LOG_COMPAT_CHANGE"}) public static boolean isChangeEnabled(long, int); method @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void setPackageOverride(@NonNull String, @NonNull java.util.Map<java.lang.Long,android.app.compat.PackageOverride>); method @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void removePackageOverrides(@NonNull String, @NonNull java.util.Set<java.lang.Long>); } public final class PackageOverride { Loading core/java/android/app/compat/CompatChanges.java +34 −3 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ import android.os.ServiceManager; import android.os.UserHandle; import com.android.internal.compat.CompatibilityOverrideConfig; import com.android.internal.compat.CompatibilityOverridesToRemoveConfig; import com.android.internal.compat.IPlatformCompat; import java.util.Map; import java.util.Set; /** * CompatChanges APIs - to be used by platform code only (including mainline Loading Loading @@ -98,15 +100,19 @@ public final class CompatChanges { } /** * Set an app compat override for a given package. This will check whether the caller is allowed * Adds app compat overrides for a given package. This will check whether the caller is allowed * to perform this operation on the given apk and build. Only the installer package is allowed * to set overrides on a non-debuggable final build and a non-test apk. * * <p>Note that calling this method doesn't remove previously added overrides for the given * package if their change ID isn't in the given map, only replaces those that have the same * change ID. * * @param packageName The package name of the app in question. * @param overrides A map from changeId to the override applied for this change id. * @param overrides A map from change ID to the override applied for this change ID. */ @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void setPackageOverride(@NonNull String packageName, public static void addPackageOverrides(@NonNull String packageName, @NonNull Map<Long, PackageOverride> overrides) { IPlatformCompat platformCompat = IPlatformCompat.Stub.asInterface( ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE)); Loading @@ -117,4 +123,29 @@ public final class CompatChanges { e.rethrowFromSystemServer(); } } /** * Removes app compat overrides for a given package. This will check whether the caller is * allowed to perform this operation on the given apk and build. Only the installer package is * allowed to clear overrides on a non-debuggable final build and a non-test apk. * * <p>Note that calling this method with an empty set is a no-op and no overrides will be * removed for the given package. * * @param packageName The package name of the app in question. * @param overridesToRemove A set of change IDs for which to remove overrides. */ @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void removePackageOverrides(@NonNull String packageName, @NonNull Set<Long> overridesToRemove) { IPlatformCompat platformCompat = IPlatformCompat.Stub.asInterface( ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE)); CompatibilityOverridesToRemoveConfig config = new CompatibilityOverridesToRemoveConfig( overridesToRemove); try { platformCompat.removeOverridesOnReleaseBuilds(config, packageName); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } } core/java/com/android/internal/compat/CompatibilityOverridesToRemoveConfig.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.compat; parcelable CompatibilityOverridesToRemoveConfig; core/java/com/android/internal/compat/CompatibilityOverridesToRemoveConfig.java 0 → 100644 +72 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.compat; import android.os.Parcel; import android.os.Parcelable; import java.util.HashSet; import java.util.Set; /** * Parcelable containing compat config change IDs for which to remove overrides for a given * application. * @hide */ public final class CompatibilityOverridesToRemoveConfig implements Parcelable { public final Set<Long> changeIds; public CompatibilityOverridesToRemoveConfig(Set<Long> changeIds) { this.changeIds = changeIds; } private CompatibilityOverridesToRemoveConfig(Parcel in) { int keyCount = in.readInt(); changeIds = new HashSet<>(); for (int i = 0; i < keyCount; i++) { changeIds.add(in.readLong()); } } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(changeIds.size()); for (Long changeId : changeIds) { dest.writeLong(changeId); } } public static final Creator<CompatibilityOverridesToRemoveConfig> CREATOR = new Creator<CompatibilityOverridesToRemoveConfig>() { @Override public CompatibilityOverridesToRemoveConfig createFromParcel(Parcel in) { return new CompatibilityOverridesToRemoveConfig(in); } @Override public CompatibilityOverridesToRemoveConfig[] newArray(int size) { return new CompatibilityOverridesToRemoveConfig[size]; } }; } core/java/com/android/internal/compat/IPlatformCompat.aidl +22 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import java.util.Map; parcelable CompatibilityChangeConfig; parcelable CompatibilityOverrideConfig; parcelable CompatibilityOverridesToRemoveConfig; parcelable CompatibilityChangeInfo; /** * Platform private API for talking with the PlatformCompat service. Loading Loading @@ -203,6 +204,27 @@ interface IPlatformCompat { */ void clearOverrideForTest(long changeId, String packageName); /** * Restores the default behaviour for compatibility changes on release builds. * * <p>The caller to this API needs to hold * {@code android.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD} and all change ids * in {@code overridesToRemove} need to annotated with * {@link android.compat.annotation.Overridable}. * * A release build in this definition means that {@link android.os.Build#IS_DEBUGGABLE} needs to * be {@code false}. * * <p>Note that this does not kill the app, and therefore overrides read from the app process * will not be updated. Overrides read from the system process do take effect. * * @param overridesToRemove parcelable containing the compat change overrides to be removed * @param packageName the package name of the app whose changes will be restored to the * default behaviour * @throws SecurityException if overriding changes is not permitted */ void removeOverridesOnReleaseBuilds(in CompatibilityOverridesToRemoveConfig overridesToRemove, in String packageName); /** * Enables all compatibility changes that have enabledSinceTargetSdk == * {@param targetSdkVersion} for an app, subject to the policy. Loading Loading
core/api/system-current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -1124,10 +1124,11 @@ package android.app.backup { package android.app.compat { public final class CompatChanges { method @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void addPackageOverrides(@NonNull String, @NonNull java.util.Map<java.lang.Long,android.app.compat.PackageOverride>); method public static boolean isChangeEnabled(long); method @RequiresPermission(allOf={"android.permission.READ_COMPAT_CHANGE_CONFIG", "android.permission.LOG_COMPAT_CHANGE"}) public static boolean isChangeEnabled(long, @NonNull String, @NonNull android.os.UserHandle); method @RequiresPermission(allOf={"android.permission.READ_COMPAT_CHANGE_CONFIG", "android.permission.LOG_COMPAT_CHANGE"}) public static boolean isChangeEnabled(long, int); method @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void setPackageOverride(@NonNull String, @NonNull java.util.Map<java.lang.Long,android.app.compat.PackageOverride>); method @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void removePackageOverrides(@NonNull String, @NonNull java.util.Set<java.lang.Long>); } public final class PackageOverride { Loading
core/java/android/app/compat/CompatChanges.java +34 −3 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ import android.os.ServiceManager; import android.os.UserHandle; import com.android.internal.compat.CompatibilityOverrideConfig; import com.android.internal.compat.CompatibilityOverridesToRemoveConfig; import com.android.internal.compat.IPlatformCompat; import java.util.Map; import java.util.Set; /** * CompatChanges APIs - to be used by platform code only (including mainline Loading Loading @@ -98,15 +100,19 @@ public final class CompatChanges { } /** * Set an app compat override for a given package. This will check whether the caller is allowed * Adds app compat overrides for a given package. This will check whether the caller is allowed * to perform this operation on the given apk and build. Only the installer package is allowed * to set overrides on a non-debuggable final build and a non-test apk. * * <p>Note that calling this method doesn't remove previously added overrides for the given * package if their change ID isn't in the given map, only replaces those that have the same * change ID. * * @param packageName The package name of the app in question. * @param overrides A map from changeId to the override applied for this change id. * @param overrides A map from change ID to the override applied for this change ID. */ @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void setPackageOverride(@NonNull String packageName, public static void addPackageOverrides(@NonNull String packageName, @NonNull Map<Long, PackageOverride> overrides) { IPlatformCompat platformCompat = IPlatformCompat.Stub.asInterface( ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE)); Loading @@ -117,4 +123,29 @@ public final class CompatChanges { e.rethrowFromSystemServer(); } } /** * Removes app compat overrides for a given package. This will check whether the caller is * allowed to perform this operation on the given apk and build. Only the installer package is * allowed to clear overrides on a non-debuggable final build and a non-test apk. * * <p>Note that calling this method with an empty set is a no-op and no overrides will be * removed for the given package. * * @param packageName The package name of the app in question. * @param overridesToRemove A set of change IDs for which to remove overrides. */ @RequiresPermission(android.Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD) public static void removePackageOverrides(@NonNull String packageName, @NonNull Set<Long> overridesToRemove) { IPlatformCompat platformCompat = IPlatformCompat.Stub.asInterface( ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE)); CompatibilityOverridesToRemoveConfig config = new CompatibilityOverridesToRemoveConfig( overridesToRemove); try { platformCompat.removeOverridesOnReleaseBuilds(config, packageName); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } }
core/java/com/android/internal/compat/CompatibilityOverridesToRemoveConfig.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.compat; parcelable CompatibilityOverridesToRemoveConfig;
core/java/com/android/internal/compat/CompatibilityOverridesToRemoveConfig.java 0 → 100644 +72 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.compat; import android.os.Parcel; import android.os.Parcelable; import java.util.HashSet; import java.util.Set; /** * Parcelable containing compat config change IDs for which to remove overrides for a given * application. * @hide */ public final class CompatibilityOverridesToRemoveConfig implements Parcelable { public final Set<Long> changeIds; public CompatibilityOverridesToRemoveConfig(Set<Long> changeIds) { this.changeIds = changeIds; } private CompatibilityOverridesToRemoveConfig(Parcel in) { int keyCount = in.readInt(); changeIds = new HashSet<>(); for (int i = 0; i < keyCount; i++) { changeIds.add(in.readLong()); } } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(changeIds.size()); for (Long changeId : changeIds) { dest.writeLong(changeId); } } public static final Creator<CompatibilityOverridesToRemoveConfig> CREATOR = new Creator<CompatibilityOverridesToRemoveConfig>() { @Override public CompatibilityOverridesToRemoveConfig createFromParcel(Parcel in) { return new CompatibilityOverridesToRemoveConfig(in); } @Override public CompatibilityOverridesToRemoveConfig[] newArray(int size) { return new CompatibilityOverridesToRemoveConfig[size]; } }; }
core/java/com/android/internal/compat/IPlatformCompat.aidl +22 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import java.util.Map; parcelable CompatibilityChangeConfig; parcelable CompatibilityOverrideConfig; parcelable CompatibilityOverridesToRemoveConfig; parcelable CompatibilityChangeInfo; /** * Platform private API for talking with the PlatformCompat service. Loading Loading @@ -203,6 +204,27 @@ interface IPlatformCompat { */ void clearOverrideForTest(long changeId, String packageName); /** * Restores the default behaviour for compatibility changes on release builds. * * <p>The caller to this API needs to hold * {@code android.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD} and all change ids * in {@code overridesToRemove} need to annotated with * {@link android.compat.annotation.Overridable}. * * A release build in this definition means that {@link android.os.Build#IS_DEBUGGABLE} needs to * be {@code false}. * * <p>Note that this does not kill the app, and therefore overrides read from the app process * will not be updated. Overrides read from the system process do take effect. * * @param overridesToRemove parcelable containing the compat change overrides to be removed * @param packageName the package name of the app whose changes will be restored to the * default behaviour * @throws SecurityException if overriding changes is not permitted */ void removeOverridesOnReleaseBuilds(in CompatibilityOverridesToRemoveConfig overridesToRemove, in String packageName); /** * Enables all compatibility changes that have enabledSinceTargetSdk == * {@param targetSdkVersion} for an app, subject to the policy. Loading