1 /*
2  * Copyright (C) 2006-2011 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.server.am;
18 
19 import android.annotation.NonNull;
20 import android.app.ActivityThread;
21 import android.content.ContentResolver;
22 import android.content.Context;
23 import android.database.ContentObserver;
24 import android.net.Uri;
25 import android.os.Bundle;
26 import android.provider.DeviceConfig;
27 import android.provider.Settings;
28 import android.text.TextFlags;
29 import android.widget.WidgetFlags;
30 
31 import com.android.internal.R;
32 import com.android.internal.annotations.VisibleForTesting;
33 import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
34 
35 import java.util.ArrayList;
36 import java.util.HashMap;
37 import java.util.HashSet;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.Objects;
41 
42 /**
43  * Helper class for watching a set of core settings which the framework
44  * propagates to application processes to avoid multiple lookups and potentially
45  * disk I/O operations. Note: This class assumes that all core settings reside
46  * in {@link Settings.Secure}.
47  */
48 final class CoreSettingsObserver extends ContentObserver {
49     private static final String LOG_TAG = CoreSettingsObserver.class.getSimpleName();
50 
51     private static class DeviceConfigEntry<T> {
52         String namespace;
53         String flag;
54         String coreSettingKey;
55         Class<T> type;
56         T defaultValue;
57 
DeviceConfigEntry(String namespace, String flag, String coreSettingKey, Class<T> type, @NonNull T defaultValue)58         DeviceConfigEntry(String namespace, String flag, String coreSettingKey, Class<T> type,
59                 @NonNull T defaultValue) {
60             this.namespace = namespace;
61             this.flag = flag;
62             this.coreSettingKey = coreSettingKey;
63             this.type = type;
64             this.defaultValue = Objects.requireNonNull(defaultValue);
65         }
66     }
67 
68     // mapping form property name to its type
69     @VisibleForTesting
70     static final Map<String, Class<?>> sSecureSettingToTypeMap = new HashMap<
71             String, Class<?>>();
72     @VisibleForTesting
73     static final Map<String, Class<?>> sSystemSettingToTypeMap = new HashMap<
74             String, Class<?>>();
75     @VisibleForTesting
76     static final Map<String, Class<?>> sGlobalSettingToTypeMap = new HashMap<
77             String, Class<?>>();
78     static final List<DeviceConfigEntry> sDeviceConfigEntries = new ArrayList<DeviceConfigEntry>();
79     static {
sSecureSettingToTypeMap.put(Settings.Secure.LONG_PRESS_TIMEOUT, int.class)80         sSecureSettingToTypeMap.put(Settings.Secure.LONG_PRESS_TIMEOUT, int.class);
sSecureSettingToTypeMap.put(Settings.Secure.MULTI_PRESS_TIMEOUT, int.class)81         sSecureSettingToTypeMap.put(Settings.Secure.MULTI_PRESS_TIMEOUT, int.class);
82         // add other secure settings here...
83 
sSystemSettingToTypeMap.put(Settings.System.TIME_12_24, String.class)84         sSystemSettingToTypeMap.put(Settings.System.TIME_12_24, String.class);
85         // add other system settings here...
86 
sGlobalSettingToTypeMap.put(Settings.Global.DEBUG_VIEW_ATTRIBUTES, int.class)87         sGlobalSettingToTypeMap.put(Settings.Global.DEBUG_VIEW_ATTRIBUTES, int.class);
sGlobalSettingToTypeMap.put( Settings.Global.DEBUG_VIEW_ATTRIBUTES_APPLICATION_PACKAGE, String.class)88         sGlobalSettingToTypeMap.put(
89                 Settings.Global.DEBUG_VIEW_ATTRIBUTES_APPLICATION_PACKAGE, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.ANGLE_DEBUG_PACKAGE, String.class)90         sGlobalSettingToTypeMap.put(
91                 Settings.Global.ANGLE_DEBUG_PACKAGE, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.ANGLE_GL_DRIVER_ALL_ANGLE, int.class)92         sGlobalSettingToTypeMap.put(
93                 Settings.Global.ANGLE_GL_DRIVER_ALL_ANGLE, int.class);
sGlobalSettingToTypeMap.put( Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS, String.class)94         sGlobalSettingToTypeMap.put(
95                 Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES, String.class)96         sGlobalSettingToTypeMap.put(
97                 Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.ANGLE_EGL_FEATURES, String.class)98         sGlobalSettingToTypeMap.put(
99                 Settings.Global.ANGLE_EGL_FEATURES, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.SHOW_ANGLE_IN_USE_DIALOG_BOX, String.class)100         sGlobalSettingToTypeMap.put(
101                 Settings.Global.SHOW_ANGLE_IN_USE_DIALOG_BOX, String.class);
sGlobalSettingToTypeMap.put(Settings.Global.ENABLE_GPU_DEBUG_LAYERS, int.class)102         sGlobalSettingToTypeMap.put(Settings.Global.ENABLE_GPU_DEBUG_LAYERS, int.class);
sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_APP, String.class)103         sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_APP, String.class);
sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_LAYERS, String.class)104         sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_LAYERS, String.class);
sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_LAYERS_GLES, String.class)105         sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_LAYERS_GLES, String.class);
sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_LAYER_APP, String.class)106         sGlobalSettingToTypeMap.put(Settings.Global.GPU_DEBUG_LAYER_APP, String.class);
sGlobalSettingToTypeMap.put(Settings.Global.UPDATABLE_DRIVER_ALL_APPS, int.class)107         sGlobalSettingToTypeMap.put(Settings.Global.UPDATABLE_DRIVER_ALL_APPS, int.class);
sGlobalSettingToTypeMap.put( Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS, String.class)108         sGlobalSettingToTypeMap.put(
109                 Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS, String.class)110         sGlobalSettingToTypeMap.put(
111                 Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS, String.class)112         sGlobalSettingToTypeMap.put(
113                 Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.UPDATABLE_DRIVER_PRODUCTION_DENYLIST, String.class)114         sGlobalSettingToTypeMap.put(
115                 Settings.Global.UPDATABLE_DRIVER_PRODUCTION_DENYLIST, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.UPDATABLE_DRIVER_PRODUCTION_ALLOWLIST, String.class)116         sGlobalSettingToTypeMap.put(
117                 Settings.Global.UPDATABLE_DRIVER_PRODUCTION_ALLOWLIST, String.class);
sGlobalSettingToTypeMap.put( Settings.Global.UPDATABLE_DRIVER_PRODUCTION_DENYLISTS, String.class)118         sGlobalSettingToTypeMap.put(
119                 Settings.Global.UPDATABLE_DRIVER_PRODUCTION_DENYLISTS, String.class);
sGlobalSettingToTypeMap.put(Settings.Global.UPDATABLE_DRIVER_SPHAL_LIBRARIES, String.class)120         sGlobalSettingToTypeMap.put(Settings.Global.UPDATABLE_DRIVER_SPHAL_LIBRARIES, String.class);
121         // add other global settings here...
122 
sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE, WidgetFlags.KEY_ENABLE_CURSOR_DRAG_FROM_ANYWHERE, boolean.class, WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT))123         sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
124                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE,
125                 WidgetFlags.KEY_ENABLE_CURSOR_DRAG_FROM_ANYWHERE, boolean.class,
126                 WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL, WidgetFlags.KEY_CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL, int.class, WidgetFlags.CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL_DEFAULT))127         sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>(
128                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL,
129                 WidgetFlags.KEY_CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL, int.class,
130                 WidgetFlags.CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.FINGER_TO_CURSOR_DISTANCE, WidgetFlags.KEY_FINGER_TO_CURSOR_DISTANCE, int.class, WidgetFlags.FINGER_TO_CURSOR_DISTANCE_DEFAULT))131         sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>(
132                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.FINGER_TO_CURSOR_DISTANCE,
133                 WidgetFlags.KEY_FINGER_TO_CURSOR_DISTANCE, int.class,
134                 WidgetFlags.FINGER_TO_CURSOR_DISTANCE_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES, WidgetFlags.KEY_ENABLE_INSERTION_HANDLE_GESTURES, boolean.class, WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES_DEFAULT))135         sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
136                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES,
137                 WidgetFlags.KEY_ENABLE_INSERTION_HANDLE_GESTURES, boolean.class,
138                 WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.INSERTION_HANDLE_DELTA_HEIGHT, WidgetFlags.KEY_INSERTION_HANDLE_DELTA_HEIGHT, int.class, WidgetFlags.INSERTION_HANDLE_DELTA_HEIGHT_DEFAULT))139         sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>(
140                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.INSERTION_HANDLE_DELTA_HEIGHT,
141                 WidgetFlags.KEY_INSERTION_HANDLE_DELTA_HEIGHT, int.class,
142                 WidgetFlags.INSERTION_HANDLE_DELTA_HEIGHT_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.INSERTION_HANDLE_OPACITY, WidgetFlags.KEY_INSERTION_HANDLE_OPACITY, int.class, WidgetFlags.INSERTION_HANDLE_OPACITY_DEFAULT))143         sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>(
144                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.INSERTION_HANDLE_OPACITY,
145                 WidgetFlags.KEY_INSERTION_HANDLE_OPACITY, int.class,
146                 WidgetFlags.INSERTION_HANDLE_OPACITY_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Float>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.LINE_SLOP_RATIO, WidgetFlags.KEY_LINE_SLOP_RATIO, float.class, WidgetFlags.LINE_SLOP_RATIO_DEFAULT))147         sDeviceConfigEntries.add(new DeviceConfigEntry<Float>(
148                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.LINE_SLOP_RATIO,
149                 WidgetFlags.KEY_LINE_SLOP_RATIO, float.class,
150                 WidgetFlags.LINE_SLOP_RATIO_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_NEW_MAGNIFIER, WidgetFlags.KEY_ENABLE_NEW_MAGNIFIER, boolean.class, WidgetFlags.ENABLE_NEW_MAGNIFIER_DEFAULT))151         sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
152                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_NEW_MAGNIFIER,
153                 WidgetFlags.KEY_ENABLE_NEW_MAGNIFIER, boolean.class,
154                 WidgetFlags.ENABLE_NEW_MAGNIFIER_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Float>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.MAGNIFIER_ZOOM_FACTOR, WidgetFlags.KEY_MAGNIFIER_ZOOM_FACTOR, float.class, WidgetFlags.MAGNIFIER_ZOOM_FACTOR_DEFAULT))155         sDeviceConfigEntries.add(new DeviceConfigEntry<Float>(
156                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.MAGNIFIER_ZOOM_FACTOR,
157                 WidgetFlags.KEY_MAGNIFIER_ZOOM_FACTOR, float.class,
158                 WidgetFlags.MAGNIFIER_ZOOM_FACTOR_DEFAULT));
sDeviceConfigEntries.add(new DeviceConfigEntry<Float>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.MAGNIFIER_ASPECT_RATIO, WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class, WidgetFlags.MAGNIFIER_ASPECT_RATIO_DEFAULT))159         sDeviceConfigEntries.add(new DeviceConfigEntry<Float>(
160                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.MAGNIFIER_ASPECT_RATIO,
161                 WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class,
162                 WidgetFlags.MAGNIFIER_ASPECT_RATIO_DEFAULT));
163 
sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION, SystemUiDeviceConfigFlags.KEY_REMOTEVIEWS_ADAPTER_CONVERSION, boolean.class, SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION_DEFAULT))164         sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
165                 DeviceConfig.NAMESPACE_SYSTEMUI,
166                 SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION,
167                 SystemUiDeviceConfigFlags.KEY_REMOTEVIEWS_ADAPTER_CONVERSION, boolean.class,
168                 SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION_DEFAULT));
169 
sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>( TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU, TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class, TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT))170         sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
171                 TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU,
172                 TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class,
173                 TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT));
174         // add other device configs here...
175     }
176     private static volatile boolean sDeviceConfigContextEntriesLoaded = false;
177 
178     private final Bundle mCoreSettings = new Bundle();
179 
180     private final ActivityManagerService mActivityManagerService;
181 
CoreSettingsObserver(ActivityManagerService activityManagerService)182     public CoreSettingsObserver(ActivityManagerService activityManagerService) {
183         super(activityManagerService.mHandler);
184 
185         if (!sDeviceConfigContextEntriesLoaded) {
186             synchronized (sDeviceConfigEntries) {
187                 if (!sDeviceConfigContextEntriesLoaded) {
188                     loadDeviceConfigContextEntries(activityManagerService.mContext);
189                     sDeviceConfigContextEntriesLoaded = true;
190                 }
191             }
192         }
193 
194         mActivityManagerService = activityManagerService;
195         beginObserveCoreSettings();
196         sendCoreSettings();
197     }
198 
loadDeviceConfigContextEntries(Context context)199     private static void loadDeviceConfigContextEntries(Context context) {
200         sDeviceConfigEntries.add(new DeviceConfigEntry<>(
201                 DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS,
202                 WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS, int.class,
203                 context.getResources()
204                         .getInteger(R.integer.config_defaultAnalogClockSecondsHandFps)));
205     }
206 
getCoreSettingsLocked()207     public Bundle getCoreSettingsLocked() {
208         return (Bundle) mCoreSettings.clone();
209     }
210 
211     @Override
onChange(boolean selfChange)212     public void onChange(boolean selfChange) {
213         synchronized (mActivityManagerService) {
214             sendCoreSettings();
215         }
216     }
217 
sendCoreSettings()218     private void sendCoreSettings() {
219         populateSettings(mCoreSettings, sSecureSettingToTypeMap);
220         populateSettings(mCoreSettings, sSystemSettingToTypeMap);
221         populateSettings(mCoreSettings, sGlobalSettingToTypeMap);
222         populateSettingsFromDeviceConfig();
223         mActivityManagerService.onCoreSettingsChange(mCoreSettings);
224     }
225 
beginObserveCoreSettings()226     private void beginObserveCoreSettings() {
227         for (String setting : sSecureSettingToTypeMap.keySet()) {
228             Uri uri = Settings.Secure.getUriFor(setting);
229             mActivityManagerService.mContext.getContentResolver().registerContentObserver(
230                     uri, false, this);
231         }
232 
233         for (String setting : sSystemSettingToTypeMap.keySet()) {
234             Uri uri = Settings.System.getUriFor(setting);
235             mActivityManagerService.mContext.getContentResolver().registerContentObserver(
236                     uri, false, this);
237         }
238 
239         for (String setting : sGlobalSettingToTypeMap.keySet()) {
240             Uri uri = Settings.Global.getUriFor(setting);
241             mActivityManagerService.mContext.getContentResolver().registerContentObserver(
242                     uri, false, this);
243         }
244 
245         HashSet<String> deviceConfigNamespaces = new HashSet<>();
246         for (DeviceConfigEntry entry : sDeviceConfigEntries) {
247             if (!deviceConfigNamespaces.contains(entry.namespace)) {
248                 DeviceConfig.addOnPropertiesChangedListener(
249                         entry.namespace, ActivityThread.currentApplication().getMainExecutor(),
250                         (DeviceConfig.Properties prop) -> onChange(false));
251                 deviceConfigNamespaces.add(entry.namespace);
252             }
253         }
254     }
255 
256     @VisibleForTesting
populateSettings(Bundle snapshot, Map<String, Class<?>> map)257     void populateSettings(Bundle snapshot, Map<String, Class<?>> map) {
258         final Context context = mActivityManagerService.mContext;
259         final ContentResolver cr = context.getContentResolver();
260         for (Map.Entry<String, Class<?>> entry : map.entrySet()) {
261             String setting = entry.getKey();
262             final String value;
263             if (map == sSecureSettingToTypeMap) {
264                 value = Settings.Secure.getStringForUser(cr, setting, cr.getUserId());
265             } else if (map == sSystemSettingToTypeMap) {
266                 value = Settings.System.getStringForUser(cr, setting, cr.getUserId());
267             } else {
268                 value = Settings.Global.getString(cr, setting);
269             }
270             if (value == null) {
271                 snapshot.remove(setting);
272                 continue;
273             }
274             Class<?> type = entry.getValue();
275             if (type == String.class) {
276                 snapshot.putString(setting, value);
277             } else if (type == int.class) {
278                 snapshot.putInt(setting, Integer.parseInt(value));
279             } else if (type == float.class) {
280                 snapshot.putFloat(setting, Float.parseFloat(value));
281             } else if (type == long.class) {
282                 snapshot.putLong(setting, Long.parseLong(value));
283             }
284         }
285     }
286 
287     @SuppressWarnings("unchecked")
populateSettingsFromDeviceConfig()288     private void populateSettingsFromDeviceConfig() {
289         for (DeviceConfigEntry<?> entry : sDeviceConfigEntries) {
290             if (entry.type == String.class) {
291                 String defaultValue = ((DeviceConfigEntry<String>) entry).defaultValue;
292                 mCoreSettings.putString(entry.coreSettingKey,
293                         DeviceConfig.getString(entry.namespace, entry.flag, defaultValue));
294             } else if (entry.type == int.class) {
295                 int defaultValue = ((DeviceConfigEntry<Integer>) entry).defaultValue;
296                 mCoreSettings.putInt(entry.coreSettingKey,
297                         DeviceConfig.getInt(entry.namespace, entry.flag, defaultValue));
298             } else if (entry.type == float.class) {
299                 float defaultValue = ((DeviceConfigEntry<Float>) entry).defaultValue;
300                 mCoreSettings.putFloat(entry.coreSettingKey,
301                         DeviceConfig.getFloat(entry.namespace, entry.flag, defaultValue));
302             } else if (entry.type == long.class) {
303                 long defaultValue = ((DeviceConfigEntry<Long>) entry).defaultValue;
304                 mCoreSettings.putLong(entry.coreSettingKey,
305                         DeviceConfig.getLong(entry.namespace, entry.flag, defaultValue));
306             } else if (entry.type == boolean.class) {
307                 boolean defaultValue = ((DeviceConfigEntry<Boolean>) entry).defaultValue;
308                 mCoreSettings.putInt(entry.coreSettingKey,
309                         DeviceConfig.getBoolean(entry.namespace, entry.flag, defaultValue) ? 1 : 0);
310             }
311         }
312     }
313 }
314