Android AOSP Lock Screen rotation

Viewed 1171

I am building a device running on Android (9) that is normally used with the display in landscape mode. I have found a way to set the the home screen to landscape as well as fix the custom application that comes with the device to landscape, but I haven't found a way to do so for the Lock Screen (aka Keyguard). Is this at all possible?

Note: I do have the complete AOSP source code available for editing and building, I just don't know where to make the required changes. The AndroidManifest.xml of frameworks/base/packages/Keyguard is surprisingly empty.

1 Answers

For that you have to make some changes in you device make file and packages. First: add this to you main device make file, and remove android.hardware.screen.portrait.xml package.

PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.screen.landscape.xml:system/etc/permissions/android.hardware.screen.landscape.xml \

Second: Create an overlay config.xml file. it should be on overlay directory of the target directory (device/{vendor-of-you-device}/{model-of-your-device}/overlay/framework/base/res/res/values). then add this configuration file (config.xml)

<resources>
    <bool name="config_forceDefaultOrientation">true</bool>
</resources>

Note: This way work for android 9 and all of the older versions, there is another way for android 10 and older.

Note: please make sure that the overlay directory path is defined in your make file so system use your overlays.

PRODUCT_PACKAGE_OVERLAYS += device/{vendor-of-you-device}/{model-of-your-device}/overlay

Note: you have to provide framework overlays in you target path (device/{vendor-of-you-device}/{model-of-your-device}/overlay) for changing the display orientation or any other framework property and not changing the android internal framework configuration because it is not safe or recommended.

Related