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

Commit f04d752f authored by Xu Cao's avatar Xu Cao
Browse files

KeyguardManager#isDeviceSecure()

KeyguardManager#isDeviceSecure() shall return false when called on a virtual display

Bug: 210153811
Test: atest CtsVirtualDevicesTestCases:DefaultDisplayIsDeviceSecureTest CtsVirtualDevicesTestCases:StreamedAppBehaviorTest#isDeviceSecure_shouldReturnFalseOnVirtualDisplay

Change-Id: I5149b08fde8d3a09e484ea965035bd5e7d2bff7b
parent 5479e1e0
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2900,6 +2900,14 @@ class ContextImpl extends Context {
        }
    }

    /**
     * @hide
     */
    @Override
    public int getAssociatedDisplayId()  {
        return isAssociatedWithDisplay() ? getDisplayId() : Display.INVALID_DISPLAY;
    }

    @Override
    public Display getDisplayNoVerify() {
        if (mDisplay == null) {
+2 −2
Original line number Diff line number Diff line
@@ -591,7 +591,7 @@ public class KeyguardManager {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public boolean isDeviceLocked(int userId) {
        try {
            return mTrustManager.isDeviceLocked(userId);
            return mTrustManager.isDeviceLocked(userId, mContext.getAssociatedDisplayId());
        } catch (RemoteException e) {
            return false;
        }
@@ -617,7 +617,7 @@ public class KeyguardManager {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public boolean isDeviceSecure(int userId) {
        try {
            return mTrustManager.isDeviceSecure(userId);
            return mTrustManager.isDeviceSecure(userId, mContext.getAssociatedDisplayId());
        } catch (RemoteException e) {
            return false;
        }
+2 −2
Original line number Diff line number Diff line
@@ -33,8 +33,8 @@ interface ITrustManager {
    void unregisterTrustListener(in ITrustListener trustListener);
    void reportKeyguardShowingChanged();
    void setDeviceLockedForUser(int userId, boolean locked);
    boolean isDeviceLocked(int userId);
    boolean isDeviceSecure(int userId);
    boolean isDeviceLocked(int userId, int displayId);
    boolean isDeviceSecure(int userId, int displayId);
    boolean isTrustUsuallyManaged(int userId);
    void unlockedByBiometricForUser(int userId, in BiometricSourceType source);
    void clearAllBiometricRecognized(in BiometricSourceType target, int unlockedUser);
+12 −0
Original line number Diff line number Diff line
@@ -7074,6 +7074,18 @@ public abstract class Context {
    @TestApi
    public abstract int getDisplayId();

    /**
     * @return Returns the id of the Display object associated with this Context or
     * {@link Display#INVALID_DISPLAY} if no Display has been associated.
     * @see #getDisplay()
     * @see #getDisplayId()
     *
     * @hide
     */
    public int getAssociatedDisplayId() {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

    /**
     * @hide
     */
+4 −0
Original line number Diff line number Diff line
@@ -606,6 +606,10 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
        }
    }

    boolean isDisplayOwnedByVirtualDevice(int displayId) {
        return mVirtualDisplayIds.contains(displayId);
    }

    interface OnDeviceCloseListener {
        void onClose(int associationId);
    }
Loading