Merge "Change screen on to home screen from settings page"
diff --git a/acts/framework/acts/base_test.py b/acts/framework/acts/base_test.py
index 8789b39..0e250f4 100755
--- a/acts/framework/acts/base_test.py
+++ b/acts/framework/acts/base_test.py
@@ -182,6 +182,7 @@
         # Set all the controller objects and params.
         self.user_params = {}
         self.testbed_configs = {}
+        self.testbed_name = ''
         for name, value in configs.items():
             setattr(self, name, value)
         self.results = records.TestResult()
@@ -206,7 +207,6 @@
                 if ad.droid:
                     utils.set_location_service(ad, False)
                     utils.sync_device_time(ad)
-        self.testbed_name = ''
 
     def _import_builtin_controllers(self):
         """Import built-in controller modules.
diff --git a/acts/framework/acts/controllers/anritsu_lib/md8475a.py b/acts/framework/acts/controllers/anritsu_lib/md8475a.py
index aeee481..c0e3d43 100644
--- a/acts/framework/acts/controllers/anritsu_lib/md8475a.py
+++ b/acts/framework/acts/controllers/anritsu_lib/md8475a.py
@@ -136,6 +136,13 @@
     LTE_BANDWIDTH_20MHz = "20MHz"
 
 
+class LteMimoMode(Enum):
+    """ Values for LTE MIMO modes. """
+    NONE = "MIMONOT"
+    MIMO_2X2 = "MIMO2X2"
+    MIMO_4X4 = "MIMO4X4"
+
+
 class BtsGprsMode(Enum):
     ''' Values for Gprs Modes '''
     NO_GPRS = "NO_GPRS"
@@ -3105,6 +3112,30 @@
         self._anritsu.send_command(cmd)
 
     @property
+    def mimo_support(self):
+        """ Gets the maximum supported MIMO mode for the LTE bases tation.
+
+        Returns:
+            the MIMO mode as a string
+        """
+        cmd = "LTEMIMO? " + self._bts_number
+        return self._anritsu.send_query(cmd)
+
+    @mimo_support.setter
+    def mimo_support(self, mode):
+        """ Sets the maximum supported MIMO mode for the LTE base station.
+
+        Args:
+            mode: a string or an object of the LteMimoMode class.
+        """
+
+        if isinstance(mode, LteMimoMode):
+            mode = mode.value
+
+        cmd = "LTEMIMO {},{}".format(self._bts_number, mode)
+        self._anritsu.send_command(cmd)
+
+    @property
     def neighbor_cell_mode(self):
         """ Gets the neighbor cell mode
 
diff --git a/acts/framework/acts/test_utils/power/PowerCellularLabBaseTest.py b/acts/framework/acts/test_utils/power/PowerCellularLabBaseTest.py
index ec1aa6a..664a84f 100644
--- a/acts/framework/acts/test_utils/power/PowerCellularLabBaseTest.py
+++ b/acts/framework/acts/test_utils/power/PowerCellularLabBaseTest.py
@@ -89,6 +89,9 @@
         for file in self.custom_files:
             if filename_calibration_table in file:
                 self.calibration_table = self.unpack_custom_file(file, False)
+                self.log.info('Loading calibration table from ' + file)
+                self.log.debug(self.calibration_table)
+                break
 
         # Store the value of the key to access the test config in the
         # user_params dictionary.
diff --git a/acts/framework/acts/test_utils/power/tel_simulations/LteCaSimulation.py b/acts/framework/acts/test_utils/power/tel_simulations/LteCaSimulation.py
index f4dd497..45109d9 100644
--- a/acts/framework/acts/test_utils/power/tel_simulations/LteCaSimulation.py
+++ b/acts/framework/acts/test_utils/power/tel_simulations/LteCaSimulation.py
@@ -17,6 +17,7 @@
 import time
 
 from acts.controllers.anritsu_lib.md8475a import BtsTechnology
+from acts.controllers.anritsu_lib.md8475a import LteMimoMode
 from acts.controllers.anritsu_lib.md8475a import BtsNumber
 from acts.controllers.anritsu_lib.md8475a import BtsPacketRate
 from acts.controllers.anritsu_lib.md8475a import TestProcedure
@@ -171,6 +172,24 @@
             *[BtsTechnology.LTE for _ in range(self.num_carriers)],
             reset=False)
 
+        # If base stations use different bands, make sure that the RF cards are
+        # not being shared by setting the right maximum MIMO modes
+        if self.num_carriers == 2:
+            # RF cards are never shared when doing 2CA so 4X4 can be done in
+            # both base stations.
+            self.bts[0].mimo_support = LteMimoMode.MIMO_4X4
+            self.bts[1].mimo_support = LteMimoMode.MIMO_4X4
+        if self.num_carriers == 3:
+            # 4X4 can only be done in the second base station if it is shared
+            # with the primary. If the RF cards cannot be shared, then at most
+            # 2X2 can be done.
+            self.bts[0].mimo_support = LteMimoMode.MIMO_4X4
+            if carriers[0] == carriers[1]:
+                self.bts[1].mimo_support = LteMimoMode.MIMO_4X4
+            else:
+                self.bts[1].mimo_support = LteMimoMode.MIMO_2X2
+            self.bts[2].mimo_support = LteMimoMode.MIMO_2X2
+
         # Enable carrier aggregation
         self.anritsu.set_carrier_aggregation_enabled()
 
diff --git a/acts/framework/acts/tracelogger.py b/acts/framework/acts/tracelogger.py
index ef978f9..ed9ee12 100644
--- a/acts/framework/acts/tracelogger.py
+++ b/acts/framework/acts/tracelogger.py
@@ -18,49 +18,47 @@
 import os
 
 
-class TraceLogger():
+class TraceLogger(object):
     def __init__(self, logger):
         self._logger = logger
 
     @staticmethod
-    def _get_trace_info(level=1):
+    def _get_trace_info(level=1, offset=2):
         # We want the stack frame above this and above the error/warning/info
         inspect_stack = inspect.stack()
-        trace_info = ""
+        trace_info = ''
         for i in range(level):
             try:
-                stack_frames = inspect_stack[2 + i]
+                stack_frames = inspect_stack[offset + i]
                 info = inspect.getframeinfo(stack_frames[0])
-                trace_info = "%s[%s:%s:%s]" % (trace_info,
+                trace_info = '%s[%s:%s:%s]' % (trace_info,
                                                os.path.basename(info.filename),
                                                info.function, info.lineno)
             except IndexError:
                 break
         return trace_info
 
+    def _log_with(self, logging_lambda, trace_level, msg, *args, **kwargs):
+        trace_info = TraceLogger._get_trace_info(level=trace_level, offset=3)
+        logging_lambda('%s %s' % (msg, trace_info), *args, **kwargs)
+
     def exception(self, msg, *args, **kwargs):
-        trace_info = TraceLogger._get_trace_info(level=5)
-        self._logger.exception("%s %s" % (msg, trace_info), *args, **kwargs)
+        self._log_with(self._logger.exception, 5, msg, *args, **kwargs)
 
     def debug(self, msg, *args, **kwargs):
-        trace_info = TraceLogger._get_trace_info(level=3)
-        self._logger.debug("%s %s" % (msg, trace_info), *args, **kwargs)
+        self._log_with(self._logger.debug, 3, msg, *args, **kwargs)
 
     def error(self, msg, *args, **kwargs):
-        trace_info = TraceLogger._get_trace_info(level=3)
-        self._logger.error("%s %s" % (msg, trace_info), *args, **kwargs)
+        self._log_with(self._logger.error, 3, msg, *args, **kwargs)
 
     def warn(self, msg, *args, **kwargs):
-        trace_info = TraceLogger._get_trace_info(level=1)
-        self._logger.warn("%s %s" % (msg, trace_info), *args, **kwargs)
+        self._log_with(self._logger.warn, 1, msg, *args, **kwargs)
 
     def warning(self, msg, *args, **kwargs):
-        trace_info = TraceLogger._get_trace_info(level=1)
-        self._logger.warning("%s %s" % (msg, trace_info), *args, **kwargs)
+        self._log_with(self._logger.warning, 1, msg, *args, **kwargs)
 
     def info(self, msg, *args, **kwargs):
-        trace_info = TraceLogger._get_trace_info(level=1)
-        self._logger.info("%s %s" % (msg, trace_info), *args, **kwargs)
+        self._log_with(self._logger.info, 1, msg, *args, **kwargs)
 
     def __getattr__(self, name):
         return getattr(self._logger, name)
diff --git a/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py b/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py
index 6e8ce49..a9401e3 100644
--- a/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py
+++ b/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py
@@ -82,6 +82,9 @@
         if not super().setup_test():
             return False
 
+        # Reset results at the start of the test
+        self.iperf_results = {}
+
         # Traffic direction
 
         values = self.consume_parameter(self.PARAM_DIRECTION, 1)