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

Commit 3580317c authored by Bryce Lee's avatar Bryce Lee
Browse files

Notify TrustListeners when enabled trust agents change.

This change adds a new callback from TrustManagerService when the
enabled trust agents change. This addition enables TrustListeners to
react when an authentication method has been enabled by the user.

Test: atest KeyguardStateControllerTest#testOnEnabledTrustAgentsChangedCallback
Test: atest KeyguardUpdateMonitorTest#testOnEnabledTrustAgentsChangedCallback
Test: atest TrustManagerServiceTest#reportEnabledTrustAgentsChangedInformsListener
Fixes: 277845892
Fixes: 279231562
Change-Id: Id6d4b65abb4de77f52f1d48499eed3ca26384663
parent 2308d69a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import java.util.List;
 * {@hide}
 */
oneway interface ITrustListener {
    void onEnabledTrustAgentsChanged(int userId);
    void onTrustChanged(boolean enabled, boolean newlyUnlocked, int userId, int flags,
        in List<String> trustGrantedMessages);
    void onTrustManagedChanged(boolean managed, int userId);
+17 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ public class TrustManager {
    private static final int MSG_TRUST_CHANGED = 1;
    private static final int MSG_TRUST_MANAGED_CHANGED = 2;
    private static final int MSG_TRUST_ERROR = 3;
    private static final int MSG_ENABLED_TRUST_AGENTS_CHANGED = 4;

    private static final String TAG = "TrustManager";
    private static final String DATA_FLAGS = "initiatedByUser";
@@ -186,6 +187,13 @@ public class TrustManager {
                    m.sendToTarget();
                }

                @Override
                public void onEnabledTrustAgentsChanged(int userId) {
                    final Message m = mHandler.obtainMessage(MSG_ENABLED_TRUST_AGENTS_CHANGED,
                            userId, 0, trustListener);
                    m.sendToTarget();
                }

                @Override
                public void onTrustManagedChanged(boolean managed, int userId) {
                    mHandler.obtainMessage(MSG_TRUST_MANAGED_CHANGED, (managed ? 1 : 0), userId,
@@ -283,6 +291,10 @@ public class TrustManager {
                case MSG_TRUST_ERROR:
                    final CharSequence message = msg.peekData().getCharSequence(DATA_MESSAGE);
                    ((TrustListener) msg.obj).onTrustError(message);
                    break;
                case MSG_ENABLED_TRUST_AGENTS_CHANGED:
                    ((TrustListener) msg.obj).onEnabledTrustAgentsChanged(msg.arg1);
                    break;
            }
        }
    };
@@ -316,5 +328,10 @@ public class TrustManager {
         * @param message A message that should be displayed on the UI.
         */
        void onTrustError(CharSequence message);

        /**
         * Reports that the enabled trust agents for the specified user has changed.
         */
        void onEnabledTrustAgentsChanged(int userId);
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -587,6 +587,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        dispatchErrorMessage(message);
    }

    @Override
    public void onEnabledTrustAgentsChanged(int userId) {
        Assert.isMainThread();

        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onEnabledTrustAgentsChanged(userId);
            }
        }
    }

    private void handleSimSubscriptionInfoChanged() {
        Assert.isMainThread();
        mLogger.v("onSubscriptionInfoChanged()");
+5 −0
Original line number Diff line number Diff line
@@ -322,4 +322,9 @@ public class KeyguardUpdateMonitorCallback {
     * Called when keyguard is going away or not going away.
     */
    public void onKeyguardGoingAway() { }

    /**
     * Called when the enabled trust agents associated with the specified user.
     */
    public void onEnabledTrustAgentsChanged(int userId) { }
}
+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ constructor(
                        override fun onTrustError(message: CharSequence?) = Unit

                        override fun onTrustManagedChanged(enabled: Boolean, userId: Int) = Unit

                        override fun onEnabledTrustAgentsChanged(userId: Int) = Unit
                    }
                trustManager.registerTrustListener(callback)
                logger.trustListenerRegistered()
Loading