summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-01-27webkit: SystemImpl: Make systemIsDebuggable() check IS_ENG as wellLuK1337
* Since we are shipping userdebug builds by default it'd be nice to keep signature and version downgrade checks intact. * Fixes : https://gitlab.com/LineageOS/issues/android/-/issues/2192 Change-Id: Ib46ccb50ac091469caf99a73a5a08942cbc457f6
2022-01-27BatteryService: Add support for OEM fast charger detectionAlexander Martinz
Allows to indicate, whether a device is charged using a proprietary OEM fast charge solution, which write their status to sysfs. The OEM fast charge detection tries to be as generic as possible and is configured via overlays. Path to sysfs to read status - core/res/res/values/custom_config.xml - config_oemFastChargerStatusPath Value expected from read status (Defaults to "1" if not specified) - core/res/res/values/custom_config.xml - config_oemFastChargerStatusValue Change-Id: I6f3598a5a6a3efc76553261d2cf73094170d4110 Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
2022-01-27SystemUI: Use DT2W setting also to wake from AODmaxwen
Change-Id: I844e36469b0e3b0168eecb62f6e8b0e9b2bff40e
2022-01-27base: Add rounded corners to activity open/close animationpaphonb
Change-Id: Ifcf49134d738693874cbdcc6f746898fa6d5942e
2022-01-27Perf: Added support for app type in launch hintAman Mehta
Added support for app type in launch hint CRs-Fixed: 3099018 Change-Id: Icba61c84d179767596fb2aa2ada38adb1ffba900
2022-01-26SettingsLib: Update 4G+ icon to Silk design as wellTH779
* The plus icon ref from I6b2947441217ddc2215d1dcb7b2e659f9bd82743. Co-authored-by: Adithya <gh0strider.2k18.reborn@gmail.com> Signed-off-by: TH779 <i@779.moe> Change-Id: I28004d62013be13dfd0825cc53049019f0e06966
2022-01-26SettingsLib: Update LTE+ icon as per new Silk designAdithya
* according to 084c13c8216f6a899cd3eda04fc1d7acff3d1248 Change-Id: I6b2947441217ddc2215d1dcb7b2e659f9bd82743
2022-01-26CarrierConfigManager: Enable LTE+ iconJake Weinstein
Change-Id: Ic8819c9b9cf5d1469a47f3d16cd10918285f40f9
2022-01-26Keyguard: don't use large clock on landscapeTimi Rautamäki
Large clock does not display properly on landscape mode. Change-Id: If803ad03568671e8aed2fe37897bd1fb9cee29ae
2022-01-26SystemUI: Dismiss keyguard on boot if disabled by current profileGabriele M
Properly dismiss keyguard on boot if the current profile has it disabled, otherwise we will just show a black screen with just the status bar and a navbar with only the back button. BUGBASH-87 Change-Id: I14ed10ae9db40c32be22c1fb43f8a1719787d91b
2022-01-26Keyguard: Do not trigger a wake up when hiding lockscreenArne Coucheron
* This piece of code was introduced in commit: Swipe up to unlock when pulsing Change-Id: Ida5adb6a18f3ee992b1d154e10b35ba244f5b712 However, it appears to not be needed and instead causes the device to wakeup right after dozing with no lockscreen set. * Remove it and test with: adb shell am broadcast -a com.android.systemui.doze.pulse com.android.systemui The device can still be unlocked from pulsing state. Change-Id: Ib5c2f930bd4de04cbf8f89f12d046f30c9b32a52
2022-01-26SystemUI: Update Bluetooth battery level assetsAndrew Fluck
* Outlined and polished. Change-Id: I94fd78d5788306f64623e850a00302bb42b7897d
2022-01-26SystemUI: Show bluetooth battery levelLuK1337
Author: LuK1337 <priv.luk@gmail.com> Date: 2018-10-31 16:31:19 +0100 SystemUI: Show bluetooth battery level when available * Somewhat inspired by change committed by Gavin Ni <gisngy@gmail.com> back in cm-13.0 days (see commit 88e7a6c). Since then completely rewritten using BluetoothDevice API introduced in Oreo, with new drawables meant to be used with 0-9 battery level range. Change-Id: I6179bfd41e033591534e8cf3c6adc98ce715a13d Author: Luca Stefani <luca.stefani.ge1@gmail.com> Date: 2021-08-23 10:11:54 +0200 fixup! SystemUI: Show bluetooth battery level when available The current update method is triggered in 2 cases: the SystemUI bluetooth controller changes device state the battery level changed intent is sent Sadly the current SysUI controller doesn't handle battery level changes, and is instead triggered in a few other cases ( ex audio state changed ). And since we use the data from SysUI controller for battery level from changes in the global bt controller we may have 2 different set of devices to work on. This could ( and does ) trigger race conditions. Instead add support battery level state changes within the SystemUI controller to work on the same data set. Change-Id: Ib57096fc2ebe151ac3860277a4db2319f230b514 Change-Id: I34344907711b7b9fc4c1d15d4516bd53bf30ebb2
2022-01-26Screenshot: Append app name to filenameezio84
Author: ezio84 <brabus84@gmail.com> Date: Tue Dec 19 14:37:35 2017 +0100 Screenshot: append app name to filename Kang Samsung's idea. Change-Id: Ibc6a52b5e2597e6014a2da6a4211febe17ec02c7 Author: Wang Han <wanghan1995315@gmail.com> Date: Fri May 11 12:47:40 2018 +0200 SystemUI: Don't append app name to file on lockscreen When device is locked, current implementation will append the current app name to file when taking screenshot. This causes information leaks. To prevent this, we check for isKeyGuardLocked() and fall back not to append the app name when taking screenshot on lockscreen. Change-Id: I04498faf51986e1a3723a32befd97d29e1f3fe58 Author: DroidFreak32 <rushabshah32@gmail.com> Date: Thu Oct 4 11:33:07 2018 +0530 Screenshot: Append app name after screenshot date. Change-Id: I2ee5d65006ff22dfa381aae50e5757b8e7596e91 Author: ezio84 <brabus84@gmail.com> Date: Sat Jun 16 16:57:19 2018 +0200 GlobalScreenshot: Fix screenshot not saved with some languages like Virgin Islands English when taking a screenshot of the Settings app Change-Id: Ic04f66f5813b9597c96835d15c74509c93530a5c Author: Han Wang <416810799@qq.com> Date: Mon May 25 11:18:01 2020 +0200 SystemUI: Do not convert application name to ISO-8859-15 * ISO-8859-15 does not handle CJK chars, so all of them are 'unknown' and empty eventually. Change-Id: I27c689f5d737190d381146e49c1989e998b4f623 Author: LuK1337 <priv.luk@gmail.com> Date: Mon Aug 24 17:52:39 2020 +0200 SystemUI: Use TaskStackChangeListener API for contextual screenshot package name * This should hopefully fix mislabeled screenshots. Change-Id: Ifde106c0e306a6700081e4d724c1cf0c06dd126c Change-Id: Ic2a42536bf763a0c6f7fb9ac4bbbe84f73723f91
2022-01-26SystemUI: Adapt screenshot sound to ringer modesAshwin R C
Co-authored-by: althafvly <althafvly@gmail.com> Change-Id: I381c351131241e45ddb6049706d6c302c2eee946
2022-01-26SystemUI: show vibration icon in collapsed statusbarTimi Rautamäki
Show the icon also when on keyguard. Change-Id: Ie3f19123edb1fa8baaeaadd307a86ae78ae7d24b
2022-01-26Use tmpArgBuffer correctly when argBuffer is nullWang Han
* Seems to be a typo and can cause NPE. Change-Id: I7e253c97e02767a076d9450e88ccea08c5122bb1
2022-01-26Correction in logic of roundend size calculation of SD cardChetan Gurjar
API FileUtils.roundStorageSize() rounded up the Storage size incorrectly and caused the storage total size to be displayed twice the actual capacity in storage Settings application. Modifications done to appropriately roundup the storage size in the multiple of power of 2 by making the loop iterations to be controlled by 1024 instead of 1000. Test: Verified with the particular SD card with which bug reported. Change-Id: I8f92248a457d6ac507d092df46e1cb0daaa55134
2022-01-26Include saved battery history chunks into BatteryUsageStats parcelDmitri Plotnikov
Bug: 209297031 Test: Test: atest FrameworksCoreTests:BatteryUsageStatsTest FrameworksCoreTests:BatteryUsageStatsProviderTest Merged-In: I369d863b6f6fd488030aa031cc465bef6ce99ab8 Change-Id: Ifc70a49b731b5510e7bcd049e0c12d9ac7f68f44
2022-01-26Fix concurrency issue with BatteryUsageStatsDmitri Plotnikov
BatteryUsageStats is created under a BatteryStatsImpl lock. One of the elements of BatteryUsageStats is the battery history buffer Parcel. Once the BatteryUsageStats object is created, the BatteryStatsImpl lock is released and the history buffer parcel continues to be appended by BatteryStatsImpl. The Parcel may even be reset altogether if the battery stats session is reset. The BatteryUsageStats object is parceled during the getBatteryUsageStats binder call. Any modification of the history buffer concurrent with parceling causes a crash. Bug: 194256984 Test: atest FrameworksCoreTests:BatteryUsageStatsTest FrameworksCoreTests:BatteryUsageStatsProviderTest Change-Id: I262c4608cd02943f926e8daaf3e782c6fe6eaee7
2022-01-26pm: stop auto-granting location to system browsersDaniel Micay
Change-Id: I63de5c36e4a2842dd2dbb1ecd5f9576faf155b95
2022-01-26SystemUI: Fix keyguard clock/status and AOD layouts without smartspaceDanny Lin
The keyguard clock layout is broken and overlaps the UDFPS icon on AOSP because there's no smartspace view, and the KeyguardStatusArea isn't accounted for correctly. Fix it by using the KeyguardStatusArea as the smartspace view when there's no smartspace, so we follow the same code paths and thus get the correct layout. As a side effect, this also makes the status/smartspace position on the AOD and big clock lock screen match that of Pixel stock. Change-Id: Ic2cf0909f1b3c588ed4bf9cbae2dc78b40afa7b9
2022-01-26Revert "[DO NOT MERGE] Make sure WiFi and Cell tiles are not created in ↵Danny Lin
Provider Model" This reverts commit 8bb5148906138b09505b85aa04755f1ec8befdb8. We've intentionally enabled and fixed the Wi-Fi and cellular data tiles to work with the provider model, so revert this to fix the dedicated network tiles. Signed-off-by: Danny Lin <danny@kdrag0n.dev> Change-Id: If3a8683ee1ce9a651800b5ae88183680bd9f3f38
2022-01-26SystemUI: Allow Wi-Fi/cell tiles to co-exist with provider modelDanny Lin
The dedicated Wi-Fi/cellular data QS tiles are partially working now that we've exposed them in the list of tile options, but they're very buggy and somewhat broken when the provider model (unified internet) is enabled. Allow the tiles to co-exist with InternetTile and the provider model (including both settings_provider_model and combined signal icons) by always including QS icons in Wi-Fi/data indicator callbacks, and add a new flag to indicate whether they should be shown in the internet tile. Change-Id: I10af134b35dfabdb9275f1aca8ca8512e1db6d27
2022-01-26SystemUI: Expose legacy Wi-Fi and cellular data QS tilesDanny Lin
We'll still use Android 12's unified internet settings and the Internet tile by default, but expose the legacy Wi-Fi and cellular data tiles so that users can add them with the QS customizer. Change-Id: I65902b38c99f61782bd9aa0ea604848fbd068bda
2022-01-26SystemUI: Fix QS status font weight mismatch in dark modeDanny Lin
Text in the QS status bar is medium in light mode and regular in dark mode. Fix the mismatch. Change-Id: Ic6e5dc547d4ded9d231f88f6cac3e1e9f8483d5e
2022-01-26Paint: Enable subpixel text positioning by defaultDanny Lin
On desktop Linux, subpixel text positioning is necessary to avoid kerning issues, and Android is no different. Even though most phone displays have relatively high DPIs, the lack of subpixel text positioning is only unnoticeable on high-end devices such as the Pixel 4 XL (1440x3040 @ 6.3 in => 537 dpi). For example, on the Pixel 5 (1080 x 2340 @ 6.0 in => 432 dpi), horizontally-scrolling labels in QS tiles can be seen "jittering" slightly upon close observation. This was tested with the Google Sans font on Google's stock OS. At this lower DPI, there is still a need for subpixel text positioning (at least in some cases). Enable subpixel text positioning by default to fix occasional kerning issues and jittering when text is in motion. Change-Id: I8d71e5848a745c5a2d457a28c68458920928ee09
2022-01-26SystemUI: Remove nav bar background in QS customizerDanny Lin
This looks outdated, since most apps are edge-to-edge nowadays. Change-Id: I8c54e61e618a9b5bed1a59753ce76e8fbd69fae2
2022-01-26fonts: Use variable font for Roboto RegularDanny Lin
I'm not sure why Google decided to revert to a static variant of *only* the regular non-italic and non-condensed weight, but using the default "Roboto" font for the lock screen clock (i.e. AOSP default) is broken with the change: - Clock is too bold when notifications are present (because SystemUI loads the regular font but can't change the weight to be less bold) - Weight animation between lock screen and AOD is broken (because weight can't be animated without the variable font) - AOD clock font is too bold (could cause burn-in) Switch back to the variable font in order to fix the clock issues. Change-Id: Ia2e5ef52e4edb5d4275f6d5faf8c74266b784762
2022-01-26SystemUI: Reduce scrim color animation duration to 375 msDanny Lin
The 2-second scrim color animation is far too long in contrast to the dark theme QS tile's state animation, and it's long enough to be something that users have to wait and watch. Reduce the duration to 375 ms, following Launcher3's activity theme cross-fade duration, which is much more reasonable. Change-Id: Id74e3d266f2cdc14d0f5c87f7650d5be730cdb67
2022-01-26SystemUI: Fix uneven volume icon padding in status barDanny Lin
The current silent and vibrate volume icons in the status bar have slightly too much padding compared to all of the other status bar icons, which makes it look out-of-place. Remove the excess insets to make it more even. Note that the silent icon still has 0.5 dp of padding on its left and right sides to make its total size match that of the vibrate icon, which is 19 dp, while the silent icon is 18 dp. Change-Id: I7fb9a6e0113f6103eed308ac2d25c392fe8abb73
2022-01-26ripple: Replace with Fluent Design-inspired ripple animationDanny Lin
This is a new GLSL ripple animation inspired by Microsoft's Fluent Design, with an emphasis on responsiveness. The first frame of the animation includes a solid base highlight and a visible portion of the ripple circle, together serving as immediate feedback on finger up (especially in cases where few additional frames can be rendered, e.g. opening activities/fragment and dismissing dialogs). After the initial frame, the animation consists of a blurred circle that gradually expands (increasing radius), becomes less blurred, and finally fades out at the end of the animation. The animation timing follows a sine-based ease out curve, which is a decent balance between the animation feeling too fast and too slow/unnatural. Demo video: https://twitter.com/kdrag0n/status/1445806323535269893 Change-Id: I27192bd406490c39487dc84941f2f5c4a0fb33fe
2022-01-26Editor: Disable magnifier position animationDanny Lin
In my opinion, this animation serves no purpose because it doesn't correspond to any animations in the text selection/handle flow, and is barely noticeable in typical text selection cases. In addition, it makes the magnifier feel slow/laggy when selecting a large block of text quickly. Change-Id: I5fed9fc06db4491dc2811815741830001d295030
2022-01-26display: Render screen-off fade animation in linear sRGB spaceDanny Lin
The sRGB transfer function is a piecewise function with linear and gamma 2.4 parts, not involving cosine or other magic constants. Fade colors in linear sRGB instead of non-linear sRGB + magic gamma to minimize color distortion as the animation progresses. Change-Id: I57db834f938cc63b7298af1c9dfe8c284dc6abe2
2022-01-26display: NightDisplay: Use chromatic adaptation when possibleDanny Lin
Night Light is currently implemented with a simple RGB tint (similar to the "wrong von Kries transform" but in linear sRGB instead of XYZ), which distorts some colors in addition to changing the neutral CCT. Switch to using full-blown chromatic adaptation (CAT16 + von Kries transform) instead to improve color quality when Night Light is active. Because accurate chromatic adaptation is only possible in linear color spaces, the old logic still needs to be used as a fallback in cases where color transformations can only be applied in the native (device) color space. This uses the existing CCT->RGB tint coefficients for the native color space, which is the only option because we can't make assumptions about the native color space (even if it's sRGB, we can't accommodate it with only matrices). Change-Id: I762610ed3c2cc417307485fd0a6a6d499b00c7d5
2022-01-26display: ChromaticAdaptation: Fix matrix formatting in logsDanny Lin
Google specified 16 columns for the 4x4 transformation matrix, causing the entire thing to get printed on a single line. Fix it to improve readability. Change-Id: I99a5bb35694d0703db3bf806af2a632dc021e5f6
2022-01-26display: ColorBalance: Add support for non-linear native color spacesDanny Lin
On some devices and/or color modes, color transforms are applied in an "unmanaged" native color space, so apply a linear sRGB transformation matrix is wrong. It's not technically possible to implement accurate color balance in such cases, but attempt to accommodate it by assuming non-linear sRGB and applying the sRGB transfer function on the matrix. Change-Id: Ia786bf2468f29d729607ecc3f4a26305440717de
2022-01-26display: Improve matrix formatting for easier debuggingDanny Lin
Change-Id: Ib806b91a1d838be86bb9095d1d5e2447aad37a5e
2022-01-26display: Create common chromatic adaptation tint controllerDanny Lin
Display white balance is not the only use case for chromatic adaptation and most of the code can be reused, so create a common tint controller class for chromatic adaptation. Change-Id: Ia5edba7669e44720bc98b7542654cda44de4bc74
2022-01-26display: Use CAT16 for display white balance transformDanny Lin
CAT16 is a successor to CIECAT02 (and the Bradford transform in CIECAM97s by extension). Switch to CAT16 for calculating the DWB chromatic adaptation matrix in order to improve color results. Change-Id: I11d598b38c1b50e89e0958827d10a9bd17b1b81d
2022-01-26graphics: Add CAT16 sensor space for chromatic adaptationDanny Lin
This is a newer CAT defined in CAM16 [1], which is a successor to CIECAM02. We'll use this to improve display color transforms in following commits. [1] https://onlinelibrary.wiley.com/doi/abs/10.1002/col.22131 Change-Id: Id660763547acbede226a135c5fc55f64b2486652
2022-01-26display: Add simple RGB color balance transformDanny Lin
This adds support for adjusting the display's RGB color balance globally via ColorDisplayManager. This is implemented as a simple color transformation matrix that scales each channel. The effect is similar to LineageOS' LiveDisplay feature, but being a native color transform, it doesn't require changes to native code, SELinux policies, or custom HALs. Change-Id: Ia7ce363e3042ecfae438e452dbf155811a6bedeb
2022-01-26display: Make Night Light transition more gradualDanny Lin
At 3 seconds long, the transition is a bit too sharp when Night Light is set to max intensity. 10 seconds is less jarring when the feature automatically turns on and off at scheduled times. Change-Id: Ie60c7d41d523f0c14aae37219ef7c75f49390e8b
2022-01-26PackageInfo: Optimize ApplicationInfo creationDanny Lin
When opening and closing activities in Settings, a significant amount of CPU time is spent in ART interface method call trampolines, as reported by simpleperf: 0.32% /apex/com.android.art/lib64/libart.so art_quick_imt_conflict_trampoline PackageInfoWithoutStateUtils is responsible for a substantial portion of the time: 0.34% 0.24% /apex/com.android.art/lib64/libart.so art_quick_imt_conflict_trampoline | -- art_quick_imt_conflict_trampoline | |--5.48%-- android.content.pm.parsing.PackageInfoWithoutStateUtils.appInfoFlags | com.android.server.pm.parsing.pkg.PackageImpl.toAppInfoWithoutState | android.content.pm.parsing.PackageInfoWithoutStateUtils.generateApplicationInfoUnchecked | com.android.server.pm.parsing.PackageInfoUtils.generateApplicationInfo | | | |--33.53%-- com.android.server.pm.parsing.PackageInfoUtils.generateActivityInfo | | | | | |--76.24%-- com.android.server.pm.ComponentResolver$ActivityIntentResolver.newResult To avoid the overhead of calling methods through interfaces, opportunistically cast ParsingPackageRead objects to the real implementation and access fields directly on it. This isn't pretty, but it reduces the CPU time wasted on interface method calls. Test: simpleperf record -a; verify that PackageInfoWithoutStateUtils.appInfoFlags no longer appears under art_quick_imt_conflict_trampoline Change-Id: I475ba804c61739c7537e664b09973665f001270b
2022-01-26LayoutInflater: Opportunistically create views directly for performanceDanny Lin
When opening and closing activities in Settings, a significant amount of CPU time is spent performing JNI calls, as reported by simpleperf: 0.39% /system/framework/arm64/boot-framework.oat art_jni_trampoline Reflection in LayoutInflater is responsible for a significant portion of the time spent in the JNI trampoline: 6.08% 0.08% /apex/com.android.art/javalib/arm64/boot.oat art_jni_trampoline | -- art_jni_trampoline | |--12.38%-- java.lang.reflect.Constructor.newInstance | |--0.09%-- [hit in function] | | | |--88.32%-- android.view.LayoutInflater.createView | | | | | |--83.39%-- com.android.internal.policy.PhoneLayoutInflater.onCreateView | | | android.view.LayoutInflater.onCreateView | | | android.view.LayoutInflater.onCreateView | | | android.view.LayoutInflater.createViewFromTag | | | | | | | |--72.73%-- android.view.LayoutInflater.rInflate | | | | | | | | | |--57.90%-- android.view.LayoutInflater.rInflate | | | | | | | | | | | |--94.90%-- android.view.LayoutInflater.inflate | | | | | | android.view.LayoutInflater.inflate | | | | | | |--35.86%-- [hit in function] | | | | | | | | | | | | | |--58.15%-- androidx.preference.PreferenceGroupAdapter.onCreateViewHolder Empirical testing of interacting with ~113 real-world apps reveals that many of the most frequently-inflated views are framework classes: 13486 android.widget.LinearLayout 6930 android.widget.View 6447 android.widget.FrameLayout 5613 android.widget.ViewStub 5608 androidx.constraintlayout.widget.ConstraintLayout 4722 android.widget.TextView 4431 com.google.android.material.textview.MaterialTextView 3570 eu.faircode.email.FixedTextView 3044 android.widget.ImageView 2665 android.widget.RelativeLayout 1694 android.widget.Space 979 androidx.preference.internal.PreferenceImageView 926 androidx.appcompat.view.menu.ActionMenuItemView 884 androidx.appcompat.widget.AppCompatImageView 855 slack.uikit.components.icon.SKIconView 770 android.widget.ProgressBar 743 com.fastaccess.ui.widgets.FontTextView 541 androidx.recyclerview.widget.RecyclerView 442 androidx.appcompat.widget.AppCompatTextView 404 org.mariotaku.twidere.view.MediaPreviewImageView 393 com.moez.QKSMS.common.widget.QkTextView 382 android.widget.Button 365 slack.widgets.core.textview.ClickableLinkTextView 365 slack.uikit.components.avatar.SKAvatarView 352 com.google.android.libraries.inputmethod.widgets.SoftKeyView 351 com.android.launcher3.BubbleTextView 315 slack.widgets.core.viewcontainer.SingleViewContainer 315 slack.widgets.core.textview.MaxWidthTextView 313 androidx.constraintlayout.widget.Barrier 302 slack.app.ui.widgets.ReactionsLayout 302 slack.app.ui.messages.widgets.MessageLayout 302 slack.app.ui.messages.widgets.MessageHeader 290 com.android.launcher3.views.DoubleShadowBubbleTextView 285 com.android.internal.widget.CachingIconView 265 android.widget.ImageButton 262 androidx.constraintlayout.widget.Guideline 249 org.thoughtcrime.securesms.components.emoji.EmojiTextView 234 com.google.android.libraries.inputmethod.widgets.AutoSizeTextView 232 com.android.internal.widget.RemeasuringLinearLayout 228 android.view.ViewStub 227 android.app.ViewStub 226 android.webkit.ViewStub 221 im.vector.app.core.ui.views.ShieldImageView 219 androidx.constraintlayout.widget.Group 214 androidx.coordinatorlayout.widget.CoordinatorLayout 204 androidx.appcompat.widget.ContentFrameLayout All framework classes seen: 13486 android.widget.LinearLayout 6930 android.widget.View 6447 android.widget.FrameLayout 5613 android.widget.ViewStub 4722 android.widget.TextView 3044 android.widget.ImageView 2665 android.widget.RelativeLayout 1694 android.widget.Space 770 android.widget.ProgressBar 382 android.widget.Button 265 android.widget.ImageButton 228 android.view.ViewStub 227 android.app.ViewStub 226 android.webkit.ViewStub 145 android.widget.Switch 117 android.widget.DateTimeView 86 android.widget.Toolbar 68 android.widget.HorizontalScrollView 67 android.widget.ScrollView 65 android.widget.NotificationHeaderView 65 android.webkit.NotificationHeaderView 65 android.view.NotificationHeaderView 65 android.app.NotificationHeaderView 63 android.webkit.View 63 android.view.View 62 android.app.View 58 android.widget.ListView 50 android.widget.QuickContactBadge 40 android.widget.SeekBar 38 android.widget.CheckBox 16 android.widget.GridLayout 15 android.widget.TableRow 15 android.widget.RadioGroup 15 android.widget.Chronometer 13 android.widget.ViewFlipper 9 android.widget.Spinner 8 android.widget.ViewSwitcher 8 android.widget.TextSwitcher 8 android.widget.SurfaceView 8 android.widget.CheckedTextView 8 android.preference.PreferenceFrameLayout 7 android.widget.TwoLineListItem 5 android.widget.TableLayout 5 android.widget.EditText 3 android.widget.TabWidget 3 android.widget.TabHost 2 android.widget.ZoomButton 2 android.widget.TextureView 2 android.widget.ExpandableListView 2 android.webkit.TextureView 2 android.view.TextureView 2 android.app.TextureView 1 android.widget.WebView 1 android.widget.ViewAnimator 1 android.widget.TextClock 1 android.widget.AutoCompleteTextView 1 android.webkit.WebView 1 android.webkit.SurfaceView 1 android.view.SurfaceView 1 android.app.SurfaceView Unfortunately, replacing reflection with MethodHandle constructors is counter-productive in terms of performance: Constructor direct: create=5 invoke=42 Constructor reflection: create=310 invoke=433 Constructor MethodHandle: create=3283 invoke=3489 Constructor MethodHandle-exact: create=3273 invoke=3453 To reduce the performance impact of slow reflection, we can leverage the fact that the most frequently-inflated classes are from the framework, and hard-code direct constructor references for them in a switch-case block. Reflection will automatically be used as a fallback for custom app views. Test: simpleperf record -a; verify that Constructor.newInstance -> LayoutInflater no longer appears at the top under art_jni_trampoline Change-Id: I8fcc0e05813ff9ecf1eddca3cc6920e747adf4fc
2022-01-26SystemServiceRegistry: Replace ArrayMap with HashMap for performanceDanny Lin
When opening and closing activities in Settings, a significant amount of CPU time is spent looking up ArrayMap entries, as reported by simpleperf: 0.12% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes PackageManagerService is responsible for a significant portion of the time spent in ArrayMap lookups: 0.08% 0.08% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes | -- android.util.ArrayMap.binarySearchHashes | --50.00%-- android.util.ArrayMap.indexOf | |--36.71%-- android.util.ArrayMap.get | |--0.87%-- [hit in function] | | | |--5.42%-- android.app.SystemServiceRegistry.getSystemService | | android.app.ContextImpl.getSystemService | | android.view.ContextThemeWrapper.getSystemService | | android.app.Activity.getSystemService | | | | | |--52.18%-- TemporaryFile-kEdnnv[+9b97baa8] | | | TemporaryFile-FwF2he[+9b96d048] | | | art_quick_invoke_stub | | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | | art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*) | | | bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*) | | | MterpInvokeVirtual | | | mterp_op_invoke_virtual | | | libcrypto.so[+3fac6] | | | MterpInvokeDirect | | | mterp_op_invoke_direct | | | libcrypto.so[+3faa8] | | | MterpInvokeVirtual | | | mterp_op_invoke_virtual | | | libcrypto.so[+3730c] | | | art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.13341777805210357670) | | | artQuickToInterpreterBridge | | | art_quick_to_interpreter_bridge | | | java.util.concurrent.Executors$RunnableAdapter.call | | | java.util.concurrent.FutureTask.run | | | java.util.concurrent.ThreadPoolExecutor.runWorker | | | java.util.concurrent.ThreadPoolExecutor$Worker.run | | | java.lang.Thread.run | | | art_quick_invoke_stub | | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | | art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*) | | | art::Thread::CreateCallback(void*) | | | __pthread_start(void*) | | | __start_thread | | | | | --47.82%-- android.view.ContextThemeWrapper.getSystemService | | android.view.ContextThemeWrapper.getSystemService | | android.content.Context.getSystemService | | android.view.View.onVisibilityAggregated | | android.view.View.dispatchAttachedToWindow | | android.view.ViewGroup.dispatchAttachedToWindow | | android.view.ViewGroup.dispatchAttachedToWindow | | android.view.ViewGroup.dispatchAttachedToWindow | | android.view.ViewGroup.dispatchAttachedToWindow | | android.view.ViewGroup.dispatchAttachedToWindow | | android.view.ViewGroup.dispatchAttachedToWindow | | android.view.ViewGroup.dispatchAttachedToWindow | | android.view.ViewRootImpl.performTraversals | | android.view.ViewRootImpl.doTraversal | | android.content.ContextWrapper.getAssets [DEDUPED] | | android.view.Choreographer.doCallbacks | | android.view.Choreographer.doFrame | | android.view.Choreographer$FrameDisplayEventReceiver.run | | android.os.Handler.dispatchMessage | | android.os.Looper.loop | | android.app.ActivityThread.main | | art_quick_invoke_static_stub | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long) | | art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) | | art_jni_trampoline | | com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run | | com.android.internal.os.ZygoteInit.main | | art_quick_invoke_static_stub | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) | | art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list) | | art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list) | | _JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...) | | android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool) | | main | | __libc_init | | Empirical testing reveals that SYSTEM_SERVICE_FETCHERS contains 134 entries, at which HashMap is 54% faster than ArrayMap for lookups and 74% faster [1] for insertions. The increased memory usage should be a worthwhile trade-off at this size, so we can safely convert the map to a HashMap in order to improve performance in this hotpath. Because SYSTEM_SERVICE_NAMES, SYSTEM_SERVICE_FETCHERS, and SYSTEM_SERVICE_CLASS_NAMES have the same names and similar uses, all of them have been converted to HashMaps for consistency and performance. [1] https://docs.google.com/spreadsheets/d/136UJS2yVlZyPx30KDNgj4AWldkp9xbzIcWkLFj9RGgk/edit Test: simpleperf record -a; verify that SystemServiceRegistry no longer appears under ArrayMap.binarySearchHashes Change-Id: I2a5b23793a4fc8aa720eead3ecc7ca4589cb67da
2022-01-26InsetsStateController: Replace ArrayMap with HashMap for performanceDanny Lin
When opening and closing activities in Settings, a significant amount of CPU time is spent looking up ArrayMap entries, as reported by simpleperf: 0.12% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes InsetsStateController is responsible for a significant portion of the time spent in ArrayMap lookups: 0.08% 0.08% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes | -- android.util.ArrayMap.binarySearchHashes | --50.00%-- android.util.ArrayMap.indexOf | |--36.71%-- android.util.ArrayMap.get | |--0.87%-- [hit in function] | | | |--6.67%-- com.android.server.wm.InsetsStateController.peekSourceProvider | | | | | |--68.77%-- com.android.server.wm.DisplayPolicy.beginLayoutLw | | | com.android.server.wm.DisplayContent.performLayoutNoTrace | | | com.android.server.wm.DisplayContent.performLayout | | | com.android.server.wm.DisplayContent.applySurfaceChangesTransaction | | | com.android.server.wm.RootWindowContainer.applySurfaceChangesTransaction | | | com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace | | | com.android.server.wm.RootWindowContainer.performSurfacePlacement | | | com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop | | | com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement | | | com.android.server.wm.WindowManagerService.relayoutWindow | | | com.android.server.wm.Session.relayout | | | android.view.IWindowSession$Stub.onTransact | | | com.android.server.wm.Session.onTransact | | | android.os.Binder.execTransactInternal | | | android.os.Binder.execTransact | | | art_quick_invoke_stub | | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) | | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list) | | | art::JNI<false>::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) | | | _JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...) | | | JavaBBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | | android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | | android::IPCThreadState::executeCommand(int) | | | android::IPCThreadState::getAndExecuteCommand() | | | android::IPCThreadState::joinThreadPool(bool) | | | android::PoolThread::threadLoop() | | | android::Thread::_threadLoop(void*) | | | android::AndroidRuntime::javaThreadShell(void*) | | | thread_data_t::trampoline(thread_data_t const*) | | | __pthread_start(void*) | | | __start_thread | | | | | --31.23%-- com.android.server.wm.DisplayPolicy.updateHideNavInputEventReceiver | | com.android.server.wm.InsetsPolicy.updateBarControlTarget | | com.android.server.wm.DisplayPolicy.updateSystemUiVisibilityLw | | com.android.server.wm.DisplayPolicy.finishPostLayoutPolicyLw | | com.android.server.wm.DisplayContent.applySurfaceChangesTransaction | | com.android.server.wm.RootWindowContainer.applySurfaceChangesTransaction | | com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace | | com.android.server.wm.RootWindowContainer.performSurfacePlacement | | com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop | | com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement | | com.android.server.wm.WindowManagerService.postWindowRemoveCleanupLocked | | com.android.server.wm.WindowState.removeImmediately | | com.android.server.wm.WindowState.removeIfPossible | | com.android.server.wm.WindowState.removeIfPossible | | com.android.server.wm.WindowManagerService.removeWindow | | com.android.server.wm.Session.remove | | android.view.IWindowSession$Stub.onTransact | | com.android.server.wm.Session.onTransact | | android.os.Binder.execTransactInternal | | android.os.Binder.execTransact | | art_quick_invoke_stub | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list) | | art::JNI<false>::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) | | _JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...) | | JavaBBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | android::IPCThreadState::executeCommand(int) | | android::IPCThreadState::getAndExecuteCommand() | | android::IPCThreadState::joinThreadPool(bool) | | android::PoolThread::threadLoop() | | android::Thread::_threadLoop(void*) | | android::AndroidRuntime::javaThreadShell(void*) | | thread_data_t::trampoline(thread_data_t const*) | | __pthread_start(void*) | | __start_thread | | Empirical testing reveals that mProviders usually contains 9 entries, at which HashMap is 34% faster than ArrayMap for lookups and 57% faster [1] for insertions. The increased memory usage should be negligible at this size, so we can safely convert the map to a HashMap in order to improve performance in this hotpath. [1] https://docs.google.com/spreadsheets/d/136UJS2yVlZyPx30KDNgj4AWldkp9xbzIcWkLFj9RGgk/edit Test: simpleperf record -a; verify that InsetsStateController no longer appears under ArrayMap.binarySearchHashes Change-Id: Ic08d4c3e56cf10b322eabc115de441c6c5f4a898
2022-01-26LocalServices: Replace ArrayMap with HashMap for performanceDanny Lin
When opening and closing activities in Settings, a significant amount of CPU time is spent looking up ArrayMap entries, as reported by simpleperf: 0.12% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes LocalServices is responsible for a significant portion of the time spent in ArrayMap lookups: 0.08% 0.08% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes | -- android.util.ArrayMap.binarySearchHashes | --50.00%-- android.util.ArrayMap.indexOf | |--36.71%-- android.util.ArrayMap.get | |--0.87%-- [hit in function] | | | |--6.12%-- com.android.server.LocalServices.getService | | | | | |--42.41%-- com.android.server.inputmethod.InputMethodManagerInternal.get [DEDUPED] | | | com.android.server.wm.-$$Lambda$DisplayContent$-xtu90EUfC_AM8Qe5g8vDDI07_E.run | | | android.os.Handler.dispatchMessage | | | android.os.Looper.loop | | | android.os.HandlerThread.run | | | com.android.server.ServiceThread.run | | | art_quick_invoke_stub | | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | | art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*) | | | art::Thread::CreateCallback(void*) | | | __pthread_start(void*) | | | __start_thread | | | | | |--36.66%-- com.android.server.notification.NotificationManagerService.enqueueNotificationInternal | | | com.android.server.notification.NotificationManagerService.enqueueNotificationInternal | | | com.android.server.notification.NotificationManagerService$10.enqueueNotificationWithTag | | | android.app.INotificationManager$Stub.onTransact | | | android.os.Binder.execTransactInternal | | | android.os.Binder.execTransact | | | art_quick_invoke_stub | | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) | | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list) | | | art::JNI<false>::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) | | | _JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...) | | | JavaBBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | | android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | | android::IPCThreadState::executeCommand(int) | | | android::IPCThreadState::getAndExecuteCommand() | | | android::IPCThreadState::joinThreadPool(bool) | | | android::PoolThread::threadLoop() | | | android::Thread::_threadLoop(void*) | | | android::AndroidRuntime::javaThreadShell(void*) | | | thread_data_t::trampoline(thread_data_t const*) | | | __pthread_start(void*) | | | __start_thread | | | | | --20.93%-- com.android.server.oemlock.OemLockService.setPersistentDataBlockOemUnlockAllowedBit | | com.android.server.oemlock.OemLockService$2.isOemUnlockAllowed | | android.service.oemlock.IOemLockService$Stub.onTransact | | android.os.Binder.execTransactInternal | | android.os.Binder.execTransact | | art_quick_invoke_stub | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list) | | art::JNI<false>::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) | | _JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...) | | JavaBBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | android::IPCThreadState::executeCommand(int) | | android::IPCThreadState::getAndExecuteCommand() | | android::IPCThreadState::joinThreadPool(bool) | | android::PoolThread::threadLoop() | | android::Thread::_threadLoop(void*) | | android::AndroidRuntime::javaThreadShell(void*) | | thread_data_t::trampoline(thread_data_t const*) | | __pthread_start(void*) | | __start_thread Empirical testing reveals that sLocalServiceObjects usually contains 68 entries, at which HashMap is 47% faster than ArrayMap for lookups and 68% faster [1] for insertions. The increased memory usage should be negligible at this size, so we can safely convert the map to a HashMap in order to improve performance in this hotpath. [1] https://docs.google.com/spreadsheets/d/136UJS2yVlZyPx30KDNgj4AWldkp9xbzIcWkLFj9RGgk/edit Test: simpleperf record -a; verify that LocalServices no longer appears under ArrayMap.binarySearchHashes Change-Id: Ifd1f8b7940eba7723f93a73456470a84d34656ae
2022-01-26ThemedResourceCache: Replace ArrayMap with HashMap for performanceDanny Lin
When opening and closing activities in Settings, a significant amount of CPU time is spent looking up ArrayMap entries, as reported by simpleperf: 0.12% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes ThemedResourceCache is responsible for a significant portion of the time spent in ArrayMap lookups: 0.08% 0.08% /system/framework/arm64/boot-framework.oat android.util.ArrayMap.binarySearchHashes | -- android.util.ArrayMap.binarySearchHashes | --50.00%-- android.util.ArrayMap.indexOf | |--36.71%-- android.util.ArrayMap.get | |--0.87%-- [hit in function] | | | |--9.64%-- android.content.res.ThemedResourceCache.getThemedLocked | | android.content.res.ThemedResourceCache.get | | | | | |--77.92%-- android.content.res.DrawableCache.getInstance | | | android.content.res.ResourcesImpl.loadDrawable | | | android.content.res.Resources.loadDrawable | | | android.content.res.TypedArray.getDrawableForDensity | | | android.content.res.Resources.getColor [DEDUPED] | | | | | | | |--62.94%-- android.view.View.<init> | | | | | | | | | |--64.58%-- android.view.ViewGroup.<init> | | | | | android.widget.LinearLayout.<init> | | | | | android.widget.LinearLayout.<init> | | | | | art_quick_invoke_stub | | | | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | | | | art::InvokeConstructor(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::ObjPtr<art::mirror::Object>, _jobject*) | | | | | art::Constructor_newInstance0(_JNIEnv*, _jobject*, _jobjectArray*) | | | | | art_jni_trampoline | | | | | java.lang.reflect.Constructor.newInstance | | | | | android.view.LayoutInflater.createView | | | | | com.android.internal.policy.PhoneLayoutInflater.onCreateView | | | | | android.view.LayoutInflater.onCreateView | | | | | android.view.LayoutInflater.onCreateView | | | | | android.view.LayoutInflater.createViewFromTag | | | | | android.view.LayoutInflater.inflate | | | | | android.view.LayoutInflater.inflate | | | | | | | | | --35.42%-- android.widget.TextView.<init> | | | | android.widget.Button.<init> | | | | art_quick_invoke_stub | | | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | | | art::InvokeConstructor(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::ObjPtr<art::mirror::Object>, _jobject*) | | | | art::Constructor_newInstance0(_JNIEnv*, _jobject*, _jobjectArray*) | | | | art_jni_trampoline | | | | java.lang.reflect.Constructor.newInstance | | | | android.view.LayoutInflater.createView | | | | com.android.internal.policy.PhoneLayoutInflater.onCreateView | | | | android.view.LayoutInflater.onCreateView | | | | android.view.LayoutInflater.onCreateView | | | | android.view.LayoutInflater.createViewFromTag | | | | android.view.LayoutInflater.rInflate | | | | android.view.LayoutInflater.rInflate | | | | android.view.LayoutInflater.rInflate | | | | android.view.LayoutInflater.inflate | | | | android.view.LayoutInflater.inflate | | | | android.view.LayoutInflater.inflate | | | | | | | --37.06%-- com.android.internal.widget.ToolbarWidgetWrapper.<init> | | | | | --22.08%-- android.content.res.ConfigurationBoundResourceCache.get | | android.content.res.ConfigurationBoundResourceCache.getInstance | | android.content.res.ResourcesImpl.loadComplexColorFromName | | android.content.res.ResourcesImpl.loadColorStateList | | android.content.res.Resources.loadColorStateList | | android.content.res.TypedArray.getColorStateList | | android.widget.TextView.readTextAppearance | | android.widget.TextView.setTextAppearance | | android.widget.TextView.setTextAppearance | | android.widget.Toolbar.setTitle | | com.android.wifi.x.com.android.internal.util.StateMachine$SmHandler.handleMessage | | android.view.SurfaceControl.copyFrom Empirical testing reveals that mThemedEntries usually contains around 14 entries, at which HashMap is 35% faster than ArrayMap for lookups and 54% faster [1] for insertions. The increased memory usage should be negligible at this size, so we can safely convert the map to a HashMap in order to improve performance in this hotpath. [1] https://docs.google.com/spreadsheets/d/136UJS2yVlZyPx30KDNgj4AWldkp9xbzIcWkLFj9RGgk/edit Test: simpleperf record -a; verify that ThemedResourceCache no longer appears under ArrayMap.binarySearchHashes Change-Id: I39e1c4b03fe0e60f933f02e253d2d3c4a483146f
2022-01-26Trace: Disable debug tracing on production buildsDanny Lin
When opening and closing activities in Settings, a significant amount of CPU time is spent checking whether ATrace tags are enabled, as measured by simpleperf: 0.12% /system/lib64/libcutils.so atrace_get_enabled_tag android.os.Trace is responsible for a significant portion of the time spent in the checks: 0.10% 0.07% /system/lib64/libcutils.so atrace_get_enabled_tags | -- atrace_get_enabled_tags | | |--1.62%-- android.os.Trace.traceEnd | |--36.90%-- [hit in function] | | | |--29.76%-- android.view.Choreographer.doCallbacks | | android.view.Choreographer.doFrame | | android.view.Choreographer$FrameDisplayEventReceiver.run | | android.os.Handler.dispatchMessage | | android.os.Looper.loop | | android.os.HandlerThread.run | | com.android.server.ServiceThread.run | | art_quick_invoke_stub | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*) | | art::Thread::CreateCallback(void*) | | __pthread_start(void*) | | __start_thread | | | |--19.00%-- com.android.server.BatteryService$BatteryPropertiesRegistrar.getProperty | | android.os.IBatteryPropertiesRegistrar$Stub.onTransact | | android.os.Binder.execTransactInternal | | android.os.Binder.execTransact | | art_quick_invoke_stub | | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) | | art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list) | | art::JNI<false>::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) | | _JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...) | | JavaBBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) | | android::IPCThreadState::executeCommand(int) | | android::IPCThreadState::getAndExecuteCommand() | | android::IPCThreadState::joinThreadPool(bool) | | android::PoolThread::threadLoop() | | android::Thread::_threadLoop(void*) | | android::AndroidRuntime::javaThreadShell(void*) | | thread_data_t::trampoline(thread_data_t const*) | | __pthread_start(void*) | | __start_thread | | | --14.33%-- android.view.ViewRootImpl.performDraw | android.view.ViewRootImpl.performTraversals | android.view.ViewRootImpl.doTraversal | android.content.ContextWrapper.getAssets [DEDUPED] | android.view.Choreographer.doCallbacks | android.view.Choreographer.doFrame | android.view.Choreographer$FrameDisplayEventReceiver.run | android.os.Handler.dispatchMessage | android.os.Looper.loop | android.app.ActivityThread.main | art_quick_invoke_static_stub | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long) | art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) | art_jni_trampoline | com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run | com.android.internal.os.ZygoteInit.main | art_quick_invoke_static_stub | art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) | art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) | art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list) | art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list) | _JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...) | android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool) | main | __libc_init We're unlikely to trace the system and framework in production systems, so disable debug tracing in non-debuggable builds. The ro.debuggable check is performed from the Java side for simplicity. Test: simpleperf record -a; verify that android.os.Trace no longer appears under atrace_get_enabled_tags Change-Id: I9b63d386c041ffd9d7ff34ecd0ec1eb95dc03b4b