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

Commit 0043caf5 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Properly unregister TrustAgentWrapper's broadcast receiver"

parents 92d8b334 1221b062
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);