Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable AOD for Asus Rog Phone (Z01QD) #42

Open
wants to merge 2 commits into
base: pie
Choose a base branch
from

Conversation

Rocky7842
Copy link

  • Enable AOD without doze display state, and adjust brightness.
  • While at it, add some overlays pulled from stock.

* Add SystemUI overlay.
* Doze display state should be supported according to stock overlay, but enabling it here broke input and caused artifacts. So disable it.
* Lower the (stock) AOD brightness.
@phhusson
Copy link

``
false
false


You're really sure? This sounds like it will eat a lot of battery

@Rocky7842
Copy link
Author

``
false
false


You're really sure? This sounds like it will eat a lot of battery

The main problem is that, if the user tries to enable the forced aod in phh settings, on this device, it'll completely break the input. For a normal user, that may result in only one solution, which is to reset the phone.
Therefore, I think it would better to give them the ability to enable it and disable it if they find the battery consumption unsuitable for their needs.

@phhusson
Copy link

"break the input"?
To clarify, how much battery life are you getting out of AOD without any other use with that overlay?
Does the CPU deep sleep?
Minimum acceptable AOD battery life is around 3 days, it shoud probably be around a week on that device

@Rocky7842
Copy link
Author

"break the input"?

The touchscreen has no response at all, even if I wake it up using power button, etc. When it wakes up, animation is lagging, brightness transition is weird, and sometimes there are also artifacts.

To clarify, how much battery life are you getting out of AOD without any other use with that overlay?
Does the CPU deep sleep?
Minimum acceptable AOD battery life is around 3 days, it shoud probably be around a week on that device

I agree the battery would be way worse than proper doze. I will put it there and see how much battery does it extactly drain.

@Rocky7842
Copy link
Author

Rocky7842 commented Jun 21, 2023

Well, it literally kills the battery. 50% loses across 8.5 hours.

@Rocky7842
Copy link
Author

Rocky7842 commented Jun 21, 2023

The touchscreen has no response at all, even if I wake it up using power button, etc. When it wakes up, animation is lagging, brightness transition is weird, and sometimes there are also artifacts.

I found that DT2W is working with doze mode aod. getevent indicate that after the device leaves aod, the panel won't send normal input event. Instead, only DT2W is working (KEY_POWER is used on this device, so double tap to sleep).
The issue, then, might be the panal cannot correctly resume from suspend.

@Rocky7842
Copy link
Author

Rocky7842 commented Jun 23, 2023

I've managed to get doze work by modifying the kernel.

The issue comes from Asus's weird implementations.

  1. They removed dsi_panel_set_nolp from dsi_display_set_power, and the resume function fts_ts_resume() is in dsi_panel_set_nolp, so it can never come back from suspend if AOD is enabled.
  2. Also, in dsi_display_set_power, they only put their "enter AOD" stuffs (including a bool g_enter_AOD for status check) in lp1, so if the system enter lp2 directly, it will never run "leave AOD" stuffs, because g_enter_AOD wasn't set to indicate the system have already executed "enter AOD" stuffs.

I have no idea how to fix this without modifying the kernel. The commits include in this PR can serve one purpose, which is prevent the phone from falling into a dead loop. However, if it's not proper to enable a half broken feature, then nvm.

@phhusson
Copy link

Well that kernel works on stock, which has proper AOD, correct?

From what I hear from what you say, we need to use ""lp1"" mode rather than ""lp2"" (ideally doing on => lp1 => lp2, but i guess just using lp1 could be enough), my guess is that this corresponds to DOZE and DOZE_SUSPEND modes.

Did you try:

    <bool name="doze_display_state_supported">true</bool>
    <bool name="doze_suspend_display_state_supported">false</bool>

? (this would go to lp1 without trying lp2, which could be good enough)

Did you try setting config_displayBlanksAfterDoze to true?

I'm not finding anything in systemui that would allow on => lp1 => lp2 => lp1 => on without a lot of changes to the code

@Rocky7842
Copy link
Author

Well that kernel works on stock, which has proper AOD, correct?

Yes.

I'm not finding anything in systemui that would allow on => lp1 => lp2 => lp1 => on without a lot of changes to the code

It need "on => lp1 => lp2", but it's ok to do "lp2 => on"

From what I hear from what you say, we need to use ""lp1"" mode rather than ""lp2"" (ideally doing on => lp1 => lp2, but i guess just using lp1 could be enough), my guess is that this corresponds to DOZE and DOZE_SUSPEND modes.

Did you try:

    <bool name="doze_display_state_supported">true</bool>
    <bool name="doze_suspend_display_state_supported">false</bool>

? (this would go to lp1 without trying lp2, which could be good enough)

Did you try setting config_displayBlanksAfterDoze to true?

I write my findings down here, it's a little long. You can skip to conclusion if needed.

Applied the above changes, and the results are:

  1. The panel only goes to lp1 like you mentioned.
  2. After wake, the display appears somewhat gray, and the refresh rate is very low (lower than 20fps or so).
  3. fts_ts_resume() is still not being called correctly on wake, so touch doesn't recover from suspend(dt2w).
  4. If the panel is getting wake by a notificaion popup, it wakes as expected (dsi_panel_disable+fts_ts_suspend and dsi_panel_enable+fts_ts_resume, more on this later).
  5. Recompiled the kernel and (only) add some printk, I discovered that the fts_ts_resume() function is only called if the system has been woken up once. It's difficult to explain, so I put the code here if you want to take a look. With this commit, when I wake the device up, it reportsSDE_MODE_DPMS_defualt, g_enter_AOD=1 and execute the "leave AOD" stuffs. Then I press the power button again, it enters AOD, and reports SDE_MODE_DPMS_defualt, g_enter_AOD=0 along withdsi_panel_disable+fts_ts_suspend and dsi_panel_enable+fts_ts_resume (suspend and resume are from fts driver) once, then SDE_MODE_DPMS_LP1, g_enter_AOD=0, dsi_panel_set_lp1, and fts_ts_suspend (suspend from dsi_panel_set_lp1). So it indeed resume, but at a wrong timing.

To compare it with the stock behavior, I flashed the stock ROM, and I found:

  1. There's a noticeable delay when transitioning from AOD state to non-AOD state, vice versa.
  2. Recompile the kernel and (only) add some printk, I found that the fts_ts_resume() is indeed only called directly from the fts driver itself, rather than dsi_panel_set_nolp.
  3. If fts_ts_resume or fts_ts_suspend is called from fts driver, it means dsi_panel have execute dsi_panel_disable or dsi_panel_enable. (fts_ts_resume is the follow up of dsi_panel_enable, etc.) (Same as on AOSP)
  4. The order of logs is the same as on AOSP, but when the device enters/leaves AOD, it automatically runs dsi_panel_disable+fts_ts_suspend and dsi_panel_enable+fts_ts_resume once, whether at the end of wake process or at the begining of the enter AOD process.
  5. I also have grab some logs from stock, when wakes it up from AOD. If you want to take a look it's here.

LONG STORY SHORT

So I guess the main difference is that, they probably do some trick to run dsi_panel_disable+dsi_panel_enable when entering and leaving AOD. Then, everything matches the log, and would explain why there's a noticeable delay when transitioning between AOD state and non-AOD state.
Is there any way I could do (test) this on GSIs? Running it on wake should be enough.

@phhusson
Copy link

So I guess the main difference is that, they probably do some trick to run dsi_panel_disable+dsi_panel_enable when entering and leaving AOD. Then, everything matches the log, and would explain why there's a noticeable delay when transitioning between AOD state and non-AOD state.

This definitely sounds like config_displayBlanksAfterDoze=true

FWIW on ROG Phone 3, this issue doesn't happen, I just tick "force enable aod" which sets doze_display_state_supported and doze_suspend_display_state_supported to true and it's alright. I didn't exactly check power loss, but that's less than 50%/24 hours (I think it was 20% over that period)

@Rocky7842
Copy link
Author

This definitely sounds like config_displayBlanksAfterDoze=true

Umm, so I do some more tests on this, and found that if config_displayBlanksAfterDoze is true, it will do dsi_panel_disable+dsi_panel_enable when entering AOD. But when it comes to leaving the AOD, it'll only do it if the system is woken by a notification. If config_displayBlanksAfterDoze is false, notifications cannot wake it correctly too.
The display will always turn black when switching state if config_displayBlanksAfterDoze is true. But if I wake it though power button or dt2w, the "black" time is much shorter, probably only half the time it take compares to wake up by notification or entering AOD.

(Tested on android_13.0.0_r52 ci-20230627)

FWIW on ROG Phone 3, this issue doesn't happen, I just tick "force enable aod" which sets doze_display_state_supported and doze_suspend_display_state_supported to true and it's alright. I didn't exactly check power loss, but that's less than 50%/24 hours (I think it was 20% over that period)

Things are a bit messy on ROG Phone 1, probably because this is their first try making a gaming phone full of weird stuff. I've also checked the kernel source of ROG Phone 2, they're already using proper dsi_panel_set_nolp on it. I really have no idea why they decided to remove dsi_panel_set_nolp, as the codes and command sets are there, and there's no issue utilizing it from my tests.

@phhusson
Copy link

Okay, I think that's great information. I guess Google "just" broke config_displayBlanksAfterDoze, since it does have an effect with notifications but not power button.

So let's go back to config_displayBlanksAfterDoze=true, but set the prop ro.config.low_ram=true (do it however you want, but it needs to be already set when android boot. Personally the way I would do it is adb root; adb shell setprop ro.config.low_ram true; adb shell 'stop;start'.

The reason I'm suggesting this is because of https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/services/core/java/com/android/server/display/DisplayPowerController.java#2195

This code handles config_displayBlanksAfterDoze and turns screen off when going from doze to on, and it seems to be could bypassed by mColorFadeEnabled, which can be disabled with low ram prop.

When setting this will fail, I'll add more logs around this code to understand precisely what happens (starting with checking whether state_off is always called or not)

@Rocky7842
Copy link
Author

Now tested with ro.config.low_ram=true, but no luck. Still, only notifications can wake it up correctly.

@phhusson
Copy link

phhusson commented Jul 1, 2023

https://phh.freeboxos.fr:49026/share/ar96NDtqe-HAJKIc/s-logs-aod.img

diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 3c1b73109420..d0e50a2df5a7 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -2215,6 +2215,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
     }
 
     private void animateScreenStateChange(int target, boolean performScreenOffTransition) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 1");
         // If there is already an animation in progress, don't interfere with it.
         if (mColorFadeEnabled &&
                 (mColorFadeOnAnimator.isStarted() || mColorFadeOffAnimator.isStarted())) {
@@ -2224,41 +2225,51 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
             // If display state changed to on, proceed and stop the color fade and turn screen on.
             mPendingScreenOff = false;
         }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 2 " + mDisplayBlanksAfterDozeConfig + ", " + Display.isDozeState(mPowerState.getScreenState()) + ", " + Display.isDozeState(target));
 
         if (mDisplayBlanksAfterDozeConfig
                 && Display.isDozeState(mPowerState.getScreenState())
                 && !Display.isDozeState(target)) {
             // Skip the screen off animation and add a black surface to hide the
             // contents of the screen.
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 3");
             mPowerState.prepareColorFade(mContext,
                     mColorFadeFadesConfig ? ColorFade.MODE_FADE : ColorFade.MODE_WARM_UP);
             if (mColorFadeOffAnimator != null) {
                 mColorFadeOffAnimator.end();
             }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 4");
             // Some display hardware will blank itself on the transition between doze and non-doze
             // but still on display states. In this case we want to report to policy that the
             // display has turned off so it can prepare the appropriate power on animation, but we
             // don't want to actually transition to the fully off state since that takes
             // significantly longer to transition from.
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 5");
             setScreenState(Display.STATE_OFF, target != Display.STATE_OFF /*reportOnly*/);
         }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 6");
 
         // If we were in the process of turning off the screen but didn't quite
         // finish.  Then finish up now to prevent a jarring transition back
         // to screen on if we skipped blocking screen on as usual.
         if (mPendingScreenOff && target != Display.STATE_OFF) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 7");
             setScreenState(Display.STATE_OFF);
             mPendingScreenOff = false;
             mPowerState.dismissColorFadeResources();
         }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 8");
 
         if (target == Display.STATE_ON) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 9");
             // Want screen on.  The contents of the screen may not yet
             // be visible if the color fade has not been dismissed because
             // its last frame of animation is solid black.
             if (!setScreenState(Display.STATE_ON)) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 10");
                 return; // screen on blocked
             }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 11");
             if (USE_COLOR_FADE_ON_ANIMATION && mColorFadeEnabled && mPowerRequest.isBrightOrDim()) {
                 // Perform screen on animation.
                 if (mPowerState.getColorFadeLevel() == 1.0f) {
@@ -2294,45 +2305,59 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
             mPowerState.setColorFadeLevel(1.0f);
             mPowerState.dismissColorFade();
         } else if (target == Display.STATE_DOZE) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 12");
             // Want screen dozing.
             // Wait for brightness animation to complete beforehand when entering doze
             // from screen on to prevent a perceptible jump because brightness may operate
             // differently when the display is configured for dozing.
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 13");
             if (mScreenBrightnessRampAnimator.isAnimating()
                     && mPowerState.getScreenState() == Display.STATE_ON) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 14");
                 return;
             }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 15");
 
             // Set screen state.
             if (!setScreenState(Display.STATE_DOZE)) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 16");
                 return; // screen on blocked
             }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 17");
 
             // Dismiss the black surface without fanfare.
             mPowerState.setColorFadeLevel(1.0f);
             mPowerState.dismissColorFade();
         } else if (target == Display.STATE_DOZE_SUSPEND) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 18");
             // Want screen dozing and suspended.
             // Wait for brightness animation to complete beforehand unless already
             // suspended because we may not be able to change it after suspension.
             if (mScreenBrightnessRampAnimator.isAnimating()
                     && mPowerState.getScreenState() != Display.STATE_DOZE_SUSPEND) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 19");
                 return;
             }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 20");
 
             // If not already suspending, temporarily set the state to doze until the
             // screen on is unblocked, then suspend.
             if (mPowerState.getScreenState() != Display.STATE_DOZE_SUSPEND) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 21");
                 if (!setScreenState(Display.STATE_DOZE)) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 22");
                     return; // screen on blocked
                 }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 23");
                 setScreenState(Display.STATE_DOZE_SUSPEND); // already on so can't block
             }
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 24");
 
             // Dismiss the black surface without fanfare.
             mPowerState.setColorFadeLevel(1.0f);
             mPowerState.dismissColorFade();
         } else if (target == Display.STATE_ON_SUSPEND) {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 25");
             // Want screen full-power and suspended.
             // Wait for brightness animation to complete beforehand unless already
             // suspended because we may not be able to change it after suspension.
@@ -2354,6 +2379,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
             mPowerState.setColorFadeLevel(1.0f);
             mPowerState.dismissColorFade();
         } else {
+android.util.Log.e("PHH-AOD", "animateScreenStateChange 26");
             // Want screen off.
             mPendingScreenOff = true;
             if (!mColorFadeEnabled) {

take logs with that. Please take care to very cleanly cut the logs, so what we know exactly which transition we're looking at in logs

@Rocky7842
Copy link
Author

Rocky7842 commented Jul 7, 2023

Sorry for the late reply, was a little busy this week.
Here's the log

Entering AOD:
06-30 05:16:35.267 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:35.267 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:16:35.267 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:35.267 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:35.267 2320 2391 E PHH-AOD : animateScreenStateChange 26
06-30 05:16:35.713 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:35.714 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:16:35.714 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:35.714 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:35.714 2320 2391 E PHH-AOD : animateScreenStateChange 26
06-30 05:16:35.765 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:35.765 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:16:35.765 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:35.765 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:35.765 2320 2391 E PHH-AOD : animateScreenStateChange 26
06-30 05:16:35.923 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:35.923 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:16:35.923 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:35.923 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:35.923 2320 2391 E PHH-AOD : animateScreenStateChange 26
06-30 05:16:36.009 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:36.009 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:16:36.010 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:36.010 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:36.010 2320 2391 E PHH-AOD : animateScreenStateChange 26
06-30 05:16:36.092 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:36.092 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, true
06-30 05:16:36.092 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:36.092 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:36.092 2320 2391 E PHH-AOD : animateScreenStateChange 12
06-30 05:16:36.092 2320 2391 E PHH-AOD : animateScreenStateChange 13
06-30 05:16:36.092 2320 2391 E PHH-AOD : animateScreenStateChange 15
06-30 05:16:36.094 2320 2391 E PHH-AOD : animateScreenStateChange 16
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, true, true
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 12
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 13
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 15
06-30 05:16:36.095 2320 2391 E PHH-AOD : animateScreenStateChange 16
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, true, true
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 12
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 13
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 15
06-30 05:16:36.175 2320 2391 E PHH-AOD : animateScreenStateChange 17
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, true, true
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 12
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 13
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 15
06-30 05:16:36.176 2320 2391 E PHH-AOD : animateScreenStateChange 17

Leaveing AOD, woken up by power button:
06-30 05:17:42.361 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:17:42.361 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, true, false
06-30 05:17:42.361 2320 2391 E PHH-AOD : animateScreenStateChange 3
06-30 05:17:42.386 2320 2391 E PHH-AOD : animateScreenStateChange 4
06-30 05:17:42.386 2320 2391 E PHH-AOD : animateScreenStateChange 5
06-30 05:17:42.391 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:17:42.391 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:17:42.391 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:17:42.396 2320 2391 E PHH-AOD : animateScreenStateChange 10
06-30 05:17:42.410 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:17:42.410 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:17:42.410 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:17:42.410 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:17:42.410 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:17:42.410 2320 2391 E PHH-AOD : animateScreenStateChange 10
06-30 05:17:42.493 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:17:42.493 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:17:42.493 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:17:42.493 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:17:42.493 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:17:42.493 2320 2391 E PHH-AOD : animateScreenStateChange 11
06-30 05:17:42.555 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:17:42.555 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:17:42.555 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:17:42.555 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:17:42.555 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:17:42.555 2320 2391 E PHH-AOD : animateScreenStateChange 11

Leaveing AOD, woken up by notification. I then clicked on the notification to continue unlock the phone:
06-30 05:18:36.191 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:36.191 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, true, false
06-30 05:18:36.191 2320 2391 E PHH-AOD : animateScreenStateChange 3
06-30 05:18:36.211 2320 2391 E PHH-AOD : animateScreenStateChange 4
06-30 05:18:36.211 2320 2391 E PHH-AOD : animateScreenStateChange 5
06-30 05:18:36.215 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:36.215 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:36.215 2320 2391 E PHH-AOD : animateScreenStateChange 26
06-30 05:18:36.216 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:36.216 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:36.216 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:36.216 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:36.216 2320 2391 E PHH-AOD : animateScreenStateChange 26
06-30 05:18:36.283 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:36.283 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:36.283 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:36.283 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:36.283 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:36.285 2320 2391 E PHH-AOD : animateScreenStateChange 10
06-30 05:18:36.326 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:36.326 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:36.326 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:36.326 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:36.326 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:36.326 2320 2391 E PHH-AOD : animateScreenStateChange 11
06-30 05:18:36.786 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:36.786 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:36.786 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:36.786 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:36.786 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:36.786 2320 2391 E PHH-AOD : animateScreenStateChange 11
06-30 05:18:37.493 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:37.493 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:37.493 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:37.493 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:37.493 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:37.493 2320 2391 E PHH-AOD : animateScreenStateChange 11
06-30 05:18:37.579 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:37.580 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:37.580 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:37.580 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:37.580 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:37.580 2320 2391 E PHH-AOD : animateScreenStateChange 11
06-30 05:18:37.665 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:37.665 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:37.665 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:37.665 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:37.665 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:37.665 2320 2391 E PHH-AOD : animateScreenStateChange 11
06-30 05:18:37.678 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:37.679 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:37.679 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:37.679 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:37.679 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:37.679 2320 2391 E PHH-AOD : animateScreenStateChange 11
06-30 05:18:38.721 2320 2391 E PHH-AOD : animateScreenStateChange 1
06-30 05:18:38.721 2320 2391 E PHH-AOD : animateScreenStateChange 2 true, false, false
06-30 05:18:38.721 2320 2391 E PHH-AOD : animateScreenStateChange 6
06-30 05:18:38.721 2320 2391 E PHH-AOD : animateScreenStateChange 8
06-30 05:18:38.721 2320 2391 E PHH-AOD : animateScreenStateChange 9
06-30 05:18:38.721 2320 2391 E PHH-AOD : animateScreenStateChange 11

It looks like the correct state change for leaving AOD should be 1-2-3-4-5-6-8-26.... However, when waked by the power button, it goes for 1-2-3-4-5-6-8-9-10....

@phhusson
Copy link

It looks like the correct state change for leaving AOD should be 1-2-3-4-5-6-8-26.... However, when waked by the power button, it goes for 1-2-3-4-5-6-8-9-10....

Showing screen states 3/4/5/6 mean that Android does indeed properly do screen_off: setScreenState(Display.STATE_OFF, target != Display.STATE_OFF /*reportOnly*/); inside
if (mDisplayBlanksAfterDozeConfig && Display.isDozeState(mPowerState.getScreenState()) && !Display.isDozeState(target)) {

My gut feeling is that it's just a timing issue (setScreenState might need to be on a vsync or something), so I'll make you a test image with a big old sleep(200ms) and let's see what happen.

Here's a test image with that
https://phh.freeboxos.fr:49026/share/HGg77b33_QVWx3sZ/s-rog-aod2.img

@Rocky7842
Copy link
Author

It looks like the correct state change for leaving AOD should be 1-2-3-4-5-6-8-26.... However, when waked by the power button, it goes for 1-2-3-4-5-6-8-9-10....

Showing screen states 3/4/5/6 mean that Android does indeed properly do screen_off: setScreenState(Display.STATE_OFF, target != Display.STATE_OFF /*reportOnly*/); inside if (mDisplayBlanksAfterDozeConfig && Display.isDozeState(mPowerState.getScreenState()) && !Display.isDozeState(target)) {

My gut feeling is that it's just a timing issue (setScreenState might need to be on a vsync or something), so I'll make you a test image with a big old sleep(200ms) and let's see what happen.

Here's a test image with that https://phh.freeboxos.fr:49026/share/HGg77b33_QVWx3sZ/s-rog-aod2.img

Now tested with this new build. Sadly still the same behaviour.

@phhusson
Copy link

Ok I'll try to dig down to the HAL to ensure that we do end up sending display state_off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants