diff options
| author | 2019-04-11 15:53:52 +0000 | |
|---|---|---|
| committer | 2019-04-11 15:53:52 +0000 | |
| commit | 1c891d6772a995211e2ee6dbd40aa9c48823dce7 (patch) | |
| tree | 20a33b07cb7f8affaf95fd9853a6c30012a99834 | |
| parent | 43e9ec2354f33b3e023329ff3b28cb9f076f539c (diff) | |
| parent | 7565fcc71bf41c6cff52e6635e329521a1e0b47e (diff) | |
Merge "Retry getting DynamicSystem service" into qt-dev
| -rw-r--r-- | services/core/java/com/android/server/DynamicSystemService.java | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/DynamicSystemService.java b/services/core/java/com/android/server/DynamicSystemService.java index 99bbcf890a0a..f1882c5f641e 100644 --- a/services/core/java/com/android/server/DynamicSystemService.java +++ b/services/core/java/com/android/server/DynamicSystemService.java @@ -47,7 +47,7 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements private static IGsiService connect(DeathRecipient recipient) throws RemoteException { IBinder binder = ServiceManager.getService("gsiservice"); if (binder == null) { - throw new RemoteException(NO_SERVICE_ERROR); + return null; } /** * The init will restart gsiservice if it crashed and the proxy object will need to be @@ -68,26 +68,31 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements private IGsiService getGsiService() throws RemoteException { checkPermission(); + if (!"running".equals(SystemProperties.get("init.svc.gsid"))) { SystemProperties.set("ctl.start", "gsid"); - for (int sleepMs = 64; sleepMs <= (GSID_ROUGH_TIMEOUT_MS << 1); sleepMs <<= 1) { - try { - Thread.sleep(sleepMs); - } catch (InterruptedException e) { - Slog.e(TAG, "Interrupted when waiting for GSID"); - break; + } + + for (int sleepMs = 64; sleepMs <= (GSID_ROUGH_TIMEOUT_MS << 1); sleepMs <<= 1) { + synchronized (this) { + if (mGsiService == null) { + mGsiService = connect(this); } - if ("running".equals(SystemProperties.get("init.svc.gsid"))) { - break; + if (mGsiService != null) { + return mGsiService; } } - } - synchronized (this) { - if (mGsiService == null) { - mGsiService = connect(this); + + try { + Slog.d(TAG, "GsiService is not ready, wait for " + sleepMs + "ms"); + Thread.sleep(sleepMs); + } catch (InterruptedException e) { + Slog.e(TAG, "Interrupted when waiting for GSID"); + return null; } - return mGsiService; } + + throw new RemoteException(NO_SERVICE_ERROR); } private void checkPermission() { |