blob: 73756c9b5b8ea8ad5c52e4d15bfd54d26f09f9af [file] [log] [blame]
Roshan Piusb790f672020-02-14 07:06:13 -08001/*
2 * Copyright (C) 2020 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
17package com.android.server.wifi;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
Roshan Piusb790f672020-02-14 07:06:13 -080021import android.content.Context;
Chris Ye04abeb22021-12-07 19:50:22 -080022import android.net.wifi.WifiManager;
Roshan Pius3225f112020-02-24 09:12:04 -080023import android.net.wifi.WifiMigration;
Roshan Piusb790f672020-02-14 07:06:13 -080024import android.os.Handler;
25import android.text.TextUtils;
26import android.util.Log;
27
28import com.android.internal.annotations.GuardedBy;
Roshan Piusb0ed8e22020-03-19 09:08:16 -070029import com.android.server.wifi.util.SettingsMigrationDataHolder;
Roshan Piusb790f672020-02-14 07:06:13 -080030import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil;
31import com.android.server.wifi.util.XmlUtil;
32
Roshan Piusb790f672020-02-14 07:06:13 -080033import org.xmlpull.v1.XmlPullParser;
34import org.xmlpull.v1.XmlPullParserException;
35import org.xmlpull.v1.XmlSerializer;
36
Roshan Piusda0d1992020-03-04 08:34:42 -080037import java.io.FileDescriptor;
Roshan Piusb790f672020-02-14 07:06:13 -080038import java.io.IOException;
Roshan Piusda0d1992020-03-04 08:34:42 -080039import java.io.PrintWriter;
Roshan Pius67ee4292020-02-25 09:51:02 -080040import java.util.ArrayList;
Roshan Piusb790f672020-02-14 07:06:13 -080041import java.util.HashMap;
42import java.util.Map;
43
44/**
45 * Store data for storing wifi settings. These are key (string) / value pairs that are stored in
46 * WifiConfigStore.xml file in a separate section.
47 */
48public class WifiSettingsConfigStore {
49 private static final String TAG = "WifiSettingsConfigStore";
50
Roshan Pius67ee4292020-02-25 09:51:02 -080051 // List of all allowed keys.
52 private static final ArrayList<Key> sKeys = new ArrayList<>();
53
Roshan Piusb790f672020-02-14 07:06:13 -080054 /******** Wifi shared pref keys ***************/
Roshan Pius0412d2d2020-02-10 13:26:42 -080055 /**
56 * Indicate whether factory reset request is pending.
57 */
Roshan Pius67ee4292020-02-25 09:51:02 -080058 public static final Key<Boolean> WIFI_P2P_PENDING_FACTORY_RESET =
59 new Key<>("wifi_p2p_pending_factory_reset", false);
Roshan Pius0412d2d2020-02-10 13:26:42 -080060
61 /**
62 * Allow scans to be enabled even wifi is turned off.
63 */
Roshan Pius67ee4292020-02-25 09:51:02 -080064 public static final Key<Boolean> WIFI_SCAN_ALWAYS_AVAILABLE =
65 new Key<>("wifi_scan_always_enabled", false);
Roshan Pius0412d2d2020-02-10 13:26:42 -080066
67 /**
68 * Whether wifi scan throttle is enabled or not.
69 */
Roshan Pius67ee4292020-02-25 09:51:02 -080070 public static final Key<Boolean> WIFI_SCAN_THROTTLE_ENABLED =
71 new Key<>("wifi_scan_throttle_enabled", true);
Roshan Pius0412d2d2020-02-10 13:26:42 -080072
73 /**
Nate(Qiang) Jiang6844aa42023-06-28 21:52:11 +000074 * Setting to enable verbose logging in Wi-Fi.
Roshan Pius0412d2d2020-02-10 13:26:42 -080075 */
Roshan Pius67ee4292020-02-25 09:51:02 -080076 public static final Key<Boolean> WIFI_VERBOSE_LOGGING_ENABLED =
77 new Key<>("wifi_verbose_logging_enabled", false);
78
79 /**
Nate(Qiang) Jiang6844aa42023-06-28 21:52:11 +000080 * Setting to enable verbose logging in Wi-Fi Aware.
81 */
82 public static final Key<Boolean> WIFI_AWARE_VERBOSE_LOGGING_ENABLED =
83 new Key<>("wifi_aware_verbose_logging_enabled", false);
84
85 /**
Roshan Pius67ee4292020-02-25 09:51:02 -080086 * The Wi-Fi peer-to-peer device name
87 */
88 public static final Key<String> WIFI_P2P_DEVICE_NAME =
89 new Key<>("wifi_p2p_device_name", null);
90
Mingguang Xu066d4442021-01-28 14:07:17 -080091 /**
Shuibing Dai6e0bfac2023-04-05 10:33:46 -070092 * The Wi-Fi peer-to-peer device mac address
93 */
94 public static final Key<String> WIFI_P2P_DEVICE_ADDRESS =
95 new Key<>("wifi_p2p_device_address", null);
96
97 /**
Mingguang Xu066d4442021-01-28 14:07:17 -080098 * Whether Wifi scoring is enabled or not.
99 */
100 public static final Key<Boolean> WIFI_SCORING_ENABLED =
101 new Key<>("wifi_scoring_enabled", true);
102
Roshan Pius1ec76102021-02-11 12:06:57 -0800103 /**
Chris Ye4ef08dd2021-06-14 23:21:45 -0700104 * Whether Wifi Passpoint is enabled or not.
105 */
106 public static final Key<Boolean> WIFI_PASSPOINT_ENABLED =
107 new Key<>("wifi_passpoint_enabled", true);
108
109 /**
Chris Ye04abeb22021-12-07 19:50:22 -0800110 * Whether Wifi Multi Internet is enabled for multi ap, dbs or disabled.
111 */
112 public static final Key<Integer> WIFI_MULTI_INTERNET_MODE =
113 new Key<Integer>("wifi_multi_internet_mode",
114 WifiManager.WIFI_MULTI_INTERNET_MODE_DISABLED);
115
116 /**
Roshan Pius1ec76102021-02-11 12:06:57 -0800117 * Store the STA factory MAC address retrieved from the driver on the first bootup.
118 */
119 public static final Key<String> WIFI_STA_FACTORY_MAC_ADDRESS =
120 new Key<>("wifi_sta_factory_mac_address", null);
121
Sunil Ravi15740d62021-04-11 19:21:06 -0700122 /**
zhujiataif2b68862022-11-24 16:21:35 +0800123 * Store the Secondary STA factory MAC address retrieved from the driver on the first bootup.
124 */
125 public static final Key<String> SECONDARY_WIFI_STA_FACTORY_MAC_ADDRESS =
126 new Key<>("secondary_wifi_sta_factory_mac_address", null);
127
128
129 /**
Sunil Ravi15740d62021-04-11 19:21:06 -0700130 * Store the default country code updated via {@link WifiManager#setDefaultCountryCode(String)}
131 */
132 public static final Key<String> WIFI_DEFAULT_COUNTRY_CODE =
133 new Key<>("wifi_default_country_code", WifiCountryCode.getOemDefaultCountryCode());
134
Sunil Ravi816ae072022-02-07 12:29:25 -0800135 /**
136 * Store the supported features retrieved from WiFi HAL and Supplicant HAL
137 */
138 public static final Key<Long> WIFI_NATIVE_SUPPORTED_FEATURES =
139 new Key<>("wifi_native_supported_features", 0L);
140
Quang Luong32e68362022-03-14 11:57:26 -0700141 /**
Chris Yeda276ae2022-10-12 16:16:28 -0700142 * Store the supported features retrieved from WiFi HAL and Supplicant HAL
143 */
144 public static final Key<Integer> WIFI_NATIVE_SUPPORTED_STA_BANDS =
145 new Key<>("wifi_native_supported_sta_bands", 0);
146
147 /**
Quang Luong32e68362022-03-14 11:57:26 -0700148 * Store the static chip info retrieved from WiFi HAL
149 */
150 public static final Key<String> WIFI_STATIC_CHIP_INFO = new Key<>("wifi_static_chip_info", "");
151
Gabriel Biren44830652022-07-13 22:30:52 +0000152 /**
Quang Luong27d7d572023-04-07 00:08:00 +0000153 * Store the last country code used by Soft AP.
154 */
155 public static final Key<String> WIFI_SOFT_AP_COUNTRY_CODE =
156 new Key<>("wifi_last_country_code", "");
157
158 /**
159 * Store the available channel frequencies in a JSON array for Soft AP for the last country
160 * code used.
161 */
162 public static final Key<String> WIFI_AVAILABLE_SOFT_AP_FREQS_MHZ =
163 new Key<>("wifi_available_soft_ap_freqs_mhz", "[]");
164
165 /**
Gabriel Biren44830652022-07-13 22:30:52 +0000166 * Whether to show a dialog when third party apps attempt to enable wifi.
167 */
168 public static final Key<Boolean> SHOW_DIALOG_WHEN_THIRD_PARTY_APPS_ENABLE_WIFI =
169 new Key<>("show_dialog_when_third_party_apps_enable_wifi", false);
170
171 /**
172 * Whether the
173 * {@link WifiManager#setThirdPartyAppEnablingWifiConfirmationDialogEnabled(boolean)} API was
174 * called to set the value of {@link #SHOW_DIALOG_WHEN_THIRD_PARTY_APPS_ENABLE_WIFI}.
175 */
176 public static final Key<Boolean> SHOW_DIALOG_WHEN_THIRD_PARTY_APPS_ENABLE_WIFI_SET_BY_API =
177 new Key<>("show_dialog_when_third_party_apps_enable_wifi_set_by_api", false);
178
Gabriel Biren022fbf12023-02-27 21:57:57 +0000179 /**
180 * AIDL version implemented by the Supplicant service.
181 */
182 public static final Key<Integer> SUPPLICANT_HAL_AIDL_SERVICE_VERSION =
183 new Key<>("supplicant_hal_aidl_service_version", -1);
184
Khanjan Desai6ba89342023-10-19 16:11:14 +0530185 /**
186 * Store wiphy capability for 11be support.
187 */
188 public static final Key<Boolean> WIFI_WIPHY_11BE_SUPPORTED =
189 new Key<>("wifi_wiphy_11be_supported", true);
190
Roshan Piusb790f672020-02-14 07:06:13 -0800191 /******** Wifi shared pref keys ***************/
192
193 private final Context mContext;
194 private final Handler mHandler;
Roshan Piusb0ed8e22020-03-19 09:08:16 -0700195 private final SettingsMigrationDataHolder mSettingsMigrationDataHolder;
Roshan Piusb790f672020-02-14 07:06:13 -0800196 private final WifiConfigManager mWifiConfigManager;
197
198 private final Object mLock = new Object();
199 @GuardedBy("mLock")
200 private final Map<String, Object> mSettings = new HashMap<>();
201 @GuardedBy("mLock")
202 private final Map<String, Map<OnSettingsChangedListener, Handler>> mListeners =
203 new HashMap<>();
Roshan Piusda0d1992020-03-04 08:34:42 -0800204 private WifiMigration.SettingsMigrationData mCachedMigrationData = null;
Roshan Piusb790f672020-02-14 07:06:13 -0800205
206 private boolean mHasNewDataToSerialize = false;
207
208 /**
209 * Interface for a settings change listener.
Roshan Pius67ee4292020-02-25 09:51:02 -0800210 * @param <T> Type of the value.
Roshan Piusb790f672020-02-14 07:06:13 -0800211 */
Roshan Pius67ee4292020-02-25 09:51:02 -0800212 public interface OnSettingsChangedListener<T> {
Roshan Piusb790f672020-02-14 07:06:13 -0800213 /**
214 * Invoked when a particular key settings changes.
215 *
216 * @param key Key that was changed.
217 * @param newValue New value that was assigned to the key.
218 */
Roshan Pius67ee4292020-02-25 09:51:02 -0800219 void onSettingsChanged(@NonNull Key<T> key, @Nullable T newValue);
Roshan Piusb790f672020-02-14 07:06:13 -0800220 }
221
222 public WifiSettingsConfigStore(@NonNull Context context, @NonNull Handler handler,
Roshan Piusb0ed8e22020-03-19 09:08:16 -0700223 @NonNull SettingsMigrationDataHolder settingsMigrationDataHolder,
Roshan Piusb790f672020-02-14 07:06:13 -0800224 @NonNull WifiConfigManager wifiConfigManager,
225 @NonNull WifiConfigStore wifiConfigStore) {
226 mContext = context;
227 mHandler = handler;
Roshan Piusb0ed8e22020-03-19 09:08:16 -0700228 mSettingsMigrationDataHolder = settingsMigrationDataHolder;
Roshan Piusb790f672020-02-14 07:06:13 -0800229 mWifiConfigManager = wifiConfigManager;
230
231 // Register our data store.
232 wifiConfigStore.registerStoreData(new StoreData());
233 }
234
235 private void invokeAllListeners() {
236 synchronized (mLock) {
Roshan Pius67ee4292020-02-25 09:51:02 -0800237 for (Key key : sKeys) {
Roshan Piusb790f672020-02-14 07:06:13 -0800238 invokeListeners(key);
239 }
240 }
241 }
242
Roshan Pius67ee4292020-02-25 09:51:02 -0800243 private <T> void invokeListeners(@NonNull Key<T> key) {
Roshan Piusb790f672020-02-14 07:06:13 -0800244 synchronized (mLock) {
Roshan Pius67ee4292020-02-25 09:51:02 -0800245 if (!mSettings.containsKey(key.key)) return;
246 Object newValue = mSettings.get(key.key);
247 Map<OnSettingsChangedListener, Handler> listeners = mListeners.get(key.key);
Roshan Piusb790f672020-02-14 07:06:13 -0800248 if (listeners == null || listeners.isEmpty()) return;
249 for (Map.Entry<OnSettingsChangedListener, Handler> listener
250 : listeners.entrySet()) {
251 // Trigger the callback in the appropriate handler.
Roshan Pius67ee4292020-02-25 09:51:02 -0800252 listener.getValue().post(() ->
253 listener.getKey().onSettingsChanged(key, newValue));
Roshan Piusb790f672020-02-14 07:06:13 -0800254 }
255 }
256 }
257
258 /**
259 * Trigger config store writes and invoke listeners in the main wifi service looper's handler.
260 */
Roshan Pius0412d2d2020-02-10 13:26:42 -0800261 private void triggerSaveToStoreAndInvokeAllListeners() {
262 mHandler.post(() -> {
263 mHasNewDataToSerialize = true;
264 mWifiConfigManager.saveToStore(true);
265
266 invokeAllListeners();
267 });
268 }
269
270 /**
271 * Trigger config store writes and invoke listeners in the main wifi service looper's handler.
272 */
Roshan Pius67ee4292020-02-25 09:51:02 -0800273 private <T> void triggerSaveToStoreAndInvokeListeners(@NonNull Key<T> key) {
Roshan Piusb790f672020-02-14 07:06:13 -0800274 mHandler.post(() -> {
275 mHasNewDataToSerialize = true;
276 mWifiConfigManager.saveToStore(true);
277
278 invokeListeners(key);
279 });
280 }
281
282 /**
Roshan Pius0412d2d2020-02-10 13:26:42 -0800283 * Performs a one time migration from Settings.Global values to settings store. Only
284 * performed one time if the settings store is empty.
285 */
286 private void migrateFromSettingsIfNeeded() {
287 if (!mSettings.isEmpty()) return; // already migrated.
288
Roshan Piusb0ed8e22020-03-19 09:08:16 -0700289 mCachedMigrationData = mSettingsMigrationDataHolder.retrieveData();
Roshan Piusda0d1992020-03-04 08:34:42 -0800290 if (mCachedMigrationData == null) {
Roshan Pius67ee4292020-02-25 09:51:02 -0800291 Log.e(TAG, "No settings data to migrate");
Roshan Pius0412d2d2020-02-10 13:26:42 -0800292 return;
293 }
294 Log.i(TAG, "Migrating data out of settings to shared preferences");
295
Roshan Pius67ee4292020-02-25 09:51:02 -0800296 mSettings.put(WIFI_P2P_DEVICE_NAME.key,
Roshan Piusda0d1992020-03-04 08:34:42 -0800297 mCachedMigrationData.getP2pDeviceName());
Roshan Pius67ee4292020-02-25 09:51:02 -0800298 mSettings.put(WIFI_P2P_PENDING_FACTORY_RESET.key,
Roshan Piusda0d1992020-03-04 08:34:42 -0800299 mCachedMigrationData.isP2pFactoryResetPending());
Roshan Pius67ee4292020-02-25 09:51:02 -0800300 mSettings.put(WIFI_SCAN_ALWAYS_AVAILABLE.key,
Roshan Piusda0d1992020-03-04 08:34:42 -0800301 mCachedMigrationData.isScanAlwaysAvailable());
Roshan Pius67ee4292020-02-25 09:51:02 -0800302 mSettings.put(WIFI_SCAN_THROTTLE_ENABLED.key,
Roshan Piusda0d1992020-03-04 08:34:42 -0800303 mCachedMigrationData.isScanThrottleEnabled());
Roshan Pius67ee4292020-02-25 09:51:02 -0800304 mSettings.put(WIFI_VERBOSE_LOGGING_ENABLED.key,
Roshan Piusda0d1992020-03-04 08:34:42 -0800305 mCachedMigrationData.isVerboseLoggingEnabled());
Roshan Pius0412d2d2020-02-10 13:26:42 -0800306 triggerSaveToStoreAndInvokeAllListeners();
307 }
308
309 /**
Roshan Pius67ee4292020-02-25 09:51:02 -0800310 * Store a value to the stored settings.
Roshan Piusb790f672020-02-14 07:06:13 -0800311 *
312 * @param key One of the settings keys.
313 * @param value Value to be stored.
314 */
Roshan Pius67ee4292020-02-25 09:51:02 -0800315 public <T> void put(@NonNull Key<T> key, @Nullable T value) {
Roshan Piusb790f672020-02-14 07:06:13 -0800316 synchronized (mLock) {
Roshan Pius67ee4292020-02-25 09:51:02 -0800317 mSettings.put(key.key, value);
Roshan Piusb790f672020-02-14 07:06:13 -0800318 }
319 triggerSaveToStoreAndInvokeListeners(key);
320 }
321
322 /**
Roshan Pius67ee4292020-02-25 09:51:02 -0800323 * Retrieve a value from the stored settings.
Roshan Piusb790f672020-02-14 07:06:13 -0800324 *
325 * @param key One of the settings keys.
Roshan Piusb790f672020-02-14 07:06:13 -0800326 * @return value stored in settings, defValue if the key does not exist.
327 */
Roshan Pius67ee4292020-02-25 09:51:02 -0800328 public @Nullable <T> T get(@NonNull Key<T> key) {
Roshan Piusb790f672020-02-14 07:06:13 -0800329 synchronized (mLock) {
Roshan Pius67ee4292020-02-25 09:51:02 -0800330 return (T) mSettings.getOrDefault(key.key, key.defaultValue);
Roshan Piusb790f672020-02-14 07:06:13 -0800331 }
332 }
333
334 /**
335 * Register for settings change listener.
336 *
337 * @param key One of the settings keys.
338 * @param listener Listener to be registered.
339 * @param handler Handler to post the listener
340 */
Roshan Pius67ee4292020-02-25 09:51:02 -0800341 public <T> void registerChangeListener(@NonNull Key<T> key,
342 @NonNull OnSettingsChangedListener<T> listener, @NonNull Handler handler) {
Roshan Piusb790f672020-02-14 07:06:13 -0800343 synchronized (mLock) {
Roshan Pius67ee4292020-02-25 09:51:02 -0800344 mListeners.computeIfAbsent(
345 key.key, ignore -> new HashMap<>()).put(listener, handler);
Roshan Piusb790f672020-02-14 07:06:13 -0800346 }
347 }
348
349 /**
350 * Unregister for settings change listener.
351 *
352 * @param key One of the settings keys.
353 * @param listener Listener to be unregistered.
354 */
Roshan Pius67ee4292020-02-25 09:51:02 -0800355 public <T> void unregisterChangeListener(@NonNull Key<T> key,
356 @NonNull OnSettingsChangedListener<T> listener) {
Roshan Piusb790f672020-02-14 07:06:13 -0800357 synchronized (mLock) {
Roshan Pius67ee4292020-02-25 09:51:02 -0800358 Map<OnSettingsChangedListener, Handler> listeners = mListeners.get(key.key);
Roshan Piusb790f672020-02-14 07:06:13 -0800359 if (listeners == null || listeners.isEmpty()) {
360 Log.e(TAG, "No listeners for " + key);
361 return;
362 }
363 if (listeners.remove(listener) == null) {
364 Log.e(TAG, "Unknown listener for " + key);
365 }
366 }
367 }
368
369 /**
Roshan Piusda0d1992020-03-04 08:34:42 -0800370 * Dump output for debugging.
371 */
372 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
373 pw.println();
374 pw.println("Dump of " + TAG);
375 pw.println("Settings:");
376 for (Map.Entry<String, Object> entry : mSettings.entrySet()) {
377 pw.print(entry.getKey());
378 pw.print("=");
379 pw.println(entry.getValue());
380 }
381 if (mCachedMigrationData == null) return;
382 pw.println("Migration data:");
383 pw.print(WIFI_P2P_DEVICE_NAME.key);
384 pw.print("=");
385 pw.println(mCachedMigrationData.getP2pDeviceName());
386 pw.print(WIFI_P2P_PENDING_FACTORY_RESET.key);
387 pw.print("=");
388 pw.println(mCachedMigrationData.isP2pFactoryResetPending());
389 pw.print(WIFI_SCAN_ALWAYS_AVAILABLE.key);
390 pw.print("=");
391 pw.println(mCachedMigrationData.isScanAlwaysAvailable());
392 pw.print(WIFI_SCAN_THROTTLE_ENABLED.key);
393 pw.print("=");
394 pw.println(mCachedMigrationData.isScanThrottleEnabled());
395 pw.print(WIFI_VERBOSE_LOGGING_ENABLED.key);
396 pw.print("=");
397 pw.println(mCachedMigrationData.isVerboseLoggingEnabled());
398 pw.println();
399 }
400
401 /**
Roshan Pius67ee4292020-02-25 09:51:02 -0800402 * Base class to store string key and its default value.
403 * @param <T> Type of the value.
404 */
405 public static class Key<T> {
406 public final String key;
407 public final T defaultValue;
408
409 private Key(@NonNull String key, T defaultValue) {
410 this.key = key;
411 this.defaultValue = defaultValue;
412 sKeys.add(this);
413 }
414
415 @Override
416 public String toString() {
417 return "[Key " + key + ", DefaultValue: " + defaultValue + "]";
418 }
419 }
420
421 /**
Roshan Piusb790f672020-02-14 07:06:13 -0800422 * Store data for persisting the settings data to config store.
423 */
424 private class StoreData implements WifiConfigStore.StoreData {
425 private static final String XML_TAG_SECTION_HEADER = "Settings";
426 private static final String XML_TAG_VALUES = "Values";
427
428 @Override
429 public void serializeData(XmlSerializer out,
430 @Nullable WifiConfigStoreEncryptionUtil encryptionUtil)
431 throws XmlPullParserException, IOException {
432 synchronized (mLock) {
433 XmlUtil.writeNextValue(out, XML_TAG_VALUES, mSettings);
434 }
435 }
436
437 @Override
438 public void deserializeData(XmlPullParser in, int outerTagDepth,
439 @WifiConfigStore.Version int version,
Roshan Piusfdf57e62020-03-16 13:33:16 -0700440 @Nullable WifiConfigStoreEncryptionUtil encryptionUtil)
Roshan Piusb790f672020-02-14 07:06:13 -0800441 throws XmlPullParserException, IOException {
Roshan Piusb790f672020-02-14 07:06:13 -0800442 if (in == null) {
Roshan Pius0412d2d2020-02-10 13:26:42 -0800443 // Empty read triggers the migration since it indicates that there is no settings
444 // data stored in the settings store.
445 migrateFromSettingsIfNeeded();
Roshan Piusb790f672020-02-14 07:06:13 -0800446 return;
447 }
448 Map<String, Object> values = null;
449 while (!XmlUtil.isNextSectionEnd(in, outerTagDepth)) {
450 String[] valueName = new String[1];
451 Object value = XmlUtil.readCurrentValue(in, valueName);
452 if (TextUtils.isEmpty(valueName[0])) {
453 throw new XmlPullParserException("Missing value name");
454 }
455 switch (valueName[0]) {
456 case XML_TAG_VALUES:
457 values = (Map) value;
458 break;
459 default:
460 Log.w(TAG, "Ignoring unknown tag under " + XML_TAG_SECTION_HEADER + ": "
461 + valueName[0]);
462 break;
463 }
464 }
465 if (values != null) {
466 synchronized (mLock) {
467 mSettings.putAll(values);
468 // Invoke all the registered listeners.
469 invokeAllListeners();
470 }
471 }
472 }
473
474 @Override
475 public void resetData() {
476 synchronized (mLock) {
477 mSettings.clear();
478 }
479 }
480
481 @Override
482 public boolean hasNewDataToSerialize() {
483 return mHasNewDataToSerialize;
484 }
485
486 @Override
487 public String getName() {
488 return XML_TAG_SECTION_HEADER;
489 }
490
491 @Override
492 public @WifiConfigStore.StoreFileId int getStoreFileId() {
493 // Shared general store.
Roshan Pius0412d2d2020-02-10 13:26:42 -0800494 return WifiConfigStore.STORE_FILE_SHARED_GENERAL;
Roshan Piusb790f672020-02-14 07:06:13 -0800495 }
496 }
497}