diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-12-20 20:21:06 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-12-20 20:21:06 +0000 |
commit | be37bc73cde5ee9866c92df2269977228075da5c (patch) | |
tree | c4adaad0d1fe6855e97f30a973d211b4baaf91dc | |
parent | f31a24f9d0eac9ad48df195765331b24f927030b (diff) | |
parent | e305f0c25a524a55cb3b0afd55711ff87ae43f62 (diff) | |
download | cts-aml_con_331411000.tar.gz |
Snap for 9424327 from e305f0c25a524a55cb3b0afd55711ff87ae43f62 to mainline-conscrypt-releaseaml_con_331413000aml_con_331411000android13-mainline-conscrypt-release
Change-Id: I12ba6b22c39e4171bd012b58f6227ceeca193ca9
-rw-r--r-- | tests/tests/permission/src/android/permission/cts/RevokeSawPermissionTest.kt | 2 | ||||
-rw-r--r-- | tests/tests/security/src/android/security/cts/WorkSourceTest.java | 67 |
2 files changed, 68 insertions, 1 deletions
diff --git a/tests/tests/permission/src/android/permission/cts/RevokeSawPermissionTest.kt b/tests/tests/permission/src/android/permission/cts/RevokeSawPermissionTest.kt index fe5373e1c37..f3f06de0041 100644 --- a/tests/tests/permission/src/android/permission/cts/RevokeSawPermissionTest.kt +++ b/tests/tests/permission/src/android/permission/cts/RevokeSawPermissionTest.kt @@ -41,7 +41,7 @@ class RevokeSawPermissionTest { SystemUtil.runShellCommand("pm uninstall $APP_PKG_NAME") } - @AsbSecurityTest(cveBugId = [247512334L]) + @AsbSecurityTest(cveBugId = [221040577L]) @Test fun testPre23AppsWithSystemAlertWindowGetDeniedOnUpgrade() { installApp(APK_22) diff --git a/tests/tests/security/src/android/security/cts/WorkSourceTest.java b/tests/tests/security/src/android/security/cts/WorkSourceTest.java new file mode 100644 index 00000000000..1438b29d1d6 --- /dev/null +++ b/tests/tests/security/src/android/security/cts/WorkSourceTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2022 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import android.os.Parcel; +import android.os.WorkSource; +import android.platform.test.annotations.AsbSecurityTest; + +import androidx.test.runner.AndroidJUnit4; + +import com.android.sts.common.util.StsExtraBusinessLogicTestCase; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class WorkSourceTest extends StsExtraBusinessLogicTestCase { + private static final int TEST_PID = 6512; + private static final String TEST_PACKAGE_NAME = "android.security.cts"; + + @Test + @AsbSecurityTest(cveBugId = 220302519) + public void testWorkChainParceling() { + WorkSource ws = new WorkSource(TEST_PID, TEST_PACKAGE_NAME); + // Create a WorkChain so the mChains becomes non-null + ws.createWorkChain(); + assertNotNull("WorkChains must be non-null in order to properly test parceling", + ws.getWorkChains()); + // Then clear it so it's an empty list. + ws.getWorkChains().clear(); + assertTrue("WorkChains must be empty in order to properly test parceling", + ws.getWorkChains().isEmpty()); + + Parcel p = Parcel.obtain(); + ws.writeToParcel(p, 0); + p.setDataPosition(0); + + // Read the Parcel back out and validate the two Parcels are identical + WorkSource readWs = WorkSource.CREATOR.createFromParcel(p); + assertNotNull(readWs.getWorkChains()); + assertTrue(readWs.getWorkChains().isEmpty()); + assertEquals(ws, readWs); + + // Assert that we've read every byte out of the Parcel. + assertEquals(p.dataSize(), p.dataPosition()); + + p.recycle(); + } +} |