Fix getUserIdFromUri() call for checkUriPermissions
checkUriPermissions is an API to check Uri permissions on a list of Uris. This is an optimisation over calling checkUriPermission separately for each Uri in the list as each call is a binder call. The bug is caused due to getContext.checkUriPermissions() for User 10 calling into ActivityManagerService(AMS) for User 0. The old APIs (checkUriPermission for 1 Uri) resolves the user one step before calling into AMS that is in ContextImpl class. But resolving the calling user via context in AMS is not resolving the actual user (in this case the calling user is user 10, and AMS context resolves the userId to User 0). Resolving the user in AMS was a conscious decision we made as we wanted to resolve the user for each uri in the list separately. Fixed the above issue by passing userId to AMS from ContextImpl and then resolving the user for each uri. Bug: 194700183 Test: atest --user-type secondary_user CtsScopedStorageDeviceOnlyTest:android.scopedstorage.cts.device.RedactUriDeviceTest#testSharedRedactedUri_openFileForRead -c Change-Id: Ia4f0ba39a34c8ae4bd46d6f10bca1052f1331400
Loading
Please register or sign in to comment