blob: f129d9373bf12a9564c438996f5b5847462a8ed0 [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_0928;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.SystemClock;
import android.util.Log;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.uiautomator.UiDevice;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class DeviceTest {
private static final String TAG = "TAG_2021_0928.DeviceTest";
private UiDevice mDevice;
@Test
public void test() {
Log.d(TAG, "test() start");
// set mDevice and go to homescreen
mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.pressHome();
Context context = getApplicationContext();
String TEST_PACKAGE = "android.security.cts.CVE_2021_0928";
PackageManager packageManager = context.getPackageManager();
// start poc app
Intent intent = packageManager.getLaunchIntentForPackage(TEST_PACKAGE);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
Log.d(TAG, "test(): Activity started");
// wait 30 seconds for poc app to complete
SystemClock.sleep(30000);
Log.d(TAG, "test() end");
}
}