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

Commit cd500106 authored by Bob Wang's avatar Bob Wang Committed by Automerger Merge Worker
Browse files

Merge "[framework] Expose setServiceEnabledForCategoryOther as system api."...

Merge "[framework] Expose setServiceEnabledForCategoryOther as system api." into main am: 6a545a31

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3302255



Change-Id: I5e7fa16c515a647183e60d6e405a7e1648157150
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 94a10629 6a545a31
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -183,6 +183,12 @@ package android.nfc.cardemulation {
    method @FlaggedApi("android.nfc.enable_nfc_mainline") @NonNull public java.util.List<android.nfc.cardemulation.ApduServiceInfo> getServices(@NonNull String, int);
    method @FlaggedApi("android.nfc.nfc_override_recover_routing_table") public void overrideRoutingTable(@NonNull android.app.Activity, int, int);
    method @FlaggedApi("android.nfc.nfc_override_recover_routing_table") public void recoverRoutingTable(@NonNull android.app.Activity);
    method @FlaggedApi("android.nfc.nfc_set_service_enabled_for_category_other") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int setServiceEnabledForCategoryOther(@NonNull android.content.ComponentName, boolean);
    field @FlaggedApi("android.nfc.nfc_set_service_enabled_for_category_other") public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_ALREADY_SET = 3; // 0x3
    field @FlaggedApi("android.nfc.nfc_set_service_enabled_for_category_other") public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_FEATURE_UNSUPPORTED = 1; // 0x1
    field @FlaggedApi("android.nfc.nfc_set_service_enabled_for_category_other") public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_INVALID_SERVICE = 2; // 0x2
    field @FlaggedApi("android.nfc.nfc_set_service_enabled_for_category_other") public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_UNKNOWN_ERROR = 4; // 0x4
    field @FlaggedApi("android.nfc.nfc_set_service_enabled_for_category_other") public static final int SET_SERVICE_ENABLED_STATUS_OK = 0; // 0x0
  }

}
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ interface INfcCardEmulation
    boolean unsetPreferredService();
    boolean supportsAidPrefixRegistration();
    ApduServiceInfo getPreferredPaymentService(int userHandle);
    boolean setServiceEnabledForCategoryOther(int userHandle, in ComponentName app, boolean status);
    int setServiceEnabledForCategoryOther(int userHandle, in ComponentName app, boolean status);
    boolean isDefaultPaymentRegistered();

    void overrideRoutingTable(int userHandle, String protocol, String technology, in String pkg);
+70 −9
Original line number Diff line number Diff line
@@ -185,6 +185,65 @@ public final class CardEmulation {
    @FlaggedApi(Flags.FLAG_NFC_OVERRIDE_RECOVER_ROUTING_TABLE)
    public static final int PROTOCOL_AND_TECHNOLOGY_ROUTE_UNSET = -1;

    /**
     * Status code returned when {@link #setServiceEnabledForCategoryOther(ComponentName, boolean)}
     * succeeded.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_NFC_SET_SERVICE_ENABLED_FOR_CATEGORY_OTHER)
    public static final int SET_SERVICE_ENABLED_STATUS_OK = 0;

    /**
     * Status code returned when {@link #setServiceEnabledForCategoryOther(ComponentName, boolean)}
     * failed due to the unsupported feature.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_NFC_SET_SERVICE_ENABLED_FOR_CATEGORY_OTHER)
    public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_FEATURE_UNSUPPORTED = 1;

    /**
     * Status code returned when {@link #setServiceEnabledForCategoryOther(ComponentName, boolean)}
     * failed due to the invalid service.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_NFC_SET_SERVICE_ENABLED_FOR_CATEGORY_OTHER)
    public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_INVALID_SERVICE = 2;

    /**
     * Status code returned when {@link #setServiceEnabledForCategoryOther(ComponentName, boolean)}
     * failed due to the service is already set to the requested status.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_NFC_SET_SERVICE_ENABLED_FOR_CATEGORY_OTHER)
    public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_ALREADY_SET = 3;

    /**
     * Status code returned when {@link #setServiceEnabledForCategoryOther(ComponentName, boolean)}
     * failed due to unknown error.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_NFC_SET_SERVICE_ENABLED_FOR_CATEGORY_OTHER)
    public static final int SET_SERVICE_ENABLED_STATUS_FAILURE_UNKNOWN_ERROR = 4;

    /**
     * Status code returned by {@link #setServiceEnabledForCategoryOther(ComponentName, boolean)}
     * @hide
     */
    @IntDef(prefix = "SET_SERVICE_ENABLED_STATUS_", value = {
            SET_SERVICE_ENABLED_STATUS_OK,
            SET_SERVICE_ENABLED_STATUS_FAILURE_FEATURE_UNSUPPORTED,
            SET_SERVICE_ENABLED_STATUS_FAILURE_INVALID_SERVICE,
            SET_SERVICE_ENABLED_STATUS_FAILURE_ALREADY_SET,
            SET_SERVICE_ENABLED_STATUS_FAILURE_UNKNOWN_ERROR
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SetServiceEnabledStatusCode {}

    static boolean sIsInitialized = false;
    static HashMap<Context, CardEmulation> sCardEmus = new HashMap<Context, CardEmulation>();
    static INfcCardEmulation sService;
@@ -883,22 +942,24 @@ public final class CardEmulation {
    }

    /**
     * Allows to set or unset preferred service (category other) to avoid  AID Collision.
     * Allows to set or unset preferred service (category other) to avoid AID Collision. The user
     * should use corresponding context using {@link Context#createContextAsUser(UserHandle, int)}
     *
     * @param service The ComponentName of the service
     * @param status  true to enable, false to disable
     * @param userId the user handle of the user whose information is being requested.
     * @return set service for the category and true if service is already set return false.
     * @return true if preferred service is successfully set or unset, otherwise return false.
     *
     * @hide
     */
    public boolean setServiceEnabledForCategoryOther(ComponentName service, boolean status,
                                                     int userId) {
        if (service == null) {
            throw new NullPointerException("activity or service or category is null");
        }
    @SystemApi
    @FlaggedApi(Flags.FLAG_NFC_SET_SERVICE_ENABLED_FOR_CATEGORY_OTHER)
    @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
    @SetServiceEnabledStatusCode
    public int setServiceEnabledForCategoryOther(@NonNull ComponentName service,
            boolean status) {
        return callServiceReturn(() ->
                sService.setServiceEnabledForCategoryOther(userId, service, status), false);
                sService.setServiceEnabledForCategoryOther(mContext.getUser().getIdentifier(),
                        service, status), SET_SERVICE_ENABLED_STATUS_FAILURE_UNKNOWN_ERROR);
    }

    /** @hide */
+8 −0
Original line number Diff line number Diff line
@@ -173,3 +173,11 @@ flag {
    description: "Share wallet role routing priority with associated services"
    bug: "366243361"
}

flag {
    name: "nfc_set_service_enabled_for_category_other"
    is_exported: true
    namespace: "nfc"
    description: "Enable set service enabled for category other"
    bug: "338157113"
}