diff options
author | David Su <dysu@google.com> | 2019-11-20 17:53:38 -0800 |
---|---|---|
committer | David Su <dysu@google.com> | 2019-11-20 18:29:45 -0800 |
commit | f11468f2884b7c3b809654126c84a0360e93ca54 (patch) | |
tree | 1207964264f327e9414166f017daa399e2e6cbe4 /service | |
parent | dda5fd8b34cc817823f4cd6a597c2a14cd0aebe6 (diff) |
Remove WifiManager.notifyUserOfApBandConversion()
Removed this API since the notification should be
handled elsewhere, not in Wifi service.
Thus, moved to SettingsBackupAgent.
Bug: 144218444
Test: atest FrameworksWifiTests
Change-Id: I4cf343e167f9c96ca7602895d5394b815647f2ff
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiApConfigStore.java | 123 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiInjector.java | 2 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 16 | ||||
-rw-r--r-- | service/res/values/strings.xml | 15 |
4 files changed, 13 insertions, 143 deletions
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java index 48ad9b1c0..80421e78c 100644 --- a/service/java/com/android/server/wifi/WifiApConfigStore.java +++ b/service/java/com/android/server/wifi/WifiApConfigStore.java @@ -17,12 +17,7 @@ package com.android.server.wifi; import android.annotation.NonNull; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; import android.content.Context; -import android.content.Intent; import android.content.IntentFilter; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; @@ -35,7 +30,6 @@ import android.text.TextUtils; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.wifi.R; import java.io.BufferedInputStream; @@ -91,13 +85,10 @@ public class WifiApConfigStore { private ArrayList<Integer> mAllowed2GChannel = null; private final Context mContext; - private final WifiInjector mWifiInjector; private final Handler mHandler; private final BackupManagerProxy mBackupManagerProxy; - private final FrameworkFacade mFrameworkFacade; private final MacAddressUtil mMacAddressUtil; private final Mac mMac; - private final WifiConfigStore mWifiConfigStore; private final WifiConfigManager mWifiConfigManager; private boolean mRequiresApBandConversion = false; private boolean mHasNewDataToSerialize = false; @@ -133,26 +124,22 @@ public class WifiApConfigStore { } WifiApConfigStore(Context context, WifiInjector wifiInjector, Handler handler, - BackupManagerProxy backupManagerProxy, FrameworkFacade frameworkFacade, - WifiConfigStore wifiConfigStore, WifiConfigManager wifiConfigManager) { - this(context, wifiInjector, handler, backupManagerProxy, frameworkFacade, wifiConfigStore, + BackupManagerProxy backupManagerProxy, WifiConfigStore wifiConfigStore, + WifiConfigManager wifiConfigManager) { + this(context, wifiInjector, handler, backupManagerProxy, wifiConfigStore, wifiConfigManager, LEGACY_AP_CONFIG_FILE); } WifiApConfigStore(Context context, - WifiInjector wifiInjector, - Handler handler, - BackupManagerProxy backupManagerProxy, - FrameworkFacade frameworkFacade, - WifiConfigStore wifiConfigStore, - WifiConfigManager wifiConfigManager, - String apConfigFile) { + WifiInjector wifiInjector, + Handler handler, + BackupManagerProxy backupManagerProxy, + WifiConfigStore wifiConfigStore, + WifiConfigManager wifiConfigManager, + String apConfigFile) { mContext = context; - mWifiInjector = wifiInjector; mHandler = handler; mBackupManagerProxy = backupManagerProxy; - mFrameworkFacade = frameworkFacade; - mWifiConfigStore = wifiConfigStore; mWifiConfigManager = wifiConfigManager; String ap2GChannelListStr = mContext.getResources().getString( @@ -188,14 +175,12 @@ public class WifiApConfigStore { } // Register store data listener - mWifiConfigStore.registerStoreData( - mWifiInjector.makeSoftApStoreData(new SoftApStoreDataSource())); + wifiConfigStore.registerStoreData( + wifiInjector.makeSoftApStoreData(new SoftApStoreDataSource())); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_HOTSPOT_CONFIG_USER_TAPPED_CONTENT); - mContext.registerReceiver( - mBroadcastReceiver, filter, null /* broadcastPermission */, mHandler); - mMacAddressUtil = mWifiInjector.getMacAddressUtil(); + mMacAddressUtil = wifiInjector.getMacAddressUtil(); mMac = mMacAddressUtil.obtainMacRandHashFunctionForSap(Process.WIFI_UID); if (mMac == null) { Log.wtf(TAG, "Failed to obtain secret for SAP MAC randomization." @@ -203,23 +188,6 @@ public class WifiApConfigStore { } } - private final BroadcastReceiver mBroadcastReceiver = - new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - // For now we only have one registered listener, but we easily could expand this - // to support multiple signals. Starting off with a switch to support trivial - // expansion. - switch(intent.getAction()) { - case ACTION_HOTSPOT_CONFIG_USER_TAPPED_CONTENT: - handleUserHotspotConfigTappedContent(); - break; - default: - Log.e(TAG, "Unknown action " + intent.getAction()); - } - } - }; - /** * Return the current soft access point configuration. */ @@ -257,47 +225,6 @@ public class WifiApConfigStore { return mAllowed2GChannel; } - /** - * Helper method to create and send notification to user of apBand conversion. - * - * @param packageName name of the calling app - */ - public void notifyUserOfApBandConversion(String packageName) { - Log.w(TAG, "ready to post notification - triggered by " + packageName); - Notification notification = createConversionNotification(); - NotificationManager notificationManager = (NotificationManager) - mContext.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.notify(SystemMessage.NOTE_SOFTAP_CONFIG_CHANGED, notification); - } - - private Notification createConversionNotification() { - CharSequence title = - mContext.getResources().getText(R.string.wifi_softap_config_change); - CharSequence contentSummary = - mContext.getResources().getText(R.string.wifi_softap_config_change_summary); - CharSequence content = - mContext.getResources().getText(R.string.wifi_softap_config_change_detailed); - int color = - mContext.getResources().getColor( - android.R.color.system_notification_accent_color, mContext.getTheme()); - - return new Notification.Builder(mContext, WifiStackService.NOTIFICATION_NETWORK_STATUS) - .setSmallIcon(R.drawable.ic_wifi_settings) - .setPriority(Notification.PRIORITY_HIGH) - .setCategory(Notification.CATEGORY_SYSTEM) - .setContentTitle(title) - .setContentText(contentSummary) - .setContentIntent(getPrivateBroadcast(ACTION_HOTSPOT_CONFIG_USER_TAPPED_CONTENT)) - .setTicker(title) - .setShowWhen(false) - .setLocalOnly(true) - .setColor(color) - .setStyle(new Notification.BigTextStyle().bigText(content) - .setBigContentTitle(title) - .setSummaryText(contentSummary)) - .build(); - } - private WifiConfiguration sanitizePersistentApConfig(WifiConfiguration config) { WifiConfiguration convertedConfig = null; @@ -572,32 +499,6 @@ public class WifiApConfigStore { return true; } - /** - * Helper method to start up settings on the softap config page. - */ - private void startSoftApSettings() { - mContext.startActivity( - new Intent("com.android.settings.WIFI_TETHER_SETTINGS") - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); - } - - /** - * Helper method to trigger settings to open the softap config page - */ - private void handleUserHotspotConfigTappedContent() { - startSoftApSettings(); - NotificationManager notificationManager = (NotificationManager) - mContext.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(SystemMessage.NOTE_SOFTAP_CONFIG_CHANGED); - } - - private PendingIntent getPrivateBroadcast(String action) { - Intent intent = new Intent(action) - .setPackage(mWifiInjector.getWifiStackPackageName()); - return mFrameworkFacade.getBroadcast( - mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); - } - private static String generatePassword() { // Characters that will be used for password generation. Some characters commonly known to // be confusing like 0 and O excluded from this list. diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 35fd64c5e..928583a8f 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -265,7 +265,7 @@ public class WifiInjector { mWifiMetrics.setWifiConfigManager(mWifiConfigManager); mWifiApConfigStore = new WifiApConfigStore( - mContext, this, wifiHandler, mBackupManagerProxy, mFrameworkFacade, + mContext, this, wifiHandler, mBackupManagerProxy, mWifiConfigStore, mWifiConfigManager); mWifiConnectivityHelper = new WifiConnectivityHelper(mWifiNative); diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index b4e749ca7..83fb40338 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -81,7 +81,6 @@ import android.os.BatteryStats; import android.os.Binder; import android.os.Build; import android.os.Bundle; -import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; @@ -1564,21 +1563,6 @@ public class WifiServiceImpl extends BaseWifiService { } /** - * Method used to inform user of Ap Configuration conversion due to hardware. - */ - @Override - public void notifyUserOfApBandConversion(String packageName) { - enforceNetworkSettingsPermission(); - - if (mVerboseLoggingEnabled) { - mLog.info("notifyUserOfApBandConversion uid=% packageName=%") - .c(Binder.getCallingUid()).c(packageName).flush(); - } - - mWifiApConfigStore.notifyUserOfApBandConversion(packageName); - } - - /** * see {@link android.net.wifi.WifiManager#isScanAlwaysAvailable()} */ @Override diff --git a/service/res/values/strings.xml b/service/res/values/strings.xml index 69d210670..4a39e9875 100644 --- a/service/res/values/strings.xml +++ b/service/res/values/strings.xml @@ -63,21 +63,6 @@ <!--Notification content for when Wi-Fi Wake enables Wi-Fi. %1$s is the SSID of the nearby saved network that triggered the wakeup. --> <string name="wifi_wakeup_enabled_content">You\u0027re near a saved network: <xliff:g id="network_ssid">%1$s</xliff:g></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 is shown when a user's selected SSID is later disabled due to connectivity problems. This is the notification's title / ticker. --> <string name="wifi_watchdog_network_disabled">Couldn\'t connect to Wi-Fi</string> <!-- A notification is shown when a user's selected SSID is later disabled due to connectivity problems. The complete alert msg is: <hotspot name> + this string, i.e. "Linksys has a poor internet connection" --> |