• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.providers.settings;
18 
19 import android.net.Uri;
20 import android.provider.Settings;
21 
22 /**
23  * Class to store the keys used for backup and restore.
24  */
25 final class SettingsBackupRestoreKeys {
26     static final String KEY_UNKNOWN = "unknown";
27     static final String KEY_SYSTEM = "system";
28     static final String KEY_SECURE = "secure";
29     static final String KEY_GLOBAL = "global";
30     static final String KEY_LOCALE = "locale";
31     static final String KEY_LOCK_SETTINGS = "lock_settings";
32     static final String KEY_SOFTAP_CONFIG = "softap_config";
33     static final String KEY_NETWORK_POLICIES = "network_policies";
34     static final String KEY_WIFI_NEW_CONFIG = "wifi_new_config";
35     static final String KEY_DEVICE_SPECIFIC_CONFIG = "device_specific_config";
36     static final String KEY_SIM_SPECIFIC_SETTINGS = "sim_specific_settings";
37     // Restoring sim-specific data backed up from newer Android version to Android 12 was causing a
38     // fatal crash. Creating a backup with a different key will prevent Android 12 versions from
39     // restoring this data.
40     static final String KEY_SIM_SPECIFIC_SETTINGS_2 = "sim_specific_settings_2";
41     static final String KEY_WIFI_SETTINGS_BACKUP_DATA = "wifi_settings_backup_data";
42 
43     /**
44      * Returns the key corresponding to the given URI.
45      *
46      * @param uri The URI of the setting's destination.
47      * @return The key corresponding to the given URI, or KEY_UNKNOWN if the URI is not recognized.
48      */
getKeyFromUri(Uri uri)49     static String getKeyFromUri(Uri uri) {
50       if (uri.equals(Settings.Secure.CONTENT_URI)) {
51         return KEY_SECURE;
52       } else if (uri.equals(Settings.System.CONTENT_URI)) {
53         return KEY_SYSTEM;
54       } else if (uri.equals(Settings.Global.CONTENT_URI)) {
55         return KEY_GLOBAL;
56       } else {
57         return KEY_UNKNOWN;
58       }
59     }
60 
61 }