Loading tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java +6 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.tests.stagedinstallinternal.host; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.android.ddmlib.Log; import com.android.tests.rollback.host.AbandonSessionsRule; Loading Loading @@ -83,7 +84,7 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { private void restartSystemServer() throws Exception { // Restart the system server long oldStartTime = getDevice().getProcessByName("system_server").getStartTime(); ProcessInfo oldPs = getDevice().getProcessByName("system_server"); getDevice().enableAdbRoot(); // Need root to restart system server assertThat(getDevice().executeShellCommand("am restart")).contains("Restart the system"); Loading @@ -91,18 +92,16 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { // Wait for new system server process to start long start = System.currentTimeMillis(); long newStartTime = oldStartTime; while (System.currentTimeMillis() < start + SYSTEM_SERVER_TIMEOUT_MS) { ProcessInfo newPs = getDevice().getProcessByName("system_server"); if (newPs != null) { newStartTime = newPs.getStartTime(); if (newStartTime != oldStartTime) { break; if (newPs.getPid() != oldPs.getPid()) { getDevice().waitForDeviceAvailable(); return; } } Thread.sleep(500); } assertThat(newStartTime).isNotEqualTo(oldStartTime); getDevice().waitForDeviceAvailable(); fail("Timed out in restarting system server"); } } Loading
tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java +6 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.tests.stagedinstallinternal.host; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.android.ddmlib.Log; import com.android.tests.rollback.host.AbandonSessionsRule; Loading Loading @@ -83,7 +84,7 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { private void restartSystemServer() throws Exception { // Restart the system server long oldStartTime = getDevice().getProcessByName("system_server").getStartTime(); ProcessInfo oldPs = getDevice().getProcessByName("system_server"); getDevice().enableAdbRoot(); // Need root to restart system server assertThat(getDevice().executeShellCommand("am restart")).contains("Restart the system"); Loading @@ -91,18 +92,16 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { // Wait for new system server process to start long start = System.currentTimeMillis(); long newStartTime = oldStartTime; while (System.currentTimeMillis() < start + SYSTEM_SERVER_TIMEOUT_MS) { ProcessInfo newPs = getDevice().getProcessByName("system_server"); if (newPs != null) { newStartTime = newPs.getStartTime(); if (newStartTime != oldStartTime) { break; if (newPs.getPid() != oldPs.getPid()) { getDevice().waitForDeviceAvailable(); return; } } Thread.sleep(500); } assertThat(newStartTime).isNotEqualTo(oldStartTime); getDevice().waitForDeviceAvailable(); fail("Timed out in restarting system server"); } }