9b31c45731eb015cc3aba50735a3f0db3c43138f
When apps try to call factoryReset to do networking reset, it will result in updating the setting in SettingsProvider. ContentProvider will verify if the package name of the caller that initiated the request being processed on the current thread. The package should belong to the calling UID. The setting update started from the ConnectivityService context, so the package will be android but the calling UID will be the calling app. It will cause a SecurityException. The behavior is fine previously as its known caller(Settings) shares system UID. But it will be a problem for other callers, such as CTS. Thus, clear the identity since the necessary permission check should be examined at the top of the method. The following actions should be fine to be proceed from the system itself. Also replace the user restriction check via hasUserRestrictionForUser with the UserHandle created from the calling uid to ensure it's verified with correct user. Bug: 186061922 Test: Factory reset from Settings Merged-In: If2dd69f702a1eafff331f9e71f6b92aeadfb715d Change-Id: If2dd69f702a1eafff331f9e71f6b92aeadfb715d (cherry picked from commit 0b1b84179f10804a55561c0d6e0751efecf2c77a)
Description
android_packages_modules_Connectivity
Languages
Java
81.4%
Kotlin
7.7%
AIDL
4.5%
C++
4.5%
C
1.7%
Other
0.1%