diff --git a/packages/SettingsProvider/Android.bp b/packages/SettingsProvider/Android.bp
index 681b4940a3c32..f40d3a160513f 100644
--- a/packages/SettingsProvider/Android.bp
+++ b/packages/SettingsProvider/Android.bp
@@ -29,6 +29,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",
],
static_libs: [
"androidx.test.rules",
diff --git a/packages/SettingsProvider/res/drawable/ic_wifi_settings.xml b/packages/SettingsProvider/res/drawable/ic_wifi_settings.xml
new file mode 100644
index 0000000000000..cb426565ae827
--- /dev/null
+++ b/packages/SettingsProvider/res/drawable/ic_wifi_settings.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
diff --git a/packages/SettingsProvider/res/values/strings.xml b/packages/SettingsProvider/res/values/strings.xml
index 9ca575e30ea90..3787727501943 100644
--- a/packages/SettingsProvider/res/values/strings.xml
+++ b/packages/SettingsProvider/res/values/strings.xml
@@ -19,4 +19,19 @@
Settings Storage
+
+
+ Changes to your hotspot settings
+
+
+ Your hotspot band has changed.
+
+
+ This device doesn\u2019t support your preference for 5GHz only. Instead, this device will use the 5GHz band when available.
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 7e60452411cb7..443288cfe4925 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -895,11 +895,9 @@ public class SettingsBackupAgent extends BackupAgentHelper {
// 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();
- }
+ if (dualMode && storedApBand != originalApBand) {
+ Log.d(TAG, "restored ap configuration requires a conversion, notify the user");
+ WifiSoftApBandChangedNotifier.notifyUserOfApBandConversion(this);
}
} catch (IOException | BackupUtils.BadVersionException e) {
Log.e(TAG, "Failed to unMarshal SoftAPConfiguration " + e.getMessage());
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/WifiSoftApBandChangedNotifier.java b/packages/SettingsProvider/src/com/android/providers/settings/WifiSoftApBandChangedNotifier.java
new file mode 100644
index 0000000000000..d0d4956725d45
--- /dev/null
+++ b/packages/SettingsProvider/src/com/android/providers/settings/WifiSoftApBandChangedNotifier.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.providers.settings;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+
+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.
+ */
+public class WifiSoftApBandChangedNotifier {
+ private WifiSoftApBandChangedNotifier() {}
+
+ /**
+ * Send a notification informing the user that their' Soft AP Band 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) {
+ NotificationManager notificationManager =
+ context.getSystemService(NotificationManager.class);
+
+ // create channel, or update it if it already exists
+ NotificationChannel channel = new NotificationChannel(
+ SystemNotificationChannels.NETWORK_STATUS,
+ context.getString(android.R.string.notification_channel_network_status),
+ NotificationManager.IMPORTANCE_LOW);
+ notificationManager.createNotificationChannel(channel);
+
+ notificationManager.notify(
+ SystemMessageProto.SystemMessage.NOTE_SOFTAP_CONFIG_CHANGED,
+ createConversionNotification(context));
+ }
+
+ private static Notification createConversionNotification(Context context) {
+ Resources resources = context.getResources();
+ CharSequence title = resources.getText(R.string.wifi_softap_config_change);
+ CharSequence contentSummary = resources.getText(R.string.wifi_softap_config_change_summary);
+ CharSequence content = resources.getText(R.string.wifi_softap_config_change_detailed);
+ int color = resources.getColor(
+ android.R.color.system_notification_accent_color, context.getTheme());
+
+ return new Notification.Builder(context, SystemNotificationChannels.NETWORK_STATUS)
+ .setSmallIcon(R.drawable.ic_wifi_settings)
+ .setPriority(Notification.PRIORITY_HIGH)
+ .setCategory(Notification.CATEGORY_SYSTEM)
+ .setContentTitle(title)
+ .setContentText(contentSummary)
+ .setContentIntent(getPendingActivity(context))
+ .setTicker(title)
+ .setShowWhen(false)
+ .setLocalOnly(true)
+ .setColor(color)
+ .setStyle(new Notification.BigTextStyle()
+ .bigText(content)
+ .setBigContentTitle(title)
+ .setSummaryText(contentSummary))
+ .setAutoCancel(true)
+ .build();
+ }
+
+ private static PendingIntent getPendingActivity(Context context) {
+ Intent intent = new Intent("com.android.settings.WIFI_TETHER_SETTINGS")
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+}
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index bbb85440f729d..b4e72abfa201c 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -161,8 +161,6 @@ interface IWifiManager
boolean setWifiApConfiguration(in WifiConfiguration wifiConfig, String packageName);
- void notifyUserOfApBandConversion(String packageName);
-
void enableTdls(String remoteIPAddress, boolean enable);
void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable);
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 6c2a08c14082c..8802c9c0a4855 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -3206,27 +3206,6 @@ public class WifiManager {
}
}
- /**
- * Method that triggers a notification to the user about a band conversion
- * (e.g. 5 GHz to 2.4 GHz) to their saved AP config.
- *
- * @hide
- */
- // TODO(b/144218444): move the notification to Settings instead of making this @SystemApi
- @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
- public void notifyUserOfApBandConversion() {
- Log.d(TAG, "apBand was converted, notify the user");
- try {
- IWifiManager iWifiManager = getIWifiManager();
- if (iWifiManager == null) {
- throw new RemoteException("Wifi service is not running");
- }
- iWifiManager.notifyUserOfApBandConversion(mContext.getOpPackageName());
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
/**
* Enable/Disable TDLS on a specific local route.
*
diff --git a/wifi/java/com/android/server/wifi/BaseWifiService.java b/wifi/java/com/android/server/wifi/BaseWifiService.java
index cf74ff07d2ee1..d740c363f889b 100644
--- a/wifi/java/com/android/server/wifi/BaseWifiService.java
+++ b/wifi/java/com/android/server/wifi/BaseWifiService.java
@@ -42,7 +42,6 @@ import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.os.IBinder;
-import android.os.Messenger;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.WorkSource;
@@ -325,7 +324,6 @@ public class BaseWifiService extends IWifiManager.Stub {
throw new UnsupportedOperationException();
}
- @Override
public void notifyUserOfApBandConversion(String packageName) {
throw new UnsupportedOperationException();
}