diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-03 08:01:30 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-03 08:01:30 +0000 |
commit | 295ec90b3fb7c802483fc443059558e120667df9 (patch) | |
tree | 897a48356290ddd2b5411e33068d52b9c8cbeddf | |
parent | 4e9eaf9936a6a84bf5d516d80964ee8d863d7de8 (diff) | |
parent | 1d6c68f3f91797a83f391b72b25fd2df602a3237 (diff) | |
download | cts-android14-mainline-healthfitness-release.tar.gz |
Snap for 11171363 from 1d6c68f3f91797a83f391b72b25fd2df602a3237 to mainline-healthfitness-releaseaml_hef_341415040android14-mainline-healthfitness-release
Change-Id: I038175851ef4197098a29bae219334fdf61bc7c2
11 files changed, 19 insertions, 333 deletions
diff --git a/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java b/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java index f2fc35b3e5a..ac0c24ef0c2 100644 --- a/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java +++ b/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java @@ -74,7 +74,8 @@ import java.util.function.Supplier; @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public class DecodeOnlyTest extends MediaTestBase { public static final boolean WAS_LAUNCHED_ON_U_OR_LATER = - SystemProperties.getInt("ro.board.first_api_level", Build.VERSION_CODES.CUR_DEVELOPMENT) + SystemProperties.getInt("ro.product.first_api_level", + Build.VERSION_CODES.CUR_DEVELOPMENT) >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE; private static final String MEDIA_DIR_STRING = WorkDir.getMediaDirString(); @@ -108,7 +109,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledPerfectSeekInitialPeekOnAvc() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledPerfectSeek(AVC_VIDEO, true); } @@ -117,7 +118,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledPerfectSeekInitialPeekOnVp9() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledPerfectSeek(VP9_VIDEO, true); } @@ -126,7 +127,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledPerfectSeekInitialPeekOnHevc() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledPerfectSeek(HEVC_VIDEO, true); } @@ -135,7 +136,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledPerfectSeekInitialPeekOffAvc() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledPerfectSeek(AVC_VIDEO, false); } @@ -144,7 +145,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledPerfectSeekInitialPeekOffVp9() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledPerfectSeek(VP9_VIDEO, false); } @@ -153,7 +154,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledPerfectSeekInitialPeekOffHevc() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledPerfectSeek(HEVC_VIDEO, false); } @@ -165,7 +166,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledTrickPlayHevc() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledTrickPlay(HEVC_VIDEO); } @@ -174,7 +175,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledTrickPlayAvc() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledTrickPlay(AVC_VIDEO); } @@ -183,7 +184,7 @@ public class DecodeOnlyTest extends MediaTestBase { @ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"}) public void testTunneledTrickPlayVp9() throws Exception { // Tunnel mode requires vendor support of the DECODE_ONLY feature - Assume.assumeTrue("First board API level is not Android 14 or later.", + Assume.assumeTrue("First API level is not Android 14 or later.", WAS_LAUNCHED_ON_U_OR_LATER); testTunneledTrickPlay(VP9_VIDEO); } diff --git a/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderTest.java b/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderTest.java index 4721f8bc829..cb88f684207 100644 --- a/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderTest.java +++ b/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderTest.java @@ -110,7 +110,8 @@ public class DecoderTest extends MediaTestBase { private static final String REPORT_LOG_NAME = "CtsMediaDecoderTestCases"; public static final boolean WAS_LAUNCHED_ON_S_OR_LATER = - SystemProperties.getInt("ro.board.first_api_level", Build.VERSION_CODES.CUR_DEVELOPMENT) + SystemProperties.getInt("ro.product.first_api_level", + Build.VERSION_CODES.CUR_DEVELOPMENT) >= Build.VERSION_CODES.S; private static boolean IS_AT_LEAST_R = ApiLevelUtil.isAtLeast(Build.VERSION_CODES.R); @@ -3531,7 +3532,7 @@ public class DecoderTest extends MediaTestBase { @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) public void testTunneledVideoPeekOnHevc() throws Exception { // Requires vendor support of the TUNNEL_PEEK feature - Assume.assumeTrue("First board API level is not Android 12 or later.", + Assume.assumeTrue("First API level is not Android 12 or later.", WAS_LAUNCHED_ON_S_OR_LATER); testTunneledVideoPeekOn(MediaFormat.MIMETYPE_VIDEO_HEVC, "video_1280x720_mkv_h265_500kbps_25fps_aac_stereo_128kbps_44100hz.mkv", 25); @@ -3545,7 +3546,7 @@ public class DecoderTest extends MediaTestBase { @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) public void testTunneledVideoPeekOnAvc() throws Exception { // Requires vendor support of the TUNNEL_PEEK feature - Assume.assumeTrue("First board API level is not Android 12 or later.", + Assume.assumeTrue("First API level is not Android 12 or later.", WAS_LAUNCHED_ON_S_OR_LATER); testTunneledVideoPeekOn(MediaFormat.MIMETYPE_VIDEO_AVC, "video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz.mp4", 25); @@ -3559,7 +3560,7 @@ public class DecoderTest extends MediaTestBase { @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) public void testTunneledVideoPeekOnVp9() throws Exception { // Requires vendor support of the TUNNEL_PEEK feature - Assume.assumeTrue("First board API level is not Android 12 or later.", + Assume.assumeTrue("First API level is not Android 12 or later.", WAS_LAUNCHED_ON_S_OR_LATER); testTunneledVideoPeekOn(MediaFormat.MIMETYPE_VIDEO_VP9, "bbb_s1_640x360_webm_vp9_0p21_1600kbps_30fps_vorbis_stereo_128kbps_48000hz.webm", @@ -3632,7 +3633,7 @@ public class DecoderTest extends MediaTestBase { @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) public void testTunneledVideoPeekOffHevc() throws Exception { // Requires vendor support of the TUNNEL_PEEK feature - Assume.assumeTrue("First board API level is not Android 12 or later.", + Assume.assumeTrue("First API level is not Android 12 or later.", WAS_LAUNCHED_ON_S_OR_LATER); testTunneledVideoPeekOff(MediaFormat.MIMETYPE_VIDEO_HEVC, "video_1280x720_mkv_h265_500kbps_25fps_aac_stereo_128kbps_44100hz.mkv", 25); @@ -3646,7 +3647,7 @@ public class DecoderTest extends MediaTestBase { @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) public void testTunneledVideoPeekOffAvc() throws Exception { // Requires vendor support of the TUNNEL_PEEK feature - Assume.assumeTrue("First board API level is not Android 12 or later.", + Assume.assumeTrue("First API level is not Android 12 or later.", WAS_LAUNCHED_ON_S_OR_LATER); testTunneledVideoPeekOff(MediaFormat.MIMETYPE_VIDEO_AVC, "video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz.mp4", 25); @@ -3660,7 +3661,7 @@ public class DecoderTest extends MediaTestBase { @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) public void testTunneledVideoPeekOffVp9() throws Exception { // Requires vendor support of the TUNNEL_PEEK feature - Assume.assumeTrue("First board API level is not Android 12 or later.", + Assume.assumeTrue("First API level is not Android 12 or later.", WAS_LAUNCHED_ON_S_OR_LATER); testTunneledVideoPeekOff(MediaFormat.MIMETYPE_VIDEO_VP9, "bbb_s1_640x360_webm_vp9_0p21_1600kbps_30fps_vorbis_stereo_128kbps_48000hz.webm", diff --git a/tests/tests/packageinstaller/install/src/android/packageinstaller/install/cts/IntentTest.kt b/tests/tests/packageinstaller/install/src/android/packageinstaller/install/cts/IntentTest.kt index 8a65ad3accb..e19ad7a5eda 100644 --- a/tests/tests/packageinstaller/install/src/android/packageinstaller/install/cts/IntentTest.kt +++ b/tests/tests/packageinstaller/install/src/android/packageinstaller/install/cts/IntentTest.kt @@ -158,7 +158,6 @@ class IntentTest : PackageInstallerTestBase() { clickInstallerUIButton(INSTALL_BUTTON_ID) // Install should not have succeeded - assertEquals(RESULT_CANCELED, installation.get(TIMEOUT, TimeUnit.MILLISECONDS)) assertNotInstalled() } finally { setSecureFrp(false) diff --git a/tests/tests/security/Android.bp b/tests/tests/security/Android.bp index 3aa25a56a0e..1bca40ac1bf 100644 --- a/tests/tests/security/Android.bp +++ b/tests/tests/security/Android.bp @@ -92,7 +92,6 @@ android_test { ":CtsPermissionBackupAppCert34", ":CtsPermissionBackupAppCert123", ":CtsPermissionBackupAppCert4History124", - ":TileServiceNullBindingTestApp", ], } diff --git a/tests/tests/security/AndroidTest.xml b/tests/tests/security/AndroidTest.xml index aa29d2bdc95..fc858384128 100644 --- a/tests/tests/security/AndroidTest.xml +++ b/tests/tests/security/AndroidTest.xml @@ -63,7 +63,6 @@ <option name="push" value="CtsPermissionBackupAppCert123.apk->/data/local/tmp/cts/security/CtsPermissionBackupAppCert123.apk" /> <option name="push" value="CtsPermissionBackupAppCert34.apk->/data/local/tmp/cts/security/CtsPermissionBackupAppCert34.apk" /> <option name="push" value="CtsPermissionBackupAppCert4History124.apk->/data/local/tmp/cts/security/CtsPermissionBackupAppCert4History124.apk" /> - <option name="push" value="TileServiceNullBindingTestApp.apk->/data/local/tmp/cts/security/TileServiceNullBindingTestApp.apk" /> </target_preparer> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > diff --git a/tests/tests/security/TileServiceNullBindingTestApp/Android.bp b/tests/tests/security/TileServiceNullBindingTestApp/Android.bp deleted file mode 100644 index 149550890a4..00000000000 --- a/tests/tests/security/TileServiceNullBindingTestApp/Android.bp +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (C) 2020 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 { - default_applicable_licenses: ["Android-Apache-2.0"], -} - -android_test_helper_app { - name: "TileServiceNullBindingTestApp", - srcs: [ - "src/**/*.kt", - ], - static_libs: [ - "kotlin-stdlib", - ], - - min_sdk_version: "30", - target_sdk_version: "33", -} diff --git a/tests/tests/security/TileServiceNullBindingTestApp/AndroidManifest.xml b/tests/tests/security/TileServiceNullBindingTestApp/AndroidManifest.xml deleted file mode 100644 index c7193769bdc..00000000000 --- a/tests/tests/security/TileServiceNullBindingTestApp/AndroidManifest.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<!-- - ~ 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. - --> - -<manifest - xmlns:android="http://schemas.android.com/apk/res/android" - package="android.security.cts.tileservice"> - - - <application android:label="TileService Null Binding Test App" - android:icon="@android:drawable/ic_info"> - <activity android:name=".BackgroundLaunchActivity" - android:exported="false"> - </activity> - <activity android:name=".ActivityStarterActivity" - android:exported="true"> - </activity> - <service android:name=".NullBindingTileService" - android:label="Tile Service" - android:exported="true" - android:icon="@android:drawable/ic_info" - android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> - <intent-filter> - <action android:name="android.service.quicksettings.action.QS_TILE" /> - </intent-filter> - </service> - </application> -</manifest> diff --git a/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/ActivityStarterActivity.kt b/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/ActivityStarterActivity.kt deleted file mode 100644 index 3d73c04ca82..00000000000 --- a/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/ActivityStarterActivity.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2023 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.tileservice - -import android.app.Activity -import android.content.Intent -import android.os.Bundle -import android.os.Handler -import android.widget.FrameLayout - -class ActivityStarterActivity : Activity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(FrameLayout(this)) - } - - override fun onResume() { - super.onResume() - Handler().postDelayed({ - startActivity(Intent(applicationContext, BackgroundLaunchActivity::class.java)) - }, DELAY) - minimizeApp() - } - - private fun minimizeApp() { - val startMain = Intent(Intent.ACTION_MAIN) - startMain.addCategory(Intent.CATEGORY_HOME) - startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - startActivity(startMain) - } - - companion object { - private const val DELAY = 15000L - } -} diff --git a/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/BackgroundLaunchActivity.kt b/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/BackgroundLaunchActivity.kt deleted file mode 100644 index 43244eedbcb..00000000000 --- a/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/BackgroundLaunchActivity.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2023 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.tileservice - -import android.app.Activity -import android.content.Intent -import android.os.Bundle - -class BackgroundLaunchActivity : Activity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - sendBroadcast(Intent(BACKGROUND_ACTIVITY_STARTED)) - finish() - } - - companion object { - private const val BACKGROUND_ACTIVITY_STARTED = - "android.security.cts.tileservice.BACKGROUND_ACTIVITY_STARTED" - } -} diff --git a/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/NullBindingTileService.kt b/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/NullBindingTileService.kt deleted file mode 100644 index 7ff03826df3..00000000000 --- a/tests/tests/security/TileServiceNullBindingTestApp/src/android/security/cts/tileservice/NullBindingTileService.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2023 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.tileservice - -import android.content.Intent -import android.os.IBinder -import android.service.quicksettings.TileService - -class NullBindingTileService : TileService() { - override fun onBind(intent: Intent?): IBinder? { - return null.also { - sendBroadcast(Intent(ON_NULL_BINDING)) - } - } - - companion object { - private const val ON_NULL_BINDING = "android.security.cts.tileservice.ON_NULL_BINDING" - } -} diff --git a/tests/tests/security/src/android/security/cts/Bug_300903792.kt b/tests/tests/security/src/android/security/cts/Bug_300903792.kt deleted file mode 100644 index 5b2784b93e7..00000000000 --- a/tests/tests/security/src/android/security/cts/Bug_300903792.kt +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2023 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 - -import android.content.ComponentName -import android.content.Intent -import android.platform.test.annotations.AsbSecurityTest -import android.service.quicksettings.TileService -import android.util.Log -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation -import com.android.compatibility.common.util.BlockingBroadcastReceiver -import com.android.compatibility.common.util.SystemUtil -import com.android.sts.common.util.StsExtraBusinessLogicTestCase -import org.junit.After -import org.junit.Assert.fail -import org.junit.Assume.assumeTrue -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class Bug_300903792 : StsExtraBusinessLogicTestCase() { - - @Before - fun setUp() { - assumeTrue(TileService.isQuickSettingsSupported()) - installPackage(TILE_SERVICE_APP_LOCATION) - } - - @After - fun tearDown() { - SystemUtil.runShellCommand(REMOVE_TILE_COMMAND) - Log.d("TestRunner", "Uninstalling $TILE_SERVICE_PACKAGE") - uninstallPackage(TILE_SERVICE_PACKAGE) - } - - @Test - @AsbSecurityTest(cveBugId = [300903792]) - fun testPocBug_300903792() { - val context = getInstrumentation().context - val nullBindingReceiver = BlockingBroadcastReceiver(context, ON_NULL_BINDING) - // First we add the tile, we should receive a broadcast once it has bound. - // We expect that the tile will be bound to notify `onTileAdded` and onNullBinding will - // happen. - try { - nullBindingReceiver.register() - SystemUtil.runShellCommand(ADD_TILE_COMMAND) - nullBindingReceiver.awaitForBroadcast(ONE_MINUTE_IN_MILLIS) - } finally { - nullBindingReceiver.unregisterQuietly() - } - - val backgroundActivityStarted = - BlockingBroadcastReceiver(context, BACKGROUND_ACTIVITY_STARTED) - // We start an activity that will schedule another activity to start and then go home - // (putting itself in the background). We expect that the backgroundActivity is not started, - // but if the security issue is not patched, it will. - try { - backgroundActivityStarted.register() - context.startActivity( - Intent() - .setComponent(ACTIVITY_STARTER_COMPONENT) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - ) - val intent = backgroundActivityStarted.awaitForBroadcast(ONE_MINUTE_IN_MILLIS) - if (intent != null) { - fail("Vulnerable to b/300903792! Activity started from the background") - } - } finally { - backgroundActivityStarted.unregisterQuietly() - } - } - - private fun installPackage(apkPath: String) { - val result = SystemUtil.runShellCommand("pm install -r $apkPath") - Log.d("security", "Install result: $result") - } - - private fun uninstallPackage(packageName: String) { - SystemUtil.runShellCommand("pm uninstall $packageName") - } - - companion object { - private const val TILE_SERVICE_APP_LOCATION = - "/data/local/tmp/cts/security/TileServiceNullBindingTestApp.apk" - private const val TILE_SERVICE_PACKAGE = "android.security.cts.tileservice" - private const val TILE_SERVICE_NAME = ".NullBindingTileService" - private const val ACTIVITY_STARTER_NAME = ".ActivityStarterActivity" - - private val TILE_SERVICE_COMPONENT = - ComponentName.createRelative(TILE_SERVICE_PACKAGE, TILE_SERVICE_NAME) - private val ACTIVITY_STARTER_COMPONENT = - ComponentName.createRelative(TILE_SERVICE_PACKAGE, ACTIVITY_STARTER_NAME) - - private const val BACKGROUND_ACTIVITY_STARTED = - "android.security.cts.tileservice.BACKGROUND_ACTIVITY_STARTED" - - private const val ON_NULL_BINDING = "android.security.cts.tileservice.ON_NULL_BINDING" - - private val ADD_TILE_COMMAND = - "cmd statusbar add-tile ${TILE_SERVICE_COMPONENT.flattenToString()}" - private val REMOVE_TILE_COMMAND = - "cmd statusbar remove-tile ${TILE_SERVICE_COMPONENT.flattenToString()}" - - private const val ONE_MINUTE_IN_MILLIS = 60 * 1000L - } -} |