diff --git a/src/com/android/settings/wifi/WifiNoInternetDialog.java b/src/com/android/settings/wifi/WifiNoInternetDialog.java index eb42097fa16..7cf7fbc81d4 100644 --- a/src/com/android/settings/wifi/WifiNoInternetDialog.java +++ b/src/com/android/settings/wifi/WifiNoInternetDialog.java @@ -55,9 +55,9 @@ public final class WifiNoInternetDialog extends AlertActivity implements private boolean mButtonClicked; private boolean isKnownAction(Intent intent) { - return intent.getAction().equals(ACTION_PROMPT_UNVALIDATED) - || intent.getAction().equals(ACTION_PROMPT_LOST_VALIDATION) - || intent.getAction().equals(ACTION_PROMPT_PARTIAL_CONNECTIVITY); + return ACTION_PROMPT_UNVALIDATED.equals(intent.getAction()) + || ACTION_PROMPT_LOST_VALIDATION.equals(intent.getAction()) + || ACTION_PROMPT_PARTIAL_CONNECTIVITY.equals(intent.getAction()); } @Override diff --git a/src/com/android/settings/wifi/WifiScanModeActivity.java b/src/com/android/settings/wifi/WifiScanModeActivity.java index 53427299df1..4dc1b97a00e 100644 --- a/src/com/android/settings/wifi/WifiScanModeActivity.java +++ b/src/com/android/settings/wifi/WifiScanModeActivity.java @@ -46,8 +46,8 @@ public class WifiScanModeActivity extends FragmentActivity { super.onCreate(savedInstanceState); Intent intent = getIntent(); if (savedInstanceState == null) { - if (intent != null && intent.getAction() - .equals(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE)) { + if (intent != null && WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE + .equals(intent.getAction())) { ApplicationInfo ai; mApp = getCallingPackage(); try { diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java index 6823874ccba..cb72a6dfb62 100644 --- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java +++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java @@ -109,9 +109,15 @@ public class WifiDppConfiguratorActivity extends WifiDppBaseActivity implements @Override protected void handleIntent(Intent intent) { + String action = intent != null ? intent.getAction() : null; + if (action == null) { + finish(); + return; + } + boolean cancelActivity = false; WifiNetworkConfig config; - switch (intent.getAction()) { + switch (action) { case ACTION_CONFIGURATOR_QR_CODE_SCANNER: config = WifiNetworkConfig.getValidConfigOrNull(intent); if (config == null) { diff --git a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java index a5fa7c0ff9f..c5f1e81f80d 100644 --- a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java +++ b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java @@ -44,7 +44,13 @@ public class WifiDppEnrolleeActivity extends WifiDppBaseActivity implements @Override protected void handleIntent(Intent intent) { - switch (intent.getAction()) { + String action = intent != null ? intent.getAction() : null; + if (action == null) { + finish(); + return; + } + + switch (action) { case ACTION_ENROLLEE_QR_CODE_SCANNER: String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID); showQrCodeScannerFragment(ssid); diff --git a/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java b/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java new file mode 100644 index 00000000000..af7a2a33437 --- /dev/null +++ b/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java @@ -0,0 +1,31 @@ +/* + * 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.settings.wifi; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; + +@RunWith(RobolectricTestRunner.class) +public class WifiNoInternetDialogTest { + @Test + public void launchActivity_noIntentAction_shouldNotFatalException() { + WifiNoInternetDialog wifiNoInternetDialog = + Robolectric.setupActivity(WifiNoInternetDialog.class); + } +} diff --git a/tests/robotests/src/com/android/settings/wifi/WifiScanModeActivityTest.java b/tests/robotests/src/com/android/settings/wifi/WifiScanModeActivityTest.java new file mode 100644 index 00000000000..3e6ba00eff5 --- /dev/null +++ b/tests/robotests/src/com/android/settings/wifi/WifiScanModeActivityTest.java @@ -0,0 +1,31 @@ +/* + * 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.settings.wifi; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; + +@RunWith(RobolectricTestRunner.class) +public class WifiScanModeActivityTest { + @Test + public void launchActivity_noIntentAction_shouldNotFatalException() { + WifiScanModeActivity wifiScanModeActivity = + Robolectric.setupActivity(WifiScanModeActivity.class); + } +} diff --git a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java new file mode 100644 index 00000000000..0c9bf37cabb --- /dev/null +++ b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java @@ -0,0 +1,31 @@ +/* + * 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.settings.wifi.dpp; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; + +@RunWith(RobolectricTestRunner.class) +public class WifiDppConfiguratorActivityTest { + @Test + public void launchActivity_noIntentAction_shouldNotFatalException() { + WifiDppConfiguratorActivity wifiDppConfiguratorActivity = + Robolectric.setupActivity(WifiDppConfiguratorActivity.class); + } +} diff --git a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java new file mode 100644 index 00000000000..819b7f4331d --- /dev/null +++ b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java @@ -0,0 +1,31 @@ +/* + * 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.settings.wifi.dpp; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; + +@RunWith(RobolectricTestRunner.class) +public class WifiDppEnrolleeActivityTest { + @Test + public void launchActivity_noIntentAction_shouldNotFatalException() { + WifiDppEnrolleeActivity wifiDppEnrolleeActivity = + Robolectric.setupActivity(WifiDppEnrolleeActivity.class); + } +}