113 Commits

Author SHA1 Message Date
Jeff Sharkey
dbea3cd118 Better am error when SELinux blocking access.
Bug: 18479882
Change-Id: I0732e54838c4e04d9d727e7c5fd9d7e7bacbaa1f
2014-11-24 14:51:34 -08:00
Dianne Hackborn
24b1c23c62 Fix issue #15828903: Intent.parseUri allows call to FLAG_GRANT_*_URI_PERMISSION
You now need to set a flag if you want this unsafe behavior.

Change-Id: I185e9a04e005e42a887c3d58a2818616790b060a
2014-11-20 17:17:39 -08:00
Dianne Hackborn
85d558cd48 Add Activity API to get referrer information.
This expands the use of EXTRA_REFERRER to be relevant anywhere,
allowing apps to supply referrer information if they want.  However,
if they don't explicitly supply it, then the platform now keeps
track of package names that go with Intents when delivering them
to apps, which it can be returned as the default value.

The new method Activity.getReferrer() is used to retrieve this
referrer information.  It knows about EXTRA_REFERRER, it can return
the default package name tracked internally, and it also can return
a new EXTRA_REFERRER_NAME if that exists.  The latter is needed
because we can't use EXTRA_REFERRER in some cases since it is a Uri,
and things like #Intent; URI extras can only generate primitive type
extras.  We really need to support this syntax for referrers, so we
need to have this additional extra field as an option.

When a referrer is to a native app, we are adopting the android-app
scheme.  Since we are doing this, Intent's URI creation and parsing
now supports this scheme, and we improve its syntax to be able to build
intents with custom actions and stuff, instead of being all hung up
on custom schemes.

While doing this, fixed a problem when parsing both intent: and new
android-app: schemes with a selector portion, where we were not
respecting any scheme that was specified.

Change-Id: I06e55221e21a8156c1d6ac755a254fea386917a2
2014-11-11 00:42:18 +00:00
Daniel Sandler
795893eb6f More flexible intent extra parsing.
Specifically, --ei (int extras) and --eia (int[] extras) now
use Integer.decode(), which means they accept negative
integers, base-16 integers formatted as #NNN and 0xNNN, and
base-8 integers formatted as 0NNN.

Additionally, --ez (boolean extras) can now be specified as
"true", "false", "t", "f", or an integer (any nonzero
treated as true). The previous behavior, based on
Boolean.valueOf(), would silently assign false if you
managed to get the spelling of "true" wrong.

Change-Id: I058254e907308006d403b5b7866c86bcaa03d8d3
2014-10-29 00:05:56 -04:00
Dianne Hackborn
ab4a81b3c6 Improve some docs, fix some debugging.
- Add docs to Binder, Messenger, ResultReceier to explain their
  relation (or lack there-of) to process lifecycle.
- Clarify some aspects of process lifecycle for services.
- Fix help text of am command.
- Fix per-package dumping of battery stats to not include history.
- Fix per-package dumping of proc stats to only include aggregated
  and current stats and fix some formatting.
- Fix per-process dumping of meminfo to have an option to interpret
  the input as a package, so including all processes that are
  running code of that package.
- Fix top-level per-package debug output to correctly include all
  of these improvements and give them a little more time (10s) to
  complete for timing out.

Change-Id: I2a04c0f862bd47b08329443d722345a13ad9b6e2
2014-10-09 18:21:59 -07:00
Alexandra Gherghina
979e40e9ba Adds the ability to start a user in background
Bug: 15900074
Change-Id: I03b278f8e7a4618ea56a5f1935cfba34beb45981
2014-09-29 12:35:03 +00:00
Dianne Hackborn
6cfbb71890 Fix issue #17536024: The am start's wait option doesn't...
...give time in some cases

This switch to multiple stacks broke the check to determine if it
should actually wait for a new activity to be shown.  The new check
now also requires that the top activity be resumed, which means
we may get some false positives where we decide to wait and shouldn't,
but that is better than consistently not deciding to wait in some
cases when we should.  (And we will always finish waiting then next
time something becomes visible).

Also add another time, which is how long it took from the startActivity
call to return with the result.  And fix when we decide to report that
we are done so that, in the case where we are bringing an existing
activity to the foreground, we don't wait until its animation is complete.

Change-Id: Id38ca0070f04e7bf8c73e131fb055808553a0e2f
2014-09-17 12:47:35 -07:00
Amith Yamasani
f58e532e01 Merge "Apply cross-user restrictions to Shell" into lmp-dev 2014-09-11 16:46:34 +00:00
Amith Yamasani
8cd28b57ed Apply cross-user restrictions to Shell
Even though Shell user is allowed to perform cross-user actions,
lock that path down if the target user has restrictions imposed by
the profile owner device admin that prevents access via adb.

If the profile owner has imposed DISALLOW_DEBUGGING_FEATURES, don't
allow the shell user to make the following types of calls:
start activities, make service calls, access content providers,
send broadcasts, block/unblock packages, clear user data, etc.

Bug: 15086577
Change-Id: I9669fc165953076f786ed51cbc17d20d6fa995c3
2014-09-10 17:15:06 -07:00
Adam Lesinski
65e76d1200 Output recent configs in am get-config command
Change-Id: Ic516e73d2e72ac0dc3136f7226cedd851fe22b85
2014-09-10 15:02:59 -07:00
Jeff Hao
1b012d302b Add sample profiling option to am.
Also bundles all profiling options into a class.

Bug: 17040932
Change-Id: I85d675ee1494bdc7308caffdf94145d27c996e9d
2014-08-26 15:54:25 -07:00
Christopher Tate
b9583c9d93 Turn on debugging override of idle time
'adb shell am idle-maintenance' has traditionally been used to force
the system to consider itself to be in an "idle" state.  Unfortunately
the new Job Manager hadn't yet been aware of this.  Rectify the situation.

Also fixes a bug in debug logging that would cause a system server
crash under certain race circumstances.

Change-Id: I8a29bd7757924f8e464865235c344233fc03d8c3
2014-07-25 00:30:07 +00:00
Adam Lesinski
afc00e1c81 Change am get-config command to use ABI string array
There is a list of supported ABIs in android.os.Build which
is ordered by preference. This is a more flexible list to use
instead of 2 fixed ABIs.

Change-Id: I6aa3b39b5ffa888ed83a870b937e18328dd6de39
2014-06-17 20:27:39 +00:00
Adam Lesinski
2c749d2427 New command to get device config
Change-Id: I7172a3a150fd83e2382ca3e4e4a0188758189f14
2014-06-16 23:01:19 +00:00
Narayan Kamath
dfed4bc99f am f7871c31: am b9b31f4b: am bd4d3203: Merge "Support an ABI flag for instrumentation."
* commit 'f7871c31469c6245c1b232a15104704f7481103c':
  Support an ABI flag for instrumentation.
2014-05-30 11:51:03 +00:00
Narayan Kamath
f7871c3146 am b9b31f4b: am bd4d3203: Merge "Support an ABI flag for instrumentation."
* commit 'b9b31f4b8eda123e7b544d1a0fa886576064adca':
  Support an ABI flag for instrumentation.
2014-05-30 10:49:00 +00:00
Narayan Kamath
8dcfefd652 Support an ABI flag for instrumentation.
Allows us to choose what ABI a process uses when
launching it with "adb shell am instrument", for eg.

adb shell am instrument --abi arm64-v8a component/runner

Note that we only perform very basic validation of the
ABI. In general, there is no guarantee that the app will
launch with the instruction set we choose, for eg. if it
has native libraries that are for a different ABI.

bug: 14453227

Change-Id: Ifb7e89b53675080dc87941091ee5ac360f218d7f
2014-05-16 10:30:00 +01:00
Dianne Hackborn
91097de49b Initial implementation of new voice interaction API.
This gives a basic working implementation of a persist
running service that can start a voice interaction when
it wants, with the target activity(s) able to go through
the protocol to interact with it.  It may even work when
the screen is off by putting the activity manager in the
correct state to act like the screen is on.

Includes a sample app that is a voice interation service
and also has an activity it can launch.

Now that I have this initial implementation, I think I
want to rework some aspects of the API.

Change-Id: I7646d0af8fb4ac768c63a18fe3de43f8091f60e9
2014-04-24 17:48:58 -07:00
Jeff Sharkey
846318a325 Allow prefix-based Uri permission grants.
Define new FLAG_GRANT_PREFIX_URI_PERMISSION which indicates that a
Uri permission grant should also apply to any other Uris that have
matching scheme, authority, and path segments.  For example, a prefix
grant for /foo/ would allow /foo/bar/ but not /foo2/.

Allow persistable and prefix grants to be issued directly through
grantUriPermission().  Relaxing persistable is fine, since it still
requires the receiver to actively take the permission.

Since exact- and prefix-match grants for the same Uri can coexist,
we track them separately using a new UriGrant key.  (Consider the
case where an app separately extends READ|PREFIX and WRITE for
the same Uri: we can't let that become READ|WRITE|PREFIX.)

Fix revoke to always take away persisted permissions.  Move prefix
matching logic to Uri and add tests.  Add new flags to "am" tool, and
various internal uses around Intent and Context.  Switch some lagging
users to ArraySet.

Bug: 10607375
Change-Id: Ia8ce2b88421ff9f2fe5a979a27a026fc445d46f1
2014-04-22 21:06:49 -07:00
Craig Mautner
aea74a5977 Add Lock Task Mode.
When in lock task mode only the specified task may run. All
attempts to switch to another task are ignored until the task
finishes or a call to stopLockTaskMode() is made.

Change-Id: I6cfe92fe1bcf22cd47b5398c08e23c52a4092dda
2014-03-13 11:09:13 -07:00
Dale Hawkins
28600e261c Adds support for array string extra.
Adds support for setting an array string extra on an intent when
launching an activity/service.  Allows inclusion of commas using
an escape character.

Change-Id: I8857f7d28d60b75ddc65dc47f345a77230d00467
2014-02-26 18:01:00 -07:00
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