summaryrefslogtreecommitdiff
path: root/cmds/bootanimation/BootAnimation.cpp
diff options
context:
space:
mode:
author Mariia Sandrikova <mariiasand@google.com> 2022-12-10 02:32:14 +0000
committer Mariia Sandrikova <mariiasand@google.com> 2022-12-19 00:54:50 +0000
commita166f0128e3bba1a29bca49a1a6cf8d2fa94e2f6 (patch)
treec0e9c0502bac53244d6f7b2c8aceaf761e7e37a9 /cmds/bootanimation/BootAnimation.cpp
parent8a83f07ae0fd61146120a42787207a4f50509968 (diff)
Set orientation for boot animation and default display rotation.
Change the default display rotation value and boot animation orientation to the value specified in the sysprop ro.bootanim.set_orientation_<display_id>. Four values are supported: ORIENTATION_0, ORIENTATION_90, ORIENTATION_180 and ORIENTATION_270. If the value isn't specified or is ORIENTATION_0, nothing will be changed. This is needed to support having default rotation behavior and boot animation in orientation different from the natural device orientation. For example, on tablets that may want to keep natural orientation portrait for applications compatibility but have landscape orientation as a default choice from the UX perspective. Bug: 260627934 Test: manual test with all 4 values and atest WmTests still pass Change-Id: I322919999ef787ff2c149293d7e1c7e669796c9a
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r--cmds/bootanimation/BootAnimation.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 3f6046f01f11..53a84bd1b21e 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -583,6 +583,15 @@ status_t BootAnimation::readyToRun() {
mFlingerSurface = s;
mTargetInset = -1;
+ // Rotate the boot animation according to the value specified in the sysprop
+ // ro.bootanim.set_orientation_<display_id>. Four values are supported: ORIENTATION_0,
+ // ORIENTATION_90, ORIENTATION_180 and ORIENTATION_270.
+ // If the value isn't specified or is ORIENTATION_0, nothing will be changed.
+ // This is needed to support having boot animation in orientations different from the natural
+ // device orientation. For example, on tablets that may want to keep natural orientation
+ // portrait for applications compatibility and to have the boot animation in landscape.
+ rotateAwayFromNaturalOrientationIfNeeded();
+
projectSceneToWindow();
// Register a display event receiver
@@ -596,6 +605,50 @@ status_t BootAnimation::readyToRun() {
return NO_ERROR;
}
+void BootAnimation::rotateAwayFromNaturalOrientationIfNeeded() {
+ const auto orientation = parseOrientationProperty();
+
+ if (orientation == ui::ROTATION_0) {
+ // Do nothing if the sysprop isn't set or is set to ROTATION_0.
+ return;
+ }
+
+ if (orientation == ui::ROTATION_90 || orientation == ui::ROTATION_270) {
+ std::swap(mWidth, mHeight);
+ std::swap(mInitWidth, mInitHeight);
+ mFlingerSurfaceControl->updateDefaultBufferSize(mWidth, mHeight);
+ }
+
+ Rect displayRect(0, 0, mWidth, mHeight);
+ Rect layerStackRect(0, 0, mWidth, mHeight);
+
+ SurfaceComposerClient::Transaction t;
+ t.setDisplayProjection(mDisplayToken, orientation, layerStackRect, displayRect);
+ t.apply();
+}
+
+ui::Rotation BootAnimation::parseOrientationProperty() {
+ const auto displayIds = SurfaceComposerClient::getPhysicalDisplayIds();
+ if (displayIds.size() == 0) {
+ return ui::ROTATION_0;
+ }
+ const auto displayId = displayIds[0];
+ const auto syspropName = [displayId] {
+ std::stringstream ss;
+ ss << "ro.bootanim.set_orientation_" << displayId.value;
+ return ss.str();
+ }();
+ const auto syspropValue = android::base::GetProperty(syspropName, "ORIENTATION_0");
+ if (syspropValue == "ORIENTATION_90") {
+ return ui::ROTATION_90;
+ } else if (syspropValue == "ORIENTATION_180") {
+ return ui::ROTATION_180;
+ } else if (syspropValue == "ORIENTATION_270") {
+ return ui::ROTATION_270;
+ }
+ return ui::ROTATION_0;
+}
+
void BootAnimation::projectSceneToWindow() {
glViewport(0, 0, mWidth, mHeight);
glScissor(0, 0, mWidth, mHeight);