127 Commits

Author SHA1 Message Date
Brian Carlstrom
f916524f44 Merge "Add support for --user to "pm path" for work profile use" 2015-10-15 15:55:45 +00:00
Brian Carlstrom
f83612b295 Add support for --user to "pm path" for work profile use
Change-Id: Ic8bb923e15a40f32cc7daa6a344250abfc81e423
2015-09-25 13:08:35 -07:00
Christopher Tate
47dd08d7fb Teach Pm about the "always ask" link-handling state
Bug 23511867

Change-Id: I74b3c8222a7d22541a96b698edd1a175d378e48f
2015-08-25 12:39:04 -07:00
Christopher Tate
56f0ff3c48 Make "Ask every time" actually work that way
..in link-opening behavior.  If a candidate is marked as "ask
every time," then the user is guaranteed to get a disambiguation
prompt including that candidate even when some other candidate
app is in the "always prefer this over a browser" state.

Bug 23147746

Change-Id: I904d8697a992b3f16f32b1c1b49c2bf9424c7137
2015-08-13 18:56:05 -07:00
Christopher Tate
387225ff01 Add 'pm' operation to set a package's app-linking state
Set an app's state:

  pm set-app-link [--user USER_ID] PACKAGE {always|ask|never|undefined}

Read an app's current state:

  pm get-app-link [--user USER_ID] PACKAGE

The latter prints to stdout one of the strings usable as an argument to
set-app-link.  If an error is encountered, the string printed to
stderr begins with "Error: ".

Bug 19628527

Change-Id: I68b6dc24445917807345a8cf5baa2078490740af
2015-07-20 17:45:17 -07:00
Jeff Sharkey
396080dd02 Add grant flag support to "install-create" verb.
This matches the "install" behavior.

Bug: 22331569
Change-Id: I07bfe067bd4be01fc92126750b0ff25a5c5ba5c9
2015-07-09 09:16:07 -07:00
Dianne Hackborn
ca8e6da41c Fix issue #22023824: Download folder is not created in internal storage
The media provider and some other things need to be given storage access.

Also, seems like we should give storage access to the camera app as well.

And add a dump dump command that will dump data about a particular
permission name.

Change-Id: Idaaa9bba2ff4dc95290cf6d17e5df933df91e909
2015-06-26 13:28:29 -07:00
Dianne Hackborn
a750a63d63 Fix issue #21814207 and issue #21814212 (alarm manager)
Issue #21814207: AlarmManager.setAndAllowWhileIdle should also allow wake locks.

Introduce a whole new infrastructure for providing options when
sending broadcasts, much like ActivityOptions.  There is a single
option right now, asking the activity manager to apply a tempory
whitelist to each receiver of the broadcast.

Issue #21814212: Need to allow configuration of alarm manager parameters

The various alarm manager timing configurations are not modifiable
through settings, much like DeviceIdleController.  Also did a few
tweaks in the existing DeviceIdleController impl.

Change-Id: Ifd01013185acc4de668617b1e46e78e30ebed041
2015-06-17 11:41:45 -07:00
Jeff Sharkey
ab2340996a Flags to select storage volume for app installs.
Remote callers can now provide the "--install-location" value from
the APK to help select a location, or they can explicitly force a
volume by UUID.

Bug: 21676789
Change-Id: Iefc92d770a851fc33e37edbf259fdb8df2b14ae5
2015-06-09 21:42:22 -07:00
Svet Ganov
4ccca50d7e Fix grant/revoke to act on owner by default and log invalid user id.
bug:21163229

Change-Id: I66d0cc130b37b5752ed06afc73259ed41bfb7830
2015-05-14 16:24:19 -07:00
Svet Ganov
8c7f700a59 Add permission meta-state flags to support grant/revoke permission policy.
We now maintain a mata-state with each permission in the form of flags
specyfying the policy for this permission. This enables support of the
following use cases:

1. The user denies a permission with prejudice in which case an app cannot
   request the permission at runtime. If an app requests such a permssion
   it gets a denial unless the user grants the permission from settings.

2. A legacy app with disabled app-ops being upgraded to support runtime
   permissions. The disabled app ops are converted to permission revocations.
   The app ops manager is a part of the activity manger which sits on top
   of the package manager, hence the latter cannot have a dependency on the
   former. To avoid this the package installer which is the global
   permission managment authority marks the permission as revoked on
   upgrade and the package manager revokes it on upgrade.

3. A device policy fixing a permission in a granted or revoked state. This
   additional information is folded in the meta-state flags and neither
   apps can request such permissions if revoked not the user can change
   the permission state in the UI.

Change-Id: I443e8a7bb94bfcb4ff6003d158e1408c26149811
2015-05-11 17:13:57 -07:00
Jeff Sharkey
275e3e43f2 Migrate primary external storage.
Wire up through MountService to call down into vold.  Watch for
unsolicited events that report progress, including special value "82"
that signals that copy has finished.  We use this value to persist
the volumeUuid in case of unexpected reboot, since it indicates the
new volume is ready.

Wire progress updates through existing callback pipeline.

Update the volume mounting code to match against the persisted UUID
when selecting the primary external storage.

Bug: 19993667
Change-Id: Id46957610fb43517bbfbc368f29b7d430664590d
2015-04-24 18:01:45 -07:00
Jeff Sharkey
620b32b316 Package and storage movement callbacks.
Since package and primary storage movement can take quite awhile,
we want to have SystemUI surface progress and allow the Settings
app to be torn down while the movement proceeds in the background.

Movement requests now return a unique ID that identifies an ongoing
operation, and interested parties can observe ongoing progress and
final status.  Internally, progress and status are overloaded so
the values 0-100 are progress, and any values outside that range
are terminal status.

Add explicit constants for special-cased volume UUIDs, and change
the APIs to accept VolumeInfo to reduce confusion.  Internally the
UUID value "null" means internal storage, and "primary_physical"
means the current primary physical volume.  These values are used
for both package and primary storage movement destinations.

Persist the current primary storage location in MountService
metadata, since it can be moved over time.

Surface disk scanned events with separate volume count so we can
determine when it's partitioned successfully.  Also send broadcast
to support TvSettings launching into adoption flow.

Bug: 19993667
Change-Id: Ic8a4034033c3cb3262023dba4a642efc6795af10
2015-04-23 20:32:17 -07:00
Jeff Sharkey
529f91fc8e Always send volume UUID with installd commands.
Since packages can be moved to other volumes, all relevant commands
to installd now require an explicit volume UUID parameter.

Bug: 20275577
Change-Id: Ie84f5bc43c7aada5800b8d71692c7928b42b965e
2015-04-18 21:11:58 -07:00
Benjamin Franz
39fb7fd730 Allow silent package install for device owner.
Allow the device owner to silently install and remove packages using the
PackageInstaller APIs. Show notifications to the user after the
installation / deletion was successful.

Bug: 19422461
Change-Id: I0506e18c510efd9d04c4aea9b60a37456e689615
2015-04-07 11:02:46 +01:00
Jeff Sharkey
b2b9ab8354 Installing packages to expanded storage.
PackageManager now offers to load/unload packages when expanded
volumes are mounted/unmounted.  Expanded storage volumes are still
treated as FLAG_EXTERNAL_STORAGE from a public API point-of-view,
but this change starts treating the INSTALL_EXTERNAL flag as
exclusively meaning ASEC containers.

Start tracking the UUID of the volume where a package is installed,
giving us a quick way to find relevant packages.  When resolving an
install location, look across all expanded volumes and pick the one
with the largest free space.  When upgrading an existing package,
continue preferring the existing volume.  PackageInstaller now knows
how to stage on these volumes.

Add new movePackage() variant that accepts a target volume UUID
as destination, it will eventually move data too.  Expose this
move command through "pm" command for testing.

Automount expanded volumes when they appear.

Bug: 19993667
Change-Id: I9ca2aa328b9977d34e8b3e153db4bea8b8d6f8e3
2015-04-06 21:17:58 -07:00
Amith Yamasani
3605fac80b Update command line usage for pm
Include the --user flag.

Change-Id: Id2a2bc73f4b7392e308c5946eeb42b21426a1bfd
2015-04-06 13:20:45 -07:00
Svet Ganov
95c1adea0c Add install option to grant all runtime permissions.
Change-Id: I72ba67a72025646a3d53611621b0353d3a86677c
2015-03-24 01:53:50 +00:00
Svetoslav
c6d1c345f4 Runtime permissions: per user permission tracking.
Before all permissions were granted at install time at once, so the user
was persented with an all or nothing choice. In the new runtime permissions
model all dangarous permissions (nomal are always granted and signature
one are granted if signatures match) are not granted at install time and
the app can request them as necessary at runtime.

Before, all granted permission to an app were identical for all users as
granting is performed at install time. However, the new runtime model
allows the same app running under two different users to have different
runtime permission grants. This change refactors the permissions book
keeping in the package manager to enable per user permission tracking.

The change also adds the app facing APIs for requesting runtime permissions.

Change-Id: Icbf2fc2ced15c42ca206c335996206bd1a4a4be5
2015-03-23 18:50:35 -07:00
John Spurlock
08c7116ab9 Remove unused imports in frameworks/base.
Change-Id: I031443de83f93eb57a98863001826671b18f3b17
2015-02-28 14:47:49 -05:00
Hui Shu
9bd1382f21 am e5cb6a25: am bb845152: Merge "pm path needs to return 0 when it succeeds." into lmp-mr1-dev
* commit 'e5cb6a253afa8faffb85c73779a78c74aead23ae':
  pm path needs to return 0 when it succeeds.
2015-01-05 22:20:28 +00:00
Narayan Kamath
1cc57aba81 am 1bafd01a: am 44a5a30a: Merge "Fix "pm list permissions" crash if resource string missing"
* commit '1bafd01a3fc5f94e77d1c18e5a7dcdecddcaa47f':
  Fix "pm list permissions" crash if resource string missing
2014-12-29 11:13:22 +00:00
Narayan Kamath
44a5a30a61 Merge "Fix "pm list permissions" crash if resource string missing" 2014-12-29 11:01:28 +00:00
Hui Shu
ac3151063e pm path needs to return 0 when it succeeds.
BUG: 18721587
Change-Id: I2136d1933e62a20645517d17c1365d214509de16
2014-12-12 14:06:01 -08:00
Evan Charlton
7c006199e5 Have Pm return the correct code
If the command fails, have Pm return a nonzero exit code.

Bug: 18085950
Change-Id: I3de1b8f69aa8f44b2e2109864c1aa093e3b82141
2014-10-31 12:45:25 -07:00
Esteban Talavera
41de9bb6fd Add 'adb dpm' subcommand to set profile owner
Required for GTS tests. Needed to relax the restriction that
only root user can run 'pm create-user' as GTS tests can't
get root permissions.

Bug: 17312478
Change-Id: I1841286ddf51756c73018c087a5f29afeb5b9f15
2014-09-16 10:24:58 +01:00
Jeff Sharkey
5ab6e0bac2 Whoops, wait around for pm result.
poll() returns immediately; we want to take() to wait for the result
to actually arrive.

Bug: 17510699
Change-Id: I87669e79e9941480fed33e4cc8a38de793d59e90
2014-09-15 14:50:41 -07:00
Jeff Sharkey
e980804df1 Bring install and install-multiple into parity.
This ensures that both are using (almost) identical logic when
deciding what installs to proceed with.  Installs from "pm" for all
users now run as OWNER, and rely solely on INSTALL_ALL_USERS to
express intent.  This keeps install session notifications simple.

Since installer UID can vary from installer package name, start
persisting the UID.  Also parse some missing flags for install
sessions.

Bug: 17469392
Change-Id: I6d89b1a787aa2024cc4bebf6b9c29317c358e147
2014-09-11 21:24:00 -07:00
Amith Yamasani
dda003ffa8 Clean up apks installed for a removed user
When a user is removed, enumerate through all installed packages
to see if any of them are not installed for any user. Delete the
package if no user has it "installed".

Added a pm option to install an apk for a specific user.

Fixed a crash in UserManagerService when executing the above
cleanup - dying users generate a null UserInfo.

Bug: 15426024
Change-Id: I571decde1ae1c257d0da6db153b896aad6d6bcb4
2014-08-29 10:28:38 -07:00
Jeff Sharkey
941a8ba1a6 Installing splits into ASECs!
Sessions can now zero-copy data directly into pre-allocated ASEC
containers.  Then at commit time, we compute the total size of the
final app, including any inherited APKs and unpacked libraries, and
resize the container in one step.

This supports both brand new ASEC installs and inheriting from
existing ASEC installs.  To keep things simple, it currently requires
copying any inherited ASEC contents, but this could be optimized in
the future.

Expose new vold resize command, and allow read-write mounting of ASEC
containers.  Move native library extraction into the installer flow,
since it needs to happen before ASEC is sealed.  Move multiArch flag
into NativeLibraryHelper, instead of making everyone pass it
around.  Migrate size calculation to shared location.

Separate "other" package name in public API, provide a path to a
storage device when relevant, and add more docs.

Bug: 16514385
Change-Id: I06c6ce588d312ee7e64cce02733895d640b88456
2014-08-22 16:25:04 -07:00
Jeff Sharkey
a0907436c0 PackageInstaller API refactoring.
Switch to using IntentSender for results to give installers easier
lifecycle management.  Move param and info objects to inner classes.

Bug: 17008440
Change-Id: I944cfc580325ccc07acf22e0c681a5542d6abc43
2014-08-15 15:57:02 -07:00
Narayan Kamath
4903f64ba2 Persist the cpuAbiOverride setting.
If an app is installed with an ABI override (adb install -r --abi)
we should remember this so that we don't revert to the scan derived
ABI on the next reboot.

bug: 16476618

Change-Id: I6085bc0099eb613dd9d3b07113c7c13859780697
2014-08-13 12:41:19 +01:00
Jeff Sharkey
fbd0e9fa37 Surface user action events when un/installing.
This will be used shortly to connect up with permissions
confirmation UI.

Bug: 16515814
Change-Id: If28cecc28549900d960ac107a1fba0b10ce5bd7b
2014-08-07 00:23:54 +00:00
Jeff Sharkey
1cb2d0d4bb Persist install sessions, more lifecycle.
To resume install sessions across device boots, persist session
details and read at boot.  Drop sessions older than 3 days, since
they're probably buggy installers.

Add session callback lifecycle around open/close to give home apps
details about active installs.  Also give them a well-known intent
to show session details.

Extend Session to list staged APKs and open them read-only, giving
installers a mechanism to verify delivered bits, for example using
MessageDigest, before committing.

Switch to generating random session IDs instead of sequential.

Defensively resize app icons if too large.  Reject runaway
installers when they have too many active sessions.

Bug: 16514389
Change-Id: I66c2266cb82fc72b1eb980a615566773f4290498
2014-07-31 15:17:03 -07:00
Jeff Sharkey
20e0c50f60 Offer force-dex-opt when running as root.
Recently we removed the PackageManager inotify triggers, meaning the
only supported ways of installing apps were:

-- adb install -r Foo.apk
-- adb shell stop && adb sync && adb shell start

Iterating on most system apps (like Settings) can use the first
approach, but it doesn't work for "persistent" processes like
SystemUI.  (ActivityManager is very particular about how it deals
with persistent apps, and it always sticks with the first
ApplicationInfo found at boot.)

So to enable rapid iteration on persistent apps, we now offer the
one missing piece of forcing a dexopt with a new pm force-dex-opt
command only available to -eng or -userdebug builds.  Typical use
for iterating on persistent apps now looks like this:

$ mmm frameworks/base/packages/SystemUI/ && adb sync &&
    adb shell pm force-dex-opt com.android.systemui &&
    adb shell kill `pid systemui`

Yay!

Change-Id: I0ae2467f1d7cda56c70ba20953cd25fa8ee766ff
2014-07-25 21:11:47 +00:00
Jeff Sharkey
16c8e3f494 PackageInstaller changes based on feedback.
Mostly cosmetic changes from API council feedback.

Bug: 16543552
Change-Id: Ic926829b3f77c31f50a899c59b779353daf00d59
2014-07-25 11:59:48 -07:00
Amith Yamasani
e5bcff624f Rename setApplicationBlocked to setApplicationHidden
This corrects the expected behavior of the app state. Hidden apps
can be installed by the store to be brought out of hidden state.

Bug: 16191518
Change-Id: Id128ce971ceee99ba1dea14ba07ce03bd8d77335
2014-07-21 22:18:40 +00:00
Jeff Sharkey
9a445771f5 Install sessions only inherit APK files.
Also track historical install sessions for debugging purposes.  Hide
signature verification API for now.  Clear code cache only after
killing the app being upgraded.

Bug: 14975160
Change-Id: I52fc7f11d2506f792236d8a365c8cfed21b46c30
2014-07-16 13:38:09 -07:00
Jeff Sharkey
69ea974f17 Merge "Public API for PackageInstaller!" into lmp-dev 2014-07-15 00:41:06 +00:00
Jeff Sharkey
6c833e07a0 Public API for PackageInstaller!
Flesh out documentation and finalize first cut of API.  Also surface
installLocation and splitNames through PackageInfo.

Bug: 14975160, 15348430
Change-Id: Ic27696d20ed06e508aa3526218e9cb20835af6a0
2014-07-14 23:06:52 -07:00
Jeff Sharkey
ad11eb52fe Pass install result message; path selection.
Oops, forgot to include message argument to invoke the new-style
callback.  Also use more robust way of generating cluster APK
directory names, and add more logging details on rename failure.

Change-Id: Ifa8abdd1db58b73e13b9a8077ec126cf20a0d90e
2014-07-14 10:57:04 -07:00
Jeff Sharkey
a103114347 Package installation listener events.
Flesh out implementation of install session observers.  Carve out 20%
of published install progress for final system operations such as
dexopt, etc.

Add dumpsys output for active install sessions.  Create explicit
fsync() instead of overriding meaning of flush().  Hack to throw
IOExceptions over Binder calls.

Bug: 14975160, 15348430
Change-Id: I874457e40c45d2661bc0a526df9285ffea4bb77c
2014-07-12 21:12:25 -07:00
Jeff Sharkey
bb58067035 Progress toward installer public API: callbacks.
Instead of surfacing all the existing cryptic error codes, we're
going to classify them into broad categories when surfacing through
public API.  This change introduces InstallResultCallback and
UninstallResultCallback, and wires them up to existing AIDL
interfaces.

Also start defining general SessionObserver for apps interested
in general progress details, such as Launcher apps.  Details about
active sessions are returned through new InstallSessionInfo objects.

Bug: 14975160
Change-Id: I068e2b0c30135f6340f59ae0fff93c321047f8f9
2014-07-11 16:54:49 -07:00
Jeff Sharkey
ec55ef0934 Extend pm to support sessions and split APKs.
Separate commands to create an install session, stream files into the
staging area, and then commit the install.  Streaming can accept data
from stdin across adb, avoiding extra copy from push.

Extend FileBridge to support blocking close().  Always destroy
session regardless of result.

Bug: 14975160
Change-Id: Ic3f462e7d1901079b785e210228950cdfa676466
2014-07-09 16:55:56 -07:00
Jeff Sharkey
513a074de6 Clean up IPackageManager install surface area.
Also more removal of encryption support.

Change-Id: If525dc5a8422134515f225a8ac4731e968069468
2014-07-08 17:41:29 -07:00
Denver Coneybeare
bf8b57af35 Fix "pm list permissions" crash if resource string missing
The "pm list permissions" command lists detailed information about
each permission on the system, including its label and description,
both of which can be stored as translatable resource strings in APK
files.  However, it is possible that the resource identifiers for
these strings point to non-existent resources.  When this happens, the
loadText() method throws Resources.NotFoundException, causing the "pm"
command to abort prematurely, simply printing "Killed" to stdout and
a stack trace to logcat.

This commit fixes the crash by explicitly catching the
Resources.NotFoundException exception in loadText() and returning null
if it is thrown.  The loadText() method already has the potential to
return null so none of its callers need be modified.  This fixes the
crash and simply shows "label:null" and/or "description:null" in the
output if the string resource is missing.

Change-Id: I92273399e1dac6029163750d004940ee1da67428
2014-06-18 19:50:51 +00:00
Jeff Sharkey
8a4c9721a9 Plumb split APKs into public API.
Introduces new ApplicationInfo fields to surface zero or more split
APKs for an application.  Splice these APKs into both the class
loader and resource system.  Cleaner building of these paths.

Run dexopt() on all split APKs found after a parse, and populate
into ApplicationInfo.

Change-Id: I4a376bf4492d84ea95aafa866e106ea43a43e492
2014-06-17 14:38:44 -07:00
Narayan Kamath
116bdbd823 Add an --abi argument to "pm install"
This allows callers to force an install to a particular
ABI. This is intended only for testing (and CTS) and is
not meant for usage by the installer package.

bug: 14453227

(cherry picked from commit 6431d11cd420536aaa9d93ae510a3151ccc4df1d)

Change-Id: I85d4f8785deea02a6a4d3cb0b05e6ef8bf64826b
2014-06-03 11:35:49 +01:00
Narayan Kamath
6431d11cd4 Add an --abi argument to "pm install"
This allows callers to force an install to a particular
ABI. This is intended only for testing (and CTS) and is
not meant for usage by the installer package.

Change-Id: Icb1528c0cd35b1aa9323386cb35ff4aaba374fcb
2014-06-03 11:11:47 +01:00
Kenny Guy
1bdbd4be02 Add ability to uninstall per user to adb shell pm.
Default is still uninstall for all users, but if --user
is passed in it will just uninstall for that user.
For system apps if --user is supplied it will uninstall
rather than revert to the current system version.

Change-Id: If1be0f78f01391f7ac6b53150dfeeccd0c002899
2014-05-23 18:37:34 +01:00