Loading services/core/java/com/android/server/pm/ApexManager.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -249,6 +249,14 @@ public abstract class ApexManager { abstract ApexInfoList submitStagedSession(ApexSessionParams params) abstract ApexInfoList submitStagedSession(ApexSessionParams params) throws PackageManagerException; throws PackageManagerException; /** * Returns {@code ApeInfo} about apex sessions that have been marked ready via * {@link #markStagedSessionReady(int)} * * Returns empty array if there is no staged apex session or if there is any error. */ abstract ApexInfo[] getStagedApexInfos(ApexSessionParams params); /** /** * Mark a staged session previously submitted using {@code submitStagedSession} as ready to be * Mark a staged session previously submitted using {@code submitStagedSession} as ready to be * applied at next reboot. * applied at next reboot. Loading Loading @@ -757,6 +765,19 @@ public abstract class ApexManager { } } } } @Override ApexInfo[] getStagedApexInfos(ApexSessionParams params) { try { return waitForApexService().getStagedApexInfos(params); } catch (RemoteException re) { Slog.w(TAG, "Unable to contact apexservice" + re.getMessage()); throw new RuntimeException(re); } catch (Exception e) { Slog.w(TAG, "Failed to collect staged apex infos" + e.getMessage()); return new ApexInfo[0]; } } @Override @Override void markStagedSessionReady(int sessionId) throws PackageManagerException { void markStagedSessionReady(int sessionId) throws PackageManagerException { try { try { Loading Loading @@ -1249,6 +1270,11 @@ public abstract class ApexManager { "Device doesn't support updating APEX"); "Device doesn't support updating APEX"); } } @Override ApexInfo[] getStagedApexInfos(ApexSessionParams params) { throw new UnsupportedOperationException(); } @Override @Override void markStagedSessionReady(int sessionId) { void markStagedSessionReady(int sessionId) { throw new UnsupportedOperationException(); throw new UnsupportedOperationException(); Loading services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageInfo; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceSpecificException; import android.platform.test.annotations.Presubmit; import android.platform.test.annotations.Presubmit; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; Loading Loading @@ -231,6 +232,21 @@ public class ApexManagerTest { () -> mApexManager.submitStagedSession(testParamsWithChildren())); () -> mApexManager.submitStagedSession(testParamsWithChildren())); } } @Test public void testGetStagedApexInfos_throwRunTimeException() throws RemoteException { doThrow(RemoteException.class).when(mApexService).getStagedApexInfos(any()); assertThrows(RuntimeException.class, () -> mApexManager.getStagedApexInfos(testParamsWithChildren())); } @Test public void testGetStagedApexInfos_returnsEmptyArrayOnError() throws RemoteException { doThrow(ServiceSpecificException.class).when(mApexService).getStagedApexInfos(any()); assertThat(mApexManager.getStagedApexInfos(testParamsWithChildren())).hasLength(0); } @Test @Test public void testMarkStagedSessionReady_throwPackageManagerException() throws RemoteException { public void testMarkStagedSessionReady_throwPackageManagerException() throws RemoteException { doAnswer(invocation -> { doAnswer(invocation -> { Loading Loading
services/core/java/com/android/server/pm/ApexManager.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -249,6 +249,14 @@ public abstract class ApexManager { abstract ApexInfoList submitStagedSession(ApexSessionParams params) abstract ApexInfoList submitStagedSession(ApexSessionParams params) throws PackageManagerException; throws PackageManagerException; /** * Returns {@code ApeInfo} about apex sessions that have been marked ready via * {@link #markStagedSessionReady(int)} * * Returns empty array if there is no staged apex session or if there is any error. */ abstract ApexInfo[] getStagedApexInfos(ApexSessionParams params); /** /** * Mark a staged session previously submitted using {@code submitStagedSession} as ready to be * Mark a staged session previously submitted using {@code submitStagedSession} as ready to be * applied at next reboot. * applied at next reboot. Loading Loading @@ -757,6 +765,19 @@ public abstract class ApexManager { } } } } @Override ApexInfo[] getStagedApexInfos(ApexSessionParams params) { try { return waitForApexService().getStagedApexInfos(params); } catch (RemoteException re) { Slog.w(TAG, "Unable to contact apexservice" + re.getMessage()); throw new RuntimeException(re); } catch (Exception e) { Slog.w(TAG, "Failed to collect staged apex infos" + e.getMessage()); return new ApexInfo[0]; } } @Override @Override void markStagedSessionReady(int sessionId) throws PackageManagerException { void markStagedSessionReady(int sessionId) throws PackageManagerException { try { try { Loading Loading @@ -1249,6 +1270,11 @@ public abstract class ApexManager { "Device doesn't support updating APEX"); "Device doesn't support updating APEX"); } } @Override ApexInfo[] getStagedApexInfos(ApexSessionParams params) { throw new UnsupportedOperationException(); } @Override @Override void markStagedSessionReady(int sessionId) { void markStagedSessionReady(int sessionId) { throw new UnsupportedOperationException(); throw new UnsupportedOperationException(); Loading
services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageInfo; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceSpecificException; import android.platform.test.annotations.Presubmit; import android.platform.test.annotations.Presubmit; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; Loading Loading @@ -231,6 +232,21 @@ public class ApexManagerTest { () -> mApexManager.submitStagedSession(testParamsWithChildren())); () -> mApexManager.submitStagedSession(testParamsWithChildren())); } } @Test public void testGetStagedApexInfos_throwRunTimeException() throws RemoteException { doThrow(RemoteException.class).when(mApexService).getStagedApexInfos(any()); assertThrows(RuntimeException.class, () -> mApexManager.getStagedApexInfos(testParamsWithChildren())); } @Test public void testGetStagedApexInfos_returnsEmptyArrayOnError() throws RemoteException { doThrow(ServiceSpecificException.class).when(mApexService).getStagedApexInfos(any()); assertThat(mApexManager.getStagedApexInfos(testParamsWithChildren())).hasLength(0); } @Test @Test public void testMarkStagedSessionReady_throwPackageManagerException() throws RemoteException { public void testMarkStagedSessionReady_throwPackageManagerException() throws RemoteException { doAnswer(invocation -> { doAnswer(invocation -> { Loading