Merge changes from topics "wifi_oem_migration", "wifi_scan_throttle_api"
* changes: WifiOemMigrationHook: Rename class & methods to be more generic WifiManager: Add API for scan throttling
This commit is contained in:
@@ -31295,6 +31295,7 @@ package android.net.wifi {
|
||||
method public boolean isP2pSupported();
|
||||
method public boolean isPreferredNetworkOffloadSupported();
|
||||
method @Deprecated public boolean isScanAlwaysAvailable();
|
||||
method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public boolean isScanThrottleEnabled();
|
||||
method public boolean isStaApConcurrencySupported();
|
||||
method public boolean isTdlsSupported();
|
||||
method public boolean isWapiSupported();
|
||||
|
||||
@@ -7693,6 +7693,7 @@ package android.net.wifi {
|
||||
method @RequiresPermission(android.Manifest.permission.WIFI_SET_DEVICE_MOBILITY_STATE) public void setDeviceMobilityState(int);
|
||||
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void setMacRandomizationSettingPasspointEnabled(@NonNull String, boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void setMeteredOverridePasspoint(@NonNull String, int);
|
||||
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void setScanThrottleEnabled(boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public boolean setSoftApConfiguration(@NonNull android.net.wifi.SoftApConfiguration);
|
||||
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void setVerboseLoggingEnabled(boolean);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.CHANGE_WIFI_STATE) public boolean setWifiApConfiguration(android.net.wifi.WifiConfiguration);
|
||||
@@ -7837,23 +7838,23 @@ package android.net.wifi {
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_CARRIER_PROVISIONING) public android.net.wifi.WifiNetworkSuggestion.Builder setCarrierId(int);
|
||||
}
|
||||
|
||||
public final class WifiOemConfigStoreMigrationHook {
|
||||
method @Nullable public static android.net.wifi.WifiOemConfigStoreMigrationHook.MigrationData load();
|
||||
public final class WifiOemMigrationHook {
|
||||
method @Nullable public static android.net.wifi.WifiOemMigrationHook.ConfigStoreMigrationData loadFromConfigStore();
|
||||
}
|
||||
|
||||
public static final class WifiOemConfigStoreMigrationHook.MigrationData implements android.os.Parcelable {
|
||||
public static final class WifiOemMigrationHook.ConfigStoreMigrationData implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @Nullable public java.util.List<android.net.wifi.WifiConfiguration> getUserSavedNetworkConfigurations();
|
||||
method @Nullable public android.net.wifi.SoftApConfiguration getUserSoftApConfiguration();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.WifiOemConfigStoreMigrationHook.MigrationData> CREATOR;
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.WifiOemMigrationHook.ConfigStoreMigrationData> CREATOR;
|
||||
}
|
||||
|
||||
public static final class WifiOemConfigStoreMigrationHook.MigrationData.Builder {
|
||||
ctor public WifiOemConfigStoreMigrationHook.MigrationData.Builder();
|
||||
method @NonNull public android.net.wifi.WifiOemConfigStoreMigrationHook.MigrationData build();
|
||||
method @NonNull public android.net.wifi.WifiOemConfigStoreMigrationHook.MigrationData.Builder setUserSavedNetworkConfigurations(@NonNull java.util.List<android.net.wifi.WifiConfiguration>);
|
||||
method @NonNull public android.net.wifi.WifiOemConfigStoreMigrationHook.MigrationData.Builder setUserSoftApConfiguration(@NonNull android.net.wifi.SoftApConfiguration);
|
||||
public static final class WifiOemMigrationHook.ConfigStoreMigrationData.Builder {
|
||||
ctor public WifiOemMigrationHook.ConfigStoreMigrationData.Builder();
|
||||
method @NonNull public android.net.wifi.WifiOemMigrationHook.ConfigStoreMigrationData build();
|
||||
method @NonNull public android.net.wifi.WifiOemMigrationHook.ConfigStoreMigrationData.Builder setUserSavedNetworkConfigurations(@NonNull java.util.List<android.net.wifi.WifiConfiguration>);
|
||||
method @NonNull public android.net.wifi.WifiOemMigrationHook.ConfigStoreMigrationData.Builder setUserSoftApConfiguration(@NonNull android.net.wifi.SoftApConfiguration);
|
||||
}
|
||||
|
||||
public class WifiScanner {
|
||||
|
||||
@@ -47,7 +47,7 @@ filegroup {
|
||||
// framework-wifi.jar. This is not a good idea, should move WifiNetworkScoreCache
|
||||
// to a separate package.
|
||||
"java/android/net/wifi/WifiNetworkScoreCache.java",
|
||||
"java/android/net/wifi/WifiOemConfigStoreMigrationHook.java",
|
||||
"java/android/net/wifi/WifiOemMigrationHook.java",
|
||||
"java/android/net/wifi/wificond/*.java",
|
||||
":libwificond_ipc_aidl",
|
||||
],
|
||||
|
||||
@@ -266,4 +266,8 @@ interface IWifiManager
|
||||
* Return the Map of {@link WifiNetworkSuggestion} and the list of <ScanResult>
|
||||
*/
|
||||
Map getMatchingScanResults(in List<WifiNetworkSuggestion> networkSuggestions, in List<ScanResult> scanResults, String callingPackage, String callingFeatureId);
|
||||
|
||||
void setScanThrottleEnabled(boolean enable);
|
||||
|
||||
boolean isScanThrottleEnabled();
|
||||
}
|
||||
|
||||
@@ -6118,4 +6118,48 @@ public class WifiManager {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable wifi scan throttling from 3rd party apps.
|
||||
*
|
||||
* <p>
|
||||
* The throttling limits for apps are described in
|
||||
* <a href="Wi-Fi Scan Throttling">
|
||||
* https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling</a>
|
||||
* </p>
|
||||
*
|
||||
* @param enable true to allow scan throttling, false to disallow scan throttling.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
|
||||
public void setScanThrottleEnabled(boolean enable) {
|
||||
try {
|
||||
mService.setScanThrottleEnabled(enable);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the persisted Wi-Fi scan throttle state. Defaults to true, unless changed by the user via
|
||||
* Developer options.
|
||||
*
|
||||
* <p>
|
||||
* The throttling limits for apps are described in
|
||||
* <a href="Wi-Fi Scan Throttling">
|
||||
* https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling</a>
|
||||
* </p>
|
||||
*
|
||||
* @return true to indicate that scan throttling is enabled, false to indicate that scan
|
||||
* throttling is disabled.
|
||||
*/
|
||||
@RequiresPermission(ACCESS_WIFI_STATE)
|
||||
public boolean isScanThrottleEnabled() {
|
||||
try {
|
||||
return mService.isScanThrottleEnabled();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,30 +28,17 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Class used to provide one time hooks for existing OEM devices to migrate their config store
|
||||
* data to the wifi mainline module.
|
||||
* <p>
|
||||
* Note:
|
||||
* <li> OEM's need to implement {@link #load()} only if their
|
||||
* existing config store format or file locations differs from the vanilla AOSP implementation (
|
||||
* which is what the wifi mainline module understands).
|
||||
* </li>
|
||||
* <li> The wifi mainline module will invoke {@link #load()} method on every bootup, its
|
||||
* the responsibility of the OEM implementation to ensure that this method returns non-null data
|
||||
* only on the first bootup. Once the migration is done, the OEM can safely delete their config
|
||||
* store files and then return null on any subsequent reboots. The first & only relevant invocation
|
||||
* of {@link #load()} occurs when a previously released device upgrades to the wifi
|
||||
* mainline module from an OEM implementation of the wifi stack.
|
||||
* </li>
|
||||
* data and other settings to the wifi mainline module.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class WifiOemConfigStoreMigrationHook {
|
||||
public final class WifiOemMigrationHook {
|
||||
/**
|
||||
* Container for all the wifi config data to migrate.
|
||||
*/
|
||||
public static final class MigrationData implements Parcelable {
|
||||
public static final class ConfigStoreMigrationData implements Parcelable {
|
||||
/**
|
||||
* Builder to create instance of {@link MigrationData}.
|
||||
* Builder to create instance of {@link ConfigStoreMigrationData}.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private List<WifiConfiguration> mUserSavedNetworkConfigurations;
|
||||
@@ -92,39 +79,40 @@ public final class WifiOemConfigStoreMigrationHook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an instance of {@link MigrationData}.
|
||||
* Build an instance of {@link ConfigStoreMigrationData}.
|
||||
*
|
||||
* @return Instance of {@link MigrationData}.
|
||||
* @return Instance of {@link ConfigStoreMigrationData}.
|
||||
*/
|
||||
public @NonNull MigrationData build() {
|
||||
return new MigrationData(mUserSavedNetworkConfigurations, mUserSoftApConfiguration);
|
||||
public @NonNull ConfigStoreMigrationData build() {
|
||||
return new ConfigStoreMigrationData(
|
||||
mUserSavedNetworkConfigurations, mUserSoftApConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
private final List<WifiConfiguration> mUserSavedNetworkConfigurations;
|
||||
private final SoftApConfiguration mUserSoftApConfiguration;
|
||||
|
||||
private MigrationData(
|
||||
private ConfigStoreMigrationData(
|
||||
@Nullable List<WifiConfiguration> userSavedNetworkConfigurations,
|
||||
@Nullable SoftApConfiguration userSoftApConfiguration) {
|
||||
mUserSavedNetworkConfigurations = userSavedNetworkConfigurations;
|
||||
mUserSoftApConfiguration = userSoftApConfiguration;
|
||||
}
|
||||
|
||||
public static final @NonNull Parcelable.Creator<MigrationData> CREATOR =
|
||||
new Parcelable.Creator<MigrationData>() {
|
||||
public static final @NonNull Parcelable.Creator<ConfigStoreMigrationData> CREATOR =
|
||||
new Parcelable.Creator<ConfigStoreMigrationData>() {
|
||||
@Override
|
||||
public MigrationData createFromParcel(Parcel in) {
|
||||
public ConfigStoreMigrationData createFromParcel(Parcel in) {
|
||||
List<WifiConfiguration> userSavedNetworkConfigurations =
|
||||
in.readArrayList(null);
|
||||
SoftApConfiguration userSoftApConfiguration = in.readParcelable(null);
|
||||
return new MigrationData(
|
||||
return new ConfigStoreMigrationData(
|
||||
userSavedNetworkConfigurations, userSoftApConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MigrationData[] newArray(int size) {
|
||||
return new MigrationData[size];
|
||||
public ConfigStoreMigrationData[] newArray(int size) {
|
||||
return new ConfigStoreMigrationData[size];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -164,16 +152,29 @@ public final class WifiOemConfigStoreMigrationHook {
|
||||
}
|
||||
}
|
||||
|
||||
private WifiOemConfigStoreMigrationHook() { }
|
||||
private WifiOemMigrationHook() { }
|
||||
|
||||
/**
|
||||
* Load data from OEM's config store.
|
||||
* <p>
|
||||
* Note:
|
||||
* <li> OEM's need to implement {@link #loadFromConfigStore()} ()} only if their
|
||||
* existing config store format or file locations differs from the vanilla AOSP implementation (
|
||||
* which is what the wifi mainline module understands).
|
||||
* </li>
|
||||
* <li> The wifi mainline module will invoke {@link #loadFromConfigStore()} method on every
|
||||
* bootup, its the responsibility of the OEM implementation to ensure that this method returns
|
||||
* non-null data only on the first bootup. Once the migration is done, the OEM can safely delete
|
||||
* their config store files and then return null on any subsequent reboots. The first & only
|
||||
* relevant invocation of {@link #loadFromConfigStore()} occurs when a previously released
|
||||
* device upgrades to the wifi mainline module from an OEM implementation of the wifi stack.
|
||||
* </li>
|
||||
*
|
||||
* @return Instance of {@link MigrationData} for migrating data, null if no
|
||||
* @return Instance of {@link ConfigStoreMigrationData} for migrating data, null if no
|
||||
* migration is necessary.
|
||||
*/
|
||||
@Nullable
|
||||
public static MigrationData load() {
|
||||
public static ConfigStoreMigrationData loadFromConfigStore() {
|
||||
// Note: OEM's should add code to parse data from their config store format here!
|
||||
return null;
|
||||
}
|
||||
@@ -2380,4 +2380,14 @@ public class WifiManagerTest {
|
||||
verify(mWifiConnectedNetworkScorer).start(0);
|
||||
verify(mWifiConnectedNetworkScorer).stop(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScanThrottle() throws Exception {
|
||||
mWifiManager.setScanThrottleEnabled(true);
|
||||
verify(mWifiService).setScanThrottleEnabled(true);
|
||||
|
||||
when(mWifiService.isScanThrottleEnabled()).thenReturn(false);
|
||||
assertFalse(mWifiManager.isScanThrottleEnabled());
|
||||
verify(mWifiService).isScanThrottleEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user