Merge "Move uwb owners file to top-level"
diff --git a/health/aidl/android/hardware/health/Translate.java b/health/aidl/android/hardware/health/Translate.java
index c8ace1c..4f840b8 100644
--- a/health/aidl/android/hardware/health/Translate.java
+++ b/health/aidl/android/hardware/health/Translate.java
@@ -44,25 +44,37 @@
         return out;
     }
 
+    private static void h2aTranslateInternal(
+            android.hardware.health.HealthInfo out, android.hardware.health.V1_0.HealthInfo in) {
+        out.chargerAcOnline = in.chargerAcOnline;
+        out.chargerUsbOnline = in.chargerUsbOnline;
+        out.chargerWirelessOnline = in.chargerWirelessOnline;
+        out.maxChargingCurrentMicroamps = in.maxChargingCurrent;
+        out.maxChargingVoltageMicrovolts = in.maxChargingVoltage;
+        out.batteryStatus = in.batteryStatus;
+        out.batteryHealth = in.batteryHealth;
+        out.batteryPresent = in.batteryPresent;
+        out.batteryLevel = in.batteryLevel;
+        out.batteryVoltageMillivolts = in.batteryVoltage;
+        out.batteryTemperatureTenthsCelsius = in.batteryTemperature;
+        out.batteryCurrentMicroamps = in.batteryCurrent;
+        out.batteryCycleCount = in.batteryCycleCount;
+        out.batteryFullChargeUah = in.batteryFullCharge;
+        out.batteryChargeCounterUah = in.batteryChargeCounter;
+        out.batteryTechnology = in.batteryTechnology;
+    }
+
+    public static android.hardware.health.HealthInfo h2aTranslate(
+            android.hardware.health.V1_0.HealthInfo in) {
+        android.hardware.health.HealthInfo out = new android.hardware.health.HealthInfo();
+        h2aTranslateInternal(out, in);
+        return out;
+    }
+
     static public android.hardware.health.HealthInfo h2aTranslate(
             android.hardware.health.V2_1.HealthInfo in) {
         android.hardware.health.HealthInfo out = new android.hardware.health.HealthInfo();
-        out.chargerAcOnline = in.legacy.legacy.chargerAcOnline;
-        out.chargerUsbOnline = in.legacy.legacy.chargerUsbOnline;
-        out.chargerWirelessOnline = in.legacy.legacy.chargerWirelessOnline;
-        out.maxChargingCurrentMicroamps = in.legacy.legacy.maxChargingCurrent;
-        out.maxChargingVoltageMicrovolts = in.legacy.legacy.maxChargingVoltage;
-        out.batteryStatus = in.legacy.legacy.batteryStatus;
-        out.batteryHealth = in.legacy.legacy.batteryHealth;
-        out.batteryPresent = in.legacy.legacy.batteryPresent;
-        out.batteryLevel = in.legacy.legacy.batteryLevel;
-        out.batteryVoltageMillivolts = in.legacy.legacy.batteryVoltage;
-        out.batteryTemperatureTenthsCelsius = in.legacy.legacy.batteryTemperature;
-        out.batteryCurrentMicroamps = in.legacy.legacy.batteryCurrent;
-        out.batteryCycleCount = in.legacy.legacy.batteryCycleCount;
-        out.batteryFullChargeUah = in.legacy.legacy.batteryFullCharge;
-        out.batteryChargeCounterUah = in.legacy.legacy.batteryChargeCounter;
-        out.batteryTechnology = in.legacy.legacy.batteryTechnology;
+        h2aTranslateInternal(out, in.legacy.legacy);
         out.batteryCurrentAverageMicroamps = in.legacy.batteryCurrentAverage;
         out.diskStats = new android.hardware.health.DiskStats[in.legacy.diskStats.size()];
         for (int i = 0; i < in.legacy.diskStats.size(); i++) {
diff --git a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
index 44f9865..c167a6d 100644
--- a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
+++ b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
@@ -612,6 +612,9 @@
         EXPECT_EQ(0, cardStatus.applications.size());
     }
 
+    // Give some time for modem to fully power down the SIM card
+    sleep(MODEM_SET_SIM_POWER_DELAY_IN_SECONDS);
+
     /* Test setSimCardPower power up */
     serial = GetRandomSerialNumber();
     radio_v1_6->setSimCardPower_1_6(serial, CardPowerState::POWER_UP);
@@ -624,6 +627,9 @@
                                   ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
                                   ::android::hardware::radio::V1_6::RadioError::SIM_ERR}));
 
+    // Give some time for modem to fully power up the SIM card
+    sleep(MODEM_SET_SIM_POWER_DELAY_IN_SECONDS);
+
     // setSimCardPower_1_6 does not return  until the request is handled. Just verify that we still
     // have CardState::PRESENT after turning the power back on
     if (radioRsp_v1_6->rspInfo.error == ::android::hardware::radio::V1_6::RadioError::NONE) {
diff --git a/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h b/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h
index 54c2977..f041865 100644
--- a/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h
+++ b/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h
@@ -47,6 +47,7 @@
 
 #define MODEM_EMERGENCY_CALL_ESTABLISH_TIME 3
 #define MODEM_EMERGENCY_CALL_DISCONNECT_TIME 3
+#define MODEM_SET_SIM_POWER_DELAY_IN_SECONDS 2
 
 #define RADIO_SERVICE_SLOT1_NAME "slot1"  // HAL instance name for SIM slot 1 or single SIM device
 #define RADIO_SERVICE_SLOT2_NAME "slot2"  // HAL instance name for SIM slot 2 on dual SIM device
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimPortInfo.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimPortInfo.aidl
index 2cfb8d0..5cc9017 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimPortInfo.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimPortInfo.aidl
@@ -36,7 +36,5 @@
 parcelable SimPortInfo {
   String iccId;
   int logicalSlotId;
-  int portState;
-  const int PORT_STATE_INACTIVE = 0;
-  const int PORT_STATE_ACTIVE = 1;
+  boolean portActive;
 }
diff --git a/radio/aidl/android/hardware/radio/config/SimPortInfo.aidl b/radio/aidl/android/hardware/radio/config/SimPortInfo.aidl
index 78f1309..54b9890 100644
--- a/radio/aidl/android/hardware/radio/config/SimPortInfo.aidl
+++ b/radio/aidl/android/hardware/radio/config/SimPortInfo.aidl
@@ -34,18 +34,10 @@
      * Logical slot id is identifier of the active slot
      */
     int logicalSlotId;
-    /*
-     * Port is Inactive
-     * Inactive means logical modem is no longer associated to the port
-     */
-    const int PORT_STATE_INACTIVE = 0;
-    /*
-     * Port is Active
-     * Active means logical modem is associated to the port
-     */
-    const int PORT_STATE_ACTIVE = 1;
     /**
-     * Port state in the slot. Values are portState.[PORT_STATE_INACTIVE, PORT_STATE_ACTIVE].
+     * Port active status in the slot.
+     * Inactive means logical modem is no longer associated to the port.
+     * Active means logical modem is associated to the port.
      */
-    int portState;
+    boolean portActive;
 }
diff --git a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
index 71a6097..7e22b19 100644
--- a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
+++ b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
@@ -537,10 +537,9 @@
 
     activateAllSensors(true);
     // Verify that the old environment does not receive any events
-    EXPECT_EQ(collectEvents(kCollectionTimeoutUs, kNumEvents, getEnvironment()).size(), 0);
+    EXPECT_EQ(getEnvironment()->collectEvents(kCollectionTimeoutUs, kNumEvents).size(), 0);
     // Verify that the new event queue receives sensor events
-    EXPECT_GE(collectEvents(kCollectionTimeoutUs, kNumEvents, newEnv.get(), newEnv.get()).size(),
-              kNumEvents);
+    EXPECT_GE(newEnv.get()->collectEvents(kCollectionTimeoutUs, kNumEvents).size(), kNumEvents);
     activateAllSensors(false);
 
     // Cleanup the test environment
@@ -555,7 +554,7 @@
 
     // Ensure that the original environment is receiving events
     activateAllSensors(true);
-    EXPECT_GE(collectEvents(kCollectionTimeoutUs, kNumEvents).size(), kNumEvents);
+    EXPECT_GE(getEnvironment()->collectEvents(kCollectionTimeoutUs, kNumEvents).size(), kNumEvents);
     activateAllSensors(false);
 }
 
@@ -565,7 +564,7 @@
     // Verify that events are received
     constexpr useconds_t kCollectionTimeoutUs = 1000 * 1000;  // 1s
     constexpr int32_t kNumEvents = 1;
-    ASSERT_GE(collectEvents(kCollectionTimeoutUs, kNumEvents, getEnvironment()).size(), kNumEvents);
+    ASSERT_GE(getEnvironment()->collectEvents(kCollectionTimeoutUs, kNumEvents).size(), kNumEvents);
 
     // Clear the active sensor handles so they are not disabled during TearDown
     auto handles = mSensorHandles;
@@ -577,9 +576,9 @@
     }
 
     // Verify no events are received until sensors are re-activated
-    ASSERT_EQ(collectEvents(kCollectionTimeoutUs, kNumEvents, getEnvironment()).size(), 0);
+    ASSERT_EQ(getEnvironment()->collectEvents(kCollectionTimeoutUs, kNumEvents).size(), 0);
     activateAllSensors(true);
-    ASSERT_GE(collectEvents(kCollectionTimeoutUs, kNumEvents, getEnvironment()).size(), kNumEvents);
+    ASSERT_GE(getEnvironment()->collectEvents(kCollectionTimeoutUs, kNumEvents).size(), kNumEvents);
 
     // Disable sensors
     activateAllSensors(false);
diff --git a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h
index 3973d7f..f3cbd78 100644
--- a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h
+++ b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h
@@ -198,49 +198,6 @@
                                             RateLevel rate,
                                             ISensors::configDirectReport_cb _hidl_cb) = 0;
 
-    std::vector<EventType> collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
-                                         bool clearBeforeStart = true,
-                                         bool changeCollection = true) {
-        return collectEvents(timeLimitUs, nEventLimit, getEnvironment(), clearBeforeStart,
-                             changeCollection);
-    }
-
-    std::vector<EventType> collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
-                                         SensorsVtsEnvironmentBase<EventType>* environment,
-                                         bool clearBeforeStart = true,
-                                         bool changeCollection = true) {
-        std::vector<EventType> events;
-        constexpr useconds_t SLEEP_GRANULARITY = 100 * 1000;  // granularity 100 ms
-
-        ALOGI("collect max of %zu events for %d us, clearBeforeStart %d", nEventLimit, timeLimitUs,
-              clearBeforeStart);
-
-        if (changeCollection) {
-            environment->setCollection(true);
-        }
-        if (clearBeforeStart) {
-            environment->catEvents(nullptr);
-        }
-
-        while (timeLimitUs > 0) {
-            useconds_t duration = std::min(SLEEP_GRANULARITY, timeLimitUs);
-            usleep(duration);
-            timeLimitUs -= duration;
-
-            environment->catEvents(&events);
-            if (events.size() >= nEventLimit) {
-                break;
-            }
-            ALOGV("time to go = %d, events to go = %d", (int)timeLimitUs,
-                  (int)(nEventLimit - events.size()));
-        }
-
-        if (changeCollection) {
-            environment->setCollection(false);
-        }
-        return events;
-    }
-
     void testStreamingOperation(SensorTypeVersion type, std::chrono::nanoseconds samplingPeriod,
                                 std::chrono::seconds duration,
                                 const SensorEventsChecker<EventType>& checker) {
@@ -268,7 +225,7 @@
 
         ASSERT_EQ(batch(handle, samplingPeriodInNs, batchingPeriodInNs), Result::OK);
         ASSERT_EQ(activate(handle, 1), Result::OK);
-        events = collectEvents(minTimeUs, minNEvent, getEnvironment(), true /*clearBeforeStart*/);
+        events = getEnvironment()->collectEvents(minTimeUs, minNEvent, true /*clearBeforeStart*/);
         ASSERT_EQ(activate(handle, 0), Result::OK);
 
         ALOGI("Collected %zu samples", events.size());
@@ -335,13 +292,13 @@
         ASSERT_EQ(activate(handle, 1), Result::OK);
 
         usleep(500000);  // sleep 0.5 sec to wait for change rate to happen
-        events1 = collectEvents(collectionTimeoutUs, minNEvent, getEnvironment());
+        events1 = getEnvironment()->collectEvents(collectionTimeoutUs, minNEvent);
 
         // second collection, without stopping the sensor
         ASSERT_EQ(batch(handle, secondCollectionPeriod, batchingPeriodInNs), Result::OK);
 
         usleep(500000);  // sleep 0.5 sec to wait for change rate to happen
-        events2 = collectEvents(collectionTimeoutUs, minNEvent, getEnvironment());
+        events2 = getEnvironment()->collectEvents(collectionTimeoutUs, minNEvent);
 
         // end of collection, stop sensor
         ASSERT_EQ(activate(handle, 0), Result::OK);
@@ -447,16 +404,17 @@
 
         getEnvironment()->setCollection(true);
         // clean existing collections
-        collectEvents(0 /*timeLimitUs*/, 0 /*nEventLimit*/, true /*clearBeforeStart*/,
-                      false /*change collection*/);
+        getEnvironment()->collectEvents(0 /*timeLimitUs*/, 0 /*nEventLimit*/,
+                                        true /*clearBeforeStart*/, false /*change collection*/);
 
         // 0.8 + 0.2 times the batching period
         usleep(batchingPeriodInNs / 1000 * 2 / 10);
         ASSERT_EQ(flush(handle), Result::OK);
 
         // plus some time for the event to deliver
-        events = collectEvents(allowedBatchDeliverTimeNs / 1000, minFifoCount,
-                               false /*clearBeforeStart*/, false /*change collection*/);
+        events = getEnvironment()->collectEvents(allowedBatchDeliverTimeNs / 1000, minFifoCount,
+                                                 false /*clearBeforeStart*/,
+                                                 false /*change collection*/);
 
         getEnvironment()->setCollection(false);
         ASSERT_EQ(activate(handle, 0), Result::OK);
diff --git a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsVtsEnvironmentBase.h b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsVtsEnvironmentBase.h
index d83425d..17a96ed 100644
--- a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsVtsEnvironmentBase.h
+++ b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsVtsEnvironmentBase.h
@@ -25,6 +25,8 @@
 #include <thread>
 #include <vector>
 
+#include <log/log.h>
+
 template <class Event>
 class IEventCallback {
   public:
@@ -74,6 +76,40 @@
         mCallback = nullptr;
     }
 
+    std::vector<Event> collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
+                                     bool clearBeforeStart = true, bool changeCollection = true) {
+        std::vector<Event> events;
+        constexpr useconds_t SLEEP_GRANULARITY = 100 * 1000;  // granularity 100 ms
+
+        ALOGI("collect max of %zu events for %d us, clearBeforeStart %d", nEventLimit, timeLimitUs,
+              clearBeforeStart);
+
+        if (changeCollection) {
+            setCollection(true);
+        }
+        if (clearBeforeStart) {
+            catEvents(nullptr);
+        }
+
+        while (timeLimitUs > 0) {
+            useconds_t duration = std::min(SLEEP_GRANULARITY, timeLimitUs);
+            usleep(duration);
+            timeLimitUs -= duration;
+
+            catEvents(&events);
+            if (events.size() >= nEventLimit) {
+                break;
+            }
+            ALOGV("time to go = %d, events to go = %d", (int)timeLimitUs,
+                  (int)(nEventLimit - events.size()));
+        }
+
+        if (changeCollection) {
+            setCollection(false);
+        }
+        return events;
+    }
+
   protected:
     SensorsVtsEnvironmentBase(const std::string& service_name)
         : mCollectionEnabled(false), mCallback(nullptr) {
diff --git a/uwb/aidl/Android.bp b/uwb/aidl/Android.bp
index a1a66e5..99fd094 100755
--- a/uwb/aidl/Android.bp
+++ b/uwb/aidl/Android.bp
@@ -35,6 +35,7 @@
                 "//apex_available:platform",
                 "com.android.uwb",
             ],
+            min_sdk_version: "current",
         },
     },
 }