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

Commit 4f7ca41f authored by Santos Cordon's avatar Santos Cordon
Browse files

Go to sleep on fold for foldable devices.

Allow configuration of foldable states to indicate the device
should sleep when entering certain states.

Test: Check that device still wakes up on unfold, and sleeps on fold.
Bug: 180154690
Change-Id: I179d93ec506deee7e9da7d9190934c52a0bc188f
parent e43cf93e
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -371,6 +371,13 @@ public abstract class DisplayManagerInternal {
     */
     */
    public abstract Point getDisplaySurfaceDefaultSize(int displayId);
    public abstract Point getDisplaySurfaceDefaultSize(int displayId);


    /**
     * Receives early interactivity changes from power manager.
     *
     * @param interactive The interactive state that the device is moving into.
     */
    public abstract void onEarlyInteractivityChange(boolean interactive);

    /**
    /**
     * Describes the requested power state of the display.
     * Describes the requested power state of the display.
     *
     *
+10 −2
Original line number Original line Diff line number Diff line
@@ -440,9 +440,15 @@ public final class PowerManager {
    public static final int GO_TO_SLEEP_REASON_DISPLAY_GROUPS_TURNED_OFF = 12;
    public static final int GO_TO_SLEEP_REASON_DISPLAY_GROUPS_TURNED_OFF = 12;


    /**
    /**
     * Go to sleep reason code: A foldable device has been folded.
     * @hide
     * @hide
     */
     */
    public static final int GO_TO_SLEEP_REASON_MAX = GO_TO_SLEEP_REASON_DISPLAY_GROUPS_TURNED_OFF;
    public static final int GO_TO_SLEEP_REASON_DEVICE_FOLD = 13;

    /**
     * @hide
     */
    public static final int GO_TO_SLEEP_REASON_MAX =  GO_TO_SLEEP_REASON_DEVICE_FOLD;


    /**
    /**
     * @hide
     * @hide
@@ -461,6 +467,7 @@ public final class PowerManager {
            case GO_TO_SLEEP_REASON_INATTENTIVE: return "inattentive";
            case GO_TO_SLEEP_REASON_INATTENTIVE: return "inattentive";
            case GO_TO_SLEEP_REASON_DISPLAY_GROUP_REMOVED: return "display_group_removed";
            case GO_TO_SLEEP_REASON_DISPLAY_GROUP_REMOVED: return "display_group_removed";
            case GO_TO_SLEEP_REASON_DISPLAY_GROUPS_TURNED_OFF: return "display_groups_turned_off";
            case GO_TO_SLEEP_REASON_DISPLAY_GROUPS_TURNED_OFF: return "display_groups_turned_off";
            case GO_TO_SLEEP_REASON_DEVICE_FOLD: return "device_folded";
            default: return Integer.toString(sleepReason);
            default: return Integer.toString(sleepReason);
        }
        }
    }
    }
@@ -568,7 +575,8 @@ public final class PowerManager {
            GO_TO_SLEEP_REASON_ACCESSIBILITY,
            GO_TO_SLEEP_REASON_ACCESSIBILITY,
            GO_TO_SLEEP_REASON_FORCE_SUSPEND,
            GO_TO_SLEEP_REASON_FORCE_SUSPEND,
            GO_TO_SLEEP_REASON_INATTENTIVE,
            GO_TO_SLEEP_REASON_INATTENTIVE,
            GO_TO_SLEEP_REASON_QUIESCENT
            GO_TO_SLEEP_REASON_QUIESCENT,
            GO_TO_SLEEP_REASON_DEVICE_FOLD
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface GoToSleepReason{}
    public @interface GoToSleepReason{}
+17 −4
Original line number Original line Diff line number Diff line
@@ -654,10 +654,23 @@
        -->
        -->
    </integer-array>
    </integer-array>


    <!-- When entering this device state (defined in device_state_configuration.xml),
    <!-- When a device enters any of these states, it should be woken up. States are defined in
         we should wake the device. -1 to disable the feature (do not wake on any device-state
         device_state_configuration.xml. -->
         transition). -->
    <integer-array name="config_deviceStatesOnWhichToWakeUp">
    <integer name="config_deviceStateOnWhichToWakeUp">-1</integer>
        <!-- Example:
        <item>0</item>
        <item>1</item>
        -->
    </integer-array>

    <!-- When a device enters any of these states, it should go to sleep. States are defined in
         device_state_configuration.xml. -->
    <integer-array name="config_deviceStatesOnWhichToSleep">
        <!-- Example:
        <item>0</item>
        <item>1</item>
        -->
    </integer-array>


    <!-- Indicate the display area rect for foldable devices in folded state. -->
    <!-- Indicate the display area rect for foldable devices in folded state. -->
    <string name="config_foldedArea"></string>
    <string name="config_foldedArea"></string>
+2 −1
Original line number Original line Diff line number Diff line
@@ -3856,7 +3856,8 @@


  <!-- For Foldables -->
  <!-- For Foldables -->
  <java-symbol type="array" name="config_foldedDeviceStates" />
  <java-symbol type="array" name="config_foldedDeviceStates" />
  <java-symbol type="integer" name="config_deviceStateOnWhichToWakeUp" />
  <java-symbol type="array" name="config_deviceStatesOnWhichToWakeUp" />
  <java-symbol type="array" name="config_deviceStatesOnWhichToSleep" />
  <java-symbol type="string" name="config_foldedArea" />
  <java-symbol type="string" name="config_foldedArea" />
  <java-symbol type="bool" name="config_supportsConcurrentInternalDisplays" />
  <java-symbol type="bool" name="config_supportsConcurrentInternalDisplays" />
  <java-symbol type="bool" name="config_unfoldTransitionEnabled" />
  <java-symbol type="bool" name="config_unfoldTransitionEnabled" />
+6 −0
Original line number Original line Diff line number Diff line
@@ -524,6 +524,7 @@ public final class DisplayManagerService extends SystemService {
            }
            }
        } else if (phase == PHASE_BOOT_COMPLETED) {
        } else if (phase == PHASE_BOOT_COMPLETED) {
            mDisplayModeDirector.onBootCompleted();
            mDisplayModeDirector.onBootCompleted();
            mLogicalDisplayMapper.onBootCompleted();
        }
        }
    }
    }


@@ -3601,6 +3602,11 @@ public final class DisplayManagerService extends SystemService {
            }
            }
            return device.getDisplaySurfaceDefaultSize();
            return device.getDisplaySurfaceDefaultSize();
        }
        }

        @Override
        public void onEarlyInteractivityChange(boolean interactive) {
            mLogicalDisplayMapper.onEarlyInteractivityChange(interactive);
        }
    }
    }


    class DesiredDisplayModeSpecsObserver
    class DesiredDisplayModeSpecsObserver
Loading