Loading services/core/java/com/android/server/BluetoothManagerService.java +27 −21 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private static final int TIMEOUT_BIND_MS = 3000; //Maximum msec to wait for a bind //Maximum msec to wait for service restart private static final int SERVICE_RESTART_TIME_MS = 200; private static final int SERVICE_RESTART_TIME_MS = 400; //Maximum msec to wait for restart due to error private static final int ERROR_RESTART_TIME_MS = 3000; //Maximum msec to delay MESSAGE_USER_SWITCHED Loading Loading @@ -1635,13 +1635,13 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // ActivityManager detects it. // The waiting for (b) and (c) is accomplished by // delaying the MESSAGE_RESTART_BLUETOOTH_SERVICE // message. On slower devices, that delay needs to be // on the order of (2 * SERVICE_RESTART_TIME_MS). // message. The delay time is backed off if Bluetooth // continuously failed to turn on itself. // waitForOnOff(false, true); Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, 2 * SERVICE_RESTART_TIME_MS); mHandler.sendMessageDelayed(restartMsg, getServiceRestartMs()); } break; Loading Loading @@ -1820,7 +1820,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { waitForOnOff(false, true); Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, 2 * SERVICE_RESTART_TIME_MS); mHandler.sendMessageDelayed(restartMsg, getServiceRestartMs()); } } if (newState == BluetoothAdapter.STATE_ON Loading Loading @@ -1863,7 +1863,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // Send a Bluetooth Restart message Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, SERVICE_RESTART_TIME_MS); mHandler.sendMessageDelayed(restartMsg, getServiceRestartMs()); } sendBluetoothServiceDownCallback(); Loading @@ -1886,7 +1886,10 @@ class BluetoothManagerService extends IBluetoothManager.Stub { break; } case MESSAGE_RESTART_BLUETOOTH_SERVICE: { Slog.d(TAG, "MESSAGE_RESTART_BLUETOOTH_SERVICE"); mErrorRecoveryRetryCounter++; Slog.d(TAG, "MESSAGE_RESTART_BLUETOOTH_SERVICE: retry count=" + mErrorRecoveryRetryCounter); if (mErrorRecoveryRetryCounter < MAX_ERROR_RESTART_RETRIES) { /* Enable without persisting the setting as it doesnt change when IBluetooth service restarts */ Loading @@ -1894,6 +1897,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { addActiveLog(BluetoothProtoEnums.ENABLE_DISABLE_REASON_RESTARTED, mContext.getPackageName(), true); handleEnable(mQuietEnable); } else { Slog.e(TAG, "Reach maximum retry to restart Bluetooth!"); } break; } case MESSAGE_TIMEOUT_BIND: { Loading Loading @@ -2332,13 +2338,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mEnable = false; if (mErrorRecoveryRetryCounter++ < MAX_ERROR_RESTART_RETRIES) { // Send a Bluetooth Restart message to reenable bluetooth Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, ERROR_RESTART_TIME_MS); } else { // todo: notify user to power down and power up phone to make bluetooth work. } } private boolean isBluetoothDisallowed() { Loading Loading @@ -2374,6 +2376,10 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } } private int getServiceRestartMs() { return (mErrorRecoveryRetryCounter + 1) * SERVICE_RESTART_TIME_MS; } @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, writer)) { Loading Loading
services/core/java/com/android/server/BluetoothManagerService.java +27 −21 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private static final int TIMEOUT_BIND_MS = 3000; //Maximum msec to wait for a bind //Maximum msec to wait for service restart private static final int SERVICE_RESTART_TIME_MS = 200; private static final int SERVICE_RESTART_TIME_MS = 400; //Maximum msec to wait for restart due to error private static final int ERROR_RESTART_TIME_MS = 3000; //Maximum msec to delay MESSAGE_USER_SWITCHED Loading Loading @@ -1635,13 +1635,13 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // ActivityManager detects it. // The waiting for (b) and (c) is accomplished by // delaying the MESSAGE_RESTART_BLUETOOTH_SERVICE // message. On slower devices, that delay needs to be // on the order of (2 * SERVICE_RESTART_TIME_MS). // message. The delay time is backed off if Bluetooth // continuously failed to turn on itself. // waitForOnOff(false, true); Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, 2 * SERVICE_RESTART_TIME_MS); mHandler.sendMessageDelayed(restartMsg, getServiceRestartMs()); } break; Loading Loading @@ -1820,7 +1820,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { waitForOnOff(false, true); Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, 2 * SERVICE_RESTART_TIME_MS); mHandler.sendMessageDelayed(restartMsg, getServiceRestartMs()); } } if (newState == BluetoothAdapter.STATE_ON Loading Loading @@ -1863,7 +1863,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // Send a Bluetooth Restart message Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, SERVICE_RESTART_TIME_MS); mHandler.sendMessageDelayed(restartMsg, getServiceRestartMs()); } sendBluetoothServiceDownCallback(); Loading @@ -1886,7 +1886,10 @@ class BluetoothManagerService extends IBluetoothManager.Stub { break; } case MESSAGE_RESTART_BLUETOOTH_SERVICE: { Slog.d(TAG, "MESSAGE_RESTART_BLUETOOTH_SERVICE"); mErrorRecoveryRetryCounter++; Slog.d(TAG, "MESSAGE_RESTART_BLUETOOTH_SERVICE: retry count=" + mErrorRecoveryRetryCounter); if (mErrorRecoveryRetryCounter < MAX_ERROR_RESTART_RETRIES) { /* Enable without persisting the setting as it doesnt change when IBluetooth service restarts */ Loading @@ -1894,6 +1897,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { addActiveLog(BluetoothProtoEnums.ENABLE_DISABLE_REASON_RESTARTED, mContext.getPackageName(), true); handleEnable(mQuietEnable); } else { Slog.e(TAG, "Reach maximum retry to restart Bluetooth!"); } break; } case MESSAGE_TIMEOUT_BIND: { Loading Loading @@ -2332,13 +2338,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mEnable = false; if (mErrorRecoveryRetryCounter++ < MAX_ERROR_RESTART_RETRIES) { // Send a Bluetooth Restart message to reenable bluetooth Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE); mHandler.sendMessageDelayed(restartMsg, ERROR_RESTART_TIME_MS); } else { // todo: notify user to power down and power up phone to make bluetooth work. } } private boolean isBluetoothDisallowed() { Loading Loading @@ -2374,6 +2376,10 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } } private int getServiceRestartMs() { return (mErrorRecoveryRetryCounter + 1) * SERVICE_RESTART_TIME_MS; } @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, writer)) { Loading