SettingsBackupAgent: notify of apBand conversion

Added support to notify user of a change to their softap configuration
preferences after being restored via SettingsBackupAgent.

Bug: 80251951
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: manually confirmed configs are converted for different device
Change-Id: I4cec15549d694cdb1a7b09f1426d027eec021122
This commit is contained in:
Rebecca Silberstein
2018-06-01 17:31:40 -07:00
parent 1b65af27d8
commit d41106c52e
6 changed files with 51 additions and 0 deletions

View File

@@ -3169,6 +3169,21 @@
<!-- A notification is shown when the user connects to a Wi-Fi network and the system detects that that network has no Internet access. This is the notification's message. -->
<string name="wifi_no_internet_detailed">Tap for options</string>
<!-- A notification is shown when the user's softap config has been changed due to underlying
hardware restrictions. This is the notifications's title.
[CHAR_LIMIT=NONE] -->
<string name="wifi_softap_config_change">Changes to your hotspot settings</string>
<!-- A notification is shown when the user's softap config has been changed due to underlying
hardware restrictions. This is the notification's summary message.
[CHAR_LIMIT=NONE] -->
<string name="wifi_softap_config_change_summary">Your hotspot band has changed.</string>
<!-- A notification is shown when the user's softap config has been changed due to underlying
hardware restrictions. This is the notification's full message.
[CHAR_LIMIT=NONE] -->
<string name="wifi_softap_config_change_detailed">This device doesn\u2019t support your preference for 5GHz only. Instead, this device will use the 5GHz band when available.</string>
<!-- A notification might be shown if the device switches to another network type (e.g., mobile data) because it detects that the network it was using (e.g., Wi-Fi) has lost Internet connectivity. This is the notification's title. %1$s is the network type that the device switched to, e.g., cellular data. It is one of the strings in the network_switch_type_name array. -->
<string name="network_switch_metered">Switched to <xliff:g id="network_type">%1$s</xliff:g></string>

View File

@@ -1061,6 +1061,9 @@
<java-symbol type="string" name="network_switch_type_name_unknown" />
<java-symbol type="string" name="wifi_no_internet" />
<java-symbol type="string" name="wifi_no_internet_detailed" />
<java-symbol type="string" name="wifi_softap_config_change" />
<java-symbol type="string" name="wifi_softap_config_change_summary" />
<java-symbol type="string" name="wifi_softap_config_change_detailed" />
<java-symbol type="string" name="wifi_connect_alert_title" />
<java-symbol type="string" name="wifi_connect_alert_message" />
<java-symbol type="string" name="wifi_connect_default_application" />

View File

@@ -841,7 +841,19 @@ public class SettingsBackupAgent extends BackupAgentHelper {
WifiConfiguration config = WifiConfiguration
.getWifiConfigFromBackup(new DataInputStream(new ByteArrayInputStream(data)));
if (DEBUG) Log.d(TAG, "Successfully unMarshaled WifiConfiguration ");
int originalApBand = config.apBand;
mWifiManager.setWifiApConfiguration(config);
// Depending on device hardware, we may need to notify the user of a setting change for
// the apBand preference
boolean dualMode = mWifiManager.isDualModeSupported();
int storedApBand = mWifiManager.getWifiApConfiguration().apBand;
if (dualMode) {
if (storedApBand != originalApBand) {
Log.d(TAG, "restored ap configuration requires a conversion, notify the user");
mWifiManager.notifyUserOfApBandConversion();
}
}
} catch (IOException | BackupUtils.BadVersionException e) {
Log.e(TAG, "Failed to unMarshal SoftAPConfiguration " + e.getMessage());
}

View File

@@ -212,6 +212,10 @@ message SystemMessage {
// Package: android
NOTE_AUTO_SAVER_SUGGESTION = 49;
// Notify the user that their softap config preference has changed.
// Package: android
NOTE_SOFTAP_CONFIG_CHANGED = 50;
// ADD_NEW_IDS_ABOVE_THIS_LINE
// Legacy IDs with arbitrary values appear below
// Legacy IDs existed as stable non-conflicting constants prior to the O release

View File

@@ -147,6 +147,8 @@ interface IWifiManager
boolean setWifiApConfiguration(in WifiConfiguration wifiConfig, String packageName);
void notifyUserOfApBandConversion(String packageName);
Messenger getWifiServiceMessenger(String packageName);
void enableTdls(String remoteIPAddress, boolean enable);

View File

@@ -2169,6 +2169,21 @@ public class WifiManager {
}
}
/**
* Method that triggers a notification to the user about a conversion to their saved AP config.
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
public void notifyUserOfApBandConversion() {
Log.d(TAG, "apBand was converted, notify the user");
try {
mService.notifyUserOfApBandConversion(mContext.getOpPackageName());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Enable/Disable TDLS on a specific local route.
*