Commit Graph

7014 Commits

Author SHA1 Message Date
Jeff Sharkey
d2b64d7018 Add ContentProvider.clearCallingIdentity().
ContentProvider has a getCallingPackage() method, which verifies
the remote package name against the current Binder identity.  When a
provider wants to clear that IPC identity, they need to clear both
the Binder state and the ContentProvider.getCallingPackage() state
together, so add methods to facilitate that.

Also fix subtle bug so we don't try translating relative paths.

Bug: 117627072
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: Ifa3e1f745334abf625fdcc314b308a047c49ce73
2018-10-20 15:14:22 -06:00
Jeff Sharkey
4e5efa3186 Convenience method for obtaining thumbnails.
Obtaining a thumbnail for a Uri requires opening it with the slightly
obscure openTypedAssetFileDescriptor(), passing in "image/*" with the
right Bundle of EXTRA_SIZE to hint the target area on screen, and
defensively scaling any returned results.

This is pretty tedious to get right, so offer a convenience method
that does all this for the developer.  Internally uses ImageDecoder
to follow best-practices, and replaces older getDocumentThumbnail()
implementation by delegating to this one.

A future CL will teach ImageDecoder about how to read any embedded
EXIF thumbnails, including any required rotation.

Bug: 111268862
Test: atest FrameworksCoreTests:android.content.ContentResolverTest
Change-Id: I5c9c09ddf9b480f3b5c6ade0a078cccb68de2f2b
2018-10-18 14:32:51 -06:00
TreeHugger Robot
38d0bd0634 Merge "Set EXTRA_USER instead of EXTRA_USER_ID for ACTION_SHOW_ADMIN_SUPPORT_DETAILS" 2018-10-17 00:26:37 +00:00
TreeHugger Robot
e9944aa1dc Merge "Make loadSafeLabel a generic facility as makeSafeForPresentation" 2018-10-16 16:21:10 +00:00
TreeHugger Robot
02f2a315d7 Merge "Add Context.getDisplayId() to avoid possible IPC" 2018-10-16 00:20:52 +00:00
TreeHugger Robot
bc9ebba7e5 Merge "Suspending app can customize intercepting dialog" 2018-10-15 21:51:52 +00:00
Philip P. Moltmann
c1fda744f0 Make loadSafeLabel a generic facility as makeSafeForPresentation
Any app loading untrusted strings should make the strings face. Hence make
the method publicly available.

Test: atest CtsTextTestCases:MakeSafeForPresentationTest GtsContentTestCases:PackageItemInfoTests
Change-Id: Ib0679fe892181535339dac77583c427e0d64dd05
Fixes: 113856697
2018-10-15 09:11:52 -07:00
Ricky Wai
6763d1f3fe Merge "Return app hidden details activity in launcher api" 2018-10-15 04:21:59 +00:00
Yohei Yukawa
5281b6b4c0 Add Context.getDisplayId() to avoid possible IPC
ContextImpl has an internal rule that when ContextImpl#mDisplay is
null the Context is associated with the default display.  The problem
is that, as discussed in Bug 117709581, when ContextImpl#mDisplay is
null ContextImpl#getDisplay() tries to get some non-null Display
object by making an IPC to the system server, which is redundant when
the display ID is the only thing that the caller wants to know.

By having an @hide method Context.getDisplayId(), we can ensure that
display ID can be obtained without any IPC.  This enables us to
re-submit my CL [1] that aimed to instantiate InputMethodManager (IMM)
for each display but then got reverted due to a performance regression
(Bug 117434607).

There should be no developer-observable behavior change.

 [1]: I7242e765426353672823fcc8277f20ac361930d7
      c53d78e992

Fix: 117712745
Test: atest FrameworksCoreTests:android.content.ContextTest
Test: prebuilts/checkstyle/checkstyle.py -f \
      frameworks/base/core/tests/coretests/src/android/content/ContextTest.java
Change-Id: I2534530a5ce90e2620c5039d793a6454a0a1e154
2018-10-15 07:38:25 +08:00
Philip P. Moltmann
add325328b Merge "Make PermissionManager use lists" 2018-10-12 23:43:11 +00:00
Suprabh Shukla
389cb6f54a Suspending app can customize intercepting dialog
The suspending app has more context about why a particular app was
suspended by the user, but we do not want to delegate the interception
of the suspended activity out of the system.
Hence allowing it further customizations to the dialog to make
it clearer.

Test: atest com.android.server.pm.SuspendDialogInfoTest \
com.android.server.pm.SuspendPackagesTest \
com.android.server.pm.PackageUserStateTest \
com.android.server.pm.PackageManagerSettingsTests \
com.android.server.am.ActivityStartInterceptorTest

atest GtsSuspendAppsPermissionTestCases GtsSuspendAppsTestCases

Bug: 112486945
Bug: 113150060
Change-Id: If9f4d14587a2b75bb572e7984a90e300a2c72d16
2018-10-12 16:02:53 -07:00
TreeHugger Robot
a87f032c15 Merge "Implement launch bounds logic in Android (2/3)" 2018-10-12 20:08:40 +00:00
Chen Xu
2a670634e3 Merge "refactor data/voice roaming states" am: 6bd29ab2df am: 652ec06948
am: 6169b04385

Change-Id: I921e3dd8f4c82d83d1f12657813945fbcc2e21b2
2018-10-12 11:57:14 -07:00
Chen Xu
6169b04385 Merge "refactor data/voice roaming states" am: 6bd29ab2df
am: 652ec06948

Change-Id: I1f82195e5477401f3216db92bbdac388bbe16c7f
2018-10-12 11:32:19 -07:00
Chen Xu
652ec06948 Merge "refactor data/voice roaming states"
am: 6bd29ab2df

Change-Id: Iac8184fe2dfdb7ff4c3d93ecb7c0c9dd9a7a46a5
2018-10-12 11:20:18 -07:00
Chen Xu
6bd29ab2df Merge "refactor data/voice roaming states" 2018-10-12 18:02:17 +00:00
Garfield Tan
b5cc09fe4a Implement launch bounds logic in Android (2/3)
This CL implements the biggest chunk of launch bounds logic in Android
branch and combine ActivityLaunchParamsModifier logic into
TaskLaunchParamsModifier. It left some things to be implemented:
1) It didn't yet consider persisting/recovering data;
2) It didn't implement letterboxing/pillarboxing, but according to
offline chat this should be enforced after launch bounds policies by
system;
3) Immersive mode is not yet implemented, but that's more tied to
recovering previous immersive mode and we won't launch apps to immersive
mode directly in any case;
4) No last seen non-fullscreen bounds are set if display is fullscreen,
which could be useful when display windowing mode changes from
fullscreen to freeform at later time.

There are also some topics that for sure need future discussions, so I
left them out of this CL as well:
1) App controlled apps (not only bounds specified in ActivityOptions);
2) Metadata indicating that the app prefers tablet-like bounds for
freeform windows (i.e. w/o limiting window size to Nexus 5x screen
size);
3) Fixed maximized size, which indicates that the maximized size
shouldn't be changed due to display resolution or orientation changes;
4) What to do if app requests to launch an activity without any flag
that indicates a new task should be used, but with a preferred display
ID/bounds set to a different value than its current window;
5) Should insets be considered in launch bounds (AM side) or on WM side,
IIUC freeform windows don't need to consider insets, and fullscreen
windows are covered by WM.

Our policy also has special treatment for Chrome snapped windows
(side-by-side mode in our tablet), which may not make much sense in
Android.

Bug: 113252871
Test: go/wm-smoke. Try launching some freeform windows on secondary
displays.
atest FrameworksServicesTests:TaskLaunchParamsModifierTests
atest ActivityManagerManifestLayoutTests
Change-Id: I974031725015b6283f33b9076788e7ce45134690
2018-10-12 10:38:34 -07:00
Jeff Sharkey
83e5229ab7 Merge "Recover shady content:// paths." into pi-dev
am: 7402d7611c

Change-Id: I499e0086df06d77d1fce3afaa86bb19a136b1ca2
2018-10-11 21:22:04 -07:00
TreeHugger Robot
7402d7611c Merge "Recover shady content:// paths." into pi-dev 2018-10-12 03:59:38 +00:00
chen xu
0281169e6d refactor data/voice roaming states
1. migrate set/get roamingType from ServiceState to
NetworkRegState.set/get roamingType
2. migrate set/get roamingStateFromRegstate from ServiceState
to NetworkRegState.regState
3. new System API for neworkRegistration.isRoaming().

Bug: 116127096
Test: ServiceStateTest, ServiceStateProviderTest

Change-Id: Ib89744089c98713819c8d313240d629ddb77d0bf
2018-10-11 15:10:32 -07:00
Philip P. Moltmann
a3ba4d9861 Make PermissionManager use lists
... as requested per API review.

- Sets require iteration via iterators
- Sets are more expensive to construct
- The advantage of sets (faster .contains) is not used
- The system ensures uniqueness of the entires in the list

Test: Built
Bug: 116798569
Change-Id: I2c3b5c6801b78e0bf942073bde1e90299aee39f6
2018-10-11 08:16:16 -07:00
Ricky Wai
cf134ebfb7 Return app hidden details activity in launcher api
If a normal app does not have launcher icon, launcher api
will return app details activity instead, so user will
be noticed that the app is still installed.

Bug: 111348460

Test: Installed an app without launcher activity, an app icon is being
shown in launcher allapps, and it forwards user to app details page.

Change-Id: I9c17f5edfdefe19727145e7176d7e113286c997d
2018-10-11 14:19:04 +00:00
Scott Kennedy
4763647b27 Merge "Mark getInstallerPackageName @Nullable" am: c41a5d6bc0 am: cecccf6258
am: 61f76551f1

Change-Id: I416572b4d162f2dd98ddcec068fcd6e835b53e7a
2018-10-10 21:35:51 -07:00
kopriva
b0353c56e0 docs: fixing errors found with lint checker am: 219f7dcb66
am: 003587b9a4

Change-Id: I056261f069ed679ed8a03bfc0791bfe59a405361
2018-10-10 19:41:15 -07:00
Philip P. Moltmann
c54c36dcc7 Set EXTRA_USER instead of EXTRA_USER_ID for ACTION_SHOW_ADMIN_SUPPORT_DETAILS
Test: Built
Bug: 116798569
Change-Id: I60e8e9613c20d860ff8fda682e9f754ee66dcbef
2018-10-10 15:51:47 -07:00
Scott Kennedy
61f76551f1 Merge "Mark getInstallerPackageName @Nullable" am: c41a5d6bc0
am: cecccf6258

Change-Id: Ib27badf42d90932da0b7f2f0922b8903936feafd
2018-10-10 15:04:12 -07:00
Scott Kennedy
cecccf6258 Merge "Mark getInstallerPackageName @Nullable"
am: c41a5d6bc0

Change-Id: I9500bd37c872fac143074d9a79402d07b0c0419d
2018-10-10 14:57:22 -07:00
TreeHugger Robot
803a52498b Merge "Show app installed notification from PackageInstaller" 2018-10-10 15:41:38 +00:00
kopriva
003587b9a4 docs: fixing errors found with lint checker
am: 219f7dcb66

Change-Id: Id38a4b2e21285d5d5e2a2124d76885febd3441c6
2018-10-09 18:30:57 -07:00
Scott Kennedy
98b5f8901b Mark getInstallerPackageName @Nullable
Test: Just an annotation

Change-Id: Ida4f40e77abec2bbf3791a6b38fdb729f6083811
2018-10-09 17:37:58 -07:00
kopriva
219f7dcb66 docs: fixing errors found with lint checker
through /bluetooth directory

amending through /content directory

Test: make ds-docs

Bug: 117494359

Change-Id: I751e15d60f0b9cc441998b27560050bf62994fef
Exempt-From-Owner-Approval: Docs-only change
2018-10-09 16:01:04 -07:00
Philip P. Moltmann
ae15e11ddd Merge "Deprecate Intent based installation/uninstallation" 2018-10-09 16:15:50 +00:00
Philip P. Moltmann
20dd431f20 Do not allow to revert setForceSafeLabel
Test: Built
Bug: 116798569
Change-Id: I3f26d4466c84d3decb1c4962fb45e900ba35f68e
2018-10-08 16:56:49 -07:00
Philip P. Moltmann
fe460100e7 Deprecate Intent based installation/uninstallation
The android.content.pm.PackageInstaller install + uninstall APIs are
fully functional. No need to try to keep the intent based APIs
feature compatible.

In the future we will be able to restrict app targeting old targetSDK
levels from using the intent-based API. Even further in the future we
can radically simplify the package installer app.

Fixes: 116616700
Test: Built
Change-Id: Ia225d70fbee3fa31a3c1de388dcb05ff1063dccd
2018-10-08 09:03:21 -07:00
TreeHugger Robot
10efed0b49 Merge "Remove SMS access for apps other than current SMS handler" 2018-10-06 20:14:06 +00:00
Eugene Susla
9351985f7a Remove SMS access for apps other than current SMS handler
Bug: 110098858
Test: atest android.telephony.cts.SmsManagerTest#testContentProviderAccessRestrictions
Change-Id: I9da992565b04ca5fa2656801fd2cfe4b196ef9b4
2018-10-05 16:51:13 -07:00
Jeff Sharkey
08a42ed82a Merge "Log when Uris are normalized to help triage." 2018-10-03 21:17:51 +00:00
Jeff Sharkey
c084ddbf82 Recover shady content:// paths.
The path-permission element offers prefix or regex style matching of
paths, but most providers internally use UriMatcher to decide what
to do with an incoming Uri.

This causes trouble because UriMatcher uses Uri.getPathSegments(),
which quietly ignores "empty" paths.  Consider this example:

    <path-permission android:pathPrefix="/private" ... />

    uriMatcher.addURI("com.example", "/private", CODE_PRIVATE);

    content://com.example//private

The Uri above will pass the security check, since it's not
technically a prefix match.  But the UriMatcher will then match it
as CODE_PRIVATE, since it ignores the "//" zero-length path.

Since we can't safely change the behavior of either path-permission
or UriMatcher, we're left with recovering these shady paths by
trimming away zero-length paths.

Bug: 112555574
Test: atest android.appsecurity.cts.AppSecurityTests
Test: atest FrameworksCoreTests:android.content.ContentProviderTest
Merged-In: Ibadbfa4fc904ec54780c8102958735b03293fb9a
Change-Id: Ibadbfa4fc904ec54780c8102958735b03293fb9a
2018-10-03 14:26:17 -06:00
Michael Groover
a117b0d4bd Add PackageSignatures readXml tests
This fix also refactors PackageParser.SigningDetails to move the
pastSigningCertificatesFlags to be a data member of Signature; this
allows the capabilities of a previous signing certificate to be
accessed directly from the Signature object as opposed to relying
on the 1-1 mapping of the past certs and flags in the SigningDetails.

Fixes: 73927696
Fixes: 73925989
Test: adb shell am instrument -w -e class com.android.server.pm.PackageSignaturesTest \
      com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: I635f2d2209350d066d1fa2ef07460071da0c023e
2018-10-03 09:47:14 -07:00
Jeff Sharkey
4a7b6ac0c4 Log when Uris are normalized to help triage.
Bug: 112555574
Test: manual
Change-Id: Iebf7785e93995f1a2a6d688a2b2aa0ec16c790c6
2018-10-03 10:33:48 -06:00
TreeHugger Robot
a4481c9c5c Merge "Fail install if split is missing" 2018-10-01 21:21:35 +00:00
Michael Wachenschwanz
03b9731830 Merge changes from topic "UsageStats2Proto"
* changes:
  Pool Package and Class names when writing UsageStats to disk
  Upgrade UsageStatsDatabase from XML to Protobuf
2018-10-01 21:20:56 +00:00
Michael Wachenschwanz
c8c26365a4 Upgrade UsageStatsDatabase from XML to Protobuf
Add the relevant methods to read from ProtoInputStream to
various classes.

Also add some framework to handle version changes in
UsageStatsDatabase. There is some risk of users losing all their current
UsageStats data, if something goes horribly wrong. The debug flag and a
keep backup files flag are temporarily set in UsageStatsDatabase with
this change. They will both be unset in the future before the Q release.

Some rough number on the impact of this change:
Proto file size on disk reduces to ~47% of XML file size :)
Proto file read time reduces to ~55% of XML file read :)
Proto file write time increases ~17% over the XML file write :(

There will be a follow up CL to address the file write time regression

Bug: 111422946
Fixes: 111449927
Test: atest UsageStatsDatabaseTest
Change-Id: I084aea796ed2163c42947d52396a36cc7c5562a2
2018-09-28 16:48:23 -07:00
Todd Kennedy
29cfa27f69 Fail install if split is missing
An application can declare that it must be installed with at least
one split using the manifest attribute "android:isSplitRequired".
Setting the attribute to 'true' [default is 'false'], the application
can't be installed with a base-only. It must be accompanied by at
least one split [either feature or config].

Change-Id: I42804af34a4209ba5d6726d681ca705ca2c21a39
Fixes: 111391719
Test: atest CtsAppSecurityHostTestCases:SplitTests
2018-09-27 21:43:36 -07:00
Amith Yamasani
0631cca3ff Merge "Keep app in high memory adjust if moving from TOP to FGS" into pi-dev
am: 311f0f5da5

Change-Id: I941f1a8f9b6ee2c65ee289a159146d5b2ee95dcc
2018-09-27 18:11:46 -07:00
TreeHugger Robot
311f0f5da5 Merge "Keep app in high memory adjust if moving from TOP to FGS" into pi-dev 2018-09-28 00:50:39 +00:00
Makoto Onuki
8426a06516 Merge "Add API surface for "keep SMS app running"." 2018-09-27 14:30:41 +00:00
Jeff Sharkey
9144b4dd85 We still need userIds to be populated.
Fixes regression from recent security patch.

Bug: 116685315
Test: none
Change-Id: I2105d974a5a77f3a38b887c8459d893639fdffa2
2018-09-26 20:15:23 -06:00
Jeff Sharkey
66768ba664 We still need userIds to be populated.
Fixes regression from recent security patch.

Bug: 116685315
Test: none
Change-Id: I2c2e3976ec7ec2b03ebee052ca8ce11b8f66495d
2018-09-26 20:13:29 -06:00
Makoto Onuki
df7e481b20 Add API surface for "keep SMS app running".
Bug: 109809543
Test: build & boot
Change-Id: Ie9ebf1f34052394a92c3f260413c18596709d3a3
2018-09-26 11:51:06 -07:00