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

Commit 23dcdcef authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use connected boolean as NLS does vs IBinder" into qt-dev

parents cc0d8f39 b1f5aafc
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ public abstract class ConditionProviderService extends Service {


    private Provider mProvider;
    private Provider mProvider;
    private INotificationManager mNoMan;
    private INotificationManager mNoMan;
    boolean mIsConnected;


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


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


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