Commit Graph

8231 Commits

Author SHA1 Message Date
TreeHugger Robot
8e6a69c3a2 Merge "Allow apps to collect which appops were noted" 2019-08-30 18:53:22 +00:00
Philip P. Moltmann
2b08aafc14 Allow apps to collect which appops were noted
If private user data is send to an app the data provider should note an
app-op. This change adds a new API AppOpsManager#setNotedAppOpsCollector
that allows an app to get notified every time such an private data access
happens.

This will allow apps to monitor their own private data usage. Esp. with
big, old apps, distributed teams or 3rd party libraries it might not always
be clear what subsystems access private data.

There are three different situations how private data can be accessed and
an app op is noted:

1. Private data access inside a two-way binder call.
E.g. LocationManager#getLastKnownLocation. When we start a two way
binder transaction, we remember the calling uid via
AppOpsManager#collectNotedAppOps. Then when the data providing code
calls AppOpsManager#noteOp->AppOpsManager#markAppOpNoted the noted
app-op is remembered in
AppOpsManager#sAppOpsNotedInThisBinderTransaction. Then when returning
from the binder call, we add the list of noted app-ops to the
reply-parcel via AppOpsManager#prefixParcelWithAppOpsIfNeeded. On the
calling side we check if there were any app-ops noted in
AppOpsManager#readAndLogNotedAppops and then call the collector while
still in the binder code. This allows the collector e.g. collect a stack
trace which can be used to figure out what app code caused the
private data access.

2. Very complex apps might do permissions checks internal to themself.
I.e. an app notes an op for itself. We detect this case in
AppOpsManager#markAppOpNoted and immediately call the collector similar
to case (1).

3. Sometimes private data is accessed outside of a two-way binder call.
E.g. if an app registers a LocationListener an app-op is noted each time
a new location is send to the app. In this case it is not clear to the
framework which app-action triggered this app-op-note. Hence the data
provider has to describe in a AsyncNotedAppOp object when an why the
access happened. These objects are then send to the system server via
IAppOpsService#noteAsyncOp and then the collector in the app. There are
rare cases where a private data access happens before the app is running
(e.g. when a geo-fence is triggered). In this case we cache a small
amount of AsyncNotedAppOps (in AppOpsService#mUnforwardedAsyncNotedOps)
and deliver them when the app is ready for these events (in
AppOpsManager#setNotedAppOpsCollector).

Test: atest CtsAppOpsTestCases (includes new tests covering this
                                functionality)
Bug: 136505050
Change-Id: I96ded4a8d8d9bcb37a4555d9b1281cb57945ffa9
2019-08-30 08:18:50 -07:00
Aurimas Liutikas
34c56bcf4a Merge "Add missing nullability annotations." 2019-08-30 15:14:37 +00:00
TreeHugger Robot
7ce605ebe9 Merge "Updated onSharedPreferenceChanged listener behavior." 2019-08-30 03:10:08 +00:00
Aurimas Liutikas
4d1699da48 Add missing nullability annotations.
To prepare for enabling MissingNullability Metalava check this CL
works on adding missing nullability issues that metalava flags if
we tell it to flag new things since API 29.

This is not a complete CL, mostly addresses public api and
toString/equals for @SystemApi

Exempt-From-Owner-Approval: Large scale nullability clean up
Bug: 124515653
Test: make -j checkapi
Change-Id: I109260842cfc25f06e40694997fcbb4afa02c867
2019-08-29 17:15:44 -07:00
Jeff Sharkey
ce766b3ac7 Merge changes from topic "mappingz"
* changes:
  Sprinkle in some TEST_MAPPING.
  Fix subtle bug when using empty withValues().
2019-08-29 02:58:51 +00:00
Kevin Hufnagle
3c7aa609cc Merge "docs: Added desc. of launcher app criteria in Q" into qt-dev am: b14d2dede2 am: 13e2b970ec am: 5e1a48a660
am: eba15ec2b4

Change-Id: I3a599fb3e781067b76b8868d7cf3013c0e4a4fb3
2019-08-28 18:23:59 -07:00
Kevin Hufnagle
eba15ec2b4 Merge "docs: Added desc. of launcher app criteria in Q" into qt-dev am: b14d2dede2 am: 13e2b970ec
am: 5e1a48a660

Change-Id: Ic65f9e1e2a51d91a08b482b3ee2e66f9f0ef29ea
2019-08-28 17:56:05 -07:00
Kevin Hufnagle
5e1a48a660 Merge "docs: Added desc. of launcher app criteria in Q" into qt-dev am: b14d2dede2
am: 13e2b970ec

Change-Id: I393ec53ecf097e5ebe4ce2878e149fbf653df622
2019-08-28 17:39:34 -07:00
Kevin Hufnagle
b14d2dede2 Merge "docs: Added desc. of launcher app criteria in Q" into qt-dev 2019-08-28 22:08:47 +00:00
Andrew Solovay
8d4be69f1c Merge "Docs: clarify getSharedPreferences behavior" into qt-dev am: 3791f9b071 am: 73a66dc100 am: c149d6ff19
am: 9f226a0085

Change-Id: Ia766df0c95dafd61e68303d49a1b5558cc4fc9d8
2019-08-28 14:28:16 -07:00
Andrew Solovay
9f226a0085 Merge "Docs: clarify getSharedPreferences behavior" into qt-dev am: 3791f9b071 am: 73a66dc100
am: c149d6ff19

Change-Id: Ieae488ea773c6f21b4f3517a682be60c99eaa628
2019-08-28 14:13:35 -07:00
Andrew Solovay
c149d6ff19 Merge "Docs: clarify getSharedPreferences behavior" into qt-dev am: 3791f9b071
am: 73a66dc100

Change-Id: Ia14424c38de4a55096bad5e1e91d29681b26f4f5
2019-08-28 13:52:14 -07:00
Andrew Solovay
676ef1a61c Merge "Docs: clarify getSharedPreferences behavior" into qt-dev am: 3791f9b071
am: 73a66dc100

Change-Id: Ie94b91be0696090bc1bcce4a787873886a268396
2019-08-28 13:45:51 -07:00
Jeff Sharkey
4ef8702ce9 Fix subtle bug when using empty withValues().
We still need to populate mValues when the ContentValues was empty.

Bug: 139356941
Test: atest --test-mapping packages/providers/ContactsProvider
Change-Id: Ice90afbb7994e1a1d10076a2aa48b4d1187abe9f
2019-08-28 13:24:47 -06:00
Kevin Hufnagle
25266af6f3 docs: Added desc. of launcher app criteria in Q
As of Android Q, an app is included in the return value of
LauncherApps#getActivityList() unless it fulfills specific criteria.
This CL describes the conditions necessary for an app's activities
to *not* appear in the list.

Test: make ds-docs -j32

Bug: 130352392
Change-Id: I6a6e17351a6c1234229d1d7eb8147ee2c24ee2c9
2019-08-28 17:55:59 +00:00
Oli Lan
df720dc785 Merge "Wait for available rollbacks in RollbackTest." 2019-08-28 09:24:29 +00:00
Nate Fischer
5272c3776d Docs: clarify getSharedPreferences behavior
No change to logic, only documentation.

This updates Context#getSharedPreferences docs:

 * Fix a typo ("thead" -> "thread")
 * Formatting: use <p> when appropriate, {@link} to other APIs, limit
   the @param to only a single sentence
 * Mention getSharedPreferences() may actually perform disk IO (this was
   undocumented)
 * Mention Editor#apply() as well as #commit()

Fixes: 140137651
Test: make docs
Change-Id: I245371d13d4f317c6c522debcdf7938ab783f897
2019-08-28 00:45:08 +00:00
Varun Shah
3bade98359 Merge "Update mTransport check before trying to configure." 2019-08-27 16:55:06 +00:00
Oli Lan
0a3c06e9c9 Wait for available rollbacks in RollbackTest.
This changes RollbackTest to retry checks for available rollbacks for
a certain period of time, using a new RollbackUtils method
waitForAvailableRollbacks.

Currently many of the tests in RollbackTest are flaky due to race conditions
between checking for available rollbacks and the installer onFinished callback.
This CL should fix all of those issues.

The previous attempt to resolve this by adding NewRollbacks speculatively to
the results of getAvailableRollbacks was not successful. This CL reverts that
change so that getAvailableRollbacks once again only returns rollbacks that are
actually available.

Bug: 136548146
Test: atest RollbackTest run on cuttlefish on acloud repeatedly
Change-Id: I27e2513b34f49af2f41cd627a5d2550541831e11
2019-08-27 17:04:25 +01:00
Lorenzo Colitti
d50b505965 Merge changes I69cdbb16,I6975e0b7 am: d889cb5098 am: ac913d725f am: 93d68de285 am: bb0edef6e8
am: 7ea7b0b1f1

Change-Id: Ie87981017bf2d4deef2092407c31fb3df4464dc8
2019-08-27 04:24:55 -07:00
Lorenzo Colitti
7ea7b0b1f1 Merge changes I69cdbb16,I6975e0b7 am: d889cb5098 am: ac913d725f am: 93d68de285
am: bb0edef6e8

Change-Id: I77ca7b17bea79dee5156839d1164b0fc78b31fe5
2019-08-27 04:12:45 -07:00
Lorenzo Colitti
ac913d725f Merge changes I69cdbb16,I6975e0b7
am: d889cb5098

Change-Id: I3c8ddf7809a0d443587c1c4c06ef56ac302fc80f
2019-08-27 03:31:02 -07:00
Varun Shah
d53955329c Update mTransport check before trying to configure.
Line was too long in previous commit so just updating that fix and
cleaning it up.

Bug: 139554125
Test: atest android.content.ContentProviderTest
Change-Id: Ie63151db35cc47f691b5a4733409c10b1ac4299c
2019-08-26 18:28:12 -07:00
Varun Shah
5d2049f2f7 Updated onSharedPreferenceChanged listener behavior.
The onSharedPreferenceChanged listener will now also be called on
Editor#clear with a null key.
This change is gated behind a flag using the new app compat framework.

Removed the OnSharedPreferencesClear listener interface.

Bug: 119147584
Bug: 138293946
Test: atest android.content.cts.SharedPreferencesTest
Change-Id: Ieea168eb40afb8f1b5830f1541be20d93d6f94b5
2019-08-26 15:26:24 -07:00
TreeHugger Robot
6ffb81d821 Merge "Fix getting target SDK version for uid in PermissionManagerService." 2019-08-26 17:42:09 +00:00
wangmingming1
71df3da8ae notify netd about uid internet permission changes when package replaced
1. If a previous version of an app doesn't declare internet permission;
2. The User upgraded it to a new version and the new one does declare the
internet permission;
3. The new app are not allowed to access the internet until next boot

Bug: 137864893
Test: Manual, just make sure the onPackageChanged would be executed on package changes
Change-Id: I69cdbb16a027a9c4e974b32371b1f64a23a51a23
Signed-off-by: wangmingming1 <wangmingming1@xiaomi.com>
2019-08-26 09:30:59 +09:00
Lorenzo Colitti
7b0411782a Backport PackageListObserver#onPackageChanged.
Added internally in Ic48e3c728387ecf02f89d517ba1fe785ab9c75fd,
of which this is a partial cherry-pick.

Bug: 137864893
Test: builds, boots
Change-Id: I6975e0b70ded6047e1ac8013a82bc35ff150f03b
Merged-In: Ic48e3c728387ecf02f89d517ba1fe785ab9c75fd
2019-08-26 09:30:59 +09:00
Anna Trostanetski
a6fe3996e1 Merge "Rename android.compat.IPlatformCompat" am: ee716a23a2 am: 81af0fc8bb am: 20f25166c3 am: 884ef46cdc
am: 8649477e74

Change-Id: I1722a3c2fc9444b4e05932bb287d5ccd389f1493
2019-08-24 01:40:24 -07:00
Anna Trostanetski
8649477e74 Merge "Rename android.compat.IPlatformCompat" am: ee716a23a2 am: 81af0fc8bb am: 20f25166c3
am: 884ef46cdc

Change-Id: I11d25c6de70389b9f8fb74b914a247bca224e631
2019-08-23 22:04:54 -07:00
Hai Zhang
053c3a2349 Fix getting target SDK version for uid in PermissionManagerService.
The lowest target SDK version (instead of the highest) should be used
in order to stay compatible with existing older apps.

Bug: 136503238
Test: presubmit
Change-Id: If3b23ae4441166c98934cdd1f4adb7ded714abc3
2019-08-23 15:11:57 -07:00
TreeHugger Robot
903102c430 Merge "Don't refer to DeviceIdle from SystemServiceRegistry" 2019-08-23 15:38:42 +00:00
Anna Trostanetski
81af0fc8bb Merge "Rename android.compat.IPlatformCompat"
am: ee716a23a2

Change-Id: I88fd93b46bcaa5ed782c407f2a9e9469fb0f5f0e
2019-08-23 02:26:15 -07:00
Jeff Sharkey
7b28a9f743 Merge "Public APIs for ID-specific Uris, misc items." 2019-08-23 04:24:31 +00:00
TreeHugger Robot
a68d535199 Merge "Defined a more generic way to let services "opt-out" from certain user types." 2019-08-22 20:59:41 +00:00
Jeff Sharkey
ec19e9b107 Public APIs for ID-specific Uris, misc items.
We have getContentUri() for entire collections of items, but we
only have ID-specific overloads for some of the MediaStore classes;
let's get them all added for consistency.

Remove primary/secondary directory logic, which was replaced by
new RELATIVE_PATH column before Q launched.

Bug: 137890034
Test: atest --test-mapping packages/providers/MediaProvider
Exempt-From-Owner-Approval: trivial API refactoring
Change-Id: Iae4e7fe57adff071c35af459e31223a1fd05fef2
2019-08-22 14:43:24 -06:00
Felipe Leme
501a514ba7 Defined a more generic way to let services "opt-out" from certain user types.
SystemService now defines a isSupported(UserInfo), which is used by SystemServiceManager to
skip the service for the unsupported types.

Also added a new argument to SystemService.onSwitch() to indicate which user is
being switched from.

Finally, also fixed VoiceInteractionManagerService so it doesn't start for headless user 0.

Test: manual verification
Test: atest CtsVoiceInteractionTestCases CtsAssistTestCases # on automotive and walleye

Bug: 133242016
Bug: 137878080

Change-Id: Ife4bd875f412f85cccf9c9fd03115abd238d7eab
2019-08-21 15:15:30 -07:00
atrost
a6a4d60ae0 Rename android.compat.IPlatformCompat
To com.android.internal.compat.IPlatformCompat. This solves a java9
issue because libcore exported api has the same package android.compat.

Test: EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9=true make framework
Change-Id: I0918344f670669cecb04f1e9e54dbcb471b587d5
2019-08-21 17:07:11 +01:00
Joanne Chung
14275a9388 Merge "Move disable autofill from AutofillManagerService to AutofillOptions." 2019-08-21 06:29:18 +00:00
Anna Trostanetski
911c6ffd6a Merge "Start platform compat service eariler." into stage-aosp-master am: 4535b04b33 am: f3fe588229
am: 0755524354

Change-Id: Ic4c4d904df1484844fbaea740674ace0be1d0491
2019-08-20 02:53:39 -07:00
Jeff Sharkey
7585618d96 Merge "Check for mTransport before trying to configure." 2019-08-20 01:03:27 +00:00
Jeff Sharkey
316a617795 Check for mTransport before trying to configure.
Bug: 139554125
Test: atest FrameworksCoreTests:android.content.ContentProviderTest
Change-Id: I4a2d78de257cb898b75543dcbfde4b6317b3393f
2019-08-19 16:04:57 -06:00
atrost
499d4bff66 Start platform compat service eariler.
It's needed by ActivityManager and PackageManager.
Also use a constant in Context for the name.

Test: flashed device with ag/9025572 and ag/9204795 and the platfrom
compat was accessible.
Bug: 137769727

Change-Id: Ie1130a3f0bdd1769fe0755db0089702ea64d9db6
Merged-In: Ie1130a3f0bdd1769fe0755db0089702ea64d9db6
2019-08-19 16:10:47 +00:00
atrost
8266ae32ba Start platform compat service eariler.
It's needed by ActivityManager and PackageManager.
Also use a constant in Context for the name.

Test: flashed device with ag/9025572 and ag/9204795 and the platfrom
compat was accessible.
Bug: 137769727
Change-Id: Ie1130a3f0bdd1769fe0755db0089702ea64d9db6
Merged-In: Ie1130a3f0bdd1769fe0755db0089702ea64d9db6
2019-08-19 16:10:31 +00:00
TreeHugger Robot
4742ee7b19 Merge "Update ContentProvider#checkUser access." 2019-08-19 14:22:14 +00:00
atrost
de54a8ac4c Start platform compat service eariler.
It's needed by ActivityManager and PackageManager.
Also use a constant in Context for the name.

Test: flashed device with ag/9025572 and ag/9204795 and the platfrom
compat was accessible.

Change-Id: Ie1130a3f0bdd1769fe0755db0089702ea64d9db6
2019-08-19 12:26:24 +01:00
Varun Shah
af8cfe34cd Update ContentProvider#checkUser access.
Packages with INTERACT_ACROSS_USERS_FULL can now access
ContentProvier#checkUser.

Bug: 139188114
Test: atest ContentProviderTest
Change-Id: Ie71387a26da66ebe34f296476c284c33abba6368
2019-08-16 16:39:21 -07:00
Oli Lan
0672808c27 Include NewRollbacks in result of getAvailableRollbacks.
This CL adds NewRollbacks to the return value of getAvailableRollbacks,
as long as the PackageRollbackInfo is complete (i.e. there is one for
each child session in the install).

Including these should avoid the potential race condition between the
install finishing and getAvailableRollbacks being called which affected
some of the tests. This means that the draining of the handler that was
previously added to getAvailableRollbacks can now be removed.

In order to avoid a similar race condition when rollbacks are expired, this
change also cancels corresponding NewRollbacks when expireRollbackForPackage
is called.

Bug: 136241838
Bug: 136548146
Test: atest RollbackTest
Test: manual local test with delay added to onFinished in the service callback
Change-Id: I015ee5925e38118c40f4b9e145f78fb12c0e2890
2019-08-16 17:52:50 +01:00
TreeHugger Robot
cf2efde135 Merge "Use PlatformConfig to gate behavior" 2019-08-15 19:08:35 +00:00
Patrick Baumann
dfb121d705 Use PlatformConfig to gate behavior
This change moves away from AppOps and explicit targetSdk
checks in favor of PlatformConfig.

Test: atest AppsFilterTest
Test: adb shell device_config put package_manager_service package_query_filtering_enabled true && atest AppEnumerationTests
Fixes: 139348423
Bug: 136675067
Change-Id: If0af198c86210c05c2e10b71f7ae6dc0b7a3ea9a
2019-08-15 09:26:14 -07:00