My Android Open Source Project (AOSP) bug fix has been approved and merged, officially making me an AOSP contributor sponsored by Amazon! This is a very exciting milestone for me and I'm looking forward to fixing future bugs (some that I've already found).
The Android Debug Bridge (ADB) command-line tool has the ability to target a specific device using the environment variable serial ANDROID_SERIAL, a very important option for device pools. I found that this option was missing when migrating projects from Ant to Android Gradle and causing problems for test labs. I'm happy to announce that you are now able to target specific devices using the same ANDROID_SERIAL environment variable in Android Gradle builds.
My fix made it in the 0.14.0 version released 10/31/14. The release notes read:
- Env var ANDROID_SERIAL (if present) restrict installation/execution of tests to device matching the serial number
Code Change Details
Commit Message:
Support the ANDROID_SERIAL property for targeting devices
Add a check in the ConnectedDeviceProvider for a specific
device serial to be targeted against based off the value
stored in the ANDROID_SERIAL environment variable.The default behavior of running across all connected devices
will occur if this variable is not defined or is empty. An
exception will be thrown if the targeted DSN is not found.Defect: 75407
Code:
final String androidSerial = System.getenv("ANDROID_SERIAL");
final Boolean isValidSerial = androidSerial != null && !androidSerial.isEmpty();
for (IDevice iDevice : devices) {
if (!isValidSerial || iDevice.getSerialNumber().equals(androidSerial)) {
localDevices.add(new ConnectedDevice(iDevice));
}
}
if (isValidSerial && (localDevices.size() == 0)) {
throw new RuntimeException("Connected device with serial " + androidSerial
+ " not found!", null);
}
Comments
comments powered by Disqus