Fix NumberFormatException when new line separator is contained in the output string.
Output string of wm size has separator in it like "Physical size: 1440x2960\nOverride size: 1080x2220".
It causes NumberFormatException and TC will be failed.
So TC use override width and height value and TC will be passed.
Bug: 118272278
Test: run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.ManagedProfileTest#testWorkProfileTimeoutUserActivity
Change-Id: I576dc936e905f7ccdf9b79ae53278dc00c0eb05e
Signed-off-by: Mark Hong <sungmin.h@samsung.com>
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java
index 0b17b17..a5fcf4e 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java
@@ -30,7 +30,15 @@
public UserActivityEmulator(ITestDevice device) throws DeviceNotAvailableException {
// Figure out screen size. Output is something like "Physical size: 1440x2880".
mDevice = device;
- final String output = mDevice.executeShellCommand("wm size");
+ String outputString = mDevice.executeShellCommand ("wm size");
+
+ // In case that "Override size" follows by separator like
+ // "Physical size: 1440x2960\nOverride size: 1080x2220"
+ if (outputString.contains("Override")) {
+ outputString = outputString.split(System.getProperty("line.separator"))[1];
+ }
+
+ final String output = outputString;
final String[] sizes = output.split(" ")[2].split("x");
mWidth = Integer.valueOf(sizes[0].trim());
mHeight = Integer.valueOf(sizes[1].trim());