-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Backport request orientation cache #757
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
base: androidx-main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Important The terms of service for this installation has not been accepted. Please ask the Organization owners to visit the Gemini Code Assist Admin Console to sign it. |
Our GH build is not in a good state, so I would ignore failures in the checks here, but just enabling it so copybara can mirror the change to Gerrit once we review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original change also returned the lastRequestedOrientation
from getRequestedOrientation
. Was there a reason you didn't override that method also to returned the cached value (as that also seems to do the same binder transaction every time it is called)?
3b19f16
to
704ac92
Compare
@@ -50,6 +50,8 @@ public open class ComponentActivity : Activity(), LifecycleOwner, KeyEventDispat | |||
*/ | |||
@Suppress("LeakingThis") private val lifecycleRegistry = LifecycleRegistry(this) | |||
|
|||
private var lastRequestedOrientation: Int = ActivityInfo.SCREEN_ORIENTATION_UNSET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to actually backport that constant as it's hidden.
API 35 / Android 15 added a field cache to `Activity.setRequestedOrientation()` because every call would lead to an IPC call, which can be expensive and hammer the system. This change backports the API 35 behavior. https://cs.android.com/android/_/android/platform/frameworks/base/+/14b59e53b82dbeb93ca1c8ac612c13d62c8672e9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the formatting needs to be corrected before this can be submitted:
Execution failed for task ':core:core:ktCheck'.
> Failed check for the following files:
$SUPPORT/core/core/src/main/java/androidx/core/app/ComponentActivity.kt
********************************************************************************
You can automatically fix these issues with:
./gradlew :core:core:ktFormat
********************************************************************************
API 35 / Android 15 added a field cache to
Activity.setRequestedOrientation()
because every call would lead to an IPC call, which can be expensive and hammer the system.https://cs.android.com/android/_/android/platform/frameworks/base/+/14b59e53b82dbeb93ca1c8ac612c13d62c8672e9
Proposed Changes
This change backports the API 35 behavior.
Note: I made the change in
androidx.core.app.ComponentActivity
as that's the top level base activity class. Let me know if you'd like me to move it somewhere else instead (or feel free to just edit).Testing
Test: we tested this change in our own base activity class in the Square Point of Sale app.
Issues Fixed
Fixes: 265021810 (not public, I couldn't read it, but it's referenced in the Android 15 change)