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

Commit ef886544 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Allow custom keyguard transient message

TrustAgentServices can now present a transient
message on the lock screen or AoD.

Bug: 63940122
Test: call TrustAgentService#showKeyguardErrorMessage via service,
      lock device, wait for message to show up.
Change-Id: I222118787a1afb526ce7c90d46c41d0f20d8d912
parent 6198ec63
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3929,6 +3929,7 @@ package android.service.trust {
    method public final void removeEscrowToken(long, android.os.UserHandle);
    method public final void revokeTrust();
    method public final void setManagingTrust(boolean);
    method public final void showKeyguardErrorMessage(java.lang.CharSequence);
    method public final void unlockUserWithToken(long, byte[], android.os.UserHandle);
    field public static final int FLAG_GRANT_TRUST_DISMISS_KEYGUARD = 2; // 0x2
    field public static final int FLAG_GRANT_TRUST_INITIATED_BY_USER = 1; // 0x1
+1 −1
Original line number Diff line number Diff line
@@ -499,7 +499,7 @@ public class KeyguardManager {
                }
            });
        } catch (RemoteException e) {
            Log.i(TAG, "Failed to dismiss keyguard: " + e);
            throw e.rethrowFromSystemServer();
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -24,4 +24,5 @@ package android.app.trust;
oneway interface ITrustListener {
    void onTrustChanged(boolean enabled, int userId, int flags);
    void onTrustManagedChanged(boolean managed, int userId);
    void onTrustError(in CharSequence message);
}
 No newline at end of file
+24 −5
Original line number Diff line number Diff line
@@ -36,9 +36,11 @@ 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 String TAG = "TrustManager";
    private static final String DATA_FLAGS = "initiatedByUser";
    private static final String DATA_MESSAGE = "message";

    private final ITrustManager mService;
    private final ArrayMap<TrustListener, ITrustListener> mTrustListeners;
@@ -148,6 +150,13 @@ public class TrustManager {
                    mHandler.obtainMessage(MSG_TRUST_MANAGED_CHANGED, (managed ? 1 : 0), userId,
                            trustListener).sendToTarget();
                }

                @Override
                public void onTrustError(CharSequence message) {
                    Message m = mHandler.obtainMessage(MSG_TRUST_ERROR);
                    m.getData().putCharSequence(DATA_MESSAGE, message);
                    m.sendToTarget();
                }
            };
            mService.registerTrustListener(iTrustListener);
            mTrustListeners.put(trustListener, iTrustListener);
@@ -221,6 +230,10 @@ public class TrustManager {
                    break;
                case MSG_TRUST_MANAGED_CHANGED:
                    ((TrustListener)msg.obj).onTrustManagedChanged(msg.arg1 != 0, msg.arg2);
                    break;
                case MSG_TRUST_ERROR:
                    final CharSequence message = msg.peekData().getCharSequence(DATA_MESSAGE);
                    ((TrustListener)msg.obj).onTrustError(message);
            }
        }
    };
@@ -229,9 +242,9 @@ public class TrustManager {

        /**
         * Reports that the trust state has changed.
         * @param enabled if true, the system believes the environment to be trusted.
         * @param userId the user, for which the trust changed.
         * @param flags flags specified by the trust agent when granting trust. See
         * @param enabled If true, the system believes the environment to be trusted.
         * @param userId The user, for which the trust changed.
         * @param flags Flags specified by the trust agent when granting trust. See
         *     {@link android.service.trust.TrustAgentService#grantTrust(CharSequence, long, int)
         *                 TrustAgentService.grantTrust(CharSequence, long, int)}.
         */
@@ -239,9 +252,15 @@ public class TrustManager {

        /**
         * Reports that whether trust is managed has changed
         * @param enabled if true, at least one trust agent is managing trust.
         * @param userId the user, for which the state changed.
         * @param enabled If true, at least one trust agent is managing trust.
         * @param userId The user, for which the state changed.
         */
        void onTrustManagedChanged(boolean enabled, int userId);

        /**
         * Reports that an error happened on a TrustAgentService.
         * @param message A message that should be displayed on the UI.
         */
        void onTrustError(CharSequence message);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -32,4 +32,5 @@ oneway interface ITrustAgentServiceCallback {
    void isEscrowTokenActive(long handle, int userId);
    void removeEscrowToken(long handle, int userId);
    void unlockUserWithToken(long handle, in byte[] token, int userId);
    void showKeyguardErrorMessage(in CharSequence message);
}
Loading