diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-02 00:59:04 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-02 00:59:04 +0000 |
commit | 8ed72e47830d54920458a465ba00f33673f5b92a (patch) | |
tree | 0229994f92780db06826b5eddcbc863dda1e0bf4 | |
parent | 3297c45d45624f285b1503c88cf1ede3ff655e20 (diff) | |
parent | 8449ddfb5f4264da8011aa119c248d132ae93769 (diff) | |
download | cts-android14-mainline-tethering-release.tar.gz |
Snap for 11168461 from 8449ddfb5f4264da8011aa119c248d132ae93769 to mainline-tethering-releaseaml_tet_341411060android14-mainline-tethering-release
Change-Id: I2380632de78bf17062f145b602dc3d8b43a0e13f
9 files changed, 7 insertions, 315 deletions
diff --git a/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerSettingsTest.java b/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerSettingsTest.java index 2146a8558d0..78b3ae8c247 100644 --- a/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerSettingsTest.java +++ b/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerSettingsTest.java @@ -50,12 +50,15 @@ import androidx.test.uiautomator.UiObjectNotFoundException; import androidx.test.uiautomator.UiSelector; import com.android.bedstead.harrier.BedsteadJUnit4; +import com.android.bedstead.harrier.DeviceState; import com.android.bedstead.harrier.annotations.RequireRunOnWorkProfile; import com.android.modules.utils.build.SdkLevel; import org.junit.After; import org.junit.Assume; import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -77,6 +80,9 @@ public class PhotoPickerSettingsTest extends PhotoPickerBaseTest { @Nullable private static DeviceStatePreserver sDeviceStatePreserver; + @ClassRule @Rule + public static final DeviceState sDeviceState = new DeviceState(); + @Before public void setUp() throws Exception { super.setUp(); @@ -145,6 +151,7 @@ public class PhotoPickerSettingsTest extends PhotoPickerBaseTest { @RequireRunOnWorkProfile @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) public void testSettingsLaunchedInPersonalProfile_WorkEnabled() throws Exception { + mSettingsIntent.putExtra(EXTRA_TAB_USER_ID, sDeviceState.initialUser().id()); launchSettingsActivityWithRetry(/* retryCount */ 3, /* backoffSeedInMillis */ 500); verifySettingsActivityIsVisible(); 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 - } -} |