Merge "[Wi-Fi] Prevent fatal exception for null intent action"

This commit is contained in:
TreeHugger Robot
2019-08-22 09:51:01 +00:00
committed by Android (Google) Code Review
8 changed files with 143 additions and 7 deletions

View File

@@ -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

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}