Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc43c77e authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Handle apexd failures" into main am: a401c5dd

parents 1dc05580 a401c5dd
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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,
+8 −7
Original line number Diff line number Diff line
@@ -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));
    }