464 Commits

Author SHA1 Message Date
Suprabh Shukla
aef2513c71 Adding an api for apps to check whether they can install apps
Some apps may want to check whether they are trusted to install apps on
the device, so they can prompt the user to go to settings and mark them
as trusted before they do an intensive operation like downloading an
apk.

Test: cts-tradefed run cts -m CtsExternalSourcesTestCases

Bug: 31002700
Change-Id: Icd9d04daa157e6733decba245ec251ce4acd4122
2017-01-25 17:26:02 -08:00
Svet Ganov
6788212d17 Platform support for static shared libraries
This change adds support for static shared libraries that
emulate static linking allowing apps that statically link
against the same library version to share a common
implementation. A library is hosed by a package in a standard
APK.

Static shared libraries have a name and a version declared
by a dedicated manifest tag. A client uses also a new tag
to refer to the static library it uses by specifying the
lib name, version, and the hash of the signing certificate.
This allows two apps to rely on two different library versions
and prevents impersonation of the shared library by a side-loaded
app with the same package name.

Internally apps providing static libs use synthetic package
name generated from the manifest package name and the library
version. This allows having different "versions" of the same
package installed at the same time.

An application cannot be installed if a static shared lib it
depends on is missing. A used shared library cannot be uninstalled.
Shared libraries can rotate certificates like normal apps. The
versions of these libs should be ordered similarly to the version
codes of the hosting package. Such libs cannot use shared user
id, cannot be ephemeral, cannot declare other libraries, cannot
rename their package, cannot declare child-packages. They must
target O SDK. Also they cannot be suspended or hidden or their
uninstall blocked. Generally, speaking policy regarding code in
static shared libs should be applied to the packages using the
library as it could have just statically linked the code.

We now have APIs to query information about the shared libraries
on the device in general. To clients static shared libraries are
presented as multiple versions of the same package which is how
they are declared and published. Therefore, one can have two
versions of the same package which means we need way to query
for and uninstall a specific version of a package. Also static
shared libs can depend on other static shared libs which are
versioned packages. To ease representation we add the concept
of a versioned package which should be used in the case of
static shared libs.

A client can see only the static shared libs it depends on and
more specifically only the versions it depends would be retrieved
by using the standard package manager APIs. There is a new
dedicated API to get info about all shared libraries which
would provide data about all static shared lib versions. Also
these libraries must use v2 signing scheme.

Test: CTS tests pass

bug:30974070

Change-Id: I4f3d537ee7a81f880950377b996e1d9d4813da5c
2017-01-22 14:05:15 -08:00
Christopher Tate
42a386b771 Enable background restrictions
Apps that target O+ are always subject to background restrictions.
Legacy apps' background restriction is subject to the OP_RUN_IN_BACKGROUND
app op.

Apps with these properties are exempted from background restrictions:
  - persistent process
  - currently on the idle battery whitelist
  - global whitelist for things like bluetooth services

Bug 30953212

Change-Id: Icc19b2fbc05f40dcf8c3fc4abf718c373dc8d4f6
2017-01-19 16:23:02 -08:00
Paul Duffin
8aeb59ebcd Prepare for removal of legacy-test from default targets
In preparation for removing junit classes from the Android API
the legacy-test target will be removed from the
TARGET_DEFAULT_JAVA_LIBRARIES. This change adds explicit
dependencies on junit and/or legacy-android-test to ensure that
modules will compile properly once it is removed.

Bug: 30188076
Test: make checkbuild
Change-Id: I13e88297731253420e4e5f5291d503f13a39a156
2017-01-18 16:39:34 +00:00
Bartosz Fabianowski
a34f53f61b Add install reason
This CL allows a reason to be specified when installing a package. The
install reason is a sticky piece of metadata: When a package is e.g.
installed via enterprise policy and an update is then manually
installed or sideloaded, the install reason will remain "policy."
The install reason is tracked separately for each user.

With this CL, two install reasons exist: "policy" and "unknown." Other
install reasons will likely be supported in the future.

Bug: 32692748
Bug: 33415829
Test: Tested manually with "adb install" / "adb uninstall"

Change-Id: I0c9b9e1b8eb666bb6962564f6efd97e41703cd86
2017-01-13 16:51:28 +01:00
Jeff Sharkey
9bc89af3f1 Add API for apps to declare their "category".
Upcoming platform features need to cluster apps together into broad
categories to help summarize information to users.  (For example,
when presenting battery, network, and disk usage.)

We are tightly limiting the set of categories to keep them easily
presentable to users when summarizing information.  This feature is
not designed to be a general-purpose taxonomy, nor should it be
allowed to become one.

Older apps may not have defined a category in their manifests, so
allow the installing app to define a category on their behalf.

Test: builds, boots
Bug: 33815939
Change-Id: I785b882ee7c18072ef47d56e0fc19ad72888e1b7
2017-01-12 09:53:44 -07:00
Tony Mak
bf9928de18 Make sure ServiceConnection callback is called in main thread
Fix: 33568999

Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases
--test com.android.cts.devicepolicy.DeviceOwnerPlusManagedProfileTest

Change-Id: I14c8b5b1f78192429e68a3057430406245a909c8
2016-12-29 14:07:46 +00:00
Paul Duffin
ed7d67a920 Copy junit-runner files into test-runner. am: eef35dd29a am: b46cecb6c4 am: b6421ce031
am: 50c1bb82b1

Change-Id: I7be2758511183480d9ba948ed1e0958e2e7a97c5
2016-12-14 13:56:44 +00:00
Paul Duffin
eef35dd29a Copy junit-runner files into test-runner.
The android.test.runner target forms part of the Android API and
so must maintain backwards compatibility. The junit classes that
belong in there are copied here to ensure that they do not
change when external/junit is upgraded.

Bug: 30188076
Test: make checkbuild and checked android.test.runner contents
Change-Id: I947144c47ae1c3eb361a43c39bdd03dc11b9575f
2016-12-14 10:41:05 +00:00
Steve McKay
ea93fe7539 Replace ContentProvider SQL args w/ Bundle & Constants.
Test: cts-tradefed run cts-dev -m CtsContentTestCases
Bug: 30927484
Change-Id: Idb9dbc2b80896e9f8474a0db71353b7a3810d597
2016-12-09 12:31:44 -08:00
Paul Duffin
4a7cda98fc Merge "Replace core-junit with junit" am: 6ac5293751 am: a4d7100a3b am: 9cb5f2815d
am: b6961ffa53

Change-Id: Id397baf01c8285b0843a66afd544ddf89abf451f
2016-12-07 13:24:14 +00:00
Paul Duffin
9249205d1b Replace core-junit with junit
Bug: 30188076
Test: make checkbuild
Change-Id: I0cb6f89907eb099714b54bac57b51c4be186c3e0
2016-12-06 14:32:41 +00:00
Kenny Guy
02c8990bd6 Allow overriding max profile in debugable builds.
Support a system property on debugable builds to
override the max number of managed profiles to
allow easier dogfooding of multiple profiles.
Support 3 different badge colours for managed profiles.

Bug: 30473760
Test: runtest -c com.android.server.pm.UserManagerServiceCreateProfileTest frameworks-services
Test: runtest -c com.android.server.pm.UserManagerServiceUserInfoTest frameworks-services
Test: manual - attempting to create 2 profiles with adb fails, passes once I set the property.
Change-Id: Ie7fb19048a04a01572666f229283152254d0ffc3
2016-11-29 14:09:37 +00:00
Paul Duffin
d5fd01c89a Move JUnit classes from here into external/junit am: 0342ab5b94 am: b9e33cd549 am: f99687ee83
am: e3b757a4bf

Change-Id: Ib11a330ca65e9c2d2904993cbd67e604b2b80d5d
2016-11-24 14:08:54 +00:00
Paul Duffin
0342ab5b94 Move JUnit classes from here into external/junit
Checked that android.test.runner had the same classes in as
before the change.

These classes are legacy 3.8.1 classes, they are not in 4.10 at
all. They appear to have been left here by accident. Looking at
the history it appears that at one time there were copies of
JUnit 3.8.1 junit.runner classes in frameworks and
external/junit. The classes here were upgraded to 4.10 but even
though these classes had been deleted immediately after 3.8.2
was released they were not removed, instead they appear to have
been reformatted as part of the upgrade. The external/junit
source was upgraded to 4.10 about two weeks later which seems to
have been done correctly. About three months after that the
classes here that were duplicates of those in external/junit
were removed from here leaving the legacy classes from 3.8.1.

I could not find any usages of these classes and they are not in
the public API so they can probably be removed altogether.
However, for now I will simply move them into external/junit as
described and remove them when upgrading JUnit there to 4.12.

Bug: 30188076
Test: Built android.test.runner and checkapi
Change-Id: I88687889315c041d999fe7e61b9652ac8406165c
2016-11-22 12:27:53 +00:00
Bartosz Fabianowski
1133424c2b Wire up PM.getInstalledApplicationsAsUser(flags, userId) as hidden API
Settings needs to access a variant of getInstalledApplications() which
takes a |userId| argument. Since this is not currently exposed by
PackageManager, Settings calls into PackageManagerService directly. This
is ugly and breaks the regular abstraction layer hierarchy.

The CL fixes the problem by exposing the required variant of
getInstalledApplications() as a hidden API, analogously to what was done
before with getInstalledPackages().

Bug: 32692748
Test: Will be CTS-verifier-tested together with Settings
Change-Id: Id9c4e8e18524d312159821f1a4d5527263c7e950
2016-11-17 20:49:16 +01:00
Tony Mak
46aabe5ef4 Allow cross profile call between DO and PO
Allow DO to bind service of PO in managed profile and vice versa.
DO and PO must be the same package.

Bug: 31895999

Change-Id: I3ce2943aebd1249401d5814757a0ce25b9f85279
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.CorpOwnedManagedProfileTest
2016-11-14 14:20:11 +00:00
Ben Lin
1cf454fcb6 Adding ContentProvider#refresh and ContentResolver#refresh.
Original CL is from ag/1568530.

Bug: 31647485
Change-Id: Ib45fc995a361b8c75cd3600f638910b18a263d51
2016-11-10 13:53:27 -08:00
TreeHugger Robot
391dfcfa68 Merge "Revert "Add per-user versions of set{Component,Application}EnabledSetting."" 2016-08-02 23:56:55 +00:00
Sudheer Shanka
38c67d3c0f Revert "Add per-user versions of set{Component,Application}EnabledSetting."
This reverts commit 0e6bfff6c1ec17cf8f3cfb6e4853d3c0fa3ffb73.

Change-Id: I4eafa9fc052e9eba9e26fd32c09b5e759fe63b00
2016-08-02 22:13:17 +00:00
Chad Brubaker
52c8edc2d8 Add asUser version of sendBroadcast(Intent, String, Bundle)
Change-Id: Id87aa1123d6c0a8a036ed9430eee10357040321f
2016-07-25 14:30:26 -07:00
Sudheer Shanka
0e6bfff6c1 Add per-user versions of set{Component,Application}EnabledSetting.
Change-Id: Id63b233308e92a4c360f38d4728c519ac2131ff0
Fixes: 30230444
2016-07-20 10:30:57 -07:00
Adam Lesinski
4ece3d6bb1 ContextImpl: Keep DisplayAdjustments and Display in sync
Make sure that when our Resources get updated, that DisplayAdjustment
and Display properly reflect the potentially new screen dimensions.

Bug:28388969
Change-Id: I340550ea094ece87abc8790dd46aaa60ab3cedd3
2016-06-21 17:55:58 -07:00
Stephan Linzner
ebdc157bc0 Un-deprecated Android mock testing APIs
Some mock APIs don't have an ATSL equivalent yet
will be deprecated in O timeframe now.

Change-Id: Ibb7ec32fba3d16f0ea02d100f4e4fc8f011288f0
Bug: 28295815
2016-05-25 22:54:27 +00:00
Svetoslav Ganov
a9c2500a68 Disallow disable of the system shared libs.
bug:28173410

Change-Id: If731f2d90312a083bb940f83431ba3eccf213947
2016-04-13 19:31:40 -07:00
Suprabh Shukla
78c9eb8947 Added api to delete cache files for a given user
Added an api to delete application cache files for a specific user. This
allows settings to clear cache files for work profile apps as well.

Bug: b/25338468
Change-Id: I52d4944a7a03b6d63ad44dd6bb868aec62815eab
2016-04-12 18:23:56 -07:00
Jeff Sharkey
70168dde6e Make Parcelable classes final, API cleanup.
Remove some Context methods that leaked through.  Add lint rule to
recommend using List<? extends Parcelable> instead of Parcelable[].

Bug: 27932224, 27930145, 27932911
Change-Id: Ia302de46cdb0c5101fa175a09316df91aeefcf0d
2016-03-30 23:31:39 -06:00
Jeff Sharkey
8a372a0a28 Refactoring FBE APIs based on council feedback.
Mostly consists of removing the word "encryption" from most APIs,
since we can't actually make promises about the data being encrypted.

Bug: 27531029
Change-Id: Iace9d7c4e64716abf86ed11847c40f3947e1d625
2016-03-17 14:49:08 -06:00
Sudheer Shanka
bbb3ff2b2a Flush package restriction changes for a user.
Change-Id: I7c4481f820b6b368487d00de6c783e64cec99f4b
2016-03-16 01:42:23 +00:00
Vadim Tryshev
66ae66a7f7 Adding getManagedUserBadgedDrawableForDensity() to PackageManager.
It allows badging an image regardless of of the user (no
user id parameter). The styling for managed users is applied.

This is useful for new cases where the existing functions
wouldn't badge the icon, but we need it.

Bug: 25192539
Change-Id: I2fd2f226f626fb2e6cda1cfe072013350e12b41c
2016-03-02 14:55:04 -08:00
Vadim Tryshev
093622f089 Revert "Adding getManagedUserBadgedDrawableForDensity() to PackageManager."
This reverts commit 9f68f41a5866e1feb810b16c769705c10e850d5d.

Caused breakage.

Change-Id: I441737f61f6f38ed9f440211b52bbac0f74982e3
2016-03-02 01:51:42 +00:00
Vadim Tryshev
9f68f41a58 Adding getManagedUserBadgedDrawableForDensity() to PackageManager.
It allows badging an image regardless of of the user (no
user id parameter). The styling for managed users is applied.

This is useful for new cases where the existing functions
wouldn't badge the icon, but we need it.

Bug: 25192539
Change-Id: I20ca2d7265cbc3a47c050a72ec1843cc0a481c74
2016-03-02 00:41:26 +00:00
Todd Kennedy
a67932374d Revert "Revert "Remove deprecated methods / classes""
This reverts commit 5cbeb5902633646fbc0a1be252081e77aaaee7b4.

Change-Id: Id96010364d65e6131221ebbcc8ce5889a2da256c
2016-03-01 07:19:33 -08:00
Todd Kennedy
fe01ea05dd Merge "Revert "Remove deprecated methods / classes"" into nyc-dev 2016-02-24 22:45:50 +00:00
Todd Kennedy
5cbeb59026 Revert "Remove deprecated methods / classes"
This reverts commit 9706c01f9b92cee64bb84782138735225c8588e0.

Change-Id: I14c53ab140220e48f6728b1173ea58760bbeb7f9
2016-02-24 22:45:00 +00:00
Todd Kennedy
ca67844e0c Merge "Remove deprecated methods / classes" into nyc-dev 2016-02-24 21:02:58 +00:00
Jeff Sharkey
2c1ba9a961 Make BackupManager encryption aware.
Backup requires both CE and DE storage to be available, so delay
spinning up the backup system until the user is unlocked, since
that's when CE storage becomes available.  Note that devices without
FBE immediately transition USER_SYSTEM into the unlocked state,
since their CE is always available.

Offer to backup and restore files under both CE and DE.  Since DE
is effectively the same as CE, most logic is simply duplicated for
now, but it could be simplified in the future.  Since system apps
can force their default storage location to DE, we always build
explicit CE and DE paths.

Add getDataDir() to give clean access to the top-level private data
directory, but disclaim that apps shouldn't create files there.

Bug: 26279618
Change-Id: Ic34a4b330223725db93b1d0f5c9dffc88002c61f
2016-02-18 10:54:11 -07:00
Andrei Stingaceanu
eb84b1843a Suspend packages - one call for multiple packages
Refactor setPackageSuspended into setPackagesSuspended. The rationale
is that the consumers of this API are likely to want to remove
multiple packages at once. Rather than calling the API N times, call
it just once.

The good part is that we already have the broadcast intent for
suspended packages take an array so only one broadcast. Less stress
on the system.

Another good part is that (right now) we only have one consumer of
this API and it will be easy to make changes once this CL goes in.

As a shell command, for consistency only allowed one package at
a time.

Bug: 22776761
Change-Id: Ic8b8cf64d0a288ea3a282bb7b72f9d663b3b0049
2016-02-17 15:14:33 +00:00
Andrei Stingaceanu
5ae4e73ef0 Merge "Suspend packages - new API for retrieving the suspended status" into nyc-dev 2016-02-17 11:57:51 +00:00
Todd Kennedy
9706c01f9b Remove deprecated methods / classes
Now that we've moved the majority of system components to the
PackageInstaller, we can remove the majority of the "installPackage"
methods and the VerificationParams/ContainerEncryptionParams
classes. There are still some lingering references to the two
installPackage() methods left [both internal and external; play
is using these methods via reflection].

Bug: 24542768
Change-Id: Ib65323d842d9f0e7fed60e37e6b5f103c94c859b
2016-02-16 13:39:55 -08:00
Andrei Stingaceanu
355b232d79 Suspend packages - new API for retrieving the suspended status
Instead of always rebuilding the full ApplicationInfo for a
package when callers are only interested in the suspended status
add a new fast API in Packagemanager (which only checks the
suspended user setting for the requested package and returns
a boolean) and change the appropriate caller code too.

Bug: 26794775
Bug: 22776761
Change-Id: Ide8428ef734479360d5a8a75fd8e0ed8ddf2da7a
2016-02-16 14:57:29 +00:00
Jeff Sharkey
115d2c189a Add feature versions for devices and apps.
We're starting to see more instances of device features that will
increment separately from the SDK API level, such as camera HAL,
GPU capabilities, Bluetooth, and other hardware standards.

This change adds the ability for device features to specify a
version, which is defined to be backwards compatible.  That is, apps
requesting an older version of a feature must continue working on
devices with a newer version of that same feature.

When a version is undefined, we assume the default version "0".

Bug: 27162500
Change-Id: If890bf3f3dbb715e8feb80e7059a0d65618482ea
2016-02-15 17:45:42 -07:00
Svet Ganov
d7b1f41109 Add an API to query the package name of the services shared lib
The servcies shared lib contains components apps can invoke such
as services to bind to, activities to start, UI choosers, etc.
This lib is built from AOSP code but an OEM may chage its
package name. For example, Google renames the package names for
GMS apps from android.foo.bar to com.google.android.foo.bar.
While we have more than one shared lib that are a part of the
platform (currently shared and services libs) the serivces lib
is the only one clients need to start components in, thus need
to know its package name. This change adds an API to query the
package name of the services shared lib. The API is hidden as
currently the only clients are a part of the system.

Change-Id: Ied48fa4819024522791764b22b3336d4f4b42cc3
2016-02-09 18:49:27 -08:00
Jeff Sharkey
35871f2c2b Offer to migrate databases and SharedPreferences.
Databases and SharedPreferences often involve multiple files under
the hood, so developers wanting to migrate them between different
storage contexts should ask us to make sure all relevant files are
migrated correctly.

This makes a best-effort attempt to recover from battery pulls
during migration, while still trying to alert developers to
conflicting files.

Bug: 26668510, 25860525
Change-Id: I9ffa3e8cb6191dfd4237b9466a081d6d77df3ba0
2016-01-30 17:03:23 -07:00
Stephan Linzner
b51617f466 Deprecated platform Android testing APIs
- Deprecated most android.test.* APIs
- Kept ProviderTestCase2 and LoaderTestCase since we don't have a
replacement yet
- Deprecated android.test.suitebuilder
- Added Javadoc to all deprecated APIs with links to corresponding
Android Testing Support Library APIs
- Removed all trailing whitespace

Bug: 22314304
Change-Id: I1b1f0dd5132364110f1dfd4e3eb2dd044700d859
2016-01-27 18:09:58 -08:00
Selim Cinek
e6ff946cd4 Switched the work profile badge used in the notifications
Change-Id: I62616f1ae8fcda9953853b9859c69a9f1e6f44ca
2016-01-21 19:42:49 -08:00
Todd Kennedy
12705131b9 Hide ephemerality
Change-Id: Ibf60366b3f00b1920e330cd804bcc1c550f8882a

Bug: 26404647
2016-01-11 16:21:03 -08:00
Jeff Sharkey
cd65448ccd Even more PackageManager caller triage.
Finish moving all UID/GID callers to single AIDL method that requires
callers to provide flags.

Triage AppWidgets and PrintServices, which currently can only live on
internal storage; we should revisit that later.

Fix two bugs where we'd drop pending install sessions and persisted
Uri grants for apps installed on external storage.

Bug: 26471205
Change-Id: I66fdfc737fda0042050d81ff8839de55c2b4effd
2016-01-08 18:35:54 -07:00
Jeff Sharkey
8588bc1ef1 Add flags to requests for package UID/GIDs.
This gives callers the ability to request details for missing
packages.  Also add annotations for userId and appId variables and
start tagging their usage.

Change-Id: I63d5d7f870ac4b7ebae501e0ba4f40e08b14f3f6
2016-01-07 10:33:26 -07:00
Jeff Sharkey
e06b4d1d9f Consistent naming for PackageManager methods.
When hidden PackageManager methods take a userId argument, they
should be named explicitly with the "AsUser" suffix.  This fixes
several lagging examples so that we can pave the way to safely
start passing flags to new methods without scary overloading.

Also fix spacing issues in various logging statements.

Change-Id: I1e42f7f66427410275df713bea04f6e0445fba28
2016-01-06 15:21:06 -07:00