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

Commit 2c5d1f8d authored by George's avatar George
Browse files

Adding Nfc Tag App Preference setting to special_access settings

In the settings app, allow users to change the preference of the Nfc Tag apps.

Bug: 244272155
Test: make RunSettingsRoboTests ROBOTEST_FILTER=NfcTagAppsPreferenceControllerTest
Change-Id: I28903fae8935613a0e8618da21ca44e98b8801d5
parent a72e62b3
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -6916,6 +6916,9 @@
    <!-- List of synonyms for the always show time and info [CHAR LIMIT=NONE] -->
    <string name="keywords_always_show_time_info">always on display, AOD</string>
    <!-- List of synonyms for the nfc tag apps control [CHAR LIMIT=NONE] -->
    <string name="keywords_change_nfc_tag_apps_state">nfc, tag, reader</string>
    <!-- Summary for sound settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
    <string name="sound_dashboard_summary">Volume, vibration, Do Not Disturb</string>
@@ -10238,6 +10241,15 @@
    <!-- Apps > App Details > Wifi access > Description. [CHAR LIMIT=NONE] -->
    <string name="change_wifi_state_app_detail_summary">Allow this app to turn Wi-Fi on or off, scan and connect to Wi-Fi networks, add or remove networks, or start a local-only hotspot</string>
    <!-- Title for Nfc Tag apps control [CHAR LIMIT=35] -->
    <string name="change_nfc_tag_apps_title">NFC Tag apps control</string>
    <!-- Apps > App Details > Nfc Tag apps control > Switch title. [CHAR LIMIT=NONE] -->
    <string name="change_nfc_tag_apps_detail_switch">Allow app to popup upon NFC tags detected</string>
    <!-- Apps > App Details > Nfc Tag apps control > Description. [CHAR LIMIT=NONE] -->
    <string name="change_nfc_tag_apps_detail_summary">Allow this app to launch and get tag contents when the device detests NFC tags</string>
    <!-- Title for media output settings -->
    <string name="media_output_title">Play media to</string>
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 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.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="change_nfc_tag_apps"
    android:title="@string/change_nfc_tag_apps_title">

  <com.android.settings.widget.FilterTouchesSwitchPreference
      android:key="app_ops_settings_switch"
      android:title="@string/change_nfc_tag_apps_detail_switch"/>

  <com.android.settingslib.widget.FooterPreference
      android:key="app_ops_settings_preference"
      android:title="@string/change_nfc_tag_apps_detail_summary"
      android:selectable="false"/>

</PreferenceScreen>
+11 −0
Original line number Diff line number Diff line
@@ -197,4 +197,15 @@
        android:title="@string/special_access_more"
        android:order="-100"
        settings:controller="com.android.settings.applications.specialaccess.MoreSpecialAccessPreferenceController" />

    <Preference
        android:key="change_nfc_tag_apps_state"
        android:title="@string/change_nfc_tag_apps_title"
        android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
        settings:keywords="@string/keywords_change_nfc_tag_apps_state"
        settings:controller="com.android.settings.nfc.NfcTagAppsPreferenceController">
        <extra
            android:name="classname"
            android:value="com.android.settings.Settings$ChangeNfcTagAppsActivity" />
    </Preference>
</PreferenceScreen>
+2 −0
Original line number Diff line number Diff line
@@ -348,6 +348,8 @@ public class Settings extends SettingsActivity {
    public static class AppMediaManagementAppsActivity extends SettingsActivity { /* empty */ }
    public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
    public static class ChangeWifiStateActivity extends SettingsActivity { /* empty */ }
    /** Activity to manage NFC Tag applications. */
    public static class ChangeNfcTagAppsActivity extends SettingsActivity { /* empty */ }
    public static class AppDrawOverlaySettingsActivity extends SettingsActivity { /* empty */ }
    public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ }
    /** Activity to manage app battery usage details. */
+14 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.settings.applications.AppStateOverlayBridge;
import com.android.settings.applications.AppStatePowerBridge;
import com.android.settings.applications.AppStateUsageBridge;
import com.android.settings.applications.AppStateWriteSettingsBridge;
import com.android.settings.nfc.AppStateNfcTagAppsBridge;
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
import com.android.settingslib.applications.ApplicationsState;

@@ -65,6 +66,7 @@ public class AppFilterRegistry {
                FILTER_APPS_BATTERY_RESTRICTED,
                FILTER_LONG_BACKGROUND_TASKS,
                FILTER_APPS_CLONE,
                FILTER_APPS_NFC_TAG,
            })
    @interface FilterType {}

@@ -95,8 +97,9 @@ public class AppFilterRegistry {
    public static final int FILTER_APPS_BATTERY_RESTRICTED = 23;
    public static final int FILTER_LONG_BACKGROUND_TASKS = 24;
    public static final int FILTER_APPS_CLONE = 25;
    // Next id: 26. If you add an entry here, please change NUM_FILTER_ENTRIES.
    private static final int NUM_FILTER_ENTRIES = 26;
    public static final int FILTER_APPS_NFC_TAG = 26;
    private static final int NUM_FILTER_ENTRIES = 27;
    // Next id: 27. If you add an entry here, please change NUM_FILTER_ENTRIES.

    private static AppFilterRegistry sRegistry;

@@ -261,6 +264,13 @@ public class AppFilterRegistry {
                        AppStateClonedAppsBridge.FILTER_APPS_CLONE,
                        FILTER_APPS_CLONE,
                        R.string.cloned_apps_dashboard_title);

        // Apps that are nfc tag allowlisted.
        mFilters[FILTER_APPS_NFC_TAG] =
                new AppFilterItem(
                        AppStateNfcTagAppsBridge.FILTER_APPS_NFC_TAG,
                        FILTER_APPS_NFC_TAG,
                        R.string.change_nfc_tag_apps_title);
    }

    public static AppFilterRegistry getInstance() {
@@ -301,6 +311,8 @@ public class AppFilterRegistry {
                return FILTER_LONG_BACKGROUND_TASKS;
            case ManageApplications.LIST_TYPE_CLONED_APPS:
                return FILTER_APPS_CLONE;
            case ManageApplications.LIST_TYPE_NFC_TAG_APPS:
                return FILTER_APPS_NFC_TAG;
            default:
                return FILTER_APPS_ALL;
        }
Loading