Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7957f6da authored by mattgilbride's avatar mattgilbride
Browse files

Move PermissionMethod/PermissionName to android.annotation

Remove these annotations from package manager, as they should
be available globally and were moved to android.annotation in
this change: aosp/2367449.

Bug: 263474178
Test: TH
Change-Id: Ibf36a0c36967c4372cd9bc23af50909fd52f30fa
parent edb20480
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.app.ActivityManager.StopUserOnSwitch;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.PermissionMethod;
import android.annotation.PermissionName;
import android.annotation.UserIdInt;
import android.app.ActivityManager.ProcessCapability;
import android.app.ActivityManager.RestrictionLevel;
@@ -31,8 +33,6 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityPresentationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PermissionMethod;
import android.content.pm.PermissionName;
import android.content.pm.UserInfo;
import android.net.Uri;
import android.os.Bundle;
+2 −2
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.PermissionMethod;
import android.annotation.PermissionName;
import android.annotation.RequiresPermission;
import android.annotation.StringDef;
import android.annotation.StringRes;
@@ -53,8 +55,6 @@ import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionMethod;
import android.content.pm.PermissionName;
import android.content.res.AssetManager;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
+0 −52
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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 android.content.pm;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.CLASS;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * Documents that the subject method's job is to look
 * up whether the provided or calling uid/pid has the requested permission.
 *
 * <p>Methods should either return `void`, but potentially throw {@link SecurityException},
 * or return {@link android.content.pm.PackageManager.PermissionResult} `int`.
 *
 * @hide
 */
@Retention(CLASS)
@Target({METHOD})
public @interface PermissionMethod {
    /**
     * Hard-coded list of permissions checked by this method
     */
    @PermissionName String[] value() default {};
    /**
     * If true, the check passes if the caller
     * has any ONE of the supplied permissions
     */
    boolean anyOf() default false;
    /**
     * Signifies that the permission check passes if
     * the calling process OR the current process has
     * the permission
     */
    boolean orSelf() default false;
}
+0 −35
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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 android.content.pm;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.CLASS;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * Denotes that the annotated {@link String} represents a permission name.
 *
 * @hide
 */
@Retention(CLASS)
@Target({PARAMETER, METHOD, LOCAL_VARIABLE, FIELD})
public @interface PermissionName {}
+4 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.PermissionMethod;
import android.annotation.PermissionName;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
@@ -48,7 +50,6 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionName;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -18483,6 +18484,8 @@ public final class Settings {
         * @see #checkCallingPermission
         * @hide
         */
        @PermissionMethod(orSelf = true)
        @PackageManager.PermissionResult
        public static int checkCallingOrSelfPermission(@NonNull @PermissionName String permission) {
            return ActivityThread.currentApplication()
               .getApplicationContext().checkCallingOrSelfPermission(permission);
Loading