Loading services/core/java/com/android/server/pm/PackageInstallerSession.java +5 −0 Original line number Diff line number Diff line Loading @@ -2112,6 +2112,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { Slog.e(TAG, "Failed to verify session " + sessionId + " [" + msgWithErrorCode + "]"); // Session is sealed and committed but could not be verified, we need to destroy it. destroyInternal(); if (isMultiPackage()) { for (PackageInstallerSession childSession : getChildSessions()) { childSession.destroyInternal(); } } if (isStaged()) { mStagedSession.setSessionFailed( SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, msgWithErrorCode); Loading services/tests/PackageManagerServiceTests/host/AndroidTest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,13 @@ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="run-command" value="pm uninstall com.android.cts.install.lib.testapp.A" /> <option name="teardown-command" value="pm uninstall com.android.cts.install.lib.testapp.A" /> </target_preparer> <test class="com.android.tradefed.testtype.HostTest"> <option name="jar" value="PackageManagerServiceHostTests.jar" /> </test> Loading services/tests/PackageManagerServiceTests/host/src/com/android/server/pm/test/PackageInstallerSessionTest.kt 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * 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 com.android.server.pm.test import com.android.tradefed.testtype.DeviceJUnit4ClassRunner import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test import com.google.common.truth.Truth import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder import org.junit.runner.RunWith import kotlin.jvm.JvmField @RunWith(DeviceJUnit4ClassRunner::class) class PackageInstallerSessionTest : BaseHostJUnit4Test() { companion object { private const val DEVICE_SIDE = "PackageManagerServiceDeviceSideTests.apk" } @Rule @JvmField val tempFolder = TemporaryFolder() @Test fun verify_parentSessionFail_childSessionFiles_shouldBeDestroyed() { runDeviceTest("com.android.server.pm.PackageInstallerSessionTest", "verify_parentSessionFail_childSessionFiles_shouldBeDestroyed") } /** * Run a device side test from com.android.server.pm.test.deviceside.DeviceSide * * @param method the method to run */ fun runDeviceTest(testClassName: String, method: String) { val deviceSideFile = HostUtils.copyResourceToHostFile(DEVICE_SIDE, tempFolder.newFile()) Truth.assertThat(device.installPackage(deviceSideFile, true)).isNull() runDeviceTests(device, "com.android.server.pm.test.deviceside", testClassName, method) } } services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ android_test_helper_app { ], static_libs: [ "androidx.annotation_annotation", "commands-helper", "cts-install-lib", "junit", "junit-params", "androidx.test.ext.junit", Loading services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package="com.android.server.pm.test.deviceside"> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <uses-permission android:name="android.permission.INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.DELETE_PACKAGES" /> <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" Loading Loading
services/core/java/com/android/server/pm/PackageInstallerSession.java +5 −0 Original line number Diff line number Diff line Loading @@ -2112,6 +2112,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { Slog.e(TAG, "Failed to verify session " + sessionId + " [" + msgWithErrorCode + "]"); // Session is sealed and committed but could not be verified, we need to destroy it. destroyInternal(); if (isMultiPackage()) { for (PackageInstallerSession childSession : getChildSessions()) { childSession.destroyInternal(); } } if (isStaged()) { mStagedSession.setSessionFailed( SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, msgWithErrorCode); Loading
services/tests/PackageManagerServiceTests/host/AndroidTest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,13 @@ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="run-command" value="pm uninstall com.android.cts.install.lib.testapp.A" /> <option name="teardown-command" value="pm uninstall com.android.cts.install.lib.testapp.A" /> </target_preparer> <test class="com.android.tradefed.testtype.HostTest"> <option name="jar" value="PackageManagerServiceHostTests.jar" /> </test> Loading
services/tests/PackageManagerServiceTests/host/src/com/android/server/pm/test/PackageInstallerSessionTest.kt 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * 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 com.android.server.pm.test import com.android.tradefed.testtype.DeviceJUnit4ClassRunner import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test import com.google.common.truth.Truth import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder import org.junit.runner.RunWith import kotlin.jvm.JvmField @RunWith(DeviceJUnit4ClassRunner::class) class PackageInstallerSessionTest : BaseHostJUnit4Test() { companion object { private const val DEVICE_SIDE = "PackageManagerServiceDeviceSideTests.apk" } @Rule @JvmField val tempFolder = TemporaryFolder() @Test fun verify_parentSessionFail_childSessionFiles_shouldBeDestroyed() { runDeviceTest("com.android.server.pm.PackageInstallerSessionTest", "verify_parentSessionFail_childSessionFiles_shouldBeDestroyed") } /** * Run a device side test from com.android.server.pm.test.deviceside.DeviceSide * * @param method the method to run */ fun runDeviceTest(testClassName: String, method: String) { val deviceSideFile = HostUtils.copyResourceToHostFile(DEVICE_SIDE, tempFolder.newFile()) Truth.assertThat(device.installPackage(deviceSideFile, true)).isNull() runDeviceTests(device, "com.android.server.pm.test.deviceside", testClassName, method) } }
services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ android_test_helper_app { ], static_libs: [ "androidx.annotation_annotation", "commands-helper", "cts-install-lib", "junit", "junit-params", "androidx.test.ext.junit", Loading
services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package="com.android.server.pm.test.deviceside"> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <uses-permission android:name="android.permission.INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.DELETE_PACKAGES" /> <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" Loading