Merge "HDMICEC: Move duplicated methods to a common file" am: ffe6634788

Original change: https://android-review.googlesource.com/c/platform/cts/+/1556137

Change-Id: Ib256bccf29692f5fe84c7d696af364324ea169c2
diff --git a/hostsidetests/hdmicec/src/android/hdmicec/cts/BaseHdmiCecCtsTest.java b/hostsidetests/hdmicec/src/android/hdmicec/cts/BaseHdmiCecCtsTest.java
index 2b6b6d1..9ebaba0 100644
--- a/hostsidetests/hdmicec/src/android/hdmicec/cts/BaseHdmiCecCtsTest.java
+++ b/hostsidetests/hdmicec/src/android/hdmicec/cts/BaseHdmiCecCtsTest.java
@@ -33,6 +33,7 @@
 @OptionClass(alias="hdmi-cec-client-cts-test")
 public class BaseHdmiCecCtsTest extends BaseHostJUnit4Test {
 
+    public static final String PROPERTY_LOCALE = "persist.sys.locale";
     public final HdmiCecClientWrapper hdmiCecClient;
     public LogicalAddress mDutLogicalAddress;
 
@@ -189,4 +190,23 @@
         }
         throw new Exception("Could not parse active source from dumpsys.");
     }
+
+    public String getSystemLocale() throws Exception {
+        ITestDevice device = getDevice();
+        return device.executeShellCommand("getprop " + PROPERTY_LOCALE).trim();
+    }
+
+    public static String extractLanguage(String locale) {
+        return locale.split("[^a-zA-Z]")[0];
+    }
+
+    public void setSystemLocale(String locale) throws Exception {
+        ITestDevice device = getDevice();
+        device.executeShellCommand("setprop " + PROPERTY_LOCALE + " " + locale);
+    }
+
+    public boolean isLanguageEditable() throws Exception {
+        String val = getDevice().executeShellCommand("getprop ro.hdmi.set_menu_language");
+        return val.trim().equals("true") ? true : false;
+    }
 }
diff --git a/hostsidetests/hdmicec/src/android/hdmicec/cts/audio/HdmiCecInvalidMessagesTest.java b/hostsidetests/hdmicec/src/android/hdmicec/cts/audio/HdmiCecInvalidMessagesTest.java
index 2b43cec..7f1b533 100644
--- a/hostsidetests/hdmicec/src/android/hdmicec/cts/audio/HdmiCecInvalidMessagesTest.java
+++ b/hostsidetests/hdmicec/src/android/hdmicec/cts/audio/HdmiCecInvalidMessagesTest.java
@@ -45,7 +45,6 @@
 public final class HdmiCecInvalidMessagesTest extends BaseHdmiCecCtsTest {
 
     private static final LogicalAddress AUDIO_DEVICE = LogicalAddress.AUDIO_SYSTEM;
-    private static final String PROPERTY_LOCALE = "persist.sys.locale";
 
     /** The package name of the APK. */
     private static final String PACKAGE = "android.hdmicec.app";
@@ -72,25 +71,6 @@
             .around(CecRules.requiresDeviceType(this, AUDIO_DEVICE))
             .around(hdmiCecClient);
 
-    private String getSystemLocale() throws Exception {
-        ITestDevice device = getDevice();
-        return device.executeShellCommand("getprop " + PROPERTY_LOCALE).trim();
-    }
-
-    private void setSystemLocale(String locale) throws Exception {
-        ITestDevice device = getDevice();
-        device.executeShellCommand("setprop " + PROPERTY_LOCALE + " " + locale);
-    }
-
-    private boolean isLanguageEditable() throws Exception {
-        String val = getDevice().executeShellCommand("getprop ro.hdmi.set_menu_language");
-        return val.trim().equals("true") ? true : false;
-    }
-
-    private static String extractLanguage(String locale) {
-        return locale.split("[^a-zA-Z]")[0];
-    }
-
     private void checkArcIsInitiated(){
         try {
             hdmiCecClient.sendCecMessage(LogicalAddress.TV, AUDIO_DEVICE,
diff --git a/hostsidetests/hdmicec/src/android/hdmicec/cts/common/HdmiCecInvalidMessagesTest.java b/hostsidetests/hdmicec/src/android/hdmicec/cts/common/HdmiCecInvalidMessagesTest.java
index b36bcac..8ef4f22 100644
--- a/hostsidetests/hdmicec/src/android/hdmicec/cts/common/HdmiCecInvalidMessagesTest.java
+++ b/hostsidetests/hdmicec/src/android/hdmicec/cts/common/HdmiCecInvalidMessagesTest.java
@@ -39,8 +39,6 @@
 @RunWith(DeviceJUnit4ClassRunner.class)
 public final class HdmiCecInvalidMessagesTest extends BaseHdmiCecCtsTest {
 
-    private static final String PROPERTY_LOCALE = "persist.sys.locale";
-
     /** The package name of the APK. */
     private static final String PACKAGE = "android.hdmicec.app";
 
@@ -64,25 +62,6 @@
                     .around(CecRules.requiresLeanback(this))
                     .around(hdmiCecClient);
 
-    private String getSystemLocale() throws Exception {
-        ITestDevice device = getDevice();
-        return device.executeShellCommand("getprop " + PROPERTY_LOCALE).trim();
-    }
-
-    private void setSystemLocale(String locale) throws Exception {
-        ITestDevice device = getDevice();
-        device.executeShellCommand("setprop " + PROPERTY_LOCALE + " " + locale);
-    }
-
-    private boolean isLanguageEditable() throws Exception {
-        String val = getDevice().executeShellCommand("getprop ro.hdmi.set_menu_language");
-        return val.trim().equals("true") ? true : false;
-    }
-
-    private static String extractLanguage(String locale) {
-        return locale.split("[^a-zA-Z]")[0];
-    }
-
     @Before
     public void setup() {
         source =
diff --git a/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecSystemInformationTest.java b/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecSystemInformationTest.java
index 893a58e..58e5bf6 100644
--- a/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecSystemInformationTest.java
+++ b/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecSystemInformationTest.java
@@ -39,8 +39,6 @@
 @RunWith(DeviceJUnit4ClassRunner.class)
 public final class HdmiCecSystemInformationTest extends BaseHdmiCecCtsTest {
 
-    private static final String PROPERTY_LOCALE = "persist.sys.locale";
-
     @Rule
     public RuleChain ruleChain =
             RuleChain
@@ -66,25 +64,6 @@
         assertThat(CecOperand.getOperand(abortedOpcode)).isEqualTo(CecOperand.GET_MENU_LANGUAGE);
     }
 
-    private String getSystemLocale() throws Exception {
-        ITestDevice device = getDevice();
-        return device.executeShellCommand("getprop " + PROPERTY_LOCALE).trim();
-    }
-
-    private void setSystemLocale(String locale) throws Exception {
-        ITestDevice device = getDevice();
-        device.executeShellCommand("setprop " + PROPERTY_LOCALE + " " + locale);
-    }
-
-    private boolean isLanguageEditable() throws Exception {
-        String val = getDevice().executeShellCommand("getprop ro.hdmi.set_menu_language");
-        return val.trim().equals("true") ? true : false;
-    }
-
-    private static String extractLanguage(String locale) {
-        return locale.split("[^a-zA-Z]")[0];
-    }
-
     /**
      * Test 11.2.6-3
      * Tests that the device handles a <SET_MENU_LANGUAGE> with a valid language correctly.