Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d9ea3f2 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #17829949: Don't kill Bluetooth service...

...even in extreme low memory condition

Bind to Bluetooth with BIND_IMPORTANT, so that it is allowed to
go to a higher oom adj level.

Fix some problems when this is done from a system or persistent
process, where this would go to a level that is *too* high.  Instead,
introduce a new oom adj level for it that is right below persistent.

Change-Id: I002bcc4accc36c8579c4cda161be7d2fba21ba17
parent 645b737c
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -663,7 +663,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                            mHandler.sendMessageDelayed(timeoutMsg,TIMEOUT_BIND_MS);
                            Intent i = new Intent(IBluetooth.class.getName());
                            if (!doBind(i, mConnection,
                                    Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) {
                                    Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT,
                                    UserHandle.CURRENT)) {
                                mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);
                            } else {
                                mBinding = true;
@@ -1050,7 +1051,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                mHandler.sendMessageDelayed(timeoutMsg,TIMEOUT_BIND_MS);
                mConnection.setGetNameAddressOnly(false);
                Intent i = new Intent(IBluetooth.class.getName());
                if (!doBind(i, mConnection,Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) {
                if (!doBind(i, mConnection,Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT,
                        UserHandle.CURRENT)) {
                    mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);
                } else {
                    mBinding = true;
@@ -1153,7 +1155,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                    if (mContext.getPackageManager().hasSystemFeature(
                                                     PackageManager.FEATURE_BLUETOOTH_LE)) {
                        Intent i = new Intent(IBluetoothGatt.class.getName());
                        doBind(i, mConnection, Context.BIND_AUTO_CREATE, UserHandle.CURRENT);
                        doBind(i, mConnection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT,
                                UserHandle.CURRENT);
                    }
                } else {
                    //If Bluetooth is off, send service down event to proxy objects, and unbind