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

Commit b1f5aafc authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Use connected boolean as NLS does vs IBinder

To determine if the CPS can get/send messages. Apparently
the IBinder can be cached in ActivityManager and onBind() is not
always called when a service is connected the second time.

Test: manual; ensure a service recieves an onsubscribe for an
active rule post requestUnbind/requestRebind
Fixes: 62584038

Change-Id: Iffe37242509f3bf26e609e6b423f3928c00156ad
(cherry picked from commit 265d093c)
parent 1ed4ce01
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ public abstract class ConditionProviderService extends Service {

    private Provider mProvider;
    private INotificationManager mNoMan;
    boolean mIsConnected;

    /**
     * The {@link Intent} that must be declared as handled by the service.
@@ -179,7 +180,7 @@ public abstract class ConditionProviderService extends Service {
        try {
            noMan.requestUnbindProvider(mProvider);
            // Disable future messages.
            mProvider = null;
            mIsConnected = false;
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
@@ -233,16 +234,16 @@ public abstract class ConditionProviderService extends Service {
     */
    @TestApi
    public boolean isBound() {
        if (mProvider == null) {
        if (!mIsConnected) {
            Log.w(TAG, "Condition provider service not yet bound.");
            return false;
        }
        return true;
        return mIsConnected;
    }

    private final class Provider extends IConditionProvider.Stub {
        @Override
        public void onConnected() {
            mIsConnected = true;
            mHandler.obtainMessage(H.ON_CONNECTED).sendToTarget();
        }

@@ -265,7 +266,7 @@ public abstract class ConditionProviderService extends Service {
        @Override
        public void handleMessage(Message msg) {
            String name = null;
            if (!isBound()) {
            if (!mIsConnected) {
                return;
            }
            try {