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

Commit a4178609 authored by Roshan Pius's avatar Roshan Pius
Browse files

Implement DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO AE user restriction

This CL adds a user restriction for disallowing NFC on a device.
A user restriction is needed for NIAP (Common Criteria) certification.
One of the requirements for the certification is to be able to enable/disable
all the radios.

Bug: 271452372
Test: Compiles
(cherry picked from https://android-review.googlesource.com/q/commit:8c7af49706b7bf8c5026d1ef826cadeb65602f95)
Merged-In: Idbdce79a4fffe62f4daf3d378452a547e8871322
Change-Id: Idbdce79a4fffe62f4daf3d378452a547e8871322

NOTE FOR REVIEWERS - errors occurred while applying the patch.
PLEASE REVIEW CAREFULLY.
Errors:
Error applying patch in core/java/android/os/UserManager.java, hunk HunkHeader[1609,6->1634,7]: Hunk cannot be applied
Error applying patch in services/core/java/com/android/server/pm/UserRestrictionsUtils.java, hunk HunkHeader[149,7->149,8]: Hunk cannot be applied

Original patch:
 From 8c7af49706b7bf8c5026d1ef826cadeb65602f95 Mon Sep 17 00:00:00 2001
From: Roshan Pius <rpius@google.com>
Date: Thu, 17 Aug 2023 14:38:03 -0700
Subject: [PATCH] Implement DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO AE user restriction

This CL adds a user restriction for disallowing NFC on a device.
A user restriction is needed for NIAP (Common Criteria) certification.
One of the requirements for the certification is to be able to enable/disable
all the radios.

Bug: 271452372
Test: Compiles
Change-Id: Idbdce79a4fffe62f4daf3d378452a547e8871322
---
parent 77bc8299
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -33955,6 +33955,7 @@ package android.os {
    field public static final String DISALLOW_MICROPHONE_TOGGLE = "disallow_microphone_toggle";
    field public static final String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts";
    field public static final String DISALLOW_MOUNT_PHYSICAL_MEDIA = "no_physical_media";
    field public static final String DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO = "no_near_field_communication_radio";
    field public static final String DISALLOW_NETWORK_RESET = "no_network_reset";
    field public static final String DISALLOW_OUTGOING_BEAM = "no_outgoing_beam";
    field public static final String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls";
+26 −0
Original line number Diff line number Diff line
@@ -1809,6 +1809,31 @@ public class UserManager {
     */
    public static final String DISALLOW_ULTRA_WIDEBAND_RADIO = "no_ultra_wideband_radio";

    /**
     * This user restriction specifies if Near-field communication is disallowed on the device. If
     * Near-field communication is disallowed it cannot be turned on via Settings.
     *
     * <p>This restriction can only be set by a device owner or a profile owner of an
     * organization-owned managed profile on the parent profile.
     * In both cases, the restriction applies globally on the device and will turn off the
     * Near-field communication radio if it's currently on and prevent the radio from being turned
     * on in the future.
     *
     * <p>
     * Near-field communication (NFC) is a radio technology that allows two devices (like your phone
     * and a payments terminal) to communicate with each other when they're close together.
     *
     * <p>Default is <code>false</code>.
     *
     * <p>Key for user restrictions.
     * <p>Type: Boolean
     * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
     * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
     * @see #getUserRestrictions()
     */
    public static final String DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO =
            "no_near_field_communication_radio";

    /**
     * List of key values that can be passed into the various user restriction related methods
     * in {@link UserManager} & {@link DevicePolicyManager}.
@@ -1893,6 +1918,7 @@ public class UserManager {
            DISALLOW_CELLULAR_2G,
            DISALLOW_ULTRA_WIDEBAND_RADIO,
            DISALLOW_GRANT_ADMIN,
            DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface UserRestrictionKey {}
+6 −3
Original line number Diff line number Diff line
@@ -151,7 +151,8 @@ public class UserRestrictionsUtils {
            UserManager.DISALLOW_ADD_WIFI_CONFIG,
            UserManager.DISALLOW_CELLULAR_2G,
            UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,
            UserManager.DISALLOW_CONFIG_DEFAULT_APPS
            UserManager.DISALLOW_CONFIG_DEFAULT_APPS,
            UserManager.DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO
    });

    public static final Set<String> DEPRECATED_USER_RESTRICTIONS = Sets.newArraySet(
@@ -201,7 +202,8 @@ public class UserRestrictionsUtils {
            UserManager.DISALLOW_WIFI_DIRECT,
            UserManager.DISALLOW_ADD_WIFI_CONFIG,
            UserManager.DISALLOW_CELLULAR_2G,
            UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO
            UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,
            UserManager.DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO
    );

    /**
@@ -243,7 +245,8 @@ public class UserRestrictionsUtils {
                    UserManager.DISALLOW_WIFI_DIRECT,
                    UserManager.DISALLOW_ADD_WIFI_CONFIG,
                    UserManager.DISALLOW_CELLULAR_2G,
                    UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO
                    UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,
                    UserManager.DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO
    );

    /**