forked from simpligility/android-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consistent output for test report and logging identifying device with…
… serial number, avdname, manufacturer and model support for avdname and emulator-xxxx for android.device parameter
- Loading branch information
Showing
3 changed files
with
82 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/jayway/maven/plugins/android/common/DeviceHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.jayway.maven.plugins.android.common; | ||
|
||
import com.android.ddmlib.IDevice; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
/** | ||
* A bunch of helper methods for dealing with IDevice instances. | ||
* @author Manfred Moser <[email protected]> | ||
*/ | ||
public class DeviceHelper { | ||
|
||
private static final String MANUFACTURER_PROPERTY = "ro.product.manufacturer"; | ||
private static final String MODEL_PROPERTY = "ro.product.model"; | ||
|
||
/** | ||
* Get a device identifier string that is suitable for filenames as well as log messages. | ||
* This means it is human readable and contains no spaces. | ||
* Used for instrumentation test report file names so see more at | ||
* AbstractInstrumentationMojo#testCreateReport javadoc since | ||
* that is the public documentation. | ||
*/ | ||
public static String getDescriptiveName(IDevice device) { | ||
// if any of this logic changes update javadoc for | ||
// AbstractInstrumentationMojo#testCreateReport | ||
String SEPARATOR = "_"; | ||
StringBuilder identfier = new StringBuilder() | ||
.append(device.getSerialNumber()); | ||
if (device.getAvdName() != null) { | ||
identfier.append(SEPARATOR).append(device.getAvdName()); | ||
} | ||
String manufacturer = getManufacturer(device); | ||
if (StringUtils.isNotBlank(manufacturer)) { | ||
identfier.append(SEPARATOR).append(manufacturer); | ||
} | ||
String model = getModel(device); | ||
if (StringUtils.isNotBlank(model)) { | ||
identfier.append(SEPARATOR).append(model); | ||
} | ||
return identfier.toString(); | ||
} | ||
|
||
/** | ||
* @return the manufacturer of the device as set in #MANUFACTURER_PROPERTY, typically "unknown" for emulators | ||
*/ | ||
public static String getManufacturer(IDevice device) { | ||
return StringUtils.deleteWhitespace(device.getProperty(MANUFACTURER_PROPERTY)); | ||
} | ||
|
||
/** | ||
* @return the model of the device as set in #MODEL_PROPERTY, typically "sdk" for emulators | ||
*/ | ||
public static String getModel(IDevice device) { | ||
return StringUtils.deleteWhitespace(device.getProperty(MODEL_PROPERTY)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters