Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5b9a556 authored by lesl's avatar lesl
Browse files

Softap: Let ap band changed notification to config changed.

The softap supports more features which related hardware.
The config store from cloud will meet the convert will not only for band
but also for others config. Revise the code to make it more general.

PS: UI wording change will in another CL# which need to discuss with
UX designer.

Bug: 142752869
Test: Manual test, restore from cloud to see if notification show or
not. And check the log.

Change-Id: I279e62841d4b14d3ba5b6792bc289c0adb8a223d
parent c64b68c3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ android_test {
        "src/com/android/providers/settings/SettingsBackupAgent.java",
        "src/com/android/providers/settings/SettingsState.java",
        "src/com/android/providers/settings/SettingsHelper.java",
        "src/com/android/providers/settings/WifiSoftApBandChangedNotifier.java",
        "src/com/android/providers/settings/WifiSoftApConfigChangedNotifier.java",
    ],
    static_libs: [
        "androidx.test.rules",
+6 −10
Original line number Diff line number Diff line
@@ -968,18 +968,14 @@ public class SettingsBackupAgent extends BackupAgentHelper {
    }

    private void restoreSoftApConfiguration(byte[] data) {
        SoftApConfiguration config = mWifiManager.restoreSoftApBackupData(data);
        if (config != null) {
            int originalApBand = config.getBand();
        SoftApConfiguration configInCloud = mWifiManager.restoreSoftApBackupData(data);
        if (configInCloud != null) {
            if (DEBUG) Log.d(TAG, "Successfully unMarshaled SoftApConfiguration ");

            // 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.getSoftApConfiguration().getBand();
            if (dualMode && storedApBand != originalApBand) {
            // Depending on device hardware, we may need to notify the user of a setting change
            SoftApConfiguration storedConfig = mWifiManager.getSoftApConfiguration();
            if (!storedConfig.equals(configInCloud)) {
                Log.d(TAG, "restored ap configuration requires a conversion, notify the user");
                WifiSoftApBandChangedNotifier.notifyUserOfApBandConversion(this);
                WifiSoftApConfigChangedNotifier.notifyUserOfConfigConversion(this);
            }
        }
    }
+5 −5
Original line number Diff line number Diff line
@@ -27,17 +27,17 @@ import com.android.internal.messages.nano.SystemMessageProto;
import com.android.internal.notification.SystemNotificationChannels;

/**
 * Helper class for sending notifications when the user's Soft AP Band was changed upon restore.
 * Helper class for sending notifications when the user's Soft AP config was changed upon restore.
 */
public class WifiSoftApBandChangedNotifier {
    private WifiSoftApBandChangedNotifier() {}
public class WifiSoftApConfigChangedNotifier {
    private WifiSoftApConfigChangedNotifier() {}

    /**
     * Send a notification informing the user that their' Soft AP Band was changed upon restore.
     * Send a notification informing the user that their' Soft AP Config was changed upon restore.
     * When the user taps on the notification, they are taken to the Wifi Tethering page in
     * Settings.
     */
    public static void notifyUserOfApBandConversion(Context context) {
    public static void notifyUserOfConfigConversion(Context context) {
        NotificationManager notificationManager =
                context.getSystemService(NotificationManager.class);