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

Commit 101ae347 authored by Victor Gabriel Savu's avatar Victor Gabriel Savu Committed by Android (Google) Code Review
Browse files

Merge "Add an MVP for policy annotations" into main

parents b15d99d5 bd0dea82
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -249,6 +249,7 @@ java_library {
        "android.system.suspend.control.internal-java",
        "devicepolicyprotosnano",
        "ImmutabilityAnnotation",
        "DevicePolicyAnnotation",

        "com.android.sysprop.localization",
        "PlatformProperties",
@@ -362,6 +363,7 @@ java_defaults {
        "staledataclass-annotation-processor",
        "error_prone_android_framework",
        "systemfeatures-metadata-processor",
        "DevicePolicyAnnotationProcessor",
    ],
    // Exports needed for staledataclass-annotation-processor, see b/139342589.
    javacflags: [
+13 −6
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static android.app.admin.flags.Flags.FLAG_POLICY_STREAMLINING;
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.processor.devicepolicy.BooleanPolicyDefinition;
import android.processor.devicepolicy.PolicyDefinition;

/**
 * Represents a type safe identifier for a policy. Use it as a key for
@@ -32,7 +34,8 @@ import android.annotation.TestApi;
public final class PolicyIdentifier<T> {
    private final String mId;

    /** Create an instance of PolicyIdentifier. Should only be used to create the static
    /**
     * Create an instance of PolicyIdentifier. Should only be used to create the static
     * definitions below.
     *
     * @hide
@@ -46,7 +49,6 @@ public final class PolicyIdentifier<T> {
     * Get the string representation of this identifier.
     *
     * @return The string representation of this identifier
     *
     * @hide
     */
    @NonNull
@@ -83,10 +85,15 @@ public final class PolicyIdentifier<T> {
     * screen capture also prevents the content from being shown on display devices that do not have
     * a secure video output. See {@link android.view.Display#FLAG_SECURE} for more details about
     * secure surfaces and secure displays.
     * Throws SecurityException if the caller is not permitted to control screen capture policy.
     * If the scope is set to {@link DevicePolicyManager.POLICY_SCOPE_PARENT_USER} and the caller
     * is not a profile owner of an organization-owned managed profile, a security exception will
     * be thrown.
     */
    // TODO(b/433951378): Document or annotate who can call this and what errors can be thrown.
    @NonNull
    @FlaggedApi(FLAG_POLICY_STREAMLINING)
    public static final PolicyIdentifier<Boolean> SCREEN_CAPTURE_DISABLED =
                new PolicyIdentifier<>(SCREEN_CAPTURE_DISABLED_KEY);
    @NonNull
    @PolicyDefinition
    @BooleanPolicyDefinition
    public static final PolicyIdentifier<Boolean> SCREEN_CAPTURE_DISABLED = new PolicyIdentifier<>(
            SCREEN_CAPTURE_DISABLED_KEY);
}
+32 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
    default_team: "trendy_team_enterprise",
}

java_library_host {
    name: "DevicePolicyAnnotationProcessorHostLibrary",
    srcs: [
        "src/**/*.kt",
        "annotations/**/*.java",
    ],
    use_tools_jar: true,
    static_libs: ["jsonlib"],
}

java_plugin {
    name: "DevicePolicyAnnotationProcessor",
    processor_class: "android.processor.devicepolicy.PolicyProcessor",
    static_libs: ["DevicePolicyAnnotationProcessorHostLibrary"],
}

java_library {
    name: "DevicePolicyAnnotation",
    srcs: ["annotations/**/*.java"],
    sdk_version: "core_current",
    host_supported: true,
}
+2 −0
Original line number Diff line number Diff line
include /core/java/android/app/admin/EnterprisePlatform_OWNERS
vsavu@google.com
 No newline at end of file
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.processor.devicepolicy;

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

/**
 * Metadata for a boolean policy.
 */
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.FIELD})
public @interface BooleanPolicyDefinition {
}
Loading