summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-10-08 02:30:14 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2024-10-08 02:30:14 +0000
commit6dd390c5de563bf4b587a992a03cd67558106540 (patch)
treea0a7622aa1b98a12cbbc16be5f8a35a4332f0901
parentdaecc8f71652b1be5018c1643d9fea46727e8a5d (diff)
parentbc43c77efa1a0c229e7df07ed433c8137a94279d (diff)
Merge "Handle apexd failures" into main am: a401c5ddd6 am: bc43c77efa
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3292671 Change-Id: I39c119e9cae441bc3993f0bdd00f037d1a6cac15 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/core/java/com/android/server/pm/ApexManager.java14
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java15
2 files changed, 17 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java
index 5d71439e8f46..458b46dab54c 100644
--- a/services/core/java/com/android/server/pm/ApexManager.java
+++ b/services/core/java/com/android/server/pm/ApexManager.java
@@ -592,7 +592,7 @@ public abstract class ApexManager {
return apexSessionInfo;
} catch (RemoteException re) {
Slog.e(TAG, "Unable to contact apexservice", re);
- throw new RuntimeException(re);
+ return null;
}
}
@@ -607,7 +607,7 @@ public abstract class ApexManager {
return result;
} catch (RemoteException re) {
Slog.e(TAG, "Unable to contact apexservice", re);
- throw new RuntimeException(re);
+ return new SparseArray<>(0);
}
}
@@ -619,7 +619,9 @@ public abstract class ApexManager {
return apexInfoList;
} catch (RemoteException re) {
Slog.e(TAG, "Unable to contact apexservice", re);
- throw new RuntimeException(re);
+ throw new PackageManagerException(
+ PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE,
+ "apexd verification failed : " + re.getMessage());
} catch (Exception e) {
throw new PackageManagerException(
PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE,
@@ -633,7 +635,7 @@ public abstract class ApexManager {
return waitForApexService().getStagedApexInfos(params);
} catch (RemoteException re) {
Slog.w(TAG, "Unable to contact apexservice" + re.getMessage());
- throw new RuntimeException(re);
+ return new ApexInfo[0];
} catch (Exception e) {
Slog.w(TAG, "Failed to collect staged apex infos" + e.getMessage());
return new ApexInfo[0];
@@ -646,7 +648,9 @@ public abstract class ApexManager {
waitForApexService().markStagedSessionReady(sessionId);
} catch (RemoteException re) {
Slog.e(TAG, "Unable to contact apexservice", re);
- throw new RuntimeException(re);
+ throw new PackageManagerException(
+ PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE,
+ "Failed to mark apexd session as ready : " + re.getMessage());
} catch (Exception e) {
throw new PackageManagerException(
PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE,
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java
index d08cdc718a82..769f071e3ddc 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java
@@ -265,19 +265,19 @@ public class ApexManagerTest {
}
@Test
- public void testSubmitStagedSession_throwRunTimeException() throws RemoteException {
+ public void testSubmitStagedSession_throwPackageManagerExceptionOnRemoteException()
+ throws RemoteException {
doThrow(RemoteException.class).when(mApexService).submitStagedSession(any(), any());
- assertThrows(RuntimeException.class,
+ assertThrows(PackageManagerException.class,
() -> mApexManager.submitStagedSession(testParamsWithChildren()));
}
@Test
- public void testGetStagedApexInfos_throwRunTimeException() throws RemoteException {
+ public void testGetStagedApexInfos_returnsEmptyOnRemoteException() throws RemoteException {
doThrow(RemoteException.class).when(mApexService).getStagedApexInfos(any());
- assertThrows(RuntimeException.class,
- () -> mApexManager.getStagedApexInfos(testParamsWithChildren()));
+ assertThat(mApexManager.getStagedApexInfos(testParamsWithChildren())).hasLength(0);
}
@Test
@@ -298,10 +298,11 @@ public class ApexManagerTest {
}
@Test
- public void testMarkStagedSessionReady_throwRunTimeException() throws RemoteException {
+ public void testMarkStagedSessionReady_throwPackageManagerExceptionOnRemoteException()
+ throws RemoteException {
doThrow(RemoteException.class).when(mApexService).markStagedSessionReady(anyInt());
- assertThrows(RuntimeException.class,
+ assertThrows(PackageManagerException.class,
() -> mApexManager.markStagedSessionReady(TEST_SESSION_ID));
}