Commit Graph

9004 Commits

Author SHA1 Message Date
Automerger Merge Worker
cc5a5939a0 Merge "Revert "Revert "[DexLoadReporter] Report classloader contexts di..."" am: 1ee3e70cf3 am: 2cef69cb5f am: a2c3c9fe10
Change-Id: I6d7ba01f4083ed01eea0ec0dda0b69f27a4b1346
2020-02-19 23:19:40 +00:00
Khaled Abdelmohsen
41456aa99c Create rule atom for source stamp
Bug: 149200249
Test: atest FrameworksCoreTests:IntegrityFormulaTest
Change-Id: I8a5ca33e8b2b125a8b7bc178557b7689c0eab50d
2020-02-19 22:41:16 +00:00
Winson Chiu
633cd037f7 Merge changes from topics "package-parsing-v2.1", "parsing-parsed-package-split"
* changes:
  Remove AndroidPackageWrite
  Migrate to new ParsedComponents and ParseResult
  Split ParsedComponents
  Add ParseResult infrastructure
  ParsingPackage/ParsedPackage test code migration
  ParsingPackage/ParsedPackage split source migration
  Important migration for new ParsingPackage/ParsedPackage split
  Separate ParsingPackage into core and ParsedPackage into server
2020-02-19 22:16:15 +00:00
Automerger Merge Worker
a2c3c9fe10 Merge "Revert "Revert "[DexLoadReporter] Report classloader contexts di..."" am: 1ee3e70cf3 am: 2cef69cb5f
Change-Id: I6146cfbbd0a8214e476e50b359ce5474e6d5070c
2020-02-19 20:12:07 +00:00
Automerger Merge Worker
2cef69cb5f Merge "Revert "Revert "[DexLoadReporter] Report classloader contexts di..."" am: 1ee3e70cf3
Change-Id: I5645d6c8f666e2e29e753cad5f216f9d7ab335d2
2020-02-19 19:52:57 +00:00
Calin Juravle
1ee3e70cf3 Merge "Revert "Revert "[DexLoadReporter] Report classloader contexts di..."" 2020-02-19 19:38:35 +00:00
Calin Juravle
c78162f489 Revert "Revert "[DexLoadReporter] Report classloader contexts di..."
Original commit:
[DexLoadReporter] Report classloader contexts directly from classloader

At the moment classloader contexts are incorrectly computed in the
PackageManager for secondary dex files. There are two issues:

(1) The wrong computed classLoaderContext will be reported for a secondary
    dex file if it was loaded at the same time as a primary dex file
    - This is due to the continue statement that doesn't increment
      dexPathIndex
(2) If a secondary dex file was loaded with a shared library then that
    shared library info isn't passed through the dex load reporting
    infrastructure, and thus its classloader context is incorrectly computed
    in PackageManager.

In order to fix the issues described above & prevent further classloader
context computation divergences between the package manager and the
runtime, lets compute the classloader context in the runtime at dex load
time and report the expected classloader context directly to
DexLoadReporter (and thus the package manager).

Notes: This is mostly just a refactor (i.e. there are a lot of line
changes, but functionally speaking this set of CLs doesn't do much
except change where the classloader context is computed)

Addendum: The bugs described above could also be fixed by:
- changing DexLoadReporter to report information about shared libraries that
  the reported classloaders depend on to PackageManager
- Teach DexoptUtils.processContextForDexLoad about shared libraries
- Fix dexPathIndex calculation in DexManager

I opted for this set of changes instead because this reduces the
possibility of context computation divergence between the framework and the
runtime. Additionally it feels more "solid" that the classloader context
is now computed directly when a dex file is loaded, rather than the
context recreated later on in the PackageManager.

Test: atest com.android.server.pm.dex.DexManagerTests
Test: atest com.android.server.pm.PackageManagerServiceTest
Test: Install app depending on shared library & uses secondary dex
files; adb shell pm bg-dexopt-job; launch app and see odex file
successfully loaded (from smaps/no logcat errors)

Bug: 148494302
Exempt-From-Owner-Approval: This is a pure re-revert, previously owner approved.
Reason for revert: Re-land
Reverted Changes:
I295a6e99e:Revert "Fix shared libraries not being reported vi...
Ib58066e8f:Revert "[DexLoadReporter] Report classloader conte...

Change-Id: I8d1af791f93a3f8fa6eca78df50891cd2ebbb4a3
2020-02-19 19:37:05 +00:00
Danning Chen
19aae7561a Merge "Add getShareTargets() to ShortcutServiceInternal and get caller's user ID from AppPredictionSessionId" 2020-02-19 17:34:40 +00:00
Winson
f00c755a23 Migrate to new ParsedComponents and ParseResult
Removes the massive old ComponentParseUtils in favor of
the new split classes.

Cleans up the parsing code to be uniform, removing the
String[] outError pattern in favor of ParseInput.

Bug: 135203078

Test: atest com.android.server.pm

Change-Id: I584ed37d4715300453dbe760d45d1eb4759b3dd3
2020-02-19 08:31:48 -08:00
Winson
022e707f90 Split ParsedComponents
This creates individual files for each Parsed_ object.

Each also has a corresponding _Utils class for holding the
parsing logic for each object. This was done to keep the data
class as simple as possible.

This commit does not migrate existing usages of ComponentParseUtils
subclasses, so there will be duplicates of everything. A follow up
change will migrate all the parsing logic to use these new classes.

Bug: 135203078

Test: none, all testing for Parsed_ is to-be-merged and/or TBD
Change-Id: I7bea3b1742bc5d945d1ad287f406488d3bf46476
2020-02-19 08:23:01 -08:00
Winson
3dc4af4769 Add ParseResult infrastructure
ParseInput is passed into all parsing methods and simply acts as
a shared container which can hold a generic success or error value.
When it is transformed into a result value, it must be returned to
its parent immediately, who can decide what to do with it.

ParseResult is the type returned when a ParseInput is set to success
or error. It casts itself to a strong type representing the returned
value, and is used by specifying ParseResult<ResultType> instead of
just ResultType for the method return type.

ParseTypeImpl is just the implementation of the two above which handles
moving between them. It also adds some debug functionality in case
the error catching code is incorrect or insufficient and it would be
preferably to always have a stack trace.

It is important to use this infrastructure in a thread-local manner,
such that you don't re-use an input already in use and always bubble
up on any success or error.

A constrained example:

class Parser {

    val shared = ParseTypeImpl<>()

    fun parse(file: File): Pair<Output, Output> {
        // Reset the shared object
        val input = shared.reset()

        // Pass it to be used by the parsing method
        var result = parseOutput(input, file.read())

        // Verify the result
        if (result.isError()) {
            // Bubble up error if necessary
            throw Exception(result.errorMessage, result.exception)
        }

        // Save the result (as it will be lost when the input is reused)
        val one = result.result

        // Parse something else
        result = parseOutput(input, file.read())

        // Same verification
        if (result.isError()) {
            // Bubble up error if necessary
            throw Exception(result.errorMessage, result.exception)
        }

        val two = result.result
        return one to two
    }

    fun parseOutput(input: Input, read: Object): ParseResult<Output> {
        return if (read == null) {
            input.error("Something went wrong")
        } else {
            input.success(read)
        }
    }
}

Bug: 135203078

Change-Id: I532d0047e67f80fd925b481dac8823ab45ad0194
2020-02-19 08:23:01 -08:00
Winson
5e0a1d5ce2 ParsingPackage/ParsedPackage split source migration
Part of the Parsing/ParsedPackage split into core/server.

This migrates any core/services source with trivially reviewable
changes. Import changes, moving files around, or generally
small single line changes scattered throughout all code that
depended on the old state of the package code.

Bug: 135203078

Test: enumerated in first commit of change ID
		Ib4fe51d729a56bfb0ea1316e577358ba0dfceccf

Change-Id: If091641a81be2d943d1d3e4a3d654e200d0ce59d
2020-02-19 00:29:05 -08:00
Winson
e23ae20e30 Important migration for new ParsingPackage/ParsedPackage split
Part of the Parsing/ParsedPackage split into core/server.

This splits all the "important" changes, or those which change
significant code/logic and that requires a closer look during
review.

Bug: 135203078

Test: enumerated in first commit of change ID
		Ib4fe51d729a56bfb0ea1316e577358ba0dfceccf

Change-Id: Ie0e4394de2b3063121d850060fcd58622511c59d
2020-02-19 00:29:05 -08:00
Winson
01e38f40c2 Separate ParsingPackage into core and ParsedPackage into server
PackageParser exists in the core framework SDK, and so callers
to it would not not expect a call into the system server.

However, some planned features require parts of parsing to exist
in the server so that package state/settings contained in the
server can be applied to the package.

To resolve this, separate ParsingPackage and ParsedPackage
through a hard boundary, where ParsingPackageImpl is roughly
equivalent to the previous PackageImpl, and the new PackageImpl
is everything that should exist in the server and not core.

This also copies over documentation and cleans up the data models
significantly. The fields have been moved to @NonNull, and in
preparation for true immutability, all Collection structures
have moved to generic types and assigned Collections#empty_().

This begins moving away from @hide AppInfo fields, so internal
use of flags/privateFlags is deprecated. It is now replaced by
straight booleans. For simplicity's sake, existing flags have
also been migrated.

This is split for readability and will not compile without
the followup commits.

Bug: 135203078

Test: atest com.android.server.pm.parsing
Test: atest PackageParserTest
Test: atest PackageParserLegacyCoreTest
Test: atest ScanTests
Test: atest ParallelPackageParserTest
Test: manual toggle and run AndroidPackageParsingTestBase

Change-Id: Ib4fe51d729a56bfb0ea1316e577358ba0dfceccf
2020-02-19 00:29:03 -08:00
Taras Antoshchuk
b073a3eb54 Merge changes from topic "dynamic-mime-types"
* changes:
  Clear preferred activities affected by MIME groups changes
  Implement new API to modify MIME groups by adding/removing MIME types
  Add mimeGroup tag to intent filters
2020-02-19 07:09:22 +00:00
Ryan Mitchell
f2392c6f56 Merge changes from topic "rro_config"
* changes:
  Make overlay config work with immutable non-android overlays
  Add xml configuration of RROs
  Extract system partitions into standalone class
2020-02-19 04:37:26 +00:00
Patrick Baumann
40127f0432 Merge "Adds NON_BROWSER & DEFAULT match flags" 2020-02-19 03:53:09 +00:00
Automerger Merge Worker
893bf3b7f5 Merge "Improve BaseBundle#kindofEquals" am: 42ab50d14b am: 1f82fbb4ac
Change-Id: I0dadb4269692a86cab1c66e1c69d9a95bfddd9a2
2020-02-19 00:53:38 +00:00
Automerger Merge Worker
1f82fbb4ac Merge "Improve BaseBundle#kindofEquals" am: 42ab50d14b
Change-Id: Ic5c2c5bcf979236c77344d0507d071bbb83f624e
2020-02-19 00:33:09 +00:00
Ryan Mitchell
b538e5b021 Make overlay config work with immutable non-android overlays
This change renames staticness to mutability and changes the OMS to
query OverlayConfig. Changing the enabled state of immutable overlays
and changing the mutability of overlays causes the overlays to be
reinitialized and the default-enabled states to be reapplied. The
default-enabled state is applied whenever the settings for the overlay
is initialized.

Bug: 135048762
Test: use package manager to dump overlay paths of package with
      static/immutable overlays
Test: verify "cmd overlay dump"
Test: atest OverlayManagerServiceImplTests
Test: atest OverlayManagerServiceImplRebootTests

Change-Id: I791befee7f4c7c6ab5ad69cd5d1f3d85e7424f96
2020-02-18 16:13:28 -08:00
Ryan Mitchell
9b93942a80 Add xml configuration of RROs
This change adds the ability to configure the priority, default enable
state, and mutability (previously know as staticness) of an overlay.
Rather than overlays configuring themselves, the system can configure
overlays relative to each other.

An example configuration file looks like:
<config>
    <merge path="auto-generated.xml" />
    <overlay package="com.example.one" mutable="false"
             enabled="true"/>
    <overlay package="com.example.two" mutable="false"
             enabled="true"/>
    <overlay package="com.example.three" enabled="true"/>
</config>

The <overlay> tag configures the overlay while the <merge> tag allows
additional configuration files to be included at a position within
the configuration file.

If the configuration file is not present for a partition, the legacy
android:isStatic and android:priority will continue to configure the
overlays in the partition. Once at least one configuration file has
been defined in any partition, strict partition precedence will be
enforced and overlays on separate partitions will no longer be able
to use android:priority to reorder themselves conversely from the
overlay partition precedence.

The order of the system partitions from least to greatest precedence
is system, vendor, odm, oem, product, system_ext.

Bug: 135048762
Test: atest OverlayConfigTest
Change-Id: If57e8caa9b881f9d424ef48bba80b18cc8b7b943
2020-02-18 16:13:22 -08:00
Patrick Baumann
6565f9636a Merge "Adds app enumeration feature" 2020-02-18 22:02:24 +00:00
Danning Chen
91f90e0fd6 Add getShareTargets() to ShortcutServiceInternal and get caller's user ID from AppPredictionSessionId
Previously, the caller's user ID was got from Binder. But
AppPredictionManager clears caller's identity. The only way to get the
caller's user ID is to get it from session ID.

Bug: 146522621
Test: atest com.android.server.people.data.DataManagerTest
Test: atest com.android.server.people.data.ShareTargetPredictorTest
Change-Id: Ia0dc35879084110849e06e919ff3b3c7241c46fd
2020-02-18 13:23:04 -08:00
Patrick Baumann
2fa1c95404 Adds NON_BROWSER & DEFAULT match flags
This change adds two new flags for starting activities:
FLAG_ACTIVITY_REQUIRE_NON_BROWSER and FLAG_ACTIVITY_REQUIRE_DEFAULT.
The first will only start if the result is a non-browser result. The
second will only start if the result is not the resolver activity.

Bug: 148452357
Test: Builds
Change-Id: I1f25bd78b6231c08036c15436bd8c2e3dccf56d6
2020-02-18 20:12:02 +00:00
Patrick Baumann
f2fe03f588 Adds app enumeration feature
This change adds a new app enumeration feature to system features.

Test: atest AppEnumerationTests
Bug: 149399359
Change-Id: Iaf181a54819343d5531d14142a844acda02b10e5
2020-02-18 12:01:03 -08:00
Alex Kershaw
0f9d6aff1d Merge "Add CrossProfileAppsInternal#getTargetUserProfiles" 2020-02-18 19:25:44 +00:00
Alex Kershaw
809c58a598 Merge "CrossProfileApps#startActivity by intent starts in same task by default" 2020-02-18 18:37:12 +00:00
Dmitri Plotnikov
ca854b42fd Merge "Prevents an NPE when content provider is slow to start" 2020-02-18 17:26:04 +00:00
Alex Kershaw
16406c38d8 CrossProfileApps#startActivity by intent starts in same task by default
This is based on developer feedback from Google Calendar. Tweak the API
to take in the calling activity.

Javadoc in ActivityTaskManagerInternal's new method is copied from the
existing method.

Bug: 149677845
Bug: 136249261
Test: atest com.android.cts.devicepolicy.CrossProfileAppsHostSideTest#testStartActivityIntent_sameTaskByDefault
Change-Id: I2f2d4d8fd82febf4916ba70a08de5e71c678a1f4
2020-02-18 13:56:53 +00:00
Nicolas Geoffray
6f589478d9 Merge "Revert "[DexLoadReporter] Report classloader contexts directly f..."" am: ae50e15d59 am: ea12868665 am: f96a5bf6a0
Change-Id: I0b69537e9c729cf5983bffcc6d37dfb35e000172
2020-02-17 14:19:52 +00:00
Calin Juravle
8e9f0b4d55 Merge "[DexLoadReporter] Report classloader contexts directly from classloader" am: 5a01991fef am: ce9b12f5bf am: cb3d0f7ab5
Change-Id: I181e9df3dbf4e0c8551abcb4b7b912f4a05c11c0
2020-02-17 14:16:38 +00:00
shubang
0184edc6ad Add tuner feature to PackageManager
Context: Tuner system APIs and Tuner HAL are adding to R. Tuner hardware
and HAL implementation are required for these new features.

Test: make;
Bug: 139308734
Change-Id: I89f56ee58cdfae447d33cdcd841e0d556e7f6cab
2020-02-16 21:44:55 -08:00
Taras Antoshchuk
58f0ffac30 Clear preferred activities affected by MIME groups changes
If MIME group change affects any intent filter,
all preferred activities from the app are cleared

Bug: 134736173
Bug: 136635677
Test: atest CtsDynamicMimeHostTestCases
Change-Id: I84b26768b2da9e98f76f1ab3ec61af58534e3eca
2020-02-16 20:10:22 +01:00
Taras Antoshchuk
a7d9c73938 Implement new API to modify MIME groups by adding/removing MIME types
MIME groups can now be modified via PackageManager.
MIME group modification will affect intent-filters
that were declared with that |mimeGroup| in manifest
in the same way, as if intent-filter was initially
declared with |mimeType| attributes that correspond to
MIME types in MIME group

Preferred activities will be handled in the next CL

Bug: 134736173
Bug: 136635677
Test: atest android.content.pm.PackageParserTest#testPackageWithIntentFilters*
Change-Id: I083a8794897e632aad5325a67311931193c69a3c
2020-02-16 20:10:22 +01:00
phweiss
26d3496c9b Add mimeGroup tag to intent filters
Intent filters can now have a |data| element
with a |mimeGroup| attribute on it. In a future
CL, the user can add mimeTypes to a mimeGroup,
which will cause the intent-filter to match all those
mimeTypes.

Bug: 134736173
Bug: 136635677
Test: atest android.content.pm.PackageParserTest#testPackageWithIntentFilters*

Change-Id: Ie44dc441e00c29d735814564b7f27b341a69a860
2020-02-16 20:10:22 +01:00
Nandana Dutt
5ff3568929 Merge changes from topic "preserve_legacy"
* changes:
  Enforce the preserveLegacyExternalStorage manifest attribute
  Support preserveLegacyExternalStorage manifest attribute
  Introduce preserveLegacyExternalStorage manifest attribute
2020-02-15 21:59:23 +00:00
Alex Kershaw
179ba0b4e4 Add CrossProfileAppsInternal#getTargetUserProfiles
This will be used by the logic that updates the app bucket state of
cross-profile connected apps that declare the crossProfile manifest
attribute.

Also makes the following changes:
- Fixes CrossProfileAppsServiceImplRoboTest by registering the local
service in a different way.
- Removes some code duplication in CrossProfileAppsServiceImpl.
- Some clean-up.

Robolectric tests will be added later. Right now, there seems to be a
problem causing log messages not to appear, making debugging impossible.

Bug: 140808123
Bug: 136249261
Test: atest com.android.server.pm.CrossProfileAppsServiceImplRoboTest
Change-Id: Iefa6b2a7cb7535d5796d5ca8916c10b29c2e0661
2020-02-15 19:42:30 +00:00
Nicolas Geoffray
f96a5bf6a0 Merge "Revert "[DexLoadReporter] Report classloader contexts directly f..."" am: ae50e15d59 am: ea12868665
Change-Id: I4faaff1f5227b64028222c5824d70ac0356cf20f
2020-02-15 17:51:03 +00:00
Nicolas Geoffray
ea12868665 Merge "Revert "[DexLoadReporter] Report classloader contexts directly f..."" am: ae50e15d59
Change-Id: Icc45c40ce116ce54a915650ca6f6600b6db08e0e
2020-02-15 17:36:14 +00:00
Nicolas Geoffray
371fcb7cf2 Revert "[DexLoadReporter] Report classloader contexts directly f..."
Revert "Fix shared libraries not being reported via Reporter"

Revert submission 1198456-slclc

Reason for revert: Fails on luci:
https://ci.chromium.org/p/art/builders/ci/host-x86_64-cdex-fast/3123

Exempt-From-Owner-Approval: pure revert

Bug: 148494302
Reverted Changes:
I46d8d9105: Fix shared libraries not being reported via Report...
I00357cfe0: [DexLoadReporter] Report classloader contexts dire...

Change-Id: Ib58066e8f059642a11d9eaab02ec0b8b3217e487
2020-02-15 17:13:58 +00:00
Alex Kershaw
c4b5cc5957 Update cross-profile javadoc
Update the javadoc after reviewing the new public-facing Javadoc
implemented for the INTERACT_ACROSS_PROFILES work.

Bug: 136249261
Test: no Java changes
Change-Id: I1a669adea2ff47171dbbcbe6e847a3be0cfa7509
2020-02-15 10:46:16 +00:00
TreeHugger Robot
d836b829c2 Merge "Improve BaseBundle#kindofEquals" 2020-02-15 00:54:50 +00:00
Suprabh Shukla
3b413dd57e Improve BaseBundle#kindofEquals
If both BaseBundles are empty, we can infer that without needing to
unparcel any of them.

Test: atest FrameworksCoreTests:android.os.BundleTest

Bug: 146037505
Change-Id: I04c28cdd1293227d9887b0c17e178f61328c1959
Merged-In: I04c28cdd1293227d9887b0c17e178f61328c1959
2020-02-14 14:05:00 -08:00
Suprabh Shukla
0e8c9c4daa Improve BaseBundle#kindofEquals
If both BaseBundles are empty, we can infer that without needing to
unparcel any of them.

Test: atest FrameworksCoreTests:android.os.BundleTest

Bug: 146037505
Change-Id: I04c28cdd1293227d9887b0c17e178f61328c1959
2020-02-14 13:43:53 -08:00
Calin Juravle
cb3d0f7ab5 Merge "[DexLoadReporter] Report classloader contexts directly from classloader" am: 5a01991fef am: ce9b12f5bf
Change-Id: I55eb1b61f848b993d17d54e68f0e6403c61e456d
2020-02-14 20:42:33 +00:00
Calin Juravle
ce9b12f5bf Merge "[DexLoadReporter] Report classloader contexts directly from classloader" am: 5a01991fef
Change-Id: Ida294271950c3f330f1acb2150ac3892db88ab64
2020-02-14 20:29:11 +00:00
Zim
b14fba21d3 Support preserveLegacyExternalStorage manifest attribute
Parsed the manifest and included in the relevant PackageManager data
structures.

Test: atest RestrictedPermissionsTest
Test: atest RestrictedStoragePermissionSharedUidTest
Bug: 148944140
Change-Id: I785e707aa4c879ea163c1611c1693fea74f4ac82
2020-02-14 14:33:51 +00:00
TreeHugger Robot
a4d20a71b3 Merge "Fixes Context Hub feature naming and documentation" 2020-02-14 04:34:23 +00:00
Ryan Mitchell
76e669069c Extract system partitions into standalone class
Extract the order system partition list from package manager so
OverlayConfig can reuse the PMS partition order.

Bug: 119442586
Bug: 135048762
Test: ScanTests and PackageManagerServiceTest
Change-Id: If281c5d47e3551eb635c466af6d2400c514518eb
2020-02-13 19:00:24 -08:00
Evgenii Stepanov
45c350c0a8 Merge changes from topic "allowNativeHeapPointerTagging"
* changes:
  Add android:allowNativeHeapPointerTagging.
  Refactor NativeHeapTagging compat feature.
2020-02-14 01:41:37 +00:00