1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.pm.permission; 18 19 import android.Manifest; 20 import android.annotation.NonNull; 21 22 import com.android.internal.util.DataClass; 23 24 /** 25 * Implements compatibility support for permissions, and old applications 26 * will be automatically granted it. 27 * 28 * Compatibility permissions are permissions that are automatically granted to 29 * packages that target an SDK prior to when the permission was introduced. 30 * Sometimes the platform makes breaking behaviour changes and hides the legacy 31 * behaviour behind a permission. In these instances, we ensure applications 32 * targeting older platform versions are implicitly granted the correct set of 33 * permissions. 34 * 35 * @hide 36 */ 37 @DataClass(genGetters = true, genBuilder = false) 38 public class CompatibilityPermissionInfo { 39 40 @NonNull 41 private final String mName; 42 private final int mSdkVersion; 43 44 /** 45 * List of new permissions that have been added since 1.0. 46 * 47 * NOTE: These must be declared in SDK version order, with permissions 48 * added to newer SDKs appearing before those added to older SDKs. 49 * 50 * @hide 51 */ 52 public static final CompatibilityPermissionInfo[] COMPAT_PERMS = 53 new CompatibilityPermissionInfo[]{ 54 new CompatibilityPermissionInfo(Manifest.permission.POST_NOTIFICATIONS, 55 android.os.Build.VERSION_CODES.TIRAMISU), 56 new CompatibilityPermissionInfo(Manifest.permission.WRITE_EXTERNAL_STORAGE, 57 android.os.Build.VERSION_CODES.DONUT), 58 new CompatibilityPermissionInfo(Manifest.permission.READ_PHONE_STATE, 59 android.os.Build.VERSION_CODES.DONUT) 60 }; 61 62 63 64 // Code below generated by codegen v1.0.23. 65 // 66 // DO NOT MODIFY! 67 // CHECKSTYLE:OFF Generated code 68 // 69 // To regenerate run: 70 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/com/android/internal/pm/permission/CompatibilityPermissionInfo.java 71 // 72 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 73 // Settings > Editor > Code Style > Formatter Control 74 //@formatter:off 75 76 77 @DataClass.Generated.Member CompatibilityPermissionInfo( @onNull String name, int sdkVersion)78 public CompatibilityPermissionInfo( 79 @NonNull String name, 80 int sdkVersion) { 81 this.mName = name; 82 com.android.internal.util.AnnotationValidations.validate( 83 NonNull.class, null, mName); 84 this.mSdkVersion = sdkVersion; 85 86 // onConstructed(); // You can define this method to get a callback 87 } 88 89 @DataClass.Generated.Member getName()90 public @NonNull String getName() { 91 return mName; 92 } 93 94 @DataClass.Generated.Member getSdkVersion()95 public int getSdkVersion() { 96 return mSdkVersion; 97 } 98 99 @DataClass.Generated( 100 time = 1701338392152L, 101 codegenVersion = "1.0.23", 102 sourceFile = "frameworks/base/core/java/com/android/internal/pm/permission/CompatibilityPermissionInfo.java", 103 inputSignatures = "private final @android.annotation.NonNull java.lang.String mName\nprivate final int mSdkVersion\npublic static final com.android.internal.pm.permission.CompatibilityPermissionInfo[] COMPAT_PERMS\nclass CompatibilityPermissionInfo extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genGetters=true, genBuilder=false)") 104 @Deprecated __metadata()105 private void __metadata() {} 106 107 108 //@formatter:on 109 // End of generated code 110 111 } 112