从你的浏览器控制和管理Android设备:STF

jopen 7年前

STF(Smartphone Test Farm)是一个Web应用程序用于从浏览器远程调试的智能手机。

It is currently being used at CyberAgent to control a growing collection of more than 160 devices.

Close-up of device shelf

Super short screencast showing usage

Features

  • OS support
    • Android
      • Supports versions 2.3.3 (SDK level 10) to 5.1 (SDK level 22), plus Android M Developer Preview
      • Supports Wear 5.1 (but not 5.0 due to missing permissions)
      • Supports Fire OS, CyanogenMod, and other heavily Android based distributions
  • Remote control any device from your browser
    • Real-time screen view
      • Refresh speed can reach 30-40 FPS depending on specs and Android version. See minicap for more information.
      • Rotation support
    • Supports typing text from your own keyboard
      • Supports meta keys
      • Copy and paste support (although it can be a bit finicky on older devices, you may need to long-press and select paste manually)
      • May sometimes not work well with non-Latin languages unfortunately.
    • Multitouch support on touch screens via minitouch, two finger pinch/rotate/zoom gesture support on regular screens by pressingAltwhile dragging
    • Drag & drop installation and launching of.apkfiles
      • Launches main launcher activity if specified in the manifest
    • Reverse port forwarding via minirev
      • Access your local server directly from the device, even if it's not on the same network
    • Open websites easily in any browser
      • Installed browsers are detected in real time and shown as selectable options
      • Default browser is detected automatically if selected by the user
    • Execute shell commands and see real-time output
    • Display and filter device logs
    • Useadb connectto connect to a remote device as if it was plugged in to your computer, regardless of ADB mode and whether you're connected to the same network
  • Manage your device inventory
    • See which devices are connected, offline/unavailable (indicating a weak USB connection), unauthorized or unplugged
    • See who's using a device
    • Search devices by phone number, IMEI, ICCID, Android version, operator, product name and/or many other attributes with easy but powerful queries
    • Show a bright red screen with identifying information on a device you need to locate physically
    • Track battery level and health
    • Rudimentary Play Store account management
      • List, remove and add new accounts (adding may not work on all devices)
    • Display hardware specs

A quick note about security

As the product has evolved from an internal tool running in our internal network, we have made certain assumptions about the trustworthiness of our users. As such, there is little to no security or encryption between the different processes. Furthermore, devices do not get completely reset between uses, potentially leaving accounts logged in or exposing other sensitive data. This is not an issue for us, as all of our devices are test devices and are only used with test accounts, but it may be an issue for you if you plan on deploying STF to a multiuser environment. We welcome contributions in this area.

Requirements

Note that you need these dependencies even if you've installed STF directly from NPM, because they can't be included.

On OS X, you can use homebrew to install most of the dependencies:

brew install rethinkdb graphicsmagick zeromq protobuf

We also provide a Docker container in the Docker Hub as openstf/stf. You can use our Dockerfile as guidance if you'd prefer to do the installation yourself.

You should now be ready to build or run STF.

Note that while OS X can be used for development, it doesn't provide a very reliable experience in production due to (presumed) bugs in ADB's OS X implementation. We use CoreOS but any Linux or BSD distribution should do fine.

Installation

As mentioned earlier, you must have all of the requirements installed first. Then you can simply install via NPM:

npm install -g stf

Now you're ready to run. For development, though, you should build instead.

Building

After you've got all the requirements installed, it's time to fetch the rest of the dependencies.

First, fetch all NPM modules:

npm install

Then, fetch all Bower modules:

bower install

You may also wish to link the module so that you'll be able to access thestfcommand directly from the command line:

npm link

You should now have a working installation for local development.

Running

STF comprises of several independent processes that must normally be launched separately. In our own setup each one these processes is its own systemd unit.

For development purposes, however, there's a helper command to quickly launch all required processes along with a mock login implementation. Note that you must have RethinkDB running first.

If you don't have RethinkDB set up yet, to start it up, go to the folder where you'd like RethinkDB to create arethinkdb_datafolder in (perhaps the folder where this repo is) and run the following command:

rethinkdb

You should now have RethinkDB running locally. Running the command again in the same folder will reuse the data from the previous session.

You're now ready to start up STF itself:

stf local

After the webpack build process has finished (which can take a small while) you should have your private STF running on http://localhost:7100. If you had devices connected before running the command, those devices should now be available for use. If not, you should see what went wrong from your console. Feel free to plug in or unplug any devices at any time.

Note that if you see your device ready to use but without a name or a proper image, we're probably missing the data for that model in our device database. Everything should work fine either way.

Updating

To update your development version, simply pull the repo and runnpm installandbower installagain. You may occasionally have to remove the wholenode_modulesfolder to prevent NPM from complaining about version mismatches.


项目主页:http://www.open-open.com/lib/view/home/1436096062149