diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-02-17 15:08:42 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-02-17 15:08:42 +0000 |
commit | 4e294dfa74013361e7e8a348ac09553e9967fa1d (patch) | |
tree | 14460952c3d26849ded242b3d8e1a02ecdef4797 | |
parent | 6bc18b46d1fe1574db3c46b9128ade1aa7977247 (diff) | |
parent | de6a141a1a4cc8dcd8e7c93210c8a673ba43284a (diff) | |
download | base-4e294dfa74013361e7e8a348ac09553e9967fa1d.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/21342999', 'googleplex-android-review.googlesource.com/21407859'] into tm-qpr2-b-release.
Change-Id: Ice2fe845156bc397754363cbc8ad108868c350ef
4 files changed, 131 insertions, 18 deletions
diff --git a/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl b/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl index 9c2aa6699334..a36ccf6150ba 100644 --- a/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl +++ b/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl @@ -39,5 +39,15 @@ oneway interface IUdfpsHbmListener { * {@link android.view.Display#getDisplayId()}. */ void onHbmDisabled(int displayId); + + /** + * To avoid delay in switching refresh rate when activating LHBM, allow screens to request + * higher refersh rate if auth is possible on particular screen + * + * @param displayId The displayId for which the refresh rate should be unset. See + * {@link android.view.Display#getDisplayId()}. + * @param isPossible If authentication is possible on particualr screen + */ + void onAuthenticationPossible(int displayId, boolean isPossible); } diff --git a/services/core/java/com/android/server/display/DisplayModeDirector.java b/services/core/java/com/android/server/display/DisplayModeDirector.java index aafba5a2a1b4..71ccfed0d891 100644 --- a/services/core/java/com/android/server/display/DisplayModeDirector.java +++ b/services/core/java/com/android/server/display/DisplayModeDirector.java @@ -561,7 +561,7 @@ public class DisplayModeDirector { /** * Sets the display mode switching type. - * @param newType + * @param newType new mode switching type */ public void setModeSwitchingType(@DisplayManager.SwitchingType int newType) { synchronized (mLock) { @@ -678,6 +678,18 @@ public class DisplayModeDirector { notifyDesiredDisplayModeSpecsChangedLocked(); } + @GuardedBy("mLock") + private float getMaxRefreshRateLocked(int displayId) { + Display.Mode[] modes = mSupportedModesByDisplay.get(displayId); + float maxRefreshRate = 0f; + for (Display.Mode mode : modes) { + if (mode.getRefreshRate() > maxRefreshRate) { + maxRefreshRate = mode.getRefreshRate(); + } + } + return maxRefreshRate; + } + private void notifyDesiredDisplayModeSpecsChangedLocked() { if (mDesiredDisplayModeSpecsListener != null && !mHandler.hasMessages(MSG_REFRESH_RATE_RANGE_CHANGED)) { @@ -996,25 +1008,29 @@ public class DisplayModeDirector { // of low priority voters. It votes [0, max(PEAK, MIN)] public static final int PRIORITY_USER_SETTING_PEAK_REFRESH_RATE = 7; + // To avoid delay in switching between 60HZ -> 90HZ when activating LHBM, set refresh + // rate to max value (same as for PRIORITY_UDFPS) on lock screen + public static final int PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE = 8; + // LOW_POWER_MODE force display to [0, 60HZ] if Settings.Global.LOW_POWER_MODE is on. - public static final int PRIORITY_LOW_POWER_MODE = 8; + public static final int PRIORITY_LOW_POWER_MODE = 9; // PRIORITY_FLICKER_REFRESH_RATE_SWITCH votes for disabling refresh rate switching. If the // higher priority voters' result is a range, it will fix the rate to a single choice. // It's used to avoid refresh rate switches in certain conditions which may result in the // user seeing the display flickering when the switches occur. - public static final int PRIORITY_FLICKER_REFRESH_RATE_SWITCH = 9; + public static final int PRIORITY_FLICKER_REFRESH_RATE_SWITCH = 10; // Force display to [0, 60HZ] if skin temperature is at or above CRITICAL. - public static final int PRIORITY_SKIN_TEMPERATURE = 10; + public static final int PRIORITY_SKIN_TEMPERATURE = 11; // The proximity sensor needs the refresh rate to be locked in order to function, so this is // set to a high priority. - public static final int PRIORITY_PROXIMITY = 11; + public static final int PRIORITY_PROXIMITY = 12; // The Under-Display Fingerprint Sensor (UDFPS) needs the refresh rate to be locked in order // to function, so this needs to be the highest priority of all votes. - public static final int PRIORITY_UDFPS = 12; + public static final int PRIORITY_UDFPS = 13; // Whenever a new priority is added, remember to update MIN_PRIORITY, MAX_PRIORITY, and // APP_REQUEST_REFRESH_RATE_RANGE_PRIORITY_CUTOFF, as well as priorityToString. @@ -1117,6 +1133,8 @@ public class DisplayModeDirector { return "PRIORITY_USER_SETTING_MIN_REFRESH_RATE"; case PRIORITY_USER_SETTING_PEAK_REFRESH_RATE: return "PRIORITY_USER_SETTING_PEAK_REFRESH_RATE"; + case PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE: + return "PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE"; default: return Integer.toString(priority); } @@ -2264,6 +2282,7 @@ public class DisplayModeDirector { private class UdfpsObserver extends IUdfpsHbmListener.Stub { private final SparseBooleanArray mLocalHbmEnabled = new SparseBooleanArray(); + private final SparseBooleanArray mAuthenticationPossible = new SparseBooleanArray(); public void observe() { StatusBarManagerInternal statusBar = @@ -2289,25 +2308,28 @@ public class DisplayModeDirector { private void updateHbmStateLocked(int displayId, boolean enabled) { mLocalHbmEnabled.put(displayId, enabled); - updateVoteLocked(displayId); + updateVoteLocked(displayId, enabled, Vote.PRIORITY_UDFPS); + } + + @Override + public void onAuthenticationPossible(int displayId, boolean isPossible) { + synchronized (mLock) { + mAuthenticationPossible.put(displayId, isPossible); + updateVoteLocked(displayId, isPossible, + Vote.PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE); + } } - private void updateVoteLocked(int displayId) { + @GuardedBy("mLock") + private void updateVoteLocked(int displayId, boolean enabled, int votePriority) { final Vote vote; - if (mLocalHbmEnabled.get(displayId)) { - Display.Mode[] modes = mSupportedModesByDisplay.get(displayId); - float maxRefreshRate = 0f; - for (Display.Mode mode : modes) { - if (mode.getRefreshRate() > maxRefreshRate) { - maxRefreshRate = mode.getRefreshRate(); - } - } + if (enabled) { + float maxRefreshRate = DisplayModeDirector.this.getMaxRefreshRateLocked(displayId); vote = Vote.forRefreshRates(maxRefreshRate, maxRefreshRate); } else { vote = null; } - - DisplayModeDirector.this.updateVoteLocked(displayId, Vote.PRIORITY_UDFPS, vote); + DisplayModeDirector.this.updateVoteLocked(displayId, votePriority, vote); } void dumpLocked(PrintWriter pw) { @@ -2318,6 +2340,13 @@ public class DisplayModeDirector { final String enabled = mLocalHbmEnabled.valueAt(i) ? "enabled" : "disabled"; pw.println(" Display " + displayId + ": " + enabled); } + pw.println(" mAuthenticationPossible: "); + for (int i = 0; i < mAuthenticationPossible.size(); i++) { + final int displayId = mAuthenticationPossible.keyAt(i); + final String isPossible = mAuthenticationPossible.valueAt(i) ? "possible" + : "impossible"; + pw.println(" Display " + displayId + ": " + isPossible); + } } } diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index a49577b21957..1aeb0ca6f8ae 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -2816,6 +2816,12 @@ bool IncrementalService::DataLoaderStub::fsmStep() { binder::Status IncrementalService::DataLoaderStub::onStatusChanged(MountId mountId, int newStatus) { if (!isValid()) { + if (newStatus == IDataLoaderStatusListener::DATA_LOADER_BOUND) { + // Async "bound" came to already destroyed stub. + // Unbind immediately to avoid invalid stub sitting around in DataLoaderManagerService. + mService.mDataLoaderManager->unbindFromDataLoader(mountId); + return binder::Status::ok(); + } return binder::Status:: fromServiceSpecificError(-EINVAL, "onStatusChange came to invalid DataLoaderStub"); } diff --git a/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java b/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java index b133a2a44fcf..b658b0726387 100644 --- a/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java +++ b/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java @@ -1997,6 +1997,74 @@ public class DisplayModeDirectorTest { eq(lightSensorTwo), anyInt(), any(Handler.class)); } + @Test + public void testAuthenticationPossibleSetsPhysicalRateRangesToMax() throws RemoteException { + DisplayModeDirector director = + createDirectorFromRefreshRateArray(new float[]{60.0f, 90.0f}, 0); + // don't call director.start(createMockSensorManager()); + // DisplayObserver will reset mSupportedModesByDisplay + director.onBootCompleted(); + ArgumentCaptor<IUdfpsHbmListener> captor = + ArgumentCaptor.forClass(IUdfpsHbmListener.class); + verify(mStatusBarMock).setUdfpsHbmListener(captor.capture()); + + captor.getValue().onAuthenticationPossible(DISPLAY_ID, true); + + Vote vote = director.getVote(DISPLAY_ID, Vote.PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE); + assertThat(vote.refreshRateRange.min).isWithin(FLOAT_TOLERANCE).of(90); + assertThat(vote.refreshRateRange.max).isWithin(FLOAT_TOLERANCE).of(90); + } + + @Test + public void testAuthenticationPossibleUnsetsVote() throws RemoteException { + DisplayModeDirector director = + createDirectorFromRefreshRateArray(new float[]{60.0f, 90.0f}, 0); + director.start(createMockSensorManager()); + director.onBootCompleted(); + ArgumentCaptor<IUdfpsHbmListener> captor = + ArgumentCaptor.forClass(IUdfpsHbmListener.class); + verify(mStatusBarMock).setUdfpsHbmListener(captor.capture()); + captor.getValue().onAuthenticationPossible(DISPLAY_ID, true); + captor.getValue().onAuthenticationPossible(DISPLAY_ID, false); + + Vote vote = director.getVote(DISPLAY_ID, Vote.PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE); + assertNull(vote); + } + + @Test + public void testUdfpsRequestSetsPhysicalRateRangesToMax() throws RemoteException { + DisplayModeDirector director = + createDirectorFromRefreshRateArray(new float[]{60.0f, 90.0f}, 0); + // don't call director.start(createMockSensorManager()); + // DisplayObserver will reset mSupportedModesByDisplay + director.onBootCompleted(); + ArgumentCaptor<IUdfpsHbmListener> captor = + ArgumentCaptor.forClass(IUdfpsHbmListener.class); + verify(mStatusBarMock).setUdfpsHbmListener(captor.capture()); + + captor.getValue().onHbmEnabled(DISPLAY_ID); + + Vote vote = director.getVote(DISPLAY_ID, Vote.PRIORITY_UDFPS); + assertThat(vote.refreshRateRange.min).isWithin(FLOAT_TOLERANCE).of(90); + assertThat(vote.refreshRateRange.max).isWithin(FLOAT_TOLERANCE).of(90); + } + + @Test + public void testUdfpsRequestUnsetsUnsetsVote() throws RemoteException { + DisplayModeDirector director = + createDirectorFromRefreshRateArray(new float[]{60.0f, 90.0f}, 0); + director.start(createMockSensorManager()); + director.onBootCompleted(); + ArgumentCaptor<IUdfpsHbmListener> captor = + ArgumentCaptor.forClass(IUdfpsHbmListener.class); + verify(mStatusBarMock).setUdfpsHbmListener(captor.capture()); + captor.getValue().onHbmEnabled(DISPLAY_ID); + captor.getValue().onHbmEnabled(DISPLAY_ID); + + Vote vote = director.getVote(DISPLAY_ID, Vote.PRIORITY_UDFPS); + assertNull(vote); + } + private Temperature getSkinTemp(@Temperature.ThrottlingStatus int status) { return new Temperature(30.0f, Temperature.TYPE_SKIN, "test_skin_temp", status); } |