Merge "[Wi-Fi] Prevent fatal exception for null intent action"
This commit is contained in:
committed by
Android (Google) Code Review
commit
04e72e23d9
@@ -55,9 +55,9 @@ public final class WifiNoInternetDialog extends AlertActivity implements
|
|||||||
private boolean mButtonClicked;
|
private boolean mButtonClicked;
|
||||||
|
|
||||||
private boolean isKnownAction(Intent intent) {
|
private boolean isKnownAction(Intent intent) {
|
||||||
return intent.getAction().equals(ACTION_PROMPT_UNVALIDATED)
|
return ACTION_PROMPT_UNVALIDATED.equals(intent.getAction())
|
||||||
|| intent.getAction().equals(ACTION_PROMPT_LOST_VALIDATION)
|
|| ACTION_PROMPT_LOST_VALIDATION.equals(intent.getAction())
|
||||||
|| intent.getAction().equals(ACTION_PROMPT_PARTIAL_CONNECTIVITY);
|
|| ACTION_PROMPT_PARTIAL_CONNECTIVITY.equals(intent.getAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -46,8 +46,8 @@ public class WifiScanModeActivity extends FragmentActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
if (intent != null && intent.getAction()
|
if (intent != null && WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE
|
||||||
.equals(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE)) {
|
.equals(intent.getAction())) {
|
||||||
ApplicationInfo ai;
|
ApplicationInfo ai;
|
||||||
mApp = getCallingPackage();
|
mApp = getCallingPackage();
|
||||||
try {
|
try {
|
||||||
|
@@ -109,9 +109,15 @@ public class WifiDppConfiguratorActivity extends WifiDppBaseActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleIntent(Intent intent) {
|
protected void handleIntent(Intent intent) {
|
||||||
|
String action = intent != null ? intent.getAction() : null;
|
||||||
|
if (action == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean cancelActivity = false;
|
boolean cancelActivity = false;
|
||||||
WifiNetworkConfig config;
|
WifiNetworkConfig config;
|
||||||
switch (intent.getAction()) {
|
switch (action) {
|
||||||
case ACTION_CONFIGURATOR_QR_CODE_SCANNER:
|
case ACTION_CONFIGURATOR_QR_CODE_SCANNER:
|
||||||
config = WifiNetworkConfig.getValidConfigOrNull(intent);
|
config = WifiNetworkConfig.getValidConfigOrNull(intent);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
|
@@ -44,7 +44,13 @@ public class WifiDppEnrolleeActivity extends WifiDppBaseActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleIntent(Intent intent) {
|
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:
|
case ACTION_ENROLLEE_QR_CODE_SCANNER:
|
||||||
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
|
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
|
||||||
showQrCodeScannerFragment(ssid);
|
showQrCodeScannerFragment(ssid);
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user