Commit Graph

9243 Commits

Author SHA1 Message Date
Kholoud Mohamed
4bf358fe39 Merge "Fix javadoc for CrossProfileApps#canRequestInteractAcrossProfiles" into rvc-dev 2020-04-23 10:12:36 +00:00
Charles Chen
1e52a093ae Merge "Limit number of window context without any window" into rvc-dev 2020-04-23 03:34:37 +00:00
kholoud mohamed
716cf78bfe Fix javadoc for CrossProfileApps#canRequestInteractAcrossProfiles
Remove the app being whitelisted requirement from
the javadoc.

Fixes: 154712757
Test: N/A
Change-Id: Ib476d0b19717e901d26039194d33f8c43f7e3f74
2020-04-22 17:03:21 +00:00
Alex Buynytskyy
d48ca975b6 Merge "Packages on IncrementalFS can't have oat dir." into rvc-dev 2020-04-22 17:01:00 +00:00
Charles Chen
2622d3ef7e Limit number of window context without any window
This change is to prevent misuse of window context from app
and leads to performance drop on system by limit the numer of window
context an app can use. Code snippet below is a sample to cause
this issue:
```
Rect getBounds() {
    Context windowContext = context.createWindowContext(...);
    return windowContext.getSystemService(WindowManager.class)
            .getCuttentWindowMetrics().getBounds()
}
```
This method could be invoked dozens of times and produce dozens of window
tokens. It would slow down the speed of window traversalling. These
token won't be removed until system server has been GC'd.

Test: atest WindowContextTests WindowContextPolicyTests
fixes: 152934797
Bug: 153369119

Change-Id: I927e85a45c05c4d90b51a624ea408ff3a3ffce93
2020-04-22 18:16:56 +08:00
Alex Buynytskyy
d29a2ccced Packages on IncrementalFS can't have oat dir.
Bug: b/154535403
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest
Change-Id: I7428f3c0a28cc300586ad083cc4ab12082d67e72
2020-04-21 16:39:38 -07:00
Jeff Sharkey
b67e70aa40 Merge changes from topic "apr19" into rvc-dev
* changes:
  Update some Parcelables to send Strings UTF-8.
  Offer to write Strings through Parcels as UTF-8.
2020-04-21 22:59:40 +00:00
Jeff Sharkey
0223df096c Update some Parcelables to send Strings UTF-8.
An earlier CL with benchmarks has shown that sending strings as UTF-8
is 50% faster for US-ASCII strings, and still 68% faster for complex
strings referencing higher Unicode planes.  (So an improvement in
both cases!)

Since code across the OS still makes heavy assumptions about Parcel
strings typically being UTF-16, we need to carefully migrate
Parcelables by hand, which is what this CLs begins doing.

This is a purely mechanical refactoring with no functional changes.

Bug: 154436100
Test: manual
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: Ia9e581efd7c40269342b7528ca07363deb843c0f
2020-04-21 22:59:26 +00:00
TreeHugger Robot
2f14c3a752 Merge "DataLoader statuses, explained." into rvc-dev 2020-04-21 22:44:40 +00:00
Alex Buynytskyy
785957d352 DataLoader statuses, explained.
Bug: b/153874006
Test: comment-only change
Change-Id: I6c85c1c6fc5c922e9d789b3ecd31a94c812dc3a1
2020-04-21 13:36:19 -07:00
Jeff Sharkey
d387e79ae1 Offer to write Strings through Parcels as UTF-8.
Recently while investigating some Binder limits, I discovered that
we're still sending Strings across Binder as UTF-16, which is very
wasteful for two reasons:

1. The majority of data flowing through APIs like PackageManager is
already limited to US-ASCII, and by sending UTF-16 we're wasting
half of our transactions on null-byte overhead.

2. Internally ART is already "compressing" simple strings by storing
them as US-ASCII instead of UTF-16, meaning every time we want to
write a simple string to Binder, we're forced to first inflate it
to UTF-16.

This change first updates Parcel.cpp to accept char* UTF-8 strings,
similar to how it accepts char16_t* for UTF-16.  It then offers
both UTF-8 and UTF-16 variants to Parcel.java via JNI.  We also
update the String8 handling to behave identical to String16.

This change adds benchmarking to show that these new methods are
about 50% faster for US-ASCII strings, and about 68% faster for
complex strings that reference higher Unicode planes.  (So an
improvement in both cases!)

Bug: 154436100
Test: atest FrameworksCoreTests:ParcelTest
Test: make core-libart conscrypt okhttp bouncycastle vogar caliper && vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/ParcelStringBenchmark.java
Change-Id: I22a11d3497486d922ec8e14c85df66ca096b8f2a
2020-04-21 09:38:36 -06:00
Jeongik Cha
9ccdd32880 Support multiple requiredSystemProperty in overlay
As-is: Only one requiredSystemProperty is allowed
To-be: It supports several requiredSystemProperty

Here is format for multiple fields.
  android:requiredSystemPropertyName="rw.num,rw.char"
  android:requiredSystemPropertyValue="1,a"

Test: m
Test: Make two overlay with different condition
      Check if it works properly depending on condition
      If there is no overlay package matching the condition, both aren't
      applied

Bug: 137628879
Merged-In: I4c8c4a1304dc52d6568767d90e3dcbf6acef024a
(cherry picked from commit 5e6a87013f)
Change-Id: If3765218c96f8922c155e18e99b0f4bb6a032ff1
2020-04-20 08:11:45 +00:00
TreeHugger Robot
dd08939ba8 Merge "RESTRICT AUTOMERGE: Autocork package invalidations" into rvc-dev 2020-04-17 23:26:42 +00:00
TreeHugger Robot
e185aca339 Merge changes If07d6938,I32f9b89a,Ife4f8c4e into rvc-dev
* changes:
  RESTRICT AUTOMERGE: Add a facility for time-based cache corking
  RESTRICT AUTOMERGE: Cork permission and package cache around bulk permission update
  RESTRICT AUTOMERGE: Cork package information cache invalidations during boot
2020-04-17 23:25:02 +00:00
Edgar Arriaga
c7f8e75806 Optimization: remove duplicated flags computations for getInstalledPackages
Below are some test runs that show 100 iterations of getInstalledPackages ran
at activity startup of touchlatency app to demonstrate the perf cost.

R Baseline:
https://screenshot.googleplex.com/PnVi5APraJo
https://pprof.corp.google.com/?id=dc105ca9592f8367c381e2dcf7f1847d

R Optimized:
https://pprof.corp.google.com/?id=2d1d9fadc20bcc61d41bd52116bd94e3
https://screenshot.googleplex.com/OAwJnvwPqPH

Savings: 8% of system_server binder response time when the call is executed.

In terms total binder transaction time. Savings are 2% of the total
binder call time.

Exempt-From-Owner-Approval: CP to correct branch for R

Bug: 153656459

Test: atest FrameworksServicesTests:PackageParserTest
Test: atest FrameworksServicesTests:PackageParserLegacyCoreTest
Test: atest FrameworksServicesTests:ScanTests
Test: atest FrameworksServicesTests:ParallelPackageParserTest

Merged-In: I2de9cf1f754a505239d4416e1fc70bf77932c5db
Change-Id: I2de9cf1f754a505239d4416e1fc70bf77932c5db
(cherry picked from commit 7cb9e5f671)
2020-04-17 18:38:29 +00:00
Daniel Colascione
d59e2a9045 RESTRICT AUTOMERGE: Autocork package invalidations
Bug: 140788621
Test: m; strace -s512 -f -p 1 2>&1 | grep 'cache_key'
Change-Id: Iceaabee5ea8eac42934c1cc4914cdf43d2f11f58
2020-04-17 00:19:21 +00:00
Daniel Colascione
f73a41c1cf RESTRICT AUTOMERGE: Cork package information cache invalidations during boot
Bug: 140788621
Bug: 150331002
Test: enable DEBUG; watch log
Change-Id: Ife4f8c4e7d10524d6000399947a4e4b9d36db750
2020-04-17 00:18:24 +00:00
Oli Lan
46a0a5abb5 Merge "Add min extension versions to AndroidPackage." into rvc-dev 2020-04-16 08:21:33 +00:00
TreeHugger Robot
a93686c403 Merge "bypass anti-malware verification" into rvc-dev 2020-04-15 20:13:43 +00:00
Todd Kennedy
75dd0e649a bypass anti-malware verification
For incremental installations only, we skip the verification
request broadcast and instead always send a verified broadcast
with the root hash.

Bug: 151240337
Test: Manual. Install APK normally and see the verifier request broadcast is sent
Test: Manual. Install APK incrementally and see verifier request broadcast is not sent, and verified broadcast is sent with root hash
Change-Id: I2599472818b63ea172d2d412741e5540c8a52176
2020-04-15 10:33:19 -07:00
Oli Lan
72ae4476d4 Add min extension versions to AndroidPackage.
The <extension-sdk> manifest tag was added in ag/1004614 to
allow apps to specify the minimum versions they need of
extension SDKs.

This adds the min extension versions to ParsingPackage.

This will be needed to allow us to perform checks that rollbacks do
not violate the min extension versions of installed apps (see
go/sdk-extensions-and-rollback).

Bug: 152737927
Test: atest PackageParserLegacyCoreTest#testUsesSdk
Change-Id: I2e080e46aaea6de489766dac0d323d7d2c7302ca
2020-04-15 15:59:23 +01:00
TreeHugger Robot
cde07e5dc5 Merge "Limit stage install to system and whitelisted packges only (2/2)" into rvc-dev 2020-04-14 13:43:50 +00:00
TreeHugger Robot
de659b3b13 Merge "Only grant visibility of protected broadcasts to system" into rvc-dev 2020-04-13 19:51:19 +00:00
Ryan Mitchell
b8a61d13c2 Merge "Fail install when resources.arsc is compressed" into rvc-dev 2020-04-13 14:57:19 +00:00
TreeHugger Robot
fd09fe5cea Merge "Return actual failure to parse base APK" into rvc-dev 2020-04-10 15:28:13 +00:00
Winson
36c4470a20 Return actual failure to parse base APK
This exposes errors directly, which mirrors what PackageParser
used to do. Just a leftover TODO from the refactor.

Bug: 153472626

Test: manual install broken APK and check the error is logged

Change-Id: I06804ad7396196e28ce2177a671d4eef3958e1d6
2020-04-09 13:51:37 -07:00
Ryan Mitchell
192400cf33 Fail install when resources.arsc is compressed
If an application targets R+, prevent the application from being
installed if the app has a compressed resources.arsc or if the
resources.arsc is not aligned on a 4-byte boundary. Resources tables
that cannot be memory mapped have to be read into a buffer in RAM
and exert unnecessary memory pressure on the system.

Bug: 132742131
Test: manual (adding CTS tests)
Change-Id: Ieef764c87643863de24531fac12cc520fe6d90d0
2020-04-09 11:01:54 -07:00
Jeff Sharkey
9d475e958d Offer a NOTIFY_NO_DELAY flag for notifications.
We've heard reports that some ContentProviders are sensitive to their
notifications being delayed, so this change adds a NOTIFY_NO_DELAY
flag that they can use to bypass any background delays.

Bug: 149370968
Test: none
Change-Id: I0465c8dee92cd5708c04035bc0396ce2d1083f67
2020-04-08 16:32:41 -06:00
Patrick Baumann
40cb0205d4 Only grant visibility of protected broadcasts to system
This change ensures that only the system (appId < 10000) may see apps
with receivers of protected broadcasts.

Test: atest AppsFilterTest
Fixes: 142386375
Change-Id: Ia421d2aa22d37eafbb6c1cd217ab2cb1626480b0
2020-04-08 10:23:49 -07:00
Jerry Chang
30a1f13dd8 Limit stage install to system and whitelisted packges only (2/2)
Add a whitelist check to limit staged installers beside system and a pm
shell command to bypass the next staged installer check.

Bug: 148664742
Test: atest StagedInstallerTest StagedRollbackTest
Change-Id: Ie9297ad8c1b74c2e63a08c71f2279658661f9a32
2020-04-08 11:05:17 +08:00
Alex Buynytskyy
f415679228 Change the way how we call setStorageParams.
Now it's unified with callback FS connector - we are passing the
callback pointer directly to dataloader. This restricts access only
to methods we want and only by someone we want.

Bug: b/153468113
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest
Change-Id: Ib557ebbe7c6c5ce92140eb20534a3626b3ac96d3
2020-04-07 14:42:50 -07:00
Kholoud Mohamed
5ec3cbac4c Merge "Remove platform-signed apps from configurable cross profile apps" into rvc-dev 2020-04-07 09:55:18 +00:00
Rhed Jao
2aab1a4d49 Merge "Fix an exception while scanning apex packages" into rvc-dev 2020-04-07 08:49:48 +00:00
kholoud mohamed
9bbab6a6df Remove platform-signed apps from configurable cross profile apps
Most apps that declare the INTERACT_ACROSS_PROFILES permission do
not have it granted, but get the app-op instead. We do not
normally want platform-signed apps that are actually given the
permission to appear in the user-configurable section in Settings,
so we remove them from the return value of
canUserAttemptToConfigureInteractAcrossProfiles in this CL.

Note that OEM can choose to allow some platform-signed apps to be
user-configurable by including them in their OEM whitelist file.
This CL respects that and allows these apps to be configured by the user,
despite being granted the permission. If the user rejects the app-op,
PermissionChecker correctly returns false.

Bug: 149742043
Test: atest CrossProfileAppsServiceImplRoboTest
Change-Id: I693338507eec9cdc0ba10a3584e994a58d2d113c
2020-04-06 10:13:09 +00:00
TreeHugger Robot
001fddc078 Merge "Update documentation of Resources#getDisplayMetrics" into rvc-dev 2020-04-06 07:01:35 +00:00
Mehdi Alizadeh
6991da300f Merge "Wrap ShortcutQuery in a parcelable wrapper object and pass it direcly through aidl." into rvc-dev 2020-04-04 00:23:47 +00:00
Ryan Mitchell
1b922d56c0 Merge "Begin moving FrameworkResourceLoaderTest to cts" into rvc-dev 2020-04-03 16:03:24 +00:00
Winson
468825347e Query PlatformCompat for targetSdk check in AndroidPackageParsingTestBase
There are prebuilts in the tree and perhaps APKs in general
which don't conform to the manifest checks added in R, so the code
that parses the APK to verify v1 vs v2 needs to actually query
PlatformCompat to do the proper targetSdkVersion check and allow
the APK through if it's not updated yet.

A related change to default enabled inside ParsingPackageImpl to
true was also made, as if any malformed APK was allowed through
without an <application> tag, it would never hit the code
where enabled gets assigned to default true.

Any further errors spit out by this test are critical and need to
updated so that their APKs can be installed on R.

Bug: 153058196

Test: manual verify error behavior with broken APK
Test: atest com.android.server.pm.parsing

Change-Id: I2b117f2098d8bd62b92921178a098e838b55b06d
2020-04-02 15:10:13 -07:00
Pinyao Ting
1f31f3ee79 Wrap ShortcutQuery in a parcelable wrapper object and pass it
direcly through aidl.

As part of the effort to simplify the implementation of
LauncherAppsService, We create ShortcutQueryWrapper, a parcelable
object that wraps ShortcutQuery and pass it to LauncherAppsService
directly.

Bug: 148104408
Test: atest ShortcutQueryTest
Merged-In: I2e2ccaf38ef6bd558b4b02e647a7e263c7e612a9
Change-Id: I2e2ccaf38ef6bd558b4b02e647a7e263c7e612a9
(cherry picked from commit d043004cee)
2020-04-02 21:51:59 +00:00
Winson Chiu
bd24ca3daf Merge changes from topic "revert-10921255-revert-10403399-pkg-override-label-icon-DCRMJNYAKW-YCXMFEDIAG" into rvc-dev
* changes:
  Add mPackageParserCallback assignment in TestParams constructor
  Revert "Revert "Allow overriding the label and icon of a MainCom..."
  Revert^2 "Add test constructor to PackageManagerService"
2020-04-02 07:49:40 +00:00
Rhed Jao
269616bed2 Fix an exception while scanning apex packages
Package parser throws an exception while it's in the onlyCoreApp
state and parsing an non-core app. Catching the parser exception
during scanning apex packages, if the apex is without coreApp
attribute and device is in minimal boot state.

Also, updates package parser to V2 for the staging manager.

Bug: 151296698
Test: atest ApexManagerTest
Test: atest StagedInstallTest
Change-Id: I098e08d4064812465a29086c3fde1a55348bcae5
2020-04-02 12:41:51 +08:00
Mehdi Alizadeh
f802f3777e Adds ShortcutServiceInternal#isSharingShortcut()
Bug: 152346206
Test: atest com.android.server.pm.ShortcutManagerTest1
Change-Id: I86bea32215a24aa5c7be3a5bc4bbf704b39baea0
2020-04-01 21:49:44 +00:00
Ryan Mitchell
199b09a1a7 Begin moving FrameworkResourceLoaderTest to cts
This changes removes FrameworkResourceLoaderTest from frameworks/base
before it is moved to CTS.

Bug: 152979463
Test: atest CtsResourcesLoaderTest
Change-Id: I4b899564ab93472cb6d2a5ed0917026753c2827f
2020-04-01 20:09:29 +00:00
Winson Chiu
8e865ecd06 Revert "Revert "Allow overriding the label and icon of a MainCom..."
Revert submission 10921255-revert-10403399-pkg-override-label-icon-DCRMJNYAKW

Reason for revert: Re-submit broken change with included fix.
Reverted Changes:
Ic5c719cbb:Revert "Allow overriding the label and icon of a M...
Id9d37e661:Revert "Add test constructor to PackageManagerServ...

Bug: 113638339

Change-Id: I4f5247f528f62c175bd34f0e4cb16c9456c8afe4
2020-04-01 19:17:53 +00:00
Steven Thomas
b69f2bc126 Merge changes from topic "revert-10403399-pkg-override-label-icon-DCRMJNYAKW" into rvc-dev
* changes:
  Revert "Add test constructor to PackageManagerService"
  Revert "Allow overriding the label and icon of a MainComponent"
2020-04-01 18:13:13 +00:00
Steven Thomas
822bc84bfe Revert "Allow overriding the label and icon of a MainComponent"
Revert submission 10403399-pkg-override-label-icon

Reason for revert: Droidcop: Potential culprit for Bug 152987173 - verifying through Forrest before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Reverted Changes:
I4b20ec294:Add test constructor to PackageManagerService
Id48eda556:Allow overriding the label and icon of a MainCompo...

Change-Id: Ic5c719cbbd904f8cc1c5c6a6d826c7b807f03e39
2020-04-01 17:50:51 +00:00
Winson Chiu
9249981abb Merge changes from topic "pkg-override-label-icon" into rvc-dev
* changes:
  Allow overriding the label and icon of a MainComponent
  Add test constructor to PackageManagerService
2020-04-01 16:53:57 +00:00
Charles Chen
529318a713 Update documentation of Resources#getDisplayMetrics
Test: build & run
fixes: 150213575
Change-Id: I439a8f8473236e29cc6371cda51e46a3b242ec3e
2020-04-01 18:29:51 +08:00
Winson
727da64be5 Gate stricter manifest enforcement on targetSdk R
Two package parsing issues have been promoted to failures in R:
a missing <application>/<instrumentation> tag, and an empty
"android:name" attribute. The latter due to a bug in the parsing
code.

These need to be gated by targetSdkVersion so that APKs built for
previous versions can still scan/install properly. This change
introduces support for this through a framework that leverages
@ChangeId to introduce individually toggle-able errors, in
case a developer needs to install an app that isn't completely
migrated for a new SDK version yet.

The ignoreError method was removed from ParseResult as the errors
it was used for were manually compared to PackageParser and it's
likely they can be hard errors without breaking anything.

This also adds tests for general ParseInput/Result behavior.

Exempt-From-Owner-Approval: AppIntegrity already approved in older PS.

Bug: 150776642

Test: atest android.content.pm.parsing.result.ParseInputAndResultTest
Test: atest com.android.server.pm.parsing.PackageParsingDeferErrorTest
Test: atest com.android.server.integrity.AppIntegrityManagerServiceImplTest
Test: atest com.android.server.pm.parsing

Change-Id: Id53a2e65f6e5e4dee9a41cc77007275b3a220ac3
2020-04-01 05:42:52 +00:00
Dmitri Plotnikov
13c7d899da Merge "Use ParcelableException to put exception in bundle" into rvc-dev 2020-03-31 18:36:57 +00:00