1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.security.cts; 18 19 import static com.android.sts.common.SystemUtil.withSetting; 20 21 import static org.junit.Assume.assumeNoException; 22 import static org.junit.Assume.assumeTrue; 23 24 import android.platform.test.annotations.AsbSecurityTest; 25 26 import com.android.sts.common.tradefed.testtype.NonRootSecurityTestCase; 27 import com.android.tradefed.device.ITestDevice; 28 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; 29 30 import org.junit.After; 31 import org.junit.Before; 32 import org.junit.Test; 33 import org.junit.runner.RunWith; 34 35 @RunWith(DeviceJUnit4ClassRunner.class) 36 public class TestLocationScanningServicesUsingSlices extends NonRootSecurityTestCase { 37 private final String mTestPkg = "android.security.cts.TestLocationScanningServicesUsingSlices"; 38 private final String mTestClass = mTestPkg + "." + "DeviceTest"; 39 private ITestDevice mDevice = null; 40 41 @Before setUp()42 public void setUp() { 43 try { 44 mDevice = getDevice(); 45 46 // Install test app 47 installPackage("TestLocationScanningServicesUsingSlices.apk", "-t"); 48 49 // Set test app as device owner 50 assumeTrue( 51 mDevice.setDeviceOwner( 52 mTestPkg + "/.PocDeviceAdminReceiver", mDevice.getCurrentUser())); 53 } catch (Exception e) { 54 assumeNoException(e); 55 } 56 } 57 58 @After tearDown()59 public void tearDown() { 60 try { 61 mDevice.removeAdmin(mTestPkg + "/.PocDeviceAdminReceiver", mDevice.getCurrentUser()); 62 AdbUtils.runCommandLine("input keyevent KEYCODE_HOME", mDevice); 63 } catch (Exception ignored) { 64 // ignore all exceptions 65 } 66 } 67 68 // b/277333781 69 // Vulnerable module : com.android.settings 70 // Vulnerable apk : Settings.apk 71 @AsbSecurityTest(cveBugId = 277333781) 72 @Test testPocCVE_2023_21247()73 public void testPocCVE_2023_21247() { 74 try (AutoCloseable withBluetoothDisabled = 75 withSetting(mDevice, "global", "ble_scan_always_enabled", "0")) { 76 runDeviceTests(mTestPkg, mTestClass, "testPocCVE_2023_21247"); 77 } catch (Exception e) { 78 assumeNoException(e); 79 } 80 } 81 82 // b/277333746 83 // Vulnerable module : com.android.settings 84 // Vulnerable apk : Settings.apk 85 @AsbSecurityTest(cveBugId = 277333746) 86 @Test testPocCVE_2023_21248()87 public void testPocCVE_2023_21248() { 88 try (AutoCloseable withWifiDisabled = 89 withSetting(mDevice, "global", "wifi_scan_always_enabled", "0")) { 90 runDeviceTests(mTestPkg, mTestClass, "testPocCVE_2023_21248"); 91 } catch (Exception e) { 92 assumeNoException(e); 93 } 94 } 95 } 96