Android-ElectricSheep-Automator
view release on metacpan or search on metacpan
`$params` is a HASH\_REF which should contain:
- **`apk-filename`**
The APK filename to install onto the device. It must
exist locally, obviously.
- **`install-parameters`**
Optional parameters to be passed on to the `adb install`
command. Nothing is expected here. Refer to the
[adb documentation](https://developer.android.com/tools/adb)
for what parameters are supported. For example, `-r` is for
re-installation of an existing app and retaining its
previous data.
It returns `1` on failure.
It returns `0` on success.
Note that there is a script available
which utilises this method, see [electric-sheep-install-app.pl](https://metacpan.org/pod/electric-sheep-install-app.pl).
## **`is_app_running($params)`**
It checks if the specified app is running on the device.
The name of the app must be exact.
Note that you can search for running apps / commands
with extended regular expressions using L/pgrep()>
`$params` is a HASH\_REF which should contain:
- **`appname`**
the name of the app to check if it is running.
It must be its exact name. Basically it checks the
output of [pidof()](https://metacpan.org/pod/pidof%28%29).
It returns `undef` on failure,
`1` if the app is running or `0` if the app is not running.
## **`find_current_device_properties($params)`**
It enquires the device currently connected,
and specified with ["connect\_device($params)"](#connect_device-params), if needed,
and returns back an [Android::ElectricSheep::Automator::DeviceProperties](https://metacpan.org/pod/Android%3A%3AElectricSheep%3A%3AAutomator%3A%3ADeviceProperties)
object containing this information, for example screen size,
resolution, serial number, etc.
It returns [Android::ElectricSheep::Automator::DeviceProperties](https://metacpan.org/pod/Android%3A%3AElectricSheep%3A%3AAutomator%3A%3ADeviceProperties)
object on success or `undef` on failure.
## **`connect_device()`**
It signals to our object that there is now
a device connected to the desktop and its
enquiry and subsequent control can commence.
If this is not called and neither `device-is-connected => 1`
is specified as a parameter to the constructor, then
the functionality will be limited and access
to functions like ["swipe($params)"](#swipe-params), ["open\_app($params)"](#open_app-params), etc.
will be blocked until the caller signals that
a device is now connected to the desktop.
Using ["connect\_device($params)"](#connect_device-params) to specify which device
to target in the case of multiple devices
connected to the desktop will also call this
method.
This method will try to enquire the connected device
about some of its properties, like screen size,
resolution, orientation, serial number etc.
This information will subsequently be available
via `$self->`device\_properties()>.
It returns `0` on success, `1` on failure.
## **`disconnect_device()`**
Signals to our object that it should consider
that there is currently no device connected to
the desktop (irrespective of that is true or not)
which will block access to ["swipe($params)"](#swipe-params), ["open\_app($params)"](#open_app-params), etc.
## **`device_properties()`**
It returns the currently connected device properties
as a [Android::ElectricSheep::Automator::DeviceProperties](https://metacpan.org/pod/Android%3A%3AElectricSheep%3A%3AAutomator%3A%3ADeviceProperties)
object or `undef` if there is no connected device.
The returned object is constructed during a call
to ["find\_current\_device\_properties($params)"](#find_current_device_properties-params)
which is called via ["connect\_device($params)"](#connect_device-params) and will persist
for the duration of the connection.
However, after a call to ["disconnect\_device()"](#disconnect_device)
this object will be discarded and `undef` will be
returned.
## **`swipe($params)`**
Emulates a "swipe" in four directions.
Sets the current Android device to control. It is only
required if you have more than one device connected.
`$params` is a HASH\_REF which may or should contain:
- **`direction`**
should be one of
- up
- down
- left
- right
- **`dt`**
denotes the time taken for the swipe
in milliseconds. The smaller its value the faster
the swipe. A value of `100` is fast enough to swipe to
the next screen.
It returns `0` on success, `1` on failure.
( run in 1.569 second using v1.01-cache-2.11-cpan-39bf76dae61 )