summaryrefslogtreecommitdiff
path: root/packages/SettingsProvider/src/com/android/providers/settings/SettingsService.java
Commit message (Collapse)AuthorAgeFilesLines
* Runtime permission attribution improvementsSvet Ganov2021-03-291-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an app is proxying access to runtime permission protected data it needs to check whether the calling app has a permission to the data it is about to proxy which leaves a trace in app ops that the requesting app perofmed a data access. However, then the app doing the work needs to get the protected data itself from the OS which access gets attributed only to itself. As a result there are two data accesses in app ops where only the first one is a proxy one that app A got access to Foo through app B - that is the one we want to show in the permission tracking UIs - and one for the data access - that is the one we would want to blame on the calling app, and in fact, these two accesses should be one - that app A accessed Foo though B. This limitation requires fragile one off workarounds where both accesses use the same attribution tag and sys UI has hardcoded rules to dedupe. Since this is not documented we cannot expect that the ecosystem would reliably do this workaround in apps that that the workaround in the OS would be respected by every OEM. This change adds a mechaism to resolve this issue. It allows for an app to create an attribution context for another app and then any private data access thorugh this context would result in a single app op blame that A accessed Foo though B, i.e. we no longer have double accounting. Also this can be nested through apps, e.g. app A asks app B which asks app C for contacts. In this case app B creates an attribution context for app A and calls into app C which creates an attribution context for app B. When app C gets contacts the entire attribution chain would get a porper, single blame: that C accessed the data, that B got the data from C, and that A got the data form B. Furthermore, this mechanism ensures that apps cannot forget to check permissions for the caller before proxying private data. In our example B and C don't need to check the permisisons for A and B, respectively, since the permisisons for the entire attribution chain are checked before data delivery. Attribution chains are not forgeable preventing a bad actor to create an arbitrary one - each attribution is created by the app it refers to and points to a chain of attributions created by their corresponding apps. This change also fixes a bug where all content provider accesses were double counted in app ops due to double noting. While at this it also fixes that apps can now access their own last ops. There was a bug where one could not pass null getting the attributed ops from a historical package ops while this is a valid use case since if there is no attribution everything is mapped to the null tag. There were some app op APIs not being piped thorough the app ops delegate and by extension through the app ops policy. Also now that we have nice way to express the permission chain in a call we no longer need the special casing in activity manager to handle content provider accesses through the OS. Fixed a bug where we don't properly handle the android.os.shell calls with an invlaid tag which was failing while the shell can do any tag. Finally, to ensure the mechanims is validated and works end-to-end we are adding support for a voice recognizer to blame the client app for the mic access. The recognition service can create a blaming context when opening the mic and if the mic is open, which would do all permission checks, we would not do so again. Since changes to PermissionChercker for handling attribution sources were made the CL also hooks up renounced permissoins in the request permission flow and in the permission checks. bug:158792096 bug:180647319 Test:atest CtsPermissionsTestCases atest CtsPermissions2TestCases atest CtsPermissions3TestCases atest CtsPermissions4TestCases atest CtsPermissions5TestCases atest CtsAppOpsTestCases atest CtsAppOps2TestCases Change-Id: Ib04585515d3dc3956966005ae9d94955b2f3ee08
* Note with featureId from ContentProviderPhilip P. Moltmann2019-10-291-5/+5
| | | | | | | | | | | | | | | | | | This takes the Context#getFeatureId from the calling context and pipes it all way through to the noteOp calls done by the content provider. Bug: 136595429 Test: atest CtsAppOpsTestCases (new test added to capture this case) TelecomUnitTests:CallLogManagerTest ContentProviderClientTest TelecomUnitTests:MissedCallNotifierImplTest TelecomUnitTests:BasicCallTests MediaInserterTest PreferencesHelperTest RankingHelperTest PinnedSliceStateTest FrameworksCoreTests:ContentResolverTest Change-Id: I53b1035626229c920b353509a5bece157b52fb51
* Extract common methods into ContentInterface.Jeff Sharkey2018-12-081-7/+9
| | | | | | | | | | | | | | | | | | | | | | Existing APIs that accept a ContentResolver are too restrictive when the caller has their own ContentProviderClient already bound and configured, so we're in the market for a solution to open those existing APIs to accept a wider range of inputs. The solution we've come up with is to introduce a super-interface which contains the common ContentProvider APIs, and then make ContentProvider, ContentResolver, and ContentProviderClient all implement that interface for consistency. After this change lands, we can then safely relax existing APIs to accept this new ContentInterface, offering a clean path to solving the problem outlined above. Bug: 117635768 Test: atest android.content.cts Test: atest android.provider.cts Change-Id: Ic5ae08107f7dd3dd23dcaec2df40c16543e0d86e Exempted-From-Owner-Approval: keep tests working
* Default settings user to current.Nicholas Sauer2018-12-081-12/+9
| | | | | | bug: 119821127 Test: Switch User 10, put setting, Switch user 0, get setting. Change-Id: Ie060155166b919f5e9df0fc488d16556e0b55208
* settings command list by userNicholas Sauer2018-11-211-25/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | bug: 119872843 Test: $ adb -e shell settings list Bad arguments $ adb -e shell settings list secure $ adb -e shell settings list gl Invalid namespace 'gl' $ adb -e shell settings list global ... $ adb -e shell settings list --user 10 global ... $ adb -e shell settings list --user 0 global ... $ adb -e shell settings put --user 10 secure zzz.test true $ adb -e shell settings get --user 10 secure zzz.test true $ adb -e shell settings get --user 0 secure zzz.test null $ adb -e shell settings list --user 0 secure ... zzz.test not present ... $ adb -e shell settings list --user 10 secure ... zzz.test=true Change-Id: I8ab3d20cbe9221a52f85151d97e0c6d92bf7bb43
* settings command delete by userNicholas Sauer2018-11-201-11/+16
| | | | | | | | | | | | bug: 118492733 Test: $ adb shell settings --user 10 put secure autofill_service blah $ adb shell settings --user 10 get secure autofill_service blah $ adb shell settings --user 10 delete secure autofill_service $ adb shell settings --user 10 get secure autofill_service null Change-Id: I771bf8e148898703332ead8162c5f9fe4863ea74
* Forward 'help' and '-h' to default implementation for ShellCommand.Matt Pape2018-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | This makes 'adb shell settings help' and 'adb shell settings -h' work. Previously: $ adb shell settings help Invalid command: help Updated: $ adb shell settings help Settings provider (settings) commands: help Print this help text. get [--user <USER_ID> | current] NAMESPACE KEY ... Test: adb tested on local devices. bug: 113100523 Change-Id: Ifc3f541aa12da9c79b9b7e9db0e30d4aace3392a
* Ensure settings provider joins the rescue partySvetoslav Ganov2017-01-261-14/+18
| | | | | | | | | | | | | | | | | | The settings provider has logic to incrementally reset state in an effort to recover from pushing a bad value putting the system in a bad state. The settings provider was not force persisting its state after a reset so after the reboot we lost the reset changes. Also while resetting we were also resetting the package name leading to a promotion of the reset value to being set by the system. Updated the tests and while at this added logic to synchronously persist critical settings such as device provisioned. Test: All tests pass. Manually tested end-to-end rescue party bug:34677175 Change-Id: Ib240072df2fa549dae39c301008adf48cdf1573a
* Add ability to dump settings as proto bufEugene Susla2017-01-221-4/+12
| | | | | | Test: Extracted the result via proto bug and as text and compared, ran new CTS Setting incident test Change-Id: Icf7b54b9c5c0a613dfd413ad575001c7b637ca01
* Warn makeDefault ignored for system settings only if trueSvetoslav Ganov2017-01-041-3/+5
| | | | | | | | Test: changed system setting and got it back without a warning bug:33816118 Change-Id: I4e185b46467fc885d2bafedbcbdf41354d0fa9d8
* Fix settings shell commandSvetoslav Ganov2016-12-271-0/+2
| | | | | | Test: run shell commands and verified result Change-Id: I24e87a0efa9330a5872d300e17083d320fcc0573
* Settings recovery supportSvetoslav Ganov2016-12-221-10/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change allows the system to perform iterative reset of changes to settings in order to recover from bad a state such as a reboot loop. To enable this we add the notion of a default value. The default can be set by any package but if the package that set it is a part of the system, i.e. trusted, then other packages that are not a part of the system, i.e. untrusted, cannot change the default. The settings setter APIs that do not take a default effectively clear the default. Putting a setting from a system component always makes it the default and if the package in not trusted then value is not made the default. The rationale is that the system is tested and its values are safe but third-party components are not trusted and their values are not safe. The reset modes from the least intrusive are: untrusted defaults - reset only settings set by untrusted components to their defaults or clear them otherwise; untrusted clear - clear settings set by untrusted components (or snap to default if provided by the system); trusted defaults - reset all settings to defaults set by the system or clear them otherwise. Also a package can reset to defaults changes it made to the global and secure settings. It is also possible to associate a setting with an optional token which can then be used to reset settings set by this package and associated with the token allowing parallel experiments over disjoint settings subsets. The default values are also useful for experiment (or more precisely iterative tuning of devices' behavior in production) as the stable configuration can be set to the "graduated" safe defaults and set the values to the experimental ones to measure impact. Test: tests pass Change-Id: I838955ea3bb28337f416ee244dff2fb1199b6943
* Replace ContentProvider SQL args w/ Bundle & Constants.Steve McKay2016-12-091-2/+2
| | | | | | Test: cts-tradefed run cts-dev -m CtsContentTestCases Bug: 30927484 Change-Id: Idb9dbc2b80896e9f8474a0db71353b7a3810d597
* Update usage of ActivityManagerNative.Sudheer Shanka2016-11-141-2/+2
| | | | | | | | | | | - Remove references to ActivityManagerProxy. - Add isSystemReady to ActivityManager. Bug: 30977067 Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test android.server.cts adb shell am instrument -e class com.android.server.am.ActivityManagerTest,com.android.server.am.TaskStackChangedListenerTest \ -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner Change-Id: I07390b6124fb1515821f5c0b37baf6ae74adc8fa
* Implement Binder shell command for settings provider.Dianne Hackborn2016-11-011-0/+375
The provider now published a system service, through which you can do direct shell commands. The commands are a copy of what the existing "settings" command does (in a follow-up, that will be converted to a simple script that calls this). Also improved a few things in the provider: - Don't allow implicit creation of settings data for users that don't exist. - Improve dump to include the package name that applied each setting and remove misleading stuff from historical data (and this is now available through "dumpsys settings" instead of the provider dump). Test: manual Change-Id: Id9aaeddc76cca4629d04cbdcbba6a311e942dfa6