1 /* 2 * Copyright (C) 2017 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 package com.android.networkrecommendation.config; 17 18 import com.android.networkrecommendation.config.PreferenceFile.SharedPreference; 19 import java.util.Collections; 20 import java.util.Set; 21 22 /** The NetRec preferences file. */ 23 public final class Preferences { Preferences()24 private Preferences() {} 25 26 private static final PreferenceFile sPrefs = 27 new PreferenceFile("com.android.networkrecommendation"); 28 29 /** 30 * {@link ScoreNetworksChimeraBroadcastReceiver} sets this to true when the scorer is enabled. 31 * {@link com.android.networkrecommendation.scoring.service.FutureRefreshRequestor} checks for 32 * this value and triggers a quick score refresh if this is set. 33 */ 34 public static final SharedPreference<Boolean> justEnabled = 35 sPrefs.booleanValue("justEnabled", false); 36 37 /** 38 * The next time, in ms since system boot, that a rapid (i.e. outside the usual refresh window) 39 * will be allowed to make a network request. 40 */ 41 public static final SharedPreference<Long> nextRapidRefreshAllowed = 42 sPrefs.longValue("nextRapidRefreshAllowedMillis", 0L); 43 44 /** 45 * The set of saved ssid hashes in previous scan result list when the user disabled Wi-Fi. Saved 46 * to preferences when {@link com.android.networkrecommendation.wakeup.WifiWakeupController} 47 * stops. 48 */ 49 public static final SharedPreference<Set<String>> savedSsidsOnDisable = 50 sPrefs.stringSetValue("savedSsidsOnDisable", Collections.emptySet()); 51 52 /** 53 * The set of saved ssid hashes that were previously shown as Wi-Fi Enabled notifications 54 * through {@link com.android.networkrecommendation.wakeup.WifiWakeupController}. 55 */ 56 public static final SharedPreference<Set<String>> ssidsForWakeupShown = 57 sPrefs.stringSetValue("ssidsForWakeupShown", Collections.emptySet()); 58 59 /** Key for {@link com.android.networkrecommendation.storage.Encrypter} on pre-MNC devices. */ 60 public static final SharedPreference<String> encrypterKey = 61 sPrefs.stringValue("encrypterKey", null); 62 63 /** 64 * How long we should wait before requesting another network. Used by {@link 65 * PersistentNetworkRequest} to support GCS/WFA. 66 */ 67 public static final SharedPreference<Integer> nextNetworkRequestDelayMs = 68 sPrefs.intValue("nextNetworkRequestDelayMs", 0); 69 70 /** 71 * Hash of the SSID that last satisfied the network request in {@link PersistentNetworkRequest}. 72 */ 73 public static final SharedPreference<String> lastSsidHash = 74 sPrefs.stringValue("lastSsidHash", ""); 75 } 76