Commit Graph

7928 Commits

Author SHA1 Message Date
Sudheer Shanka
1b817f65db Don't use linked mediastore uris in DownloadProvider operations.
When MediaProvider db gets recreated, all the media content ids
get renumbered. It's possible that when DownloadProvider is
trying to delete an entry, it is holding onto a invalid mediastore
uri. So, don't use linked mediastore uris in DownloadProvider
operations. Also, revoke any prior uri grants of media content from
DownloadStorageProvider.

Bug: 132087334
Test: manual
Test: atest DownloadProviderTests
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java
Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java
Change-Id: I4885f5a0ae0b3ab660426605a8a43b8c1d66a4c7
2019-05-21 10:21:43 -07:00
TreeHugger Robot
743288a029 Merge "Fix sysui's security issue of cross-user copy/paste" into qt-dev 2019-05-21 16:50:52 +00:00
Felka Chang
33f56060d5 Fix sysui's security issue of cross-user copy/paste
Background:
The applications with the granted INTERNAL_SYSTEM_WINDOW and
INTERACT_ACROSS_USERS_FULL means that it could show the same
window for all of users. i.e. to use user 0 presents all of
UI things to all of users.

INTERNAL_SYSTEM_WINDOW usually comes with INTERACT_ACROSS_USERS_FULL
because it will serve all of users to know the information that
comes from framework and system server.

Solution:
Because SystemUI never restarts after the user changing,
ClipboardService can't tell if the callingUid has the the same userId
with the current user or not.  The solution is to use the permission
check. Especially, INTERACT_ACROSS_USERS_FULL and
INTERNAL_SYSTEM_WINDOW. To check INTERACT_ACROSS_USERS_FULL by using
ActivityManagerInternal.handleIncomingUser.

Caution:
The application with INTERNAL_SYSTEM_WINDOW usually use user 0
to show the window. But, the current user is user 10, WindowManager
know the focus windows is belong to user 0 rather user 10. That's
why user 10 can't copy the the text from systemui directly reply to
the other applications.

Readability:
ClipboardService use callingUid everywhere but actaully it is not
appropriated to fix this kind of bug. This patch refactor the naming
to produce two name. i.e. intendingUid and intentdingUserId that are
validated by ActivityManagerInternal.handleIncomingUser.

Test: manual test
Test: atest android.widget.cts.TextViewTest
Test: atest CtsTextTestCases
Test: atest CtsContentTestCases

Bug: 123232892
Bug: 117768051
Change-Id: Ie3daecd1e8fc2f7fdf37baeb5979da9f2e0b3937
2019-05-21 14:16:59 +08:00
Eric Holk
4487398e0d Remove obtainStyledAttribute and AssetManager2::GetBag tracing
These traces are small and noisy, so they hurt performance more than they help.

This reverts commit c37457799b.

Test: m
Bug: 132721345
Change-Id: I9ef719f54f2bc8a54f23e88f46d74e35417a6519
(cherry picked from commit 3509b624fe)
2019-05-21 00:31:03 +00:00
Philip P. Moltmann
4f09b09f62 Merge "Whitelist all perms on installExistingPackage" into qt-dev 2019-05-17 19:56:19 +00:00
TreeHugger Robot
141e7b0395 Merge "Add support for returning installed apex modules in getInstalledModules" into qt-dev 2019-05-17 12:13:32 +00:00
Jeff Sharkey
04e5f7acff Merge "Cache resolved details about remote callers." into qt-dev 2019-05-16 03:29:16 +00:00
Jeff Sharkey
951f99ba02 Cache resolved details about remote callers.
The logic in MediaProvider is technically correct, but it's sometimes
inefficient in calling into the OS multiple times with the same
questions, such as validating getCallingPackage().

To mitigate this overhead, and start paving the way for more dynamic
delegation of permission checks, collect these details into a
LocalCallingIdentity object.  We carefully perform all permissions
checking against this new object, and avoid using any other
thread-local values from ContentProvider or Binder.

Local tests show this CL improves performance of a test app that
takes 100 rapid shots by 37%.

This change is a no-op refactoring.

Bug: 130758409, 115619667
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: If250a7675f2246cd10881acf615619d6d6061f3d
2019-05-15 19:20:01 -06:00
Mohammad Samiul Islam
c15221e354 Add support for returning installed apex modules in getInstalledModules
Bug: 131929295
Test: atest ModuleMetadataTests
Change-Id: I40be703f9844521342761f5af671823514a93d88
2019-05-15 19:22:20 +01:00
Philip P. Moltmann
a4bd150588 Whitelist all perms on installExistingPackage
The code allows to also whitelist only a select set of permissions, but
this is not yet exposed in the API.

Also: Fix up shell commands for restricted permissions

Fixes: 132368462
Test: - Enabled app via device admin in secondary profile
        -> verified that permissions were whitelisted
      - Installed existing and new app using --restrictpermissions and
        not
	-> verified that permissions were whitelisted or not
      atest AppRestrictionsHelperTest
            RestrictedPermissionsTest
Change-Id: I9cd76c555b40663f2e25ad86e8a54991baae346c
Merged-In: I9787e63d8beb8f6b1ba2d15532d4c0f69dbdf863
2019-05-15 11:09:45 -07:00
Ian Pedowitz
3bd719b534 Merge "Revert "Revert "Remove deprecated System APIs added in Q.""" into qt-dev 2019-05-15 16:28:54 +00:00
TreeHugger Robot
13e4ff16c4 Merge "Add an API for launching intent to view permission usage." into qt-dev 2019-05-14 13:24:56 +00:00
Suprabh Shukla
169bed7b7a Revert "Revert "Remove deprecated System APIs added in Q.""
This reverts commit 79a19effee.

Bug: 129975435
Change-Id: I113c87f8c0b7ab225e4b99ef2462ae12e199b816
2019-05-13 21:04:39 +00:00
TreeHugger Robot
81f5007d5f Merge "Clarify ContentResolver docs." into qt-dev 2019-05-13 20:38:54 +00:00
Svet Ganov
810d48445b Add an API for launching intent to view permission usage.
Adding a new intent acttion for the permission controller to ask an
app to show its permission usage to help the user understand what
and why is being used. We are adding a permission to protect this
action to prevent apps trampolining into other apps when asked to
show their permission usge.

Test: compiles

bug:131760942

Change-Id: I5217d6319fd98d40c8879bdd7af5fe466bf9143e
2019-05-13 03:40:13 +00:00
TreeHugger Robot
22f9d7ea44 Merge "Fix the constant value for hidden BIND flag" into qt-dev 2019-05-10 21:45:42 +00:00
Varun Shah
c4fdfa3a3f Clarify ContentResolver docs.
Explain under what conditions #query and #insert may return null.

Bug: 31043947
Test: n/a (docs update only)
Change-Id: I8880f80bfa2efff296a0a07c0bf28e9606d6db65
2019-05-10 14:10:08 -07:00
Amith Yamasani
0b3ae0eb81 Fix the constant value for hidden BIND flag
The hidden flags should use higher values so as to not
interleave with public flags.

Bug: 132438913
Test: CtsAppTestCases
Change-Id: Ic1dad21c2da5e5e60dc0401ee163f2188cc0f5dc
2019-05-10 10:51:15 -07:00
Shafik Nassar
b273078adf Merge "Fail to enable rollback if enable rollback times out" into qt-dev 2019-05-10 10:23:53 +00:00
TreeHugger Robot
1fca828af3 Merge "Remove hasIsolatedStorage() related logic from PackageParser." into qt-dev 2019-05-09 20:44:26 +00:00
Dario Freni
fca6e42895 Merge "Allow persistent APKs updates using PM flags." into qt-dev 2019-05-09 18:49:13 +00:00
Hai Zhang
e7e00bdaca Remove hasIsolatedStorage() related logic from PackageParser.
The ACCESS_MEDIA_LOCATION and WRITE_OBB permissions will always be
available.

Bug: 112545973
Fixes: 132226317
Test: presubmit
Change-Id: Ie61eba427b48f347438522bc11cfa748ad5ba1f1
2019-05-09 11:29:50 -07:00
Hai Zhang
8e1c4a0916 Merge "Remove default app permission granting from DefaultPermissionGrantPolicy." into qt-dev 2019-05-09 17:33:50 +00:00
shafik
4831ad7039 Fail to enable rollback if enable rollback times out
Make PackageManager send a ACTION_CANCEL_ENABLE_ROLLBACK intent to
RollbackManager. RollbackManager marks the relevant rollback as invalid.
Allow enable rollback to continue as usual, before making the rollback
available, RollbackManager checks whether it's valid. If it's not, the
rollback data is deleted.

Add a test case for expired rollback enabling attempt in RollbackTest.

Test: atest RollbackTest#testEnableRollbackTimeoutFailsRollback
Test: manual -
      * Set ENABLE_ROLLBACK_TIMEOUT_MILLIS to 1 ms using DeviceConfig
      * Install a mainline module with rollback enabled
      * adb shell dumpsys rollback
      * observe that no rollback was made available
Fixes: 131679409

Change-Id: Iaa4dbff002b820aff1fc3e1b985f129cf5ebe2e6
2019-05-09 12:38:04 +01:00
Svetoslav Ganov
650cb05202 Merge "Restricted permission whitelisted by default" into qt-dev 2019-05-08 02:17:24 +00:00
Hai Zhang
c139927c0a Remove default app permission granting from DefaultPermissionGrantPolicy.
This change removes the permission granting for non-system dialer and
SMS apps in DefaultPermissionGrantPolicy. Permission granting to
system apps is left unchanged. Package manager is also made to query
role manager for the current default dialer instead of maintaining its
own storage.

Bug: 124452117
Bug: 129211673
Test: presubmit
Change-Id: I3c5c122802c3ecf15984a24c24c69a9e2f310bb7
2019-05-07 16:03:54 -07:00
Svet Ganov
83a3a4a9db Restricted permission whitelisted by default
To ensure existing installers would work without a change the
default state of installing a package is now that all restricted
permissions are whitelisted. If the installer specifies another
whitelist at install time, it determines the install state. In
addition to this we now enable the restricted permission checks
as a prebuilt installer is no longer required.

Test: atest CtsPermission2TestCases
Test: atest CtsPermissionTestCases
Test: atest CtsAppSecurityTestCases:android.appsecurity.cts.PermissionsHostTest

bug:132160728

Change-Id: I705e341faebe62fc2d88fd37ad8870b98e1b71b1
2019-05-07 12:25:39 -07:00
Tim Murray
d06c6d2932 Revert "Add optional reasons why permissions were denied"
This reverts commit 3623f3219e.

Reason for revert: 40% startup perf regression

Test: revert
Bug 132129453
Exempt-From-Owner-Approval: critical revert

Change-Id: I19dc33e6a71c9254b4096154f4089c059fe408dd
2019-05-07 07:10:30 +00:00
TreeHugger Robot
cc1159a166 Merge "Add Locale#script to Configuration proto." into qt-dev 2019-05-06 18:29:30 +00:00
TreeHugger Robot
dd82c4513b Merge "Add optional reasons why permissions were denied" into qt-dev 2019-05-06 06:21:23 +00:00
Philip P. Moltmann
3623f3219e Add optional reasons why permissions were denied
Currently only for the ContextImpl.enforcePermission code paths and only
when 'secure debug_package_permission_check' is set.

This feature is disabled on user-builds.

Test: Enabled permission checking for my app and
      - checked runtime permision denial
      - permission denial because app is instant
Bug: 111075456
Change-Id: Ib85777db69ee490608e9dac32a3b97971c0ba215
2019-05-05 21:05:13 -07:00
Philip P. Moltmann
55ecaac312 Add new permission flags to @Flags int-def
also expose all flags for being tested.

Test: built
Bug: 131188279
Change-Id: I2874298d87a76ee2bc95f18346d8ae597a3152ad
2019-05-03 08:33:27 -07:00
Richard Uhler
07a9e9f9f9 Merge "Ensure race between rollback and roll forward is properly handled" into qt-dev 2019-05-03 08:09:17 +00:00
Varun Shah
95fabaf389 Add Locale#script to Configuration proto.
Read/Write Locale#script along with language, country, and variant
for the Configuration proto.

Bug: 131507134
Test: atest UsageStatsDatabaseTest
Test: atest LocaleListTest [unit-test, cts, gts]
Change-Id: I09b7d3b2e6c6d339cbb75bf19f89251b777bbbe6
2019-05-02 11:56:50 -07:00
TreeHugger Robot
2cf92e602a Merge "Address some comments for the soft restriction CL" into qt-dev 2019-05-02 17:02:23 +00:00
TreeHugger Robot
b037feb130 Merge "Fix can't create thumbnail and wrong orientation issue" into qt-dev 2019-05-02 05:01:15 +00:00
Ian Pedowitz
8b3b7771c1 Merge "Revert "RESTRICT AUTOMERGE Remove deprecated System APIs added in Q."" into qt-dev 2019-05-02 00:59:09 +00:00
Ian Pedowitz
79a19effee Revert "RESTRICT AUTOMERGE Remove deprecated System APIs added in Q."
This reverts commit 02014297fd.

Reason for revert: QT SDK Finalization. Will be merged again on/after May 13th

Bug: 129975435
Change-Id: Ia054b193a982dee669630555974d2d7831fe2b50
2019-05-02 00:54:39 +00:00
Ian Pedowitz
3f38719b74 Merge "RESTRICT AUTOMERGE Remove deprecated System APIs added in Q." into qt-dev 2019-05-02 00:53:29 +00:00
TreeHugger Robot
9f514dbb27 Merge "Fix issue #126884118: API Review: API Review: Enabling Chrome Site Isolation" into qt-dev 2019-05-01 20:08:37 +00:00
Dario Freni
a2afebf9ea Allow persistent APKs updates using PM flags.
This is a different approach than
I346d772e1f4aed94f6faead3b6455efc4666b651, suggested during reviews.

Bug: 131046856
Test: marked the NetworkStack APK as persistent, verified that
  - adb install networkstack.apk fails
  - adb install --staged networkstack.apk succeds (after reboot)

Change-Id: I1facb24786431906a8056a50bff01745cebacf24
2019-05-01 20:14:26 +01:00
TreeHugger Robot
552edb80ad Merge "Un-deprecate PackageManager.replacePreferredActivity." into qt-dev 2019-05-01 16:57:06 +00:00
Richard Uhler
2124d4b313 Ensure race between rollback and roll forward is properly handled
If rollback for a package is committed at the same time the package is
updated, it's possible we will incorrectly roll back the newly updated
version of the application.

Add a hidden API to the package installer that lets you set a required
existing version of a package to be updated. If the expected package
version is not installed at the time of commit, the update install
fails.

The RollbackManager uses this new API to ensure that rollback will fail
if the package in question was just updated.

Test: atest RollbackTest, with new test added and manual confirmation
      that the race condition was exercised by the new test.
Bug: 128831080

Change-Id: Ifa5627e257d2ef13e2b213ef0dbc93932797ce0d
2019-05-01 09:10:36 +00:00
Svet Ganov
b687fad0dd Address some comments for the soft restriction CL
Test: compiles

bug:130739772

Change-Id: Ibf545434db59d17affcc0bba54a9ca7cf16c4012
2019-04-30 17:32:48 -07:00
Sudheer Shanka
02014297fd RESTRICT AUTOMERGE Remove deprecated System APIs added in Q.
Test: Builds, boots
Bug: 129975435
Change-Id: I4bfd0bfbbc52b7822477ec0c70a08de6f85a3672
2019-04-30 10:49:28 -07:00
Sudheer Shanka
d4122490da Un-deprecate PackageManager.replacePreferredActivity.
PermissionController needs this.

Bug: 131634653
Test: builds
Change-Id: If1639d8a0abbc8b3840a5868be9aa94963280a9d
2019-04-30 00:48:09 -07:00
Dianne Hackborn
cc67f96ef6 Fix issue #126884118: API Review: API Review: Enabling Chrome Site Isolation
Improve documentation.

Fixes: 126884118
Test: manually built docs
Change-Id: I31118e792ceeeea8390bccedc06cf6655fc064f9
2019-04-29 16:34:24 -07:00
Winson Chung
43f311e9ec Exposing default theme overlays to system callers
Bug: 130185871
Test: Manual
Change-Id: Iadb08d76ef7e176e270d4f052c86b631f0810b80
2019-04-29 15:34:45 -07:00
Ivan Chiang
6da7b0adcc Fix can't create thumbnail and wrong orientation issue
- When MediaMetadataRetriever can't create the thumbnail of some
  HEIF files, attempt decoding it from ExifInterface.

- ImageDecoder can't create the thumbnail with getThumbnailBytes
  from ExifInterface in some cases. It will occur DecodeException:
  Failed to create image decoder with message 'unimplemented'Input
  contained an error. Attempt to decoding the full image in these
  cases.

- Use orientation from ExifInterface to transform the thumbnail to
  right orientation.

Test: manual
Test: atest ThumbnailUtilsTest
Bug: 130775874
Fix: 130446058
Change-Id: Icd0726ec49fe85651150736199c3caa184fa1a3f
2019-04-29 21:18:57 +08:00
Hai Zhang
9ab1a0daf3 Merge "Add FLAG_PERMISSION_GRANTED_BY_ROLE." into qt-dev 2019-04-28 14:41:09 +00:00