On newer devices dumpsys output is more explanatory and does not only
contain numerical data. Update the parser to ignore non numerical
data for example the arguments that were passed and section headers.
As of commit 5601fdb1085af2eccf16a84b48c9995699bb8489 the
`connected_as_root` status is tracked in the connection. Add missing
implementation to `LocalConnection`.
A `Target` should be independent of the connection type used however we
do have some adb specific functionality as part of the `Target` for
speed/compatibility reasons. For the cases that we can perform the
operation in a connection agnostic method add alternative implementation
and for those raise a error to inform the user of the issue.
Un-memoize the `is_rooted` property of the connection and perform our
own caching instead as the state can be changed depending on the
connection status.
To allow for connecting to an `AndroidTarget` as root before the target
has been initialised, allow for passing `adb_as_root` as a connection
parameter to the `AdbConnection`. This will restart `adbd` as root
before attempting to connect to the target and will restart as unrooted
once all connections to that target have been closed.
Add a method to `AdbConnection` to control whether whether adb is
connected as root. This allows for the connection to track whether it is
connected as root for a particular device across all instances of a
connection.
Improve the detection of being `connected_as_root` from comparing the
username to checking the actual id of the user and export this as a
property for the connection.
Make sure that the subprocesses of the command that is spawned see the same
value of PATH env var, so that the tools installed by devlib are available from
scripts that could be started as well.
Turns out you can't change cpufreq attributes on an offlined
CPU (no big surprise!), so use_governor() will fail if a whole
frequency domain has been hotplugged out.
Change the default behaviour to only target online CPUs.
The fix in commit 964fde2 caused issues with certain command structures,
for example running in the background. To prevent this run the original
command as a subshell.
When executing a command using `su`, the `echo` command was returning the
error code of the invocation of `su` rather than the command itself.
Usually `su` should mimic the return code of the command it is executing
however this is not always the case which can cause issues.
Same as write_value(), but returns a context manager that will write
back the old value on exit.
Also add batch_revertable_write_value() that takes a list of kwargs
dict, and will call revertable_write_value() on each of them, returning
a single combined context manager.
In SystraceCollector, start() returns after executing
subprocess.Popen() for systrace. That doesn't mean that systrace is
running though, the function can return even before systrace has had a
chance to execute anything. Therefore, when you run the command
you want to trace, systrace will miss the first seconds of the
execution.
Run systrace with -u to unbuffer its stdin and wait for it to print
"Starting tracing (stop with enter)" before returning.
Fixes#403
Commit 89c40fb switched from using `echo CMD | su` to `su -c CMD`
however not all modern versions of `su` support this format.
Automatically try and detect if the new style is supported when
connecting and if not, fall back to the old implementation.
As per #407 if the kernel is compiled with the ability to switch cpuidle
governors via sysfs `current_governor_ro` is replaced with
`current_governor` so check if the intial path exists before reading.
Move from pipes.quote (private) to shlex.quote (Py3.3+ standard).
Make tests of inputs against None (their default value) instead of based
on their truthiness.
Improve logging through quoted commands (runnable as-is, less confusing).
Make the command-building process straightforward for readability and
maintainability.
To aid in checking whether any information is contained in the
`KernelConfig` ensure that that `__bool__` method value indicated the
presence of parsed input.
Right now, this module won't be loaded if the sched_domain procfs
entries are not present on the target. However, other pieces of
information may be present in which case it would make sense to load
the module.
For instance, mainline kernels compiled without SCHED_DEBUG can still
expose the cpu_capacity sysfs entry. As such, try to get a better idea
of what's available and only disable the loading of the module if it
can provide absolutely nothing.
As mentioned in the previous commit, CPU numbers would be passed to
SchedProcFSData's __init__() (instead of a proper sysfs path). When
done with CPU0, that path would be evaluated as False and the code
would carry on with the default path, which was quite confusing.
This has now been fixed (and 0 isn't such a great path to give
anyway), nevertheless this check should just catter to None.
Rather than using the conveniently provided `get_cpu_sd_info()` helper
method, `has_em()` and `get_em_capacity()` would build a
`SchedProcFSData` with `path=<CPU number>`, which is obviously broken.
Do the right thing and use `get_cpu_sd_info()` in those places.