Do not use stableDisplaySize for scale factor

The stableDisplaySize doesn't account for different
displays, and only returns the stable display size of one of the
displays. Instead of using stableDisplaySize, use the
maxResolutionDisplayMode for the current display to determine
whether the resolution of the device changed.

Test: manually check that lock icon is an expected size
on a device with multiple displays
Test: UDFPS is the correct size at different display resolutions
Fixes: 246631157

Change-Id: Iea933733f00ac7b8446ce6fc5825475e4b490655
This commit is contained in:
Beverly
2022-09-19 14:23:44 +00:00
parent 88deb41710
commit 54a7b623b1

View File

@@ -56,6 +56,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.UserManager;
import android.util.DisplayUtils;
import android.util.Log;
import android.util.RotationUtils;
import android.util.SparseBooleanArray;
@@ -118,8 +119,6 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
private final Provider<UdfpsController> mUdfpsControllerFactory;
private final Provider<SidefpsController> mSidefpsControllerFactory;
@NonNull private Point mStableDisplaySize = new Point();
private final Display mDisplay;
private float mScaleFactor = 1f;
// sensor locations without any resolution scaling nor rotation adjustments:
@@ -509,10 +508,11 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
*/
private void updateSensorLocations() {
mDisplay.getDisplayInfo(mCachedDisplayInfo);
final Display.Mode maxDisplayMode =
DisplayUtils.getMaximumResolutionDisplayMode(mCachedDisplayInfo.supportedModes);
final float scaleFactor = android.util.DisplayUtils.getPhysicalPixelDisplaySizeRatio(
mStableDisplaySize.x, mStableDisplaySize.y, mCachedDisplayInfo.getNaturalWidth(),
mCachedDisplayInfo.getNaturalHeight());
maxDisplayMode.getPhysicalWidth(), maxDisplayMode.getPhysicalHeight(),
mCachedDisplayInfo.getNaturalWidth(), mCachedDisplayInfo.getNaturalHeight());
if (scaleFactor == Float.POSITIVE_INFINITY) {
mScaleFactor = 1f;
} else {
@@ -769,7 +769,6 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
mFingerprintAuthenticatorsRegisteredCallback);
}
mStableDisplaySize = mDisplayManager.getStableDisplaySize();
mActivityTaskManager.registerTaskStackListener(mTaskStackListener);
mOrientationListener.enable();
updateSensorLocations();
@@ -1149,7 +1148,6 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
@Override
public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
final AuthDialog dialog = mCurrentDialog;
pw.println(" stableDisplaySize=" + mStableDisplaySize);
pw.println(" mCachedDisplayInfo=" + mCachedDisplayInfo);
pw.println(" mScaleFactor=" + mScaleFactor);
pw.println(" faceAuthSensorLocationDefault=" + mFaceSensorLocationDefault);