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

Commit fd27baff authored by Derek Jedral's avatar Derek Jedral Committed by Beverly
Browse files

Add isActiveUnlockRunning

Add isActiveUnlockRunning and onIsActiveUnlockRunningChanged, in order to
track when active unlock is available on the device or not. Listeners
are notified if the value is true on subscription.

Test: atest, local build, verify listeners notified
Bug: b/267322286
Change-Id: Ibceac9d721190a4da3905e71d11c4424f7ee9676
Merged-In: Ibceac9d721190a4da3905e71d11c4424f7ee9676
parent c3b80dc7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,4 +29,5 @@ oneway interface ITrustListener {
        in List<String> trustGrantedMessages);
    void onTrustManagedChanged(boolean managed, int userId);
    void onTrustError(in CharSequence message);
    void onIsActiveUnlockRunningChanged(boolean isRunning, int userId);
}
+1 −0
Original line number Diff line number Diff line
@@ -40,4 +40,5 @@ interface ITrustManager {
    boolean isTrustUsuallyManaged(int userId);
    void unlockedByBiometricForUser(int userId, in BiometricSourceType source);
    void clearAllBiometricRecognized(in BiometricSourceType target, int unlockedUser);
    boolean isActiveUnlockRunning(int userId);
}
+29 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class TrustManager {
    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 int MSG_IS_ACTIVE_UNLOCK_RUNNING = 5;

    private static final String TAG = "TrustManager";
    private static final String DATA_FLAGS = "initiatedByUser";
@@ -165,6 +166,17 @@ public class TrustManager {
        }
    }

    /**
     * Returns whether active unlock can be used to unlock the device for user {@code userId}.
     */
    public boolean isActiveUnlockRunning(int userId) {
        try {
            return mService.isActiveUnlockRunning(userId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Registers a listener for trust events.
     *
@@ -206,6 +218,12 @@ public class TrustManager {
                    m.getData().putCharSequence(DATA_MESSAGE, message);
                    m.sendToTarget();
                }

                @Override
                public void onIsActiveUnlockRunningChanged(boolean isRunning, int userId) {
                    mHandler.obtainMessage(MSG_IS_ACTIVE_UNLOCK_RUNNING,
                            (isRunning ? 1 : 0), userId, trustListener).sendToTarget();
                }
            };
            mService.registerTrustListener(iTrustListener);
            mTrustListeners.put(trustListener, iTrustListener);
@@ -295,6 +313,10 @@ public class TrustManager {
                case MSG_ENABLED_TRUST_AGENTS_CHANGED:
                    ((TrustListener) msg.obj).onEnabledTrustAgentsChanged(msg.arg1);
                    break;
                case MSG_IS_ACTIVE_UNLOCK_RUNNING:
                    ((TrustListener) msg.obj)
                            .onIsActiveUnlockRunningChanged(msg.arg1 != 0, msg.arg2);
                    break;
            }
        }
    };
@@ -333,5 +355,12 @@ public class TrustManager {
         * Reports that the enabled trust agents for the specified user has changed.
         */
        void onEnabledTrustAgentsChanged(int userId);

        /**
         * Reports changes on if the device can be unlocked with active unlock.
         * @param isRunning If true, the device can be unlocked with active unlock.
         * @param userId The user, for which the state changed.
        */
        void onIsActiveUnlockRunningChanged(boolean isRunning, int userId);
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -570,6 +570,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
    }

    @Override
    public void onIsActiveUnlockRunningChanged(boolean isRunning, int userId) {
    }

    /**
     * Whether the trust granted call with its passed flags should dismiss keyguard.
     * It's assumed that the trust was granted for the current user.
+5 −0
Original line number Diff line number Diff line
@@ -95,6 +95,11 @@ constructor(
                                "onTrustManagedChanged"
                            )
                        }

                        override fun onIsActiveUnlockRunningChanged(
                            isRunning: Boolean,
                            userId: Int
                        ) = Unit
                    }
                trustManager.registerTrustListener(callback)
                logger.trustListenerRegistered()
Loading