186 Commits

Author SHA1 Message Date
Tony Mak
787703431b Return exit code 0 when the command run successfully
Fix: 62410589
Test: run the pm create-user command and check the exit code

Change-Id: I5bde1f886860cd8edb869ebaa8f6e5376882f03b
2017-06-08 20:33:14 +00:00
Jeff Sharkey
ddff807b76 Consistent "low storage" behavior.
When answering the question "how much space is free", use the same
logic for Settings UI and StorageManager.getAllocatableBytes().  That
is, the reported free space is usable bytes plus any cached data the
system is willing to delete automatically.

This does *not* include any reserved cache space, since we don't want
abusive apps to penalize other well-behaved apps that are storing
their data in cache locations.  Callers freeing cached data need to
now explicitly request defiance of the reserved cache space.  (Most
callers are already doing this by using FLAG_ALLOCATE_AGGRESSIVE.)

Rewrite the core logic of DeviceStorageMonitorService to understand
this new "reserved" cache space, and to be easier to understand.  It
also now handles cached data on adopted storage volumes, which had
been ignored until now.  Also fix bug where we had skipped "low"
broadcasts when the device skipped directly from/to "full" state.

Bug: 38008706
Test: cts-tradefed run commandAndExit cts-dev -m CtsJobSchedulerTestCases -t android.jobscheduler.cts.StorageConstraintTest
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Change-Id: Icbdcf3b52775f7ada1ceaeff2f96094c8d8052f9
2017-05-30 22:17:23 -06:00
Dianne Hackborn
983055231b Fix issue #37360626: Apps can schedule alarms (and other things) with temp whitelist
There is now an IBinder "token" that must be specified when setting
the whitelist duration for an Intent.  To have the whitelist supplied,
the caller to send a PendingIntent must pass in the same token.  The
PendingIntent and IntentSender classes now internally maintain this token
to pass in when their send() is called.

The big complexity for making this work is we now need to associate this
whitelist token correctly with the actual PendingIntent objects that
applications and other code is getting.  To do this, we propagate the
token in the Notification object, and have a new API on Parcel that allows
us to make it available to PendingIntent when it is unmarshalled.  And
this allows to deal with PendingIntents appearing in nested bundles, as
we can propagate that information from the original Parcel to the new
Parcel that Bundle keeps to delay unmarshalling.

Test: manual
Change-Id: Idda00490ccfe2be37e4ab21354b9ab7528a52750
2017-05-10 17:23:02 -07:00
Jeff Sharkey
fd65813157 Offer to wait until broadcasts have drained.
We've seen evidence of lab devices racing with other apps that are
using cache space immediately after tests wipe it clean, which can
cause test failures.  To mitigate this, try our best to wait for the
device to go "idle" by watching for broadcast queues to fully drain.

Also improve javadocs along the way.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Bug: 37486230, 37566983, 37913442, 37914374
Change-Id: I4d430db443b6fa6d33a625fe07b90279b5d51c12
2017-05-05 14:58:47 -06:00
Felipe Leme
24d5893b25 Added a UserManager.DISALLOW_AUTOFILL restriction.
bug: 35710740

Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases -t android.autofillservice.cts.LoginActivityTest#testUserRestriction
Test: cts-tradefed run commandAndExit cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDisallowAutofill_allowed
Test: cts-tradefed run commandAndExit cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedProfileOwnerTest#testDisallowAutofill_allowed
Test: cts-tradefed run commandAndExit cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testDisallowAutofill_allowed

Change-Id: I41b2bf9fe3bc8df627c6650960bd11346c430a7e
2017-03-22 17:20:48 -07:00
Adam Lesinski
1665d0f028 Add support for configForSplit
Applications with the android:isolatedSplits="true" attribute in
their AndroidManifest.xml would have their Split APKs loaded in
isolation of each other, based on a set of dependencies.

Configuration Splits generated for a Feature split would not be properly
loaded before, so this change, along with a tools change, fixes this
issue and completes support for isolatedSplits.

Bug: 30999713
Test: CTS test coming (depends on some tool changes)
Change-Id: Ia4e7b0e69168a9d6637867558e306f7031720fb3
2017-03-16 15:45:10 -07:00
Sunny Goyal
6d7cb23236 Sending explicit broadcast to the launcher when a package is installed
Test: Manually tested on device and add CTS tests
Bug: 32920609
Change-Id: Ic23c077a469fb41d6c4e123d4bc022899f634198
2017-02-28 12:55:59 -08:00
TreeHugger Robot
ed4cd7a1ba Merge "Log pm install time and package name" 2017-02-21 21:01:20 +00:00
Fyodor Kupolov
4b4ce6fa17 Log pm install time and package name
Bug: 32559349
Test: manual
Change-Id: Ibfbea8cab2ab085109ee4d5a248bfacf82cdfbbb
2017-02-17 16:30:00 -08:00
Todd Kennedy
be0b8896d1 Revert "Revert "Per user setting for instant app""
This reverts commit be9ffa15af9e1906e9ffb505768328d62d4a3793.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest
Change-Id: Ib21321cf157a79890de487060a093840f7182047
2017-02-16 12:43:37 -08:00
Sudheer Shanka
f88ebeb250 Use correct packageName for checking if it belongs to callingUid.
In AccountManagerService.getAccountsAsUser, we check if opPackageName
belongs to calling uid by calling AppOpsManager.checkPackage. But when
AccountManagerService.getAccountsAsUser is called from
AccountManagerService.addSharedAccountsFromParentUser, we're using the
opPackageName from system context instead of calling context.

Bug: 35258008
Test: cts-tradefed run singleCommand cts-dev --module CtsMultiUserHostTestCases \
      -t android.host.multiuser.CreateUsersPermissionTest#testCanCreateRestrictedUser
Change-Id: I5c425d9314beb86f7c64a5b5c64b7d879711879a
2017-02-14 18:35:05 -08:00
Adam Lesinski
4e8628157a Add support for Split APK dependcies
Apps can now declare in their base APK AndroidManifest.xml
that they want to have their split APKs loaded in isolated
Contexts. This means code and resources from the split
get loaded into their own ClassLoader and AssetManager.

<manifest xmlns:android="..."
          ...
          android:isolatedSplits="true"
          ...

In order to make this more useful, splits can declare dependencies
on other splits, which will all get pulled in to the Context
and run as expected at runtime.

A split declares its dependency on another split by using the
tag <uses-split> in its AndroidManifest.xml:

<manifest xmlns:android="...">
    ...
    <uses-split android:name="feature_split_1" />
    ...

A split can have a single parent on which it depends on. This is
due to the limitation of having a single ClassLoader parent.
All splits depend on the base APK implicitly.

PackageManager verifies that no cycles exist and that each dependency
is present before allowing an installation to succeed.

The runtime will then load splits based on the dependencies.

Given the following APKs:

base <-- split A <-- split C
  ^----- split B

If an Activity defined in split C is launched, then the base,
split A, and split C will be loaded into the ClassLoader defined
for the Activity's Context. The AssetManager will similarly be loaded
with the resources of the splits.

A split can be manually loaded by creating a Context for that split, defined
by its name:

Context.createContextForSplit("my_feature_split_1");

All installed Activities, Services, Receivers, and Providers are accessible
to other apps via Intent resolution. When they are instantiated, they are
given the appropriate Context that satisfies any dependencies the split they
were defined in stipulated.

Test: WIP (CTS tests to come)
Change-Id: I8989712b241b7bc84381f2919d88455fcad62161
2017-01-24 18:34:08 -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
Todd Kennedy
b771768249 Add system API to install ephemeral apps
Test: manual; install using "adb install --ephemeral"
Change-Id: Idce214779fea5f3c4a0121542319044f9f0e0a42
2016-12-08 14:51:43 -08:00
Sudheer Shanka
dc589ac82b Update usage of ActivityManagerNative.
- Remove references to ActivityManagerProxy.
- Add isSystemReady to ActivityManager.

Bug: 30977067
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test android.server.cts
      adb shell am instrument -e class com.android.server.am.ActivityManagerTest,com.android.server.am.TaskStackChangedListenerTest \
          -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I07390b6124fb1515821f5c0b37baf6ae74adc8fa
2016-11-14 11:27:12 -08:00
Todd Kennedy
9caf94e535 force appropriate size
during install, the user could specify an invalid size [ie. a negative
number].

also error out if we're given a path that's not a file.

Change-Id: I79e9ef82723495782146208eb5469722d1f8ed02
Test: manually ran 'adb install' with invalid arguments
2016-10-17 14:50:52 -07:00
Shunta Sato
852638dad6 Fix: "adb install -s" adaptation for session based install am: 4f26cb5a36 am: 55bcb9f422
am: 4549426d6e

Change-Id: I400fc32717172cca401e3ccdae9a6b17687390b6
2016-10-11 17:04:16 +00:00
Shunta Sato
4549426d6e Fix: "adb install -s" adaptation for session based install am: 4f26cb5a36
am: 55bcb9f422

Change-Id: Id9dcfdd12f190744fe84136c0a53e2cfb6638516
2016-10-11 16:57:34 +00:00
Shunta Sato
4f26cb5a36 Fix: "adb install -s" adaptation for session based install
Internal implementation of "adb install" has been changed to
session install. As a result '-s' option doesn't work.
Size info is required when using '-s' option in session install.
PackageHelper.fitsOnExternal() returns false and moving app to SD is
failed when size info is not set.

So set size info when '-s' option is used.
And change identity on some method because shell doesn't have some
permission to access to asec.

Bug: 29932779
Author: Ryuki Nakamura <ryuki.x.nakamura@sonymobile.com>
Change-Id: I65edcc0f01ceecaaba17792ad329791a9253d603
2016-10-11 06:33:22 -07:00
Sudheer Shanka
7cb54a34c4 Allow some packages to be excluded during during work profile creation.
Bug: 31657192
Test: adb shell am instrument -e class com.android.server.pm.UserManagerTest#testAddManagedProfile_withDisallowedPackages -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I37eab6084e0f911d0e2407186b789875588194a2
2016-10-07 18:11:11 -07:00
Dianne Hackborn
354736e196 New infrastructure to switch remaining commands to "cmd" calls.
This introduces a new feature of the IBinder command protocol
to allow the shell command implementation to call back into
its caller to ask it to open files in the calling context.  This
is needed so that commands that have arguments specifying files
can open those files as the calling shell, not the system (or
whatever) process.

To test this all out, move the "am start" implementation over
to ActivityManagerShellCommand, in particular along with its
option to specify a file in which to write profiling data.

Test: Manual

Change-Id: I0c1e3857defefbd19a2ac29413aafbb34b1e48a3
2016-09-29 10:58:44 -07:00
Amith Yamasani
42daac6289 Merge \"Add tron logging for retail demo session counters\" into nyc-mr1-dev
am: 30a2b43f6d

Change-Id: Iaca49cc4aad9285e87d869b112b6c2986073f006
2016-06-28 01:06:47 +00:00
Amith Yamasani
b75fc2b2b7 Add tron logging for retail demo session counters
Count each demo user creation and time between
first touch (to dismiss the video) and the start
of inactivity timeout.

Fixed an NPE in SysUI when user switcher is missing.

Bug: 29540372
Change-Id: I7bc0e0dde75e7b213a025683c15c9b3e750643a9
2016-06-27 11:15:38 -07:00
Sudheer Shanka
098bc0d840 Merge \"Add pm operation to set user restrictions.\" into nyc-dev
am: f6824b51cc

Change-Id: I137151742049c0a02d41a02e49abb679234f14b9
2016-06-17 22:08:07 +00:00
Sudheer Shanka
bf0a9a7445 Add pm operation to set user restrictions.
Bug: 29189712
Change-Id: I6fdb3b68dfe3f51119e5ce8008880fc7d9c793df
2016-06-16 09:43:29 -07:00
Dianne Hackborn
a24af982ff Merge "Fix issue #27532364: Security Vulnerability in IIntentSender.send" into nyc-dev
am: 607844efa5

* commit '607844efa59f79bd9fab55eb75f217d21cd15f5f':
  Fix issue #27532364: Security Vulnerability in IIntentSender.send

Change-Id: I749b455402caef335239b540ec8883a8d7b2a974
2016-05-17 18:32:46 +00:00
Dianne Hackborn
0c4e6a8da3 Fix issue #27532364: Security Vulnerability in IIntentSender.send
We need to make IIntentSender oneway...  but when the system is
calling that for itself, it needs to be able to return a result code.

Solution: instead of directly calling the interface, we have a new
IPC through the activity manager.  If the thing being used is the
activity manager impl, it can do the synchronous send and return
the result directly in place.  If not, you only get asynchronous
sending and thus never a failure result back (too bad for you!).

Change-Id: I4096e5b00063e8dba66230585a2dfe67e35e8092
2016-05-13 17:37:08 -07:00
Todd Kennedy
9a50b6abf1 Merge "Don\'t override pre-release target sdk" into nyc-dev
am: 97ef0e7

* commit '97ef0e77afa3be6255b70c8567843ac298386251':
  Don't override pre-release target sdk

Change-Id: Ib70b0e908dc148799875afcedeeb1d59f2d90367
2016-04-27 00:58:47 +00:00
Todd Kennedy
b107271813 Don't override pre-release target sdk
If a package targets a pre-release SDK [eg a letter version] it should not
be allowed to be upgraded by a release SDK [eg a number version]. If one
absolutely must upgrade to a release SDK, use the "--force-sdk" option
during install.

Bug: 28345311
Change-Id: Ic9fb209968e7c5da2c80c5ca4c0f44f5125f610a
2016-04-26 16:25:43 -07:00
Todd Kennedy
61c24ded75 Merge "Add "do not kill" install option" into nyc-dev
am: 6958226

* commit '69582262f0dfa8cdca232d03ff3239fa026326ab':
  Add "do not kill" install option

Change-Id: I438e486400d00070fd424cb811e578d5f3a1c60d
2016-04-26 17:24:02 +00:00
Todd Kennedy
47763629fe Add "do not kill" install option
Passing the "--dont-kill" argument to pm install-create can be used to
install a feature split without killing the contianing application.
Use with caution.

Bug: 27780548
Change-Id: I743ac4f640c9c4251d1b3bc70ddf428bd79e07bf
2016-04-21 15:21:20 -07:00
Fyodor Kupolov
3f7fa3be86 Merge "Fixed arguments order for addSharedAccountsFromParentUser" into nyc-dev
am: da466f7

* commit 'da466f72727a06c71735c35acd70d5b8b284c8be':
  Fixed arguments order for addSharedAccountsFromParentUser

Change-Id: I6b568dc352282bda8e68ddf1b88303e4f158092a
2016-03-30 22:37:37 +00:00
Fyodor Kupolov
4d709f998d Fixed arguments order for addSharedAccountsFromParentUser
Bug: 27900775
Change-Id: I8c48fabddb778bfd94333d4dcdd296fef87cb59a
2016-03-29 11:20:19 -07:00
Dan Willemsen
dc3b852125 resolve merge conflicts of 8416096 to nyc-dev-plus-aosp
Change-Id: I1638601fe84dda01bf52c59eb6c976bc1fe37498
2016-03-23 15:31:32 -07:00
Dan Willemsen
98ff0b72f0 Remove custom copy rules, stop using ACP
Replace some custom rules with BUILD_PREBUILT.

Move tools from ALL_PREBUILTS to BUILD_PREBUILT. All of them are already
in PRODUCT_PACKAGES in build/target/product/base.mk.

Remove uses of ACP and replace with core build system macros or 'cp'

Change-Id: I529e7c6c50fc64ad36b75bb47142f6bde909d141
2016-03-23 13:42:52 -07:00
Alex Klyubin
88b42855c9 Only debuggable packages can be downgraded.
This reflects the change in PackageManager service:
frameworks/base commit 921dd754ab49df0cd580ff96503f7616c4c85f4a.

Bug: 27327503
Change-Id: Ic13788a3850c4d1a3a566b208853de9a6d2c5237
2016-02-24 16:52:01 -08:00
Todd Kennedy
8d9366cfe9 Remove 2nd line from failure
In an attempt to provide more detailed information to the end-user, we
caused tests to fail [they parse the output of the 'pm' command]. Remove
the 2nd line of the output that was causing the failure.

Also took the opportunity to merge changes from the Pm command to the
Cmd command.

Bug: 26131598
Change-Id: I459f9ec8978d87dd571136222f780039e426474e
2015-12-16 13:47:14 -08:00
Todd Kennedy
1fd413f637 Merge "Temporarily stop proxying to cmd" 2015-12-08 17:07:15 +00:00
Lenka Trochtova
c4dd021322 Introduce ephemeral users.
BUG: 24883058

Change-Id: I2e1d6aa184142c2a3dc0415c0cd407573453cf41
2015-12-08 15:47:10 +01:00
Todd Kennedy
9619d049bf Temporarily stop proxying to cmd
Unless the APK is streamed, proxying pm install commands to the cmd command
will generally not work on any system that has SElinux enforcement. This
is due to the system sever [where cmd commands are run] not having access
to the directories where files are uploaded to. We'll re-enable the proxy
once we determine an appropriate, safe location for uploaded APKs.

Bug: 25769800
Change-Id: I73b2da0b03fe8bd9ce29e20b37cb4eeff9b491b4
2015-12-07 13:26:08 -08:00
Todd Kennedy
2699f06555 Add ephemeral installs
* Add a new --ephemeral argument to 'adb install'
* Add plumbing to internally track ephemeralness
* Create new app directory for ephemeral installs

Bug: 25119046
Change-Id: I1d379f5ccd42e9444c9051eef2d025a37bd824fe
2015-12-03 14:47:01 -08:00
Todd Kennedy
72cfcd02b8 Move 'un/install' to cmd
Move the implementation of the install variants and uninstall to the cmd
command. Additionally, make two other important changes: 1) replace calls
to the legacy PackageManager#installPackageAsUser with the PackageInstaller
2) allow streaming package bits for 'pm install'

Change-Id: I5680f57208d377daadb69b2cc09c233c02fe5016
2015-11-09 15:07:18 -08:00
Todd Kennedy
18bc3305e4 Revert "Move 'un/install' to cmd"
This reverts commit ec059d839de6d061085dcfd85ce6565dcf4d5b69.

Change-Id: Ieaa1373e96fb4cc20aa41c3159518bd9e86c572b
2015-11-09 15:36:43 +00:00
Todd Kennedy
ec059d839d Move 'un/install' to cmd
Move the implementation of the install variants and uninstall to the cmd
command. Additionally, make two other important changes: 1) replace calls
to the legacy PackageManager#installPackageAsUser with the PackageInstaller
2) allow streaming package bits for 'pm install'

Change-Id: Ia49dac0ccd6470f9d1c1964bdeb3c0b22b856075
2015-11-06 09:27:22 -08:00
Brian Carlstrom
ce8bf86d6d Merge "Fixes for sm and pm usage" am: ffb15da518 am: 671d5965f7
am: f73e78fe1c

* commit 'f73e78fe1cb6803a29f7f85b49792f4e8a7350c8':
  Fixes for sm and pm usage
2015-11-05 18:55:49 +00:00
Brian Carlstrom
82bfca4609 Fixes for sm and pm usage
sm showed IllegalArgumentException after usage.
pm inconsistently used "return showUsage()"

Bug: 20948199
Change-Id: I5828489a9d4ef2eabfb97dd408d66e1560a5a983
2015-11-05 10:33:40 -08:00
Todd Kennedy
60459abb21 Implement shell commands for package and user services
Only implement the 'list' package service command. More will follow
in future CLs.

Change-Id: Iae225cd4ee63c7d468a4fd882d8cb4b6b76ccc09
2015-11-02 16:19:50 -08:00
Xiaohui Chen
f5bf0de1aa clean up USER_OWNER in Pm command
Change-Id: I3092cdf1ca619b4c1ba881955b8a55b97ba10e24
2015-10-26 10:45:15 -07:00
Brian Carlstrom
80435a7fcd am bd5b6252: am b9a28ae1: am f916524f: Merge "Add support for --user to "pm path" for work profile use"
* commit 'bd5b6252a5dd068c2db30fbbd16e87a656047197':
  Add support for --user to "pm path" for work profile use
2015-10-15 16:16:07 +00:00
Brian Carlstrom
f916524f44 Merge "Add support for --user to "pm path" for work profile use" 2015-10-15 15:55:45 +00:00