Commit Graph

9039 Commits

Author SHA1 Message Date
Arthur Ishiguro
6c46c74576 Merge "Hides FEATURE_CONTEXT_HUB from Android SDK" into rvc-dev 2020-03-03 01:52:07 +00:00
Jayachandran Chinnakkannu
db5c0688f3 Merge "Make IccCardConstants APIs hidden as per API concil's feedback" into rvc-dev 2020-03-02 21:18:50 +00:00
Arthur Ishiguro
8b9db55adb Hides FEATURE_CONTEXT_HUB from Android SDK
This feature guards a @SystemApi and should be hidden from the SDK.

Bug: 150326953
Test: None
Change-Id: Ifc5087fc956efd966e38934fcaacfa46f2cd7b28
2020-03-02 18:45:55 +00:00
Ryan Mitchell
dc65c78fcf Merge "Fix overlaying shared libraries" into rvc-dev 2020-03-02 16:51:56 +00:00
Jayachandran C
6c546d00d0 Make IccCardConstants APIs hidden as per API concil's feedback
We will make the external components to use alternate APIs in S

Bug: 147320577
Change-Id: I22d35ea0fceb3071b1e21899cbdc3a26c9d8e972
2020-02-28 16:57:54 -08:00
Ryan Mitchell
41b93d8caa Fix overlaying shared libraries
Overlaying shared library support accidentally got dropped while
refactoring internal PMS structure.getAllOverlayPaths includes shared
library overlay paths.

Bug: 150446147
Test: OverlayRemountedTest
Change-Id: I5eed0f219c85156c753df6ff829970e1c4e4c4de
2020-02-28 11:40:44 -08:00
Peter Wang
879f32b1cc Merge "[API Review] Expose sendOrderedBroadcast" into rvc-dev 2020-02-28 19:05:26 +00:00
Winson
d2732995bb Skip no-state checkUseInstalled check inside PackageInfoUtils
PackageInfoWithoutStateUtils is designed for use in core when
the caller doesn't have a PackageSeting.

Because its generic generateApplicationInfo method does a simplified
checkUseInstalled check without the PackageSetting, this fails whenever
state must be taken into account.

This introduces method variants which skips the checks and defers to
PackageInfoUtils's own check.

Bug: 150328400

Test: manual verify call into PackageManager#setSystemAppState with
    SYSTEM_APP_STATE_UNINSTALLED and verify
    PackageManager#getApplicationInfo throws NameNotFoundException
    without fix and succeeds with fix
Test: atest com.android.server.pm.parsing
Test: TODO PackageInfo(WithoutState)Utils test in follow up change

Change-Id: Ie00984c2e1b80d2a3948923dc1293fbfddf01037
2020-02-27 17:07:51 -08:00
Winson Chiu
b0c5105b2d Merge changes from topic "actor-signature-policy-rvc-dev" into rvc-dev
* changes:
  Actor signature overlayable policy
  Refactor overlayable policy
2020-02-27 18:27:53 +00:00
Sudheer Shanka
442399b1c1 Merge "Include pending media as well when deleting mediastore entries." into rvc-dev 2020-02-27 17:49:53 +00:00
Winson
f56ade365a Actor signature overlayable policy
There are cases where an app can ship overlays for itself,
but the "signature" policy as described would open up
a vulnerability by allowing the system actor to create
and sign any arbitrary overlay that will apply to the target.

To prevent this, redefine "signature" as target package only,
and introduce "actor" for checking against the actor signature.
Any app that wishes to use both can include both policies.

Bug: 130563563

Test: m aapt2_tests idmapt2_tests and run from host test output
Test: atest libandroidfw_tests

Change-Id: I1c583a5b37f4abbeb18fc6a35c502377d8977a41
2020-02-26 15:59:44 -08:00
Peter Wang
2361687bec [API Review] Expose sendOrderedBroadcast
with appOp as String and options as Bundle

Bug: 139077993
Bug: 146423958
Test: Build
Change-Id: I5325e08d60016741139251813a5df9b42f2efc82
Merged-In: I5325e08d60016741139251813a5df9b42f2efc82
2020-02-26 15:58:33 -08:00
Ryan Mitchell
93f2b3f9a2 Restore UnsupportedAppUsage method call
4579c0aea2 changed the method signature
of the constructor of ResourcesKey, which is marked
UnsupportedappUsage. Restore the previous signature and provide a new
constructor that is hidden.

Bug: 147359613
Test: none
Change-Id: I391167e9064b1d88f4ad75200a190e5e3b0968cf
2020-02-25 22:10:22 +00:00
Sunny Goyal
9962f03b77 Merge "Updating documentation for isDefaultApplicationIcon API" into rvc-dev 2020-02-25 17:46:23 +00:00
Makoto Onuki
9577cd78ff Merge "Squash same ApplicationInfo's in Parcel" into rvc-dev 2020-02-25 15:17:14 +00:00
Galia Peycheva
641e2e6361 Create DreamManager System Server TestApi
Bug: 141771803
Bug: 133216167

Test: atest DreamManagerServiceTests
Test: make checkbuild

Merged-In: I937061138bc8ccaf4475674f00331c3fe1c5a495
Change-Id: I937061138bc8ccaf4475674f00331c3fe1c5a495
(cherry picked from commit 4467c53c11)
2020-02-25 12:32:02 +00:00
Sunny Goyal
c25c4bb378 Updating documentation for isDefaultApplicationIcon API
Bug: 149758817
Test: N/A
Change-Id: Iaa9b29f55087204f4af849a384cb6c9b01df4465
2020-02-24 15:16:08 -08:00
Makoto Onuki
2d80ca09fc Squash same ApplicationInfo's in Parcel
ApplicationInfo now automatically tries to "squash" the same instances in a
Parcel.

NOTE: This CL still does *not* optimize the package manager APIs that return a
list. e.g. PM.queryContentProviders() still return duplicate AppInfo's.
We can optimize them by making ParcelableListSlice call "allowSquashing",
but that *could* have negative side effects, so I'm not doing it in this CL.
I think we can do that for S.

Bug: 148588589
Test: atest CtsContentTestCases # except for two preexsiting failures:
- android.content.pm.cts.PackageManagerTest#testGetIcon
- android.content.pm.cts.PackageManagerTest#testGetPreferredActivities

Test: Use the debugger and make sure bindApplication() is not receiving
duplicate AppInfo's in the provider list.

Change-Id: I3ba2c047a469169340c0f75c36bdfd394bc5d627
(cherry picked from commit 7d09275d70)
2020-02-24 22:22:13 +00:00
Sudheer Shanka
7d28b5bf81 Include pending media as well when deleting mediastore entries.
Bug: 146914674
Bug: 140565622
Bug: 137381621
Test: manual
Change-Id: I903a13deb467b45839a7d03b60754c8fc464456c
2020-02-24 05:50:33 +00:00
Evan Severson
2aa3230ca0 Merge "Add method to give a permission revoke a reason" 2020-02-21 23:16:09 +00:00
Julius D'souza
4358010076 Merge "Add background thread notes for package restriction serialisation." 2020-02-21 23:08:52 +00:00
Julius D'souza
5745b057ec Add background thread notes for package restriction serialisation.
Serialising package restrictions uses synchronous disk access; callers
of these methods should probably use background threads for this.

Bug: 149216360
Test: TreeHugger
Change-Id: I6607a7225bf7daaad8a78e4d1e4c585ba5ac3efc
Signed-off-by: Julius D'souza <jdsouza@google.com>
2020-02-21 12:49:40 -08:00
Tim Murray
8a9c5795e0 Merge "Cache package and permission information" 2020-02-21 20:22:19 +00:00
Danning Chen
876a4ab9c0 Merge "Adds ShortcutChangeCallback in LauncherApps - Service side" 2020-02-20 20:28:08 +00:00
Mehdi Alizadeh
b754b7ac7a Adds ShortcutChangeCallback in LauncherApps - Service side
Bug: 148615405
Test: atest com.android.server.pm.ShortcutManagerTest1 \
            com.android.server.pm.ShortcutManagerTest2 \
            com.android.server.pm.ShortcutManagerTest3 \
            com.android.server.pm.ShortcutManagerTest4 \
            com.android.server.pm.ShortcutManagerTest5 \
            com.android.server.pm.ShortcutManagerTest6 \
            com.android.server.pm.ShortcutManagerTest7 \
            com.android.server.pm.ShortcutManagerTest8 \
            com.android.server.pm.ShortcutManagerTest9 \
            com.android.server.pm.ShortcutManagerTest10

Change-Id: Ida60b2d0b3d5792e7013ffa703b2f3b45361a4db
2020-02-20 10:05:54 -08:00
Dmitri Plotnikov
23132a29eb Merge "Add async version of "canonicalize"" 2020-02-20 17:42:52 +00:00
Daniel Colascione
a46b7b3f5e Cache package and permission information
We use the package settings class as a central point for invalidating
on package information changes; for permission changes, we invalidate
from inside the individual permission data objects.

Bug: 140788621
Test: boots, package tests (pending)
Change-Id: Iec14d4ec872124e7ef4612c72d94c89a7319ace0
2020-02-20 09:24:32 -08:00
Charles Chen
c56ce6fd08 Merge "Exempt-From-Owner-Approval: Report non-visual Context misuse" 2020-02-20 12:30:06 +00:00
Alex Kershaw
f0f598a711 Merge "Enforce the cross-profile intent check." 2020-02-20 11:40:54 +00:00
Mehdi Alizadeh
f1bdf99b89 Merge "Adds ShortcutManager#pushDynamicShortcut(ShortcutInfo)" 2020-02-20 03:06:28 +00:00
Andrii Kulian
5877c7d6c0 Exempt-From-Owner-Approval: Report non-visual Context misuse
Make obtaining a visual service from non-visual Context instance
report a strict mode violation and print the stacktrace.

Make calling getDisplay() throw an exception if called on an instance
that is not associated with a display. For existing usages introduce
a new internal method that does not perform the verification until
the usages are properly fixed.

Bug: 128338354
Test: StrictModeTest#testIncorrectContextUse_GetSystemService
Test: StrictModeTest#testIncorrectContextUse_GetDisplay
Change-Id: Id25d590eca6e10066e55d7ed6436d3bc9e433beb
2020-02-20 01:29:25 +00:00
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
Evan Severson
43b2a199ab Add method to give a permission revoke a reason
Test: Compile
Bug: 149861310
Change-Id: I865a300a9795550a2549f928f4e967b2b695439e
2020-02-19 14:23:56 -08: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
Dmitri Plotnikov
7a223fbcf1 Add async version of "canonicalize"
Fixes: b/147699082
Test: atest FrameworksCoreTests:android.content.ContentResolverTest
Change-Id: I2e851839a454ad5eabc981c76774d03b57a1aa09
2020-02-19 11:58:26 -08:00
Mehdi Alizadeh
413e8fa698 Adds ShortcutManager#pushDynamicShortcut(ShortcutInfo)
Bug: 137397357
Bug: 148561453
Test: atest com.android.server.pm.ShortcutManagerTest1 \
            com.android.server.pm.ShortcutManagerTest2 \
            com.android.server.pm.ShortcutManagerTest3 \
            com.android.server.pm.ShortcutManagerTest4 \
            com.android.server.pm.ShortcutManagerTest5 \
            com.android.server.pm.ShortcutManagerTest6 \
            com.android.server.pm.ShortcutManagerTest7 \
            com.android.server.pm.ShortcutManagerTest8 \
            com.android.server.pm.ShortcutManagerTest9 \
            com.android.server.pm.ShortcutManagerTest10

Change-Id: I20585a978bfee961df3326f38b11766ea403a5cd
2020-02-19 11:57:21 -08: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
Alex Kershaw
3e3f4964a6 Enforce the cross-profile intent check.
DocumentsUI currently hard-codes the IntentForwarderActivity class name.
It uses this to determine whether to show a 'switch to personal profile'
button. Essentially, it wants to know if the intent it received is a
cross-profile intent, so it asks package manager which intents can
resolve it and checks whether one of them is IntentForwarderActivity.

This is not CTS-enforced, so this CL ensures that it is. OEMs can remove
or rename IntentForwarderActivity as long as they update this API and
keep the corresponding CTS test passing.

Bug: 149568382
Bug: 136249261
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.ManagedProfileCrossProfileTest#testCrossProfileIntentFilters
Change-Id: I51916c13320420068987925ac979e59bef3b660d
2020-02-19 14:01:23 +00: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