blob: e709d0a8044c9c5e75ab90714b96f9475648afc4 [file] [log] [blame]
/**
* Copyright (C) 2021 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 android.security.cts.CVE_2021_0965;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import android.content.Intent;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.uiautomator.UiDevice;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class DeviceTest {
@Before
public void startMainActivityFromHomeScreen() {
UiDevice device = UiDevice.getInstance(getInstrumentation());
try {
device.wakeUp();
} catch (Exception e) {
}
device.pressHome();
}
@Test
public void testPermission() {
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings",
"com.android.settings.bluetooth.BluetoothPairingDialog");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(intent);
} catch (SecurityException e) {
return;
}
/* If SecurityException is not thrown, it indicates absence of fix */
throw new RuntimeException("Vulnerable to b/194300867 !!");
}
}