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

Commit 1221b062 authored by Adrian Roos's avatar Adrian Roos
Browse files

Properly unregister TrustAgentWrapper's broadcast receiver

Bug: 19820505
Change-Id: I6f9463a54aa1c33d485b8f55c5f22f18535b0d29
parent 5093cd36
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -272,13 +272,14 @@ public class TrustAgentWrapper {
        alarmFilter.addDataScheme(mAlarmIntent.getScheme());
        final String pathUri = mAlarmIntent.toUri(Intent.URI_INTENT_SCHEME);
        alarmFilter.addDataPath(pathUri, PatternMatcher.PATTERN_LITERAL);
        mContext.registerReceiver(mBroadcastReceiver, alarmFilter, PERMISSION, null);

        // Schedules a restart for when connecting times out. If the connection succeeds,
        // the restart is canceled in mCallback's onConnected.
        scheduleRestart();
        mBound = context.bindServiceAsUser(intent, mConnection, Context.BIND_AUTO_CREATE, user);
        if (!mBound) {
        if (mBound) {
            mContext.registerReceiver(mBroadcastReceiver, alarmFilter, PERMISSION, null);
        } else {
            Log.e(TAG, "Can't bind to TrustAgent " + mName.flattenToShortString());
        }
    }
@@ -398,7 +399,6 @@ public class TrustAgentWrapper {
    }

    public void destroy() {
        mContext.unregisterReceiver(mBroadcastReceiver);
        mHandler.removeMessages(MSG_RESTART_TIMEOUT);

        if (!mBound) {
@@ -408,6 +408,7 @@ public class TrustAgentWrapper {
        mTrustManagerService.mArchive.logAgentStopped(mUserId, mName);
        mContext.unbindService(mConnection);
        mBound = false;
        mContext.unregisterReceiver(mBroadcastReceiver);
        mTrustAgentService = null;
        mSetTrustAgentFeaturesToken = null;
        mHandler.sendEmptyMessage(MSG_REVOKE_TRUST);