211 Commits

Author SHA1 Message Date
David Brazdil
d5d4217ece Add flag to AMS.startInstrumentation() to disable hidden API checks
Some tests need to use hidden APIs to check the internal state of
the framework. For those special use cases, we add a new flag to
ActivityManagerService.startInstrumentation that enables to start
instrumented processes without hidden API enforcement. Individual
test harnesses can change their Am command to request the exemption.

Bug: 64382372
Test: adb shell am instrument --no-hidden-api-checks <component>
      adb logcat | grep 'Accessing hidden'
Change-Id: I1d734a95423fae90dae63ff09d5f606495830905
2018-02-14 19:45:11 +00:00
Mike Ma
da3a2955cc Add instrumentation data to host proto lib
Add instrumentation data proto to host proto lib and add a few comment
to am instrument.
Test: no test needed

Change-Id: Ibbb0394dcf0ad27b53d5c97104456798863ce82c
2017-11-13 12:16:22 -08:00
Mike Ma
d2239828d6 Record proto to file in am instrument
Add an option -f to record instrumentdata proto produced by am instrument
to a file in addition to printing to stdout. Default path is
/sdcard/instrument-logs/log-yyyyMMdd-hhmmss-SSS.instrumentation_data_proto.
If the file exits, it will be deleted before writing. Path can be changed
via optional <FILE> argument after -f.
If -f and -m are both present, proto will be written to a file and print
to stdout.

Test: build, flash and run:
bit -bi FrameworksCoreTests
adb shell am instrument -w -r -f tmp/tmp.log \
-e class com.android.internal.os.BatteryStatsNoteTest \
com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Iabc320c066d5995eee842c26416623eeb3d403f4
2017-11-01 14:20:31 -07:00
Dianne Hackborn
ca3872ce36 Fully implement "install" and "install-write" in PackageManagerShellCommand.
We can use the new mechanism to ask the calling shell to open
a file in order to implement the rest of these commands, allowing
you to give the path to an apk to install.  That API is thus
extended to allow you to open readable files, not just opening
file for writing.

Doing this however means we no longer can pass a file path to
AssetManager for the apk to parse, we only have an already open
fd for that.  Extending AssetManager to allow adding apks from
fds is not that hard, however, since the underlying zip library
already supports this.

This main thing this changes is in AssetManager.cpp where we
retrieve the open zip file for a particular apk that has been
added.  This used to look up the zip file by path every time
it was needed, but that won't work anymore now that we can have
things added by fd.  Instead, we keep track of each opened zip
in the AssetManager, so we can just directly retrieve it from
the asset_path representing the item that was added.  As a
side-effect, this means for normal paths we no longer need to
look up by name, but just have the opened zip file directly
accessible.  (This is probably good, but it does mean that we
no longer run the logic of seeing if the zip file's timestamp
has changed and re-opening it if it has.  We probably shouldn't
be relying on that for an active AssetManager anyway, and maybe
it is even good that we don't allow the zip file to change
under it?)

A follow-up change will finally remove the Pm.java implementation
and turn the pm "command" into a simple shell script that runs
cmd package.

Test: manual

Change-Id: Ie103e3bdaa5b706796cc329254f2638151a3924f
2017-10-31 10:54:31 -07:00
Chih-hung Hsieh
decc397b26 Merge "Use -Werror in frameworks/base" am: 16fbd3a1d8 am: 0bfb717a37
am: 9f004b1752

Change-Id: I6517ee1689b0247caf830a6c3528bfa9bcf91f75
2017-10-16 19:50:38 +00:00
Chih-Hung Hsieh
c7edf078f9 Use -Werror in frameworks/base
* Fix unused variable and return value warnings.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I890e65a20848d00559ba5a4f9691be1347b456af
2017-10-13 16:25:16 -07:00
Dan Willemsen
2e9ec5f0de Merge changes I93cf24d4,I32e438ef am: 30798ad13a am: c28d591b36
am: 59225490b8

Change-Id: I6cf57e951900b3df816070feee0d3bf92a6a5a7d
2017-09-10 02:05:05 +00:00
Dan Willemsen
d3eac266b0 Convert host tools to Android.bp
See build/soong/README.md for more information.

Test: m libinstrumentation interrupter accessorychat accessorytest bit obbtool pbkdf2gen libsplit-select_tests split-select protoc-gen-javastream validatekeymaps libaapt_tests aapt
Test: mmma frameworks/base
Test: out/host/linux-x86/nativetest64/libaapt_tests/libaapt_tests
Test: out/host/linux-x86/nativetest64/libsplit-select_tests/libsplit-select_tests
Change-Id: I93cf24d4b232353a52d53be8ed85781b8f4a3877
2017-09-09 06:18:48 +00:00
Makoto Onuki
6fb2c9718c Bit: Don't ignore errors and crashes
Bit used to only see success results and failures (== assertion failures?),
and didn't see "errors" (other exceptions) and test process crashes.

Fixed it.

Now it also returns an error status code if there was a test failure.

Bug 64292779
Test: manual

Change-Id: Iaba93910d32abfc615ae595746a0e9be1108583a
2017-08-02 14:49:30 -07:00
Andrii Kulian
94e82d9b0e DO NOT MERGE ActivityView be gone!
This hidden functionality is no longer support/needed since
we now have multi-window/display. A new view group class
will be added later that uses multi-window to support remaining
functionality of this class.

Test: go/wm-smoke
Change-Id: Ie2fa2de92841d33199da9988741905060dd1ddf4
2017-07-21 13:14:19 -07:00
Makoto Onuki
f6d6e9ecd7 Sort INSTRUMENTATION_STATUS keys on am instrument output
Previously the output from perftests was printed in a random order:
INSTRUMENTATION_STATUS: timeGetDataCapacity_standardDeviation=5
INSTRUMENTATION_STATUS: timeGetDataCapacity_median=486
INSTRUMENTATION_STATUS: timeGetDataCapacity_mean=489
INSTRUMENTATION_STATUS: timeGetDataCapacity_min=484
INSTRUMENTATION_STATUS_CODE: -1

Now it's always printed in the same (sorted) order.
INSTRUMENTATION_STATUS: timeGetDataCapacity_mean=489
INSTRUMENTATION_STATUS: timeGetDataCapacity_median=486
INSTRUMENTATION_STATUS: timeGetDataCapacity_min=484
INSTRUMENTATION_STATUS: timeGetDataCapacity_standardDeviation=5
INSTRUMENTATION_STATUS_CODE: -1

Test: manual test
Change-Id: I807aa05e6523b70a132ab97fc099156bb3dc1f96
2017-06-28 20:23:46 +00:00
Chet Haase
e5b44043f7 Make --no-window-animation flag apply to animators, too
There is a flag for 'adb shell am instrument' that disables animations, which
is useful for testing (if you want to, for example, disable animations to speed
up tests or remove animation-caused side-effects as a factor). But only the
pre-honeycomb animations (window transitions and window animations) were listening
to this flag. This change makes animators listen as well, so all three duration scale
settings are affected.

Bug: 32072407  --no_window_animation ADB arg should set all animation scales to 0.0f
Test: manual. Ran frameworks APCT tests with --no_window_animation and verified
that all three types of animations had their duration scales set to 0 for the
duration of the tests.

Change-Id: I5ae4a60faa714c9534dfae58d1efcd54f577d82b
2017-06-14 18:55:19 -07: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
Dianne Hackborn
2882406de3 Switch am command to go through "cmd activity".
For almost everything...  except instrument, which still needs
to be run as the shell user so its UiAutomator callbacks
will work correctly (and not create security holes).

Test: manual

Change-Id: I2e62714a2d5b52501aa261b7e4d6b282b54a0027
2016-11-01 11:00:41 -07:00
Joe Onorato
f0c719821d am instrument gets protobuf
Refactor the am instrument command and add a version that
outputs protobuf in addition to the old one that prints
loosely formatted text.

Change-Id: I34079d8af2b7b6c6c59837d54719806109ba286c
Test: bit tool
2016-10-20 11:57:57 -07:00
Dianne Hackborn
665378081b Work around issue #32096507: 'am send broadcast' fails the second...
...time it's called from dumpstate

Bring back the shell-side implementation of this, until we can
figure out why the raw shell command transaction is failing.

Test: bugreport works

Change-Id: Ia9422a653feffb0236613d43e022458c101b9583
2016-10-13 14:11:54 -07:00
Dianne Hackborn
331084dca6 Move the remaining am commands to ActivityManagerShellCommand.
The only thing not removed is the "instrument" command, which
really needs to run Java code in the shell.  We'll deal with
that later.

Test: manual
Change-Id: I9df0cdf831ac280cb0eb85c857d27166bc00604d
2016-10-10 16:58:12 -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
John Reck
d31f3467d9 Add error messages to send-trim-memory
Fixes: 23006305
Test: manual, adb shell am send-trim-memory
Change-Id: Iae5607ea9abf0ffa5b5276a6540afb0dc6aa31f5
2016-09-23 13:00:01 -07:00
Chong Zhang
2fde939272 Fix off-by-one in am start -R (repeat)
bug: 26028552
Change-Id: I075b378b6f126d124d867282d76a78d865b54178
2016-06-28 18:08:13 -07:00
Christopher Tate
27d92e4e39 Move the 'pretend idle jobs can run now' broadcast into AMS
It's a protected broadcast, so sending it directly from 'am' is
no longer an option.  This is needed for CTS as well as being
generally useful during app development.

Bug 28406044

Change-Id: I101915a8c6f19454330a8db2079a75023c112582
2016-05-06 11:25:11 -07:00
Andrii Kulian
435ce5ff1c Allow setting fullscreen stack as target via adb shell
Bug: 27906038
Change-Id: Ie6feede3f7c412bc51550626a008cb0729e5e0e0
2016-04-26 00:00:01 -07:00
Narayan Kamath
a09b4d2a61 Remove unnecessary allocation+unboxing of objects.
Transforming String->int can be done with 0 allocations
using Integer.parseInt.

bug: 28078871
Change-Id: I8d9f322d7154728849dde61ef282046032858d60
2016-04-18 09:55:59 +01:00
Philip P. Moltmann
01ee1b7eb6 Allow to provide only a component name prefix to 'am instrument'
Bug: 27831862
Change-Id: I1d57e416c47fc7d9ea212f0002986932663081b8
2016-04-04 16:37:37 -07:00
Jeff Sharkey
bd91e2f3f6 Update PRE_BOOT_COMPLETED for FBE.
Now that CE data isn't available until after a user is unlocked, we
need to delay the PRE_BOOT_COMPLETED broadcasts.  This is done by
adding a new RUNNING_UNLOCKING user state to the UserController
lifecycle.

We now track the last fingerprint a user was logged in under, and we
dispatch PRE_BOOT receivers when that fingerprint changes.  To work
around battery pull issues, we only persist the updated fingerprint
once all PRE_BOOT receivers have finished.  This is less granular
than the original solution, but it's still correct.  We only consider
a user as "logged in" once it transitions into the RUNNING_UNLOCKED
state.

When starting a process, track if the user was "unlocked" when
started, so that we only spin up unaware providers in processes
started before user unlock.

Add generic IProgressListener to communicate PRE_BOOT progress and
strings up to lock screen.  For now, LockSettingsService just blocks
until finished, but it could display these strings in the future.

Bug: 27220885
Change-Id: I349439776b885acd32f6a578d8951ffd95640be2
2016-03-27 10:56:48 -06:00
Wale Ogunwale
e75a9adfbd Added support to specify animation duration when resizing stack
Needed for sys-ui to control the duration of various Pip transitions.

Bug: 27674339
Change-Id: I7bad27aaa19755a73c594e88b88b56db033e1a45
2016-03-21 11:17:19 -07:00
Jeff Sharkey
d5896630f6 Move more PM calls to ParceledListSlice.
Since the data returned by these calls can grow unbounded based on
various GET flags, we need to switch 'em over.

Bug: 27391893
Change-Id: Ie849ca30dbaaa91158da4c83675657715629a0ee
2016-03-04 16:31:34 -07:00
Nick Kralevich
bb8b4814df Am.java: Use write-only file descriptors
Use write only file descriptors for am commands. Having read-write
file descriptors isn't needed, and not all SELinux app domains have
read access to /data/local/tmp file descriptors.

Addresses the following denial:

  avc: denied { read } for path="/data/local/tmp/foo" dev="dm-2"
  ino=654084 scontext=u:r:system_app:s0
  tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=0

Steps to reproduce:

  adb shell ps | grep settings
  adb shell am dumpheap PID_FROM_ABOVE /data/local/tmp/settings.hat

Expected:
1) command works

Actual:
1) SELinux denial and no settings.hat output.

Bug: 27472701
Change-Id: Id8df0c5a41046b405444e14c70075c986d9936c3
2016-03-03 15:24:29 -08:00
Dianne Hackborn
4a18c26609 Fix issue #27385109: control activity behavior without triggering...
...isUserAMonkey for testing purpose

Add an argument for the caller to specify if they are a poo flinging
monkey.

Change-Id: I0e149a8d78776abaf07517bd4ae886047b7f4252
2016-02-29 12:37:11 -08:00
Wale Ogunwale
06e8ee0c8a Added AM API to remove a stack
Use the new API when closing Pip.

Bug: 26982752
Change-Id: I074d23b5535a4534626183ab77142d3932a803f0
2016-02-16 10:09:51 -08:00
Paul Crowley
faeb3eb0ba Password security for FBE disk encryption keys
Add the means to protect FBE keys with a combination of an auth token
from Gatekeeper, and a hash of the password. Both of these must be
passed to unlock_user_key. Keys are created unprotected, and
change_user_key changes the way they are protected.

Bug: 22950892
Change-Id: Ie13bc6f82059ce941b0e664a5b60355e52b45f30
2016-02-08 15:58:29 +00:00
Tamas Berghammer
25222f55f2 Merge "Add flag to "am start" to enable native debugging" 2016-02-06 13:18:58 +00:00
Filip Gruszczynski
c17d8b79af Infrastructure for animating of maximizing pip activity.
Bug: 25672053
Change-Id: Ie8a83c626680e01ff7115f40731ab9e6c13769c0
2016-02-04 09:01:05 -08:00
Filip Gruszczynski
debd9a5ed5 Allow specifying stack when starting activity in AM command.
Change-Id: I42032bdebf16b6cd2c0c87fd9aa5c261bc9fe25d
2016-02-02 16:27:18 -08:00
Tamas Berghammer
df6cb28293 Add flag to "am start" to enable native debugging
Specifying the new flag will enable several features in the runtime
required by the native debugger to debug Java and C++ code at the same
time.

The enabled features:
* Force JIT (never use the interpreter)
* Debug info generation
* Disbale some optimizations

Change-Id: Iaf5ab649715a0c274bd1b0fc64e483705da53cd0
2016-02-01 13:49:32 +00:00
Wale Ogunwale
b1faf60b89 Use resizeMode integer instead of resizeable boolean.
Changes activity manager and window manager to use resizeMode
as defined by ActivityInfo#resizeMode instead of a boolean.

Bug: 26774816
Change-Id: I8cef46d9fba6bfdd21df7da63ed5d5330ad03d4b
2016-01-29 07:44:33 -08:00
Filip Gruszczynski
84fa3351a2 Animate pinned stack resizing.
This introduces animating of stack bounds within window manager
module. It also uses this type of animation when moving an activity from
fullscreen stack to pinned stack.

Bug: 25672053
Change-Id: I75914a685d10021f8a7535b47ef12b6920b3fd5e
2016-01-28 08:47:54 -08:00
Michal Karpinski
3da5c97460 Adjusting AMN#requestBugReport() to be able to invoke 3 types
of bugreport services

ActivityManagerNative#requestBugReport() now can accept 3 types:
FULL, INTERACTIVE AND REMOTE.

Bug: 26152603
Change-Id: Ife9bbef4691e172fb56b72b256880f0d4ad4d198
2016-01-08 17:50:16 +00:00
Jorim Jaggi
52641bc309 Add am command for CTS tests for resizedDockedStack (1/2)
Bug: 25015474
Bug: 26311778
Change-Id: Ia2b1f8ffc5c777d8199409041090a0106503c2e4
2016-01-05 13:50:10 +01:00
Felipe Leme
4cc863338d Changed ActivityManager.requestBugreport() to take a 'progress' parameter.
When progress is set to 'true', it calls the new, enhanced
'bugreportplus' service, while when 'false' it calls the regular
'bugreport' service.

'bugreportplus' is more user-friendly (it shows a system notification
with the progress, allow user to cancel, etc...), at the cost of
consuming more resources. As such, the "Take Bug Report" UI will be
changed to offer the user a combo with these 2 options, but for now it's
always going to be 'bugreportplus'

BUG: 26034608
Change-Id: I21a6b5b092a85614e91d523b8f4df1fb00e49b3b
2015-12-05 10:30:18 -08:00
Fyodor Kupolov
9cbfc9e212 Added DISALLOW_RUN_IN_BACKGROUND user restriction
It forces the user to stop instead of going into the background. Also
changed behavior of stopUser method. Now it also attempts to stop related
users along with the specified userId.

Based on ag/807976, with the only difference that it's now a user restriction.

Bug: 24579258
Bug: 24708668
Change-Id: I357298908816fc58feeed83b7e9979fc33d25da6
2015-12-02 10:22:23 -08:00
Jeff Sharkey
ba51235ef5 More file-based encryption work.
Add new "am unlock-user" command so we can trigger changes from the
command line.

Move FBE check to static method so it can safely be called early
during boot before the mount service is ready.  Move FBE emulation
to persisted system property, and start reading/writing that value.

Change default permission grants to ignore current encryption-aware
flags, since many of the target apps aren't crypto aware.

Always prepare package data directories, which is how we create the
new "user_de" paths during boot.

Bug: 22358539
Change-Id: I6f58ea2d34b3a466d3775d614f8a13de92272621
2015-11-19 11:02:30 -07:00
Dianne Hackborn
3cdb56efea Some debugging improvements.
- Fix dumping of package manager intent filters so the option
  to print the filter detail works again.
- Extend dump resolvers to allow you to specify the specific
  types of resolvers you'd like to dump.
- Add new package manager commands for querying activities,
  services, receivers.
- Move the code for parsing a command line into an intent to
  the framework, so it can be used by the new package manager
  commands and later elsewhere.

Change-Id: I56ea2bb8c3dd0e5198ee333be8f41ad9dcdb626f
2015-11-11 12:45:44 -08:00
Wale Ogunwale
3797c22ea1 Added StackId object for checking what features a stack supports
Helps make the code easier to follow since we are no longer checking
multiple stack ids at various decision points.

Bug: 25282299
Change-Id: Ifa6864a1ef56ce2eca4c94f87a4e0b993de987cd
2015-11-02 11:32:42 -08:00
Wale Ogunwale
079a0044a3 API for moving top activity in a stack to pinned stack.
* AMS.moveTopStackActivityToPinnedStack can be used to move the top
activity in a stack to the pinned stack and also specify the bounds
the pinned stack should be sized to.
* 'am stack move-top-activity-to-pinned-stack' command for testing
AMS.moveTopStackActivityToPinnedStack API

Bug: 25006507
Change-Id: I8392b4c39d8542153e691be7a627b7f35fd44884
2015-10-26 12:07:00 -07:00
Pablo Ceballos
63afb86381 Merge "Remove GLTrace support" 2015-10-19 17:55:59 +00:00
Wale Ogunwale
ffc11bb712 Don't set incorrect stack bounds when rotating screen in docked mode
Both window manager and activity manager could decide what the bounds
of other stacks should be when the docked stack exist which can get
out of sync. Now window manager does the bounds calculation and
activity manager asks window manager what the bounds should be when
it needs to resize the stack.

Bug: 24738105
Change-Id: I97356f008b676d2f58a8b54fdb08735ab51394af
2015-10-12 18:56:28 -07:00
Pablo Ceballos
a4d4e82927 Remove GLTrace support
GLTrace is defunct, it does not support newer GL features, breaks
security requirements, and has no supported tooling now that Eclipse
is at end of life.

Bug 22329852

Change-Id: I64c58464f8c2c7ae6125f5d5c7884e3fd34d68ea
2015-10-06 15:18:40 -07:00
Fyodor Kupolov
0df68cd13b Do now allow current user to be removed
It was possible to remove a foreground user using pm remove-user command.
The system ends up in the inconsistent state, because switch does not happen
and the removed user stays in the foreground, but its state is removed.

Also added am get-current-user command.

Change-Id: Ida2dce8f99bac55e106cdd44c93e96cc9142d7fb
2015-10-02 12:19:39 -07:00
Wale Ogunwale
83301a933f Added am command to suppress config. changes during task resize.
This command is useful for testing during development, but at some
point we will decide if allowing configuration changes during resizing
is okay or merge in http://ag/759766 to suppress configuration changes
during resizing and deliver the new config. to the app.

This functionality will be reverted once we decide.

Bug: 24380097
Change-Id: I223c08bc939e564a78e70994b599770be9d4730d
2015-09-24 15:54:08 -07:00