From 11c37350d9a3e83dfbdee0113c1bf78b6cb49539 Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Thu, 18 Mar 2021 16:30:27 +0800 Subject: [PATCH] Replace the way to get the network for no internet dialog It's a refactor work for incoming connectivity mainline. The network information contained in the no ineternet notification action was placed the target network id. The receiver which is Settings will need to construct the network from the network id using the hidden Network constructor. Since Network is moving into module, Settings will not be able to access it. Apps should use Network instead of network id, so just send the network object to Settings. Update the corresponding logic in Settings. Bug: 172183305 Test: manually test with no internet dialog and check the behavior and log Test: make RunSettingsRoboTests ROBOTEST_FILTER=\ com.android.settings.wifi.WifiNoInternetDialogTest Change-Id: I75c04d6f1c2159ae990f6015551eb39d99266336 --- .../android/settings/wifi/WifiNoInternetDialog.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/wifi/WifiNoInternetDialog.java b/src/com/android/settings/wifi/WifiNoInternetDialog.java index ccfda3a6ad4..10f4c798a54 100644 --- a/src/com/android/settings/wifi/WifiNoInternetDialog.java +++ b/src/com/android/settings/wifi/WifiNoInternetDialog.java @@ -65,22 +65,17 @@ public final class WifiNoInternetDialog extends AlertActivity implements super.onCreate(savedInstanceState); final Intent intent = getIntent(); - if (intent == null || !isKnownAction(intent) || !"netId".equals(intent.getScheme())) { + if (intent == null || !isKnownAction(intent)) { Log.e(TAG, "Unexpected intent " + intent + ", exiting"); finish(); return; } mAction = intent.getAction(); - - try { - mNetwork = new Network(Integer.parseInt(intent.getData().getSchemeSpecificPart())); - } catch (NullPointerException|NumberFormatException e) { - mNetwork = null; - } + mNetwork = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK); if (mNetwork == null) { - Log.e(TAG, "Can't determine network from '" + intent.getData() + "' , exiting"); + Log.e(TAG, "Can't determine network from intent extra, exiting"); finish(); return; }