1 /*
2  * Copyright (C) 2022 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 org.junit.Assert.assertTrue;
20 
21 import android.platform.test.annotations.AppModeFull;
22 import android.platform.test.annotations.AsbSecurityTest;
23 
24 import com.android.tradefed.device.ITestDevice;
25 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
26 import com.android.sts.common.tradefed.testtype.NonRootSecurityTestCase;
27 
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 
31 @RunWith(DeviceJUnit4ClassRunner.class)
32 public class CVE_2020_0015 extends NonRootSecurityTestCase {
33 
34     @AppModeFull
35     @AsbSecurityTest(cveBugId = 139017101)
36     @Test
testPocCVE_2020_0015()37     public void testPocCVE_2020_0015() throws Exception {
38         ITestDevice device = getDevice();
39         final String testPkg = "android.security.cts.CVE_2020_0015";
40         uninstallPackage(device, testPkg);
41 
42         /* Wake up the screen */
43         AdbUtils.runCommandLine("input keyevent KEYCODE_WAKEUP", device);
44         AdbUtils.runCommandLine("input keyevent KEYCODE_MENU", device);
45         AdbUtils.runCommandLine("input keyevent KEYCODE_HOME", device);
46 
47         installPackage("CVE-2020-0015.apk");
48         AdbUtils.runCommandLine("pm grant " + testPkg + " android.permission.SYSTEM_ALERT_WINDOW",
49                 device);
50         assertTrue(runDeviceTests(testPkg, testPkg + ".DeviceTest", "testOverlayButtonPresence"));
51     }
52 }
53