summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-09-29Merge cherrypicks of [2986362] into oc-releaseandroid-8.0.0_r28oreo-releaseandroid-build-team Robot
Change-Id: Ieb07b20c6e8b0558dd7cf0a37aad58c2a19010e7
2017-09-29Revert "Prevent getting data from Clipboard if device is locked"Adam Seaton
This reverts commit 93d77b07c34077b6c403c459b7bb75933446a502. Change-Id: I3ab20d3de1cb1e5fa94fffb8b69683b7508a3503 (cherry picked from commit 4fd5096fffb5aba9cde567981e28558e31e86345)
2017-09-21Merge cherrypicks of [2940345, 2938007, 2940429, 2939599, 2939600, 2940430, ↵android-build-team Robot
2940431, 2940432, 2940433, 2939601, 2939602, 2940112, 2940113, 2940114, 2940115, 2940116, 2938720, 2938721, 2938722, 2938723, 2938724, 2939603, 2939604, 2939605, 2939608, 2938725, 2938008, 2940438, 2940439, 2938727, 2940549, 2940551, 2940553, 2938335, 2940555, 2940557, 2940440] into oc-release Change-Id: Ie06c6230ac8e634432378d685fb8e9cb5fad5a9a
2017-09-21disable carrier actions on redirection by defaultfionaxu
1. the assumption of "carrier will redirect users to their captive portal page when users dont have data plan" might not be true for all carriers. We have seem issues like carriers random redirect users when they still have balance left. 2. turn this off by default and turn it on if the carrier is behaving correctly and agree with it. Merged-in: I6bc2d8ba45958eaf09e09e3ea2e57c79e0ac461e Merged-in: I445c7bce01e0bf36214f5f4f6327a0582c774dae Bug: 65113738 Test: Manual Change-Id: I60be2de3aa227298e60ea7eb9535bad8967b1fe3 (cherry picked from commit 1aedcdd075cf770332e1d45dc4cf0cbbe130e6da)
2017-09-21Prevent getting data from Clipboard if device is lockedSiyamed Sinir
Clipboard should not return data if the device is locked. This CL checks for device locked state before returning values from get/has functions. Test: bit -t CtsContentTestCases:android.content.cts.ClipboardManagerTest Bug: 64934810 Change-Id: Icefac226615fe22a7735dff4ba4c3b528fb2ac12 (cherry picked from commit 93d77b07c34077b6c403c459b7bb75933446a502)
2017-09-21DPC should not be allowed to grant development permissionTony Mak
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --t com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPermissionGrant_developmentPermission Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --t com.android.cts.devicepolicy.MixedProfileOwnerTest#testPermissionGrant_developmentPermission Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --t com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPermissionGrant Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --t com.android.cts.devicepolicy.MixedProfileOwnerTest#testPermissionGrant Test: Run "Permissions lockdown" test in CtsVerifier Bug: 62623498 Merged-In: If83d8edd0eea99145421e967ae47fdc264a5cf7c Change-Id: I129bfe850981cf0b3646b7c1cf19c8a3ec69f512 (cherry picked from commit d05d2bac845048f84eebad8060d28332b6eda259)
2017-09-21Backport overlay security fixPhil Weaver
Replacing app opps fix with the flag that is used elsewhere. Bug: 37442941 Test: Verified that toast and system overlay still goes away on permission and a11y service capability screens. Merged-In: I1a3e3c5b1696a5f5b95eac187acb5a03863b4a0b Change-Id: If9bec515105369055415d54c7fcad7a65431f8e7 (cherry picked from commit c510ecb3ec0eeca5425f5bc96fae80ea56f85be6)
2017-08-22Merge cherrypicks of [2775115, 2774970, 2775080, 2774971, 2775063, 2775066, ↵android-8.0.0_r13android-build-team Robot
2775357, 2775358, 2774351, 2774352, 2774797, 2774798, 2775359, 2775360, 2775361, 2775362, 2775363, 2774972, 2774973, 2774974, 2774975, 2774976, 2774977, 2774978, 2775397, 2774353, 2774354, 2774355, 2774907] into oc-release Change-Id: I670e7e2b804b5042c00f816d4cff4f52e0937227
2017-08-22Fix race condition of removing surface.Seigo Nonaka
mContainer.startingSurface can be replaced between posting mRemoveStartingWindow and actually surface.remove() is called. 1. removeStartingWindow is called, then mRemoveStartingWindow is posted to mHandler 2. transferStartingWindow is called, then mContainer.startingWindow is replaced with new surface. 3. mHandler pops the callback and surface.remove() is called. Here the remove is only called for replaced surface and never called for older surface. To fix this issue, surely removes the surface when the removeStartingWindow is called. Bug: 63156080 Bug: 63784898 Test: Watch /proc/<pid>/fd Change-Id: Iccf13bdc98b4012168910305568f5dd4bbedbf54 Merged-In: I55e2c1b8fba32b3a19603e6ad4743f07576abd48 (cherry picked from commit 0bf3dc9822a4817b1fea1d819ab7abf61013ad8b)
2017-08-22Fix security hole in GateKeeperResponse.Charles He
GateKeeperResponse has inconsistent writeToParcel() and createFromParcel() methods, making it possible for a malicious app to create a Bundle that changes contents after reserialization. Such Bundles can be used to execute Intents with system privileges. This CL changes writeToParcel() to make serialization and deserialization consistent, thus fixing the issue. Bug: 62998805 Test: use the debug app (see bug) Change-Id: Ie1c64172c454c3a4b7a0919eb3454f0e38efcd09 (cherry picked from commit e74cae8f7c3e6b12f2bf2b75427ee8f5b53eca3c)
2017-08-22Enforce policy for camera gesture in keyguardEsteban Talavera
If the admin has disabled the camera for secure keyguards, in addition to removing the bottom-right hand corner camera button do not allow the camera to be opened via the camera gesture either. Bug: 63334090 Merged-In: I104688eaad719528376e2851f837d5956a6a1169 Test: Manually tested launching the camera on secure and non-secure keyguard and non-keyguard, both via camera icon and gesture Change-Id: I104688eaad719528376e2851f837d5956a6a1169 (cherry picked from commit 98ec92375d75630c10595bfcbae184ad7350e2d3)
2017-08-22Fix BLE scan leaksVinay Kalia
If an app starts multiple scans with same callback then there is a collision in mLeScanClients hash map which results in leaking first scan. This change fixes it by not allowing the second scan with same callback. BUG: 62389939 BUG: 38198694 Test: Tested applications which started multiple scans with same callback. Change-Id: I569069a40b6f8b4b8bb070731225e732c6b23ec8 (cherry picked from commit 9722971cb4a79e37165f636f9dd057707d2e620a) (cherry picked from commit c2fd144218d035f45e7063134f4c644a1dc36535)
2017-08-22Improve AVRCP quality and state handling (2/2)Ajay Panicker
Bug: 64749777 Test: Play music with various car kits and see that metadata shows up See go/oc-avrcp-sotu - 8/15/20 OC + Patches for further info Change-Id: I58c9dd0bf976485a2efefd042cd667ee433e07e1 (cherry picked from commit 2a9eef7a3be53cb8da1e6e4f394062d0301474a3)
2017-08-22power: throttle interaction hintsTim Murray
Don't send power HAL interaction hints more than every 100ms. Also can send userActivity calls every 100ms too (down from 500ms). Test: power HAL doesn't run every 8ms Bug: 63632697 Change-Id: Ic986f6fc51e58f8060f7bf2d2ac61a9906be5c1f (cherry picked from commit c203016b590230092d1385fdeac5a3a7d3206e33)
2017-08-22Fix nomanservice notificationrecord leakJulia Reynolds
Test: runtest systemui-notification Change-Id: Ic5761b917edd000bf73b3291b0ca95bbb0b9bedb Fixes: 63585648 (cherry picked from commit 080361ee313c4eae07ca1d17edafb371672fc76e) (cherry picked from commit 61e1f496e86ae94fc522b421afc0ac8c695afc2d)
2017-08-17Merge cherrypicks of [2749914] into oc-releaseandroid-8.0.0_r7android-build-team Robot
Change-Id: I6d252bf421bf47f64c640599abfb08389fe40b86
2017-08-17Properly compute default and system set flag on an upgradeSvetoslav Ganov
We added the notions of a default value and whether this default is set by the system for a setting which is needed for experiments since in case a bad value is pushed we should be able to incrementally rollback to a stable state. If a system component sets a setting value this automatically becomes the default. System components are the platform package, the special UIDs (telephony, etc), apps singed with the platform cert, system installed persistent apps, and SUW. In N we did not have the notion of a default and during an upgrade need to adjust the default and whether this default is set by the system. This migration runs as the system UID and was incorrectly computing that the package that changed the settings last was a part of the system and setting the current value as its default set by the system. This resulted in taking more storage space as we also count the default which led the package which changed the setting to go over the quota and that throws. If the first caller into the settings provider is the system main thread (almost certain) we end up throwing an exception on the system main thread - crashing the system server. Test: flash N, install an app abusing sys settings, update to O Merged-In:I8e2c578cb564b2bc2de7c793eb40dea2639fa04e bug:64718888 Change-Id: I82f0d52fd7984fb2d0da1fd91399a0c914dfa24b (cherry picked from commit eb1936cb98a25a437ce90ebdbdc6f09a96e7d6a9)
2017-07-29Merge cherrypicks of [2627701] into oc-releaseandroid-build-team Robot
Change-Id: I13dba40107ad2acef7dbe717fcd01f39dbc9ad49
2017-07-29Add a missing null checkSvet Ganov
Test: manual bug::62755026 Change-Id: Icf719d0e62986febd4d31f22be3e59d83c8e6e09 (cherry picked from commit 0ae9570c9925603a04d5a78775a68cc9d437542b)
2017-07-28Merge cherrypicks of [2624661, 2624224] into oc-releaseandroid-build-team Robot
Change-Id: I37c6e10bca102f2cea44717868c3aac4267ad02e
2017-07-28Handle case for missing permissions - fix NPESvet Ganov
Test: manual Bug:62755026 Change-Id: Ie4dddffdb055f6084d9420ae94d0de2a61574bd8 (cherry picked from commit 39cc33f192d528f250818446ea0418aaf0cfe41f)
2017-07-28Merge cherrypicks of [2622852, 2622193, 2622194, 2622195, 2622933, 2622990, ↵android-build-team Robot
2622991, 2622992, 2622993, 2622994, 2622995, 2622934, 2622196, 2622975, 2622996, 2622997, 2622998, 2623050, 2622935, 2622197, 2623051, 2622936, 2622918, 2622919, 2622999] into oc-release Change-Id: I797b38442045e5165db55d70617201e8338bc5cc
2017-07-28Report permission flags for all protections based on SDKSvetoslav Ganov
We added a couple of protection flags that also apply to normal and dangerous permissions. These flags are folded in the protection level breaking apps that directly and compare against the protection constants. Apps that target older than O SDK don't get protection flags folded into the protection level. Test: All permission tests pass Added a new test to ensure no protection flags reported for normal and dangerous permissions Change-Id: I87b10a7695d8ecfa7156525d6f3d101fc0639513 bug:62755026 (cherry picked from commit adb8c522a84b5c7531b009b7a8d4c854ca7dee08)
2017-07-28Import translations. DO NOT MERGEBill Yi
Change-Id: I640b8c920e55d419bd52e767ff15764d0921ae08 Auto-generated-cl: translation import Exempt-From-Owner-Approval: translation import (cherry picked from commit d6d188b8271ef850f8806029a4349c1aa65f012c)
2017-07-28Import translations. DO NOT MERGEBill Yi
Change-Id: I8e7ec46b61a5122fbd12d08160c2be3144d4f561 Auto-generated-cl: translation import Exempt-From-Owner-Approval: translation import (cherry picked from commit 23a34a9e686f6fe20d6d22da2b3481dc5de9d5ad)
2017-07-28Import translations. DO NOT MERGEBill Yi
Change-Id: Ic3a619349e2cd79fb5b26a442557df0f0d423798 Auto-generated-cl: translation import Exempt-From-Owner-Approval: translation import (cherry picked from commit 76d4743aeb6c97cb95d7546744b78ca31df40be4)
2017-07-28Import translations. DO NOT MERGEBill Yi
Change-Id: Ibb7718de71cfc02a3160d536cf1ab46cb10c925c Auto-generated-cl: translation import Exempt-From-Owner-Approval: translation import (cherry picked from commit 21e57f60fdd6c4581c9655e6cd1931b2b2118d89)
2017-07-07Merge cherrypicks of [2507192] into oc-releaseandroid-cts-8.0_r1android-build-team Robot
Change-Id: I056e9eb24334d18b675c71d452f521973c4a82ed
2017-07-07SurfaceView: Avoid initializing Surface from an invalidRobert Carr
SurfaceControl. In a recent CL we introduced a call to Surface#createFrom, in order to recreate the Surface object from the underlying SurfaceControl, as a workaround to emulate when it was parcelled over binder in the past. However this is causing BufferQueue abandoned errors when stopping and resuming some applications. To understand them, we need to revisit the SurfaceView destruction process when handling onStop. First mWindowStopped will be set to true (SurfaceView#windowStopped), and we should then enter updateSurface. Our requested visibility will now be false and so we emit the Surface destroyed callbacks. Notice in the finally block in mUpdateSurface, we will release mSurface, but we will NOT null mSurfaceControl. Inline documentation explains why. In the case that the activity is not actually being destroyed, it's possible that we may not get a dispatchDetachedFromWindow. This means that we will not null mSurfaceControl. Now if the activity is un-stopped and we re-enter updateSurface we encounter a problem state. "creating" will be set to false since mSurfaceControl != null, however mSurfaceControl will not point to a valid surface. Prior to the introduction of the #createFrom call, this unwanted state didn't cause any problems. Because mSurface was released back in the finally block as we were stopping we now fall out of the mSurface.isValid() block in updateSurface. As we reach the finally block again, we would now set mSurfaceControl=null since the app was no longer stopped. Later when we reach updateSurface again (which tends to happen quite often) it will now be null and we will correctly set creating=true, create a valid SurfaceControl, and move along happily. However following, the introduction of this Surface#createFrom call we will now reinitialize the Surface from an invalid underlying SurfaceControl. This means we will enter the mSurface.isValid block, but will proceed to emit an invalid Surface to the client in the callbacks. We avoid this state by making creating=true even if SurfaceControl=non-null when the calculated visibility changes from invisible to visible. Bug: 63251745 Test: Manual of app from bug and apps from previous related bugs. go/wm-smoke. Additional manual testing of many SV apps. Change-Id: Icc32a34cac239d65267da705cc23feb23e1ceb67 (cherry picked from commit 7c67b7d097bbf4a32e7b97689f97139a4b71007b)
2017-07-03Merge cherrypicks of [2489285, 2489286, 2489323, 2489399, 2489257, 2489326] ↵android-build-team Robot
into oc-release Change-Id: I0a71668cc1c1238ce5b82f282c2f7be155ef2f9f
2017-07-03Send disable messages when Bluetooth is disallowedMyles Watson
Bug: 63021124 Test: cts-tradefed run commandAndExit cts \ -m CtsDevicePolicyManagerTestCases \ -t com.android.cts.devicepolicy.DeviceOwnerTest#testBluetoothRestriction Change-Id: I0ef538a4d0f0632ce303b29595ac1cab3b7d29ce (cherry picked from commit 6291fae58543e69901fb55398d560ce3cd3878b3)
2017-06-30Merge cherrypicks of [2481491, 2481800, 2481782, 2481665, 2481547, 2481358, ↵android-build-team Robot
2481802, 2481613, 2481668, 2481614, 2481594, 2481595, 2481548, 2481744, 2481493, 2481494, 2481709] into oc-release Change-Id: Ie9bbb629b1cc534f289d3bb3e649cc4e0c0f0c97
2017-06-30docs: Updated isAutofillSupported description.Ricardo Loo
The description for `AutofillManager.isAutofillSupported` doesn't make clear that either the device or the user can make autofill unsupported. Bug: 62604325 Test: Ran 'make ds-docs -j16' and staged content to go/dac-stage/reference/android/view/autofill/AutofillManager.html#isAutofillSupported() Change-Id: I298b9f535e23dc3cb54fabed36642523753c13a5 (cherry picked from commit 33d226c95333e40e8b46e173c2483ad6728b5e56)
2017-06-30Add docs for new padding/margin attributes.Chet Haase
The attributes for View, paddingHorizontal and paddingVertical, were added in the O release and are documented in R.attr. But they should also be referenced in View itself, alongside the other padding parameters. Similarly, the new layout_MarginHorizontal and layout_marginVertical should be referenced in ViewGroup.MarginLayoutParams. Bug: 63128350 Add docs about new padding/margin params Test: built docs, checked the result Change-Id: I3021df5ea83c469811b4a6ec6ecd3ab2966ec384 (cherry picked from commit 353d397d17c2224540cfe7fa4e33a1b0b4d3490f)
2017-06-30Prevent unwanted keypress actions during TV Setup.Sujith Ramakrishnan
- Prevent Search or long-press Home actions while TV setup is being completed based on flag TV_USER_SETUP_COMPLETE. Test: Manual - Reset device, ran Setup, tried keys. Test: Manual - Rebooted device after Setup, tried keys. Bug: 62419382 Change-Id: Ic8fb0f10943ab7c39a7d9857f62e6ab292231b40 (cherry picked from commit 0390fff82c37c705670a6c8937c11b52e2af4cb6)
2017-06-29Merge cherrypicks of [2476230, 2476289, 2476272, 2476118, 2475997, 2476251, ↵android-build-team Robot
2476119, 2476341, 2476252, 2476290, 2476232, 2476274, 2475999, 2476343, 2476275, 2476216, 2476381, 2476256, 2476000, 2476362, 2476345, 2476364, 2476234, 2476346, 2476347, 2476365, 2476276, 2476219, 2476277, 2476402, 2476348, 2476235, 2476383, 2476257, 2476278, 2476236, 2476350, 2476351, 2476307, 2476403, 2476308, 2476258] into oc-release Change-Id: I3e45afab5b6c2e2a29e60638c33d090b368c4424
2017-06-29Further restrict activity launch on virtual displaysAndrii Kulian
Only callers with INTERNAL_SYSTEM_WINDOW permission can launch an activity to a virtual display. Bug: 63094482 Test: android.server.cts.ActivityManagerDisplayTests Change-Id: I3f618fcbf3c07e5085e2b43b0f038f240df0c9d3 (cherry picked from commit 3a95edc0f51dbef8fbe7b3afa731f482454537c3)
2017-06-29Disable requestVisibleBehind.Robert Carr
As there is no caller for the SystemAPI convertToTranslucent, there is no situation where requestVisibleBehind will actually result in the activity becoming visible behind. However we have bugs in the requestVisibleBehind code-path, so rather than fix them...it seems better to just prevent ourselves from running in to them. Full deletion of the code-path is scheduled for post-O branches. Change-Id: I6e7c79e036986564d2d443a603e63c341de23057 Fixes: 62512584 Test: Repro from bug. go/wm-smoke. (cherry picked from commit 8661c5e519ef0f5ab2122f8280364d8e90caedf7)
2017-06-29[Companion] Dont crash if started with bluetooth offEugene Susla
Bug: 63068644 Test: Turn BT off, and ensure the attached bud doesn't reproduce Change-Id: I0de5ba6d28d7195dd3ebc7a3af36f057c762de60 (cherry picked from commit 7a090a11ed00aa492684800de890f4df633409d8)
2017-06-29Selectively disable filtering if estimated safeJohn Reck
If the output matches the source rect then use GL_NEAREST instead of GL_FILTER. This is a more pixel-exact capture. Bug: 38242146 Test: CtsUiRendering & CtsViewTestCases:.PixelCopyTest passes on fugu Change-Id: I9f57a4124374568f83d45fdc8f83cc767ded888a (cherry picked from commit 7bf96a0a6f4824f2d15ec95249b8ff038fe02239)
2017-06-29Properly check for orientation mismatchJorim Jaggi
Previous check tested against the display, which is wrong. Now we properly check against the configuration. Test: go/wm-smoke Test: Enter split screen, go home, launch app, go home, relaunch app, ensure no splash screen shown Test: Enter split screen with 2 apps, lock phone, unlock phone Change-Id: I62d45b6d3e5aa91dcb5edffed4233a5fed7ac9aa Fixes: 63075521 (cherry picked from commit 1dda7a62a20c247fe97f5791dc2a199a3723c3bd)
2017-06-29Fix empty signal line thickness / color in status barEvan Laird
Parameterize the line thickness to the height of the drawable. Also draw the empty state as background signal instead of foreground. Test: visual Change-Id: I39a7ef3164b784008e3dba5284b7fe83e4666607 Fixes: 63097113 (cherry picked from commit 718b4753f58f5019a8b622f0ef29483065f3cca6)
2017-06-29Don't break key event stream when enabling a11yPhil Weaver
Bug: 62862624 Test: Enable magnification, then enable TalkBack with the a11y shortcut. Verify that volume keys work. A11y service CTS, a11y units tests. Change-Id: I729ab17d24f758b5ce534ffde43d2126a1f9536c (cherry picked from commit 6b5cde5f256fe75acbfda1b447dc6230753700ca)
2017-06-29Restrict launching activities on virtual displaysAndrii Kulian
If an app creates a Surface and a virtual display backed by that Surface, it can then launch activities and hijack their content. This CL restrict activities that can be launched to virtual displays created by apps only to those who set "allowEmbedded" attribute. If a virtual display was created by system, apps won't get access to the surface, so we're not limiting in this case. Bug: 63094482 Test: android.server.cts.ActivityManagerDisplayTests Test: #testLaunchNotEmbeddedOnVirtualDisplay Change-Id: Ied216bdf33df4b5a6cc8cac0e006a4883a36f94f (cherry picked from commit 1cba31c3dc307a8629d32434bd5846a0097c240a)
2017-06-29If the menu hasn't been created yet don't do things with itMady Mellor
Test: runtest systemui Fixes: 62594598 Change-Id: I1050e2b2bf1ece960d19ad13cb6a9bf71512db57 (cherry picked from commit 0b3f004acbb0eef38ee5e8d920e934f7ab2f7cde) (cherry picked from commit 104be2e0196fec5198b866834d19a26e938d4afc)
2017-06-29Use content type specified on the command lineTodd Kennedy
Bug: 62914247 Test: Manual; query before change and no intents resolved. query after and intent resolved. Test: sample query command: adb shell cmd package query-activities -a android.intent.action.OPEN_DOCUMENT -c android.intent.category.OPENABLE -t \\*/\\* Change-Id: Ieadb15bcdebeff01e9b8075932417ba5585de16e (cherry picked from commit 0e2a75d96d1deab417a7a32fc4007fd7d8057ebf)
2017-06-27Merge cherrypicks of [2467803, 2467786, 2467717, 2467598, 2467823, 2467734, ↵android-build-team Robot
2467671, 2467718, 2467599, 2467753, 2467672, 2467600, 2467735, 2467841, 2467638, 2467824, 2467736, 2467754, 2467737, 2467674] into oc-release Change-Id: Id09e872fb1d3bb98329812eecb69e201e95698d6
2017-06-27Fix an NPE when cancelling full backup in BMS#endFullBackup()Michal Karpinski
Bug: 63000171 Test: it's just a nullcheck that compiles Change-Id: I90faa5577f2fd656bb4f7b6af39494590a77e3bf (cherry picked from commit 077d6371931dcefeb882a694524753c24bed3313)
2017-06-27Supress roaming indications during a carrier network change.Shishir Agrawal
Change-Id: Ib39d229b67374c4ca30c3a2c8c3b0050106733cd Fixes: 62795179 Test: NetworkControllerSignalTest (cherry picked from commit ecbb1f60f0558e894a82c59d3f94370370f991b3)
2017-06-27Fix deadlock in NetworkLoggingHandlerKenny Guy
Stop NetworkLoggingHandler holding a lock when calling back into DevicePolicyManagerService. Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithSingleUser Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithTwoUsers Bug: 62966480 Change-Id: I41c3edca8922008a9d838d71ddcc50883699bc74 (cherry picked from commit 08a8783c56539b4a990a8c95d7f5011a263848b8)