Loading services/core/java/com/android/server/pm/ApexManager.java +9 −5 Original line number Diff line number Diff line Loading @@ -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; } } Loading @@ -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); } } Loading @@ -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, Loading @@ -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]; Loading @@ -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, Loading services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java +8 −7 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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)); } Loading Loading
services/core/java/com/android/server/pm/ApexManager.java +9 −5 Original line number Diff line number Diff line Loading @@ -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; } } Loading @@ -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); } } Loading @@ -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, Loading @@ -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]; Loading @@ -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, Loading
services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java +8 −7 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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)); } Loading