Loading services/core/java/com/android/server/BatteryService.java +15 −21 Original line number Original line Diff line number Diff line Loading @@ -253,39 +253,33 @@ public final class BatteryService extends SystemService { mHealthServiceWrapper.init(mHealthHalCallback, mHealthServiceWrapper.init(mHealthHalCallback, new HealthServiceWrapper.IServiceManagerSupplier() {}, new HealthServiceWrapper.IServiceManagerSupplier() {}, new HealthServiceWrapper.IHealthSupplier() {}); new HealthServiceWrapper.IHealthSupplier() {}); } catch (RemoteException | NoSuchElementException ex) { } catch (RemoteException ex) { Slog.w(TAG, "health: cannot register callback. " Slog.e(TAG, "health: cannot register callback. (RemoteException)"); + "BatteryService will be started with dummy values. Reason: " throw ex.rethrowFromSystemServer(); + ex.getClass().getSimpleName() + ": " + ex.getMessage()); } catch (NoSuchElementException ex) { update(new HealthInfo()); Slog.e(TAG, "health: cannot register callback. (no supported health HAL service)"); return; throw ex; } } // init register for new service notifications, and IServiceManager should return the // init register for new service notifications, and IServiceManager should return the // existing service in a near future. Wait for this.update() to instantiate // existing service in a near future. Wait for this.update() to instantiate // the initial mHealthInfo. // the initial mHealthInfo. long timeWaited = 0; synchronized (mLock) { long beforeWait = SystemClock.uptimeMillis(); long beforeWait = SystemClock.uptimeMillis(); while (mHealthInfo == null && synchronized (mLock) { (timeWaited = SystemClock.uptimeMillis() - beforeWait) < HEALTH_HAL_WAIT_MS) { while (mHealthInfo == null) { Slog.i(TAG, "health: Waited " + (SystemClock.uptimeMillis() - beforeWait) + "ms for callbacks. Waiting another " + HEALTH_HAL_WAIT_MS + " ms..."); try { try { mLock.wait(HEALTH_HAL_WAIT_MS - timeWaited); mLock.wait(HEALTH_HAL_WAIT_MS); } catch (InterruptedException ex) { } catch (InterruptedException ex) { break; Slog.i(TAG, "health: InterruptedException when waiting for update. " + " Continuing..."); } } } } if (mHealthInfo == null) { Slog.w(TAG, "health: Waited " + timeWaited + "ms for callbacks but received " + "nothing. BatteryService will be started with dummy values."); update(new HealthInfo()); return; } } } if (DEBUG) { Slog.i(TAG, "health: Waited " + (SystemClock.uptimeMillis() - beforeWait) Slog.d(TAG, "health: Waited " + timeWaited + "ms and received the update."); + "ms and received the update."); } } } private void updateBatteryWarningLevelLocked() { private void updateBatteryWarningLevelLocked() { Loading Loading
services/core/java/com/android/server/BatteryService.java +15 −21 Original line number Original line Diff line number Diff line Loading @@ -253,39 +253,33 @@ public final class BatteryService extends SystemService { mHealthServiceWrapper.init(mHealthHalCallback, mHealthServiceWrapper.init(mHealthHalCallback, new HealthServiceWrapper.IServiceManagerSupplier() {}, new HealthServiceWrapper.IServiceManagerSupplier() {}, new HealthServiceWrapper.IHealthSupplier() {}); new HealthServiceWrapper.IHealthSupplier() {}); } catch (RemoteException | NoSuchElementException ex) { } catch (RemoteException ex) { Slog.w(TAG, "health: cannot register callback. " Slog.e(TAG, "health: cannot register callback. (RemoteException)"); + "BatteryService will be started with dummy values. Reason: " throw ex.rethrowFromSystemServer(); + ex.getClass().getSimpleName() + ": " + ex.getMessage()); } catch (NoSuchElementException ex) { update(new HealthInfo()); Slog.e(TAG, "health: cannot register callback. (no supported health HAL service)"); return; throw ex; } } // init register for new service notifications, and IServiceManager should return the // init register for new service notifications, and IServiceManager should return the // existing service in a near future. Wait for this.update() to instantiate // existing service in a near future. Wait for this.update() to instantiate // the initial mHealthInfo. // the initial mHealthInfo. long timeWaited = 0; synchronized (mLock) { long beforeWait = SystemClock.uptimeMillis(); long beforeWait = SystemClock.uptimeMillis(); while (mHealthInfo == null && synchronized (mLock) { (timeWaited = SystemClock.uptimeMillis() - beforeWait) < HEALTH_HAL_WAIT_MS) { while (mHealthInfo == null) { Slog.i(TAG, "health: Waited " + (SystemClock.uptimeMillis() - beforeWait) + "ms for callbacks. Waiting another " + HEALTH_HAL_WAIT_MS + " ms..."); try { try { mLock.wait(HEALTH_HAL_WAIT_MS - timeWaited); mLock.wait(HEALTH_HAL_WAIT_MS); } catch (InterruptedException ex) { } catch (InterruptedException ex) { break; Slog.i(TAG, "health: InterruptedException when waiting for update. " + " Continuing..."); } } } } if (mHealthInfo == null) { Slog.w(TAG, "health: Waited " + timeWaited + "ms for callbacks but received " + "nothing. BatteryService will be started with dummy values."); update(new HealthInfo()); return; } } } if (DEBUG) { Slog.i(TAG, "health: Waited " + (SystemClock.uptimeMillis() - beforeWait) Slog.d(TAG, "health: Waited " + timeWaited + "ms and received the update."); + "ms and received the update."); } } } private void updateBatteryWarningLevelLocked() { private void updateBatteryWarningLevelLocked() { Loading