92 Commits

Author SHA1 Message Date
Craig Mautner
e0a3884cb6 Extend stack management to other displays.
- Abandon ActivityContainer.startActivity() in favor of
IActivityManager.startActivityAsUserInContainer().
- Modify Am to test starting an activity on a container.
- Create a DisplayContext as the base context if the activity token
is on a different display.
- Test for home display in more cases when manipulating home stack.
- Rename mDisplayInfos => mActivityDisplays.
- Create new method for moving task to front of stack regardless of
which display it is on.

Change-Id: I4fcb83ae844c5839ee3e2722229623d1a80ed921
2014-01-06 08:51:21 -08:00
Craig Mautner
4a1cb22056 Pair ActivityStacks with Displays
- Introduce concept of ActivityStacks residing on Displays and able
to be decoupled and moved around.
- Add a new interface, IActivityContainer for clients to handle
ActivityStacks.
- Abandon ordering of stacks based on mStackState and instead use
ActivityDisplayInfo.stacks<ActivityStack> ordering.

Progress towards closing bug 12078972.

Change-Id: I7785b61c26dc17f432a4803eebee07c7415fcc1f
2013-12-18 15:08:15 -08:00
Craig Mautner
bdc748af8c DO NOT MERGE: Eliminate StackBox.
StackBox is too constraining. Adding size and position to TaskStacks
directly makes stack positioning and management more flexible and
prepares for ActivityView.

Change-Id: I33c6b4e1c23a5a8069fd507c160bcb34e4d287b2
2013-12-09 15:15:34 -08:00
Jeff Sharkey
7625c84045 Fix am argument ordering documentation.
Bug: 11690520
Change-Id: I84b10a6eb6e6404212ab9737e7cee1f1ad4d5309
2013-11-14 10:57:55 -08:00
Dianne Hackborn
35f72be50b Implement issue #10691359: Kill long-running processes
We now have the activity manager kill long-running processes
during idle maintanence.

This involved adding some more information to the activity manager
about the current memory state, so that it could know if it really
should bother killing anything.  While doing this, I also improved
how we determine when memory is getting low by better ignoring cases
where processes are going away for other reasons (such as now idle
maintenance).  We now won't raise our memory state if either a process
is going away because we wanted it gone for another reason or the
total number of processes is not decreasing.

The idle maintanence killing also uses new per-process information
about whether the process has ever gone into the cached state since
the last idle maintenance, and the initial pss and current pss size
over its run time.

Change-Id: Iceaa7ffb2ad2015c33a64133a72a272b56dbad53
2013-09-16 14:05:34 -07:00
Andy McFadden
c0046f2167 Add #! to 'am' shell script
Shell script needs to start with #! for exec().

Bug 10606037

Change-Id: I594da6f0433e838dcf5b45b991188ceaa52d9bd1
2013-09-04 15:39:51 -07:00
Dianne Hackborn
57a7f5954c Add "adb shell am restart" command.
So you can restart the system without being root.

Change-Id: I89770f497833ecbe2b69e3a0cfafae7ef472a9f5
2013-07-23 11:51:22 -07:00
Marco Nelissen
f2ca6e2717 Add stopservice command to am
Change-Id: I639ad418750c0e1825b330b3bd56e5628926e7f1
2013-07-11 09:32:30 -07:00
Evan Charlton
4d7dc1a2b1 Fix a typo
s/will/while/ for the --no-window-animation explanation.

Change-Id: Ia068809d385cc4f54f9603a8713a581fd4f59440
2013-06-25 14:49:08 -07:00
Craig Mautner
fd1ce8d5a7 Add new API getStackBoxInfo
Change-Id: Ie2861e5e31bb3876cfe2d5c3d04ff58bb3955634
2013-06-17 18:34:28 -07:00
Craig Mautner
5a449154d1 Convert API refs to StackBox from ActivityStack.
- Removed IActivityManager.getStacks() since getStackBoxes() is better.
- Made createStacks operate relative to StackBox instead of TaskStack.
- Made resizeStack into resizeStackBox.

Change-Id: I7a0e1f4e34f399b4fd1180c60cc3989f9c2433f3
2013-05-24 16:12:57 -07:00
Craig Mautner
5ff1210172 Add retrieval of StackBox info for more flexibility
First step in permitting StackBoxes to be manipulated by user.
Necessary for Configuration changes coming down.

Change-Id: I4029926a35e4fdc59a5759fd9e4bae10bb308413
2013-05-24 12:50:15 -07:00
Craig Mautner
1602ec2188 Log stack issues and start resize effort.
- Modify Am.java to accept 'stack resize' command.

- Add logging for assigning home stack to non-home task to track down
bug. And maybe fix bug.

- Add template parameter to ArrayList.

Change-Id: Ia73182afc20e9e4430ddadebae034cecb3798eec
2013-05-13 14:39:39 -07:00
Guang Zhu
befa8b5553 Revert "Log stack issues and start resize effort."
Bug: 8935057

This reverts commit b0245edae86b5811ea743c0f4cea095488304b1a.
2013-05-12 23:10:39 -07:00
Craig Mautner
b0245edae8 Log stack issues and start resize effort.
- Modify Am.java to accept 'stack resize' command.

- Add logging for assigning home stack to non-home task to track down
bug. And maybe fix bug.

- Add template parameter to ArrayList.

Change-Id: If904c3ead623464ff5863b7241c68c1b7573bcf4
2013-05-12 10:27:38 -07:00
Kenny Root
1d69bad411 resolved conflicts for merge of a98b0ff8 to master
Change-Id: I1f4a952d360c48426e22a7772726b6867cc19771
2013-05-07 10:14:46 -07:00
Kenny Root
add582122d resolved conflicts for merge of 485d7a31 to master
Change-Id: I058e19af8732df44457bdc614ee810a642dc25e4
2013-05-07 09:51:31 -07:00
Dianne Hackborn
8bd64df2ad Help for the debugging help for issue #8734824.
Add a new "hang" am command that lets you hang the system
process.  Useful for testing.

Change-Id: Ice0fc52b49d80e5189f016108b03f9fd549b58a7
2013-05-06 16:07:26 -07:00
Dianne Hackborn
5b88a2fd7b Debugging help for issue #8734824: WATCHDOG KILLING SYSTEM PROCESS
IActivityController has a new callback which the Watchdog calls
when it detects that the system process is hung.  This may be
use full monkey.  All hail the monkey!

Also add a new private feature to Binder to be able to turn off
all incoming dump() calls to a process.  The watchdog uses this
when it reports it is hung, so that if someone, say, wants to
collect a bug report at this point they won't get stuck waiting
for things that are all busted.

Change-Id: Ib514d97451cf3b93f29e194c1954e29f948c13b1
2013-05-06 11:16:18 -07:00
Craig Mautner
4cd0c13f8f Incremental repairs to side by side stacks.
- Add taskId parameter to createStack() so stacks are pre-populated
with a task.
- Keep track of stack access order in DisplayContent so getTasks
returns in MRU order.
- Set touchableRegion in InputMonitor so modal touching does not
extend beyond stack boundary.
- Fix stack merging so that deleting a stack results in a new
stack the size of the two children.

Change-Id: I62a6ba0a34f34dd7ec866b440bf04595379e19e8
2013-04-16 18:55:07 -07:00
Craig Mautner
967212cb54 Implement stack splitting and task movement.
Split stacks and move tasks between them. Layout the windows
according to the new stack split.

After layout content rectangles are known split the available area
between all stack boxes. Then use those values for future layout.

Provide stack contents to ActivityManager.

Change-Id: I9746e6185445633810d506be514d0b7b540a7f99
2013-04-15 13:46:47 -07:00
Dianne Hackborn
79f7ec70eb Have audio service clean up new receivers in crashing processes.
The new media button receiver with only a pending intent (no
component name) could be left hanging if the process that
registered it went away.  These semantically need to be tied
to the calling process's lifetime; we now clean them up when
the calling process goes away.

Also added some additional cleanup of media button receivers
when packages change (updated, cleared).

And on top of that, a new "media" command for doing media
things.  Currently lets you send media keys and monitor
remote display data.

Oh and finally added a new BaseCommand base class for
implementing these command line utilities.

Change-Id: Iba1d56f10bab1eec4a94a7bb1d1c2ae614c8bcf5
2013-04-08 13:08:37 -07:00
Jeff Sharkey
02ffba940c Handle finished bugreports, share from private.
Show notification when a bugreport is finished, letting the user
launch a SEND_MULTIPLE intent to share them.  Add dialog that warns
user about contents before sharing.  Since bugreports are now stored
in private app data of the Shell app, use FileProvider to build Uris
that we can grant others access to.

Define BUGREPORT_FINISHED as being a protected broadcast.  Delete
older bugreports automatically to reclaim disk space.  Migrate any
Intent extras to ClipData when building PendingIntents.

Add --receiver-permission support to am shell command.

Bug: 7005318
Change-Id: If6c607dbcf137362d5887eac482ff7391563890f
2013-03-13 16:42:38 -07:00
Ying Wang
33c29b0e16 Use BUILD_PREBUILT to install the shell script
NOTICE files will be picked up automatically.

Change-Id: Ia4938aff013f1c010cbbfceacf5685722c86c39a
2013-02-19 16:42:16 -08:00
Dianne Hackborn
c652de8141 Implement display overscan support.
The window manager now keeps track of the overscan of
each display, with an API to set it.  The overscan impacts
how it positions windows in the display.  There is a new set
of APIs for windows to say they would like to go into the
overscan region.  There is a call into the window manager to
set the overscan region for a display, and it now has a
concept of display settings that it stores presistently.

Also added a new "wm" command, moving the window manager
specific commands from the "am" command to there and adding
a new now to set the overscan region.

Change-Id: Id2c8092db64fd0a982274fedac7658d82f30f9ff
2013-02-19 12:08:58 -08:00
Dianne Hackborn
f51f61269a App ops: new operations for SMS.
Implementation required a new framework feature
to associate an app op with a broadcast.

Change-Id: I4ff41a52f7ad4ee8fd80cbf7b394f04d6c4315b3
2013-02-05 11:56:12 -08:00
Dianne Hackborn
f265ea9d83 App ops: vibration, neighboring cells, dialing, etc.
Improve handling of vibration op, so that apps are
better blamed (there is now a hidden vibrator API that
supplies the app to blame, and the system now uses this
when vibrating on behalf of an app).

Add operation for retrieving neighboring cell information.

Add a new op for calling a phone number.  This required
plumbing information about the launching package name through
the activity manager, which required changing the internal
startActivity class, which required hitting a ton of code that
uses those internal APIs.

Change-Id: I3f8015634fdb296558f07fe654fb8d53e5c94d07
2013-02-01 15:14:29 -08:00
Svetoslav Ganov
80943d8daa Adding UI test automation APIs.
This change adds APIs support for implementing UI tests. Such tests do
not rely on internal application structure and can span across application
boundaries. UI automation APIs are encapsulated in the UiAutomation object
that is provided by an Instrumentation object. It is initialized by the
system and can be used for both introspecting the screen and performing
interactions simulating a user. UI test are normal instrumentation tests
and are executed on the device.

UiAutomation uses the accessibility APIs to introspect the screen and
a special delegate object to perform privileged operations such as
injecting input events. Since instrumentation tests are invoked by a shell
command, the shell program launching the tests creates a delegate object and
passes it as an argument to started instrumentation. This delegate
allows the APK that runs the tests to access some privileged operations
protected by a signature level permissions which are explicitly granted
to the shell user.

The UiAutomation object also supports running tests in the legacy way
where the tests are run as a Java shell program. This enables existing
UiAutomator tests to keep working while the new ones should be implemented
using the new APIs. The UiAutomation object exposes lower level APIs which
allow simulation of arbitrary user interactions and writing complete UI test
cases. Clients, such as UiAutomator, are encouraged to implement higher-
level APIs which minimize development effort and can be used as a helper
library by the test developer.

The benefit of this change is decoupling UiAutomator from the system
since the former was calling hidden APIs which required that it is
bundled in the system image. This prevented UiAutomator from being
evolved separately from the system. Also UiAutomator was creating
additional API surface in the system image. Another benefit of the new
design is that now test cases have access to a context and can use
public platform APIs in addition to the UiAutomator ones. Further,
third-parties can develop their own higher level test APIs on top
of the lower level ones exposes by UiAutomation.

bug:8028258

Also this change adds the fully qualified resource name of the view's
id in the emitted AccessibilityNodeInfo if a special flag is set while
configuring the accessibility service. Also added is API for looking
up node infos by this id. The id resource name is relatively more stable
compared to the generaed id number which may change from one build to
another. This API facilitate reuing the already defined ids for UI
automation.

bug:7678973

Change-Id: I589ad14790320dec8a33095953926c2a2dd0228b
2013-01-22 17:56:53 -08:00
Dianne Hackborn
c0bd747b06 Further work on issue #7307399: Framework needs a new pre-user-shutdown...
...phase & callback API

I realized there were a few things wrong with what was there.  The new
ACTION_USER_STARTING was not being sent for the first user at boot, and
there was an existing problem where ACTION_USER_STARTED was sent every
time there was a user switch.

Also improved some debug output of broadcasts to make it easier to see
what is going on in this stuff, and better reporting of why a service
couldn't be started.

Change-Id: Id8a536defbbad1f73d94a37d13762436b822fbe3
2012-10-09 17:57:14 -07:00
Dianne Hackborn
d4ac8d7b3d Fix issue #7211769 and #7244492, thrash around on #7226656.
Issue #7211769: Crash dialog from background user has non-working "report"

The report button now launches the issue reporter for the correct user.
Also for crashes on background users, either disable the report button,
or simply don't show the dialog depending on the build config.

Issue #7244492: Bugreport button in Quick Settings doesn't actually do anything

Now they do.

Issue #7226656: second user seeing primary user's apps

I haven't had any success at reproducing this.  I have tried to tighten up
the path where we create the user to ensure nothing could cause the
user's applications to be accessed before the user it fully created and thus
make them installed...  but I can't convince myself that is the actual problem.

Also tightened up the user switch code to use forground broadcasts for all
of the updates about the switch (since this is really a foreground operation),
added a facility to have BOOT_COMPELTED broadcasts not get launched for
secondary users and use that on a few key system receivers, fixed some debug
output.

Change-Id: Iadf8f8e4878a86def2e495e9d0dc40c4fb347021
2012-09-28 15:37:22 -07:00
Dianne Hackborn
b12e1354f2 Maybe fix issue #7211766: bindService() to User u0 While u10 is...
...Forground Sometimes Doesn't Take

The main change here is a one-liner in ActiveServices to check the
uid when deciding whether to remove an item from mPendingServices.
This could cause the problem being seen -- if the same service for
two users is starting at the same time, the second one would blow
away the pending start of the first one.  Unfortunately I have had
trouble reproducing the bug, so I don't know if this is actually
fixing it.  It's a bug, anyway.

The reason so much has changed here is because I spread around
logging and printing of the user ID associated with operations and
objects to make it easier to debug these kind of multi-user things.

Also includes some tweaks to the oom manager to allow more background
processes (I have seen many times in logs where we thrash through
processes because the LRU list is too short), plus to compensate an
additional time-based metric for when to get rid of background processes,
plus some new logic to try to help things like Chrome keep around
their service processes.

Change-Id: Icda77fb2a1dd349969e3ff2c8fff0f19b40b31d3
2012-09-26 14:50:12 -07:00
Jeff Brown
43aa159128 Allow adb shell am display-size to use bigger sizes.
We now support scaling the logical display to fit the
physical display, whatever size it is.  So we can allow
adb shell am display-size to use more or less arbitrary sizes
although we do enforce an upper and lower bound to
protect the user.

Change-Id: I5fe6ba32ad1f9e4fbcd6915f7d36850b987bbcc0
2012-09-10 17:50:18 -07:00
Dianne Hackborn
1676c856d6 Flesh out multi-user in am commands.
Now we default to the current user instead of user 0 for most commands
(except where we can do the command for all users).

Many more commands take a user argument: force-stop, kill, profile,
dumpheap.

Improved help text.

Change-Id: I719a13b4d31b668f57ca21e51d7043ac3e0d4e1b
2012-09-10 14:52:30 -07:00
Dianne Hackborn
649d0d71b2 Merge "More multi-user stuff:" into jb-mr1-dev 2012-09-07 14:11:56 -07:00
Dianne Hackborn
5e03e2ca7d More multi-user stuff:
- New (hidden) isUserRunning() API.
- Maintain LRU list of visited users.
- New FLAG_IS_DATA_ONLY for ApplicationInfo.
- Clean up pending intent records when force-stopping a user (or package).
  (Also fixes bug #6880627: PendingIntent.getService() returns stale
  intent of force stopped app)
- Fix force-stopping when installing an app to do the force-stop across
  all users for that app.
- When selecting which processes to kill during a force stop, do this
  based on the actual packages loaded in the process, not just process
  name matching.
- You can now use --user option in am when starting activities, services,
  and instrumentation.
- The am --user option accepts "current" and "all" as arguments.
- The pm uninstall command now uninstalls for all users, so it matches
  the semantics of the install command.
- PhoneWindowManager now explicitly says to start home in the current
  user.
- Activity manager call to retrieve the MIME type from a content provider
  now takes a user argument, so it will direct this to the proper user.
- The package manager uninstall paths are now implemented around
  PackageSetting, not PackageParser.Package.  This allows them to work
  even if the application's apk has been removed (in which case it only
  exists as a PackageSetting, not the PackageParser.Package parsed from
  the apk).

Change-Id: I3522f6fcf32603090bd6e01cc90ce70b6c5aae40
2012-09-07 13:55:23 -07:00
Felipe Leme
3065963f81 Wrapped call to notifyAll() in a synchronized block
Change-Id: I452caa56bef4541b53917bdd6f22034161255dd1
Bug: 7118468
2012-09-06 11:43:03 -07:00
Dianne Hackborn
e2bdca5c43 Fix my fix.
Change-Id: I35fce760f8d91fceb554d372e7423749a4ac6d2d
2012-09-04 11:13:41 -07:00
Dianne Hackborn
52fba38f7d Fix build.
Change-Id: I15592889b8679d946e402dcfdeb124df349cbd4d
2012-09-04 11:08:43 -07:00
Dianne Hackborn
80a4af2bbc Start implementing concept of "running" users.
The activity manager now keeps track of which users are running.

Initially, only user 0 is running.

When you switch to another user, that user is started so it is
running.  It is only at this point that BOOT_COMPLETED is sent
for that user and it is allowed to execute anything.

You can stop any user except user 0, which brings it back to the
same state as when you first boot the device.  This is also used
to be able to more cleaning delete a user, by first stopping it
before removing its data.

There is a new broadcast ACTION_USER_STOPPED sent when a user is
stopped; system services need to handle this like they currently
handle ACTION_PACKAGE_RESTARTED when individual packages are
restarted.

Change-Id: I89adbd7cbaf4a0bb72ea201385f93477f40a4119
2012-08-28 16:30:55 -07:00
Dianne Hackborn
7e0e19d420 Restore man page entries.
Change-Id: I002808037ec117c039aeb71f425c1f43d4cac6d8
2012-08-27 10:57:30 -07:00
Dianne Hackborn
7767eac323 Keep track of whether an app is installed for each user.
This add a new per-user state for an app, indicating whether
it is installed for that user.

All system apps are always installed for all users (we still
use disable to "uninstall" them).

Now when you call into the package manager to install an app,
it will only install the app for that user unless you supply
a flag saying to install for all users.  Only being installed
for the user is just the normal install state, but all other
users have marked in their state for that app that it is not
installed.

When you call the package manager APIs for information about
apps, uninstalled apps are treated as really being not visible
(somewhat more-so than disabled apps), unless you use the
GET_UNINSTALLED_PACKAGES flag.

If another user calls to install an app that is already installed,
just not for them, then the normal install process takes place
but in addition that user's installed state is toggled on.

The package manager will not send PACKAGE_ADDED, PACKAGE_REMOVED,
PACKAGE_REPLACED etc broadcasts to users who don't have a package
installed or not being involved in a change in the install state.
There are a few things that are not quite right with this -- for
example if you go through a full install (with a new apk) of an
app for one user who doesn't have it already installed, you will
still get the PACKAGED_REPLACED messages even though this is
technically the first install for your user.  I'm not sure how
much of an issue this is.

When you call the existing API to uninstall an app, this toggles
the installed state of the app for that user to be off.  Only if
that is the last user user that has the app uinstalled will it
actually be removed from the device.  Again there is a new flag
you can pass in to force the app to be uninstalled for all users.

Also fixed issues with cleaning external storage of apps, which
was not dealing with multiple users.  We now keep track of cleaning
each user for each package.

Change-Id: I00e66452b149defc08c5e0183fa673f532465ed5
2012-08-24 13:53:13 -07:00
Dianne Hackborn
dde331cebd We can now (kind-of) change screen density on the fly.
Preloaded drawables now have a density associated with them, so we
can load the correct drawable if we are using a different density.

Window manager now formally keeps track of the density for each
screen, allowing it to be overridden like you can already do with
size, and relies on this density to drive itself internally and
the configurations it reports.

There are a new set of Bitmap constructors where you provide a
DisplayMetrics so they can be constructed with the correct density.
(This will be for when you can have different windows in the same
app running at different densities.)

ActivityThread now watches for density changes, and pushes them
to the DENSITY_DEVICE and Bitmap global density values for that
process.

A new am command allows you to change the density.
2012-08-03 17:27:29 -07:00
Craig Mautner
59c009776d Introduce multiple displays with DisplayContent.
Fix a couple of bugs that turned up.
Remove touch/focus from display. Add iterators for access.
Respond to comments. Remove TODOs, and some deviceId parameters.

Change-Id: Idcdb4f1979aa7b14634d450fd0333d6eff26994d
2012-08-02 08:47:44 -07:00
Amith Yamasani
fd3d009dde Remove some unnecessary man page entries
Change-Id: I1ceda3f5efac83b80ab4b6e7cae4086aeed5062a
2012-05-30 17:57:06 -07:00
Romain Guy
13b907353f Remove unused, obsolete debug code
All these features have either been abandonned and left un-maintained
for years or can be replaced by systrace.

Change-Id: I42e4579a8078744047e5fe08a7a15254970b09bc
2012-05-21 13:29:06 -07:00
Dianne Hackborn
7df7d2022d Fix issue #4499996: LiveWallpaperPreview activity intent filter
Change-Id: I5fc71503d2c59c907da954dbda3587394e6405bf
2012-04-19 18:00:04 -07:00
Amith Yamasani
483f3b06ea Package restrictions per user
Packages can be enabled/disabled per user.
This requires maintaining stopped/launched states and
enabled / disabled components and packages per user.

Refactored pm.Settings and PackageSettingsBase to keep
track of states per user.

Migrated the stopped-packages.xml to users/<u>/package-restrictions.xml

Changed intent resolution to handle individual user restrictions.
Bunch of IPackageManager calls now have a userId argument.
Make AppWidgetService handle removals of packages.

Added some tests for pm.Settings and PackageManager.

Change-Id: Ia83b529e1df88dbcb3bd55ebfc952a6e9b20e861
2012-03-22 10:08:24 -07:00
Dianne Hackborn
a4972e951b Add new "options" argument to all startActivity APIs.
This will be used to allow new features to be requested...  such as,
say, a special kind of animation.  Right now there are no options
defined.

Change-Id: I4eb6f27275cdd4bf186f6da316ab93a2372ad4b7
2012-03-14 12:57:14 -07:00
Siva Velusamy
92a8b22e74 ActivityManager: add option to allow OpenGL trace.
This patch adds an option to enable tracing of OpenGL functions.
OpenGL tracing can be enabled by passing "--opengl-trace" option
to am start.  This option requires either a device in debug mode,
or that the application itself has debug permission set.

Change-Id: I77788bfe97c9108943b1f947ce81afe8293d78a0
2012-03-12 12:18:53 -07:00
Mike J. Chen
3a2ce935b9 Add the ability to pass float extras to AM.
commit 43a2825a283e29c0f70100146394957af0598b0e
Author: John Grossman <johngro@google.com>
Date:   Wed Apr 27 09:03:53 2011 -0700

    Add the ability to pass float extras to AM.

    Change-Id: I970ad3f76a65bd781099204019095c73ed8c09db

Signed-off-by: Mike J. Chen <mjchen@google.com>
Signed-off-by: John Grossman <johngro@google.com>

Conflicts:

	cmds/am/src/com/android/commands/am/Am.java
2012-02-10 12:03:53 -08:00