Backports interface for AltitudeService to T.

Test: VtsHalAltitudeServiceTargetTest
Bug: 265013616
Change-Id: Id9d9b05c80f6abd8e7c22d46393784f685473409
Merged-In: Id9d9b05c80f6abd8e7c22d46393784f685473409
diff --git a/location/OWNERS b/location/OWNERS
new file mode 100644
index 0000000..1937bce
--- /dev/null
+++ b/location/OWNERS
@@ -0,0 +1 @@
+include platform/frameworks/base:/services/core/java/com/android/server/location/OWNERS
diff --git a/location/altitude/aidl/Android.bp b/location/altitude/aidl/Android.bp
new file mode 100644
index 0000000..f4ecf50
--- /dev/null
+++ b/location/altitude/aidl/Android.bp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+aidl_interface {
+    name: "android.frameworks.location.altitude",
+    srcs: ["android/frameworks/location/altitude/*.aidl"],
+    owner: "google",
+    vendor_available: true,
+    host_supported: true,
+    stability: "vintf",
+    backend: {
+        java: {
+            platform_apis: true,
+        },
+        cpp: {
+            enabled: false,
+        },
+    },
+    versions_with_info: [
+        {
+            version: "1",
+            imports: [],
+        },
+    ],
+    frozen: true,
+
+}
diff --git a/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/.hash b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/.hash
new file mode 100644
index 0000000..ab2b34a
--- /dev/null
+++ b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/.hash
@@ -0,0 +1 @@
+763e0415cde10c922c590396b90bf622636470b1
diff --git a/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl
new file mode 100644
index 0000000..bc2be18
--- /dev/null
+++ b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.location.altitude;
+@VintfStability
+parcelable AddMslAltitudeToLocationRequest {
+  double latitudeDegrees;
+  double longitudeDegrees;
+  double altitudeMeters;
+  float verticalAccuracyMeters;
+}
diff --git a/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl
new file mode 100644
index 0000000..9e8e471
--- /dev/null
+++ b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.location.altitude;
+@VintfStability
+parcelable AddMslAltitudeToLocationResponse {
+  double mslAltitudeMeters;
+  float mslAltitudeAccuracyMeters;
+}
diff --git a/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/IAltitudeService.aidl b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/IAltitudeService.aidl
new file mode 100644
index 0000000..9ef2e3a
--- /dev/null
+++ b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/1/android/frameworks/location/altitude/IAltitudeService.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.location.altitude;
+@VintfStability
+interface IAltitudeService {
+  android.frameworks.location.altitude.AddMslAltitudeToLocationResponse addMslAltitudeToLocation(in android.frameworks.location.altitude.AddMslAltitudeToLocationRequest request);
+}
diff --git a/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl
new file mode 100644
index 0000000..bc2be18
--- /dev/null
+++ b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.location.altitude;
+@VintfStability
+parcelable AddMslAltitudeToLocationRequest {
+  double latitudeDegrees;
+  double longitudeDegrees;
+  double altitudeMeters;
+  float verticalAccuracyMeters;
+}
diff --git a/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl
new file mode 100644
index 0000000..9e8e471
--- /dev/null
+++ b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.location.altitude;
+@VintfStability
+parcelable AddMslAltitudeToLocationResponse {
+  double mslAltitudeMeters;
+  float mslAltitudeAccuracyMeters;
+}
diff --git a/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/IAltitudeService.aidl b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/IAltitudeService.aidl
new file mode 100644
index 0000000..9ef2e3a
--- /dev/null
+++ b/location/altitude/aidl/aidl_api/android.frameworks.location.altitude/current/android/frameworks/location/altitude/IAltitudeService.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.location.altitude;
+@VintfStability
+interface IAltitudeService {
+  android.frameworks.location.altitude.AddMslAltitudeToLocationResponse addMslAltitudeToLocation(in android.frameworks.location.altitude.AddMslAltitudeToLocationRequest request);
+}
diff --git a/location/altitude/aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl b/location/altitude/aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl
new file mode 100644
index 0000000..c3073db
--- /dev/null
+++ b/location/altitude/aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.aidl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.frameworks.location.altitude;
+
+@VintfStability
+parcelable AddMslAltitudeToLocationRequest {
+
+    /** @see android.location.Location#getLatitude() */
+    double latitudeDegrees;
+
+    /** @see android.location.Location#getLongitude() */
+    double longitudeDegrees;
+
+    /** @see android.location.Location#getAltitude() */
+    double altitudeMeters;
+
+    /** @see android.location.Location#getVerticalAccuracyMeters() */
+    float verticalAccuracyMeters;
+}
diff --git a/location/altitude/aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl b/location/altitude/aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl
new file mode 100644
index 0000000..b6190a9
--- /dev/null
+++ b/location/altitude/aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.frameworks.location.altitude;
+
+@VintfStability
+parcelable AddMslAltitudeToLocationResponse {
+
+    /** @see android.location.Location#getMslAltitudeMeters() */
+    double mslAltitudeMeters;
+
+    /** @see android.location.Location#getMslAltitudeAccuracyMeters() */
+    float mslAltitudeAccuracyMeters;
+}
diff --git a/location/altitude/aidl/android/frameworks/location/altitude/IAltitudeService.aidl b/location/altitude/aidl/android/frameworks/location/altitude/IAltitudeService.aidl
new file mode 100644
index 0000000..6e93f77
--- /dev/null
+++ b/location/altitude/aidl/android/frameworks/location/altitude/IAltitudeService.aidl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.frameworks.location.altitude;
+
+import android.frameworks.location.altitude.AddMslAltitudeToLocationRequest;
+import android.frameworks.location.altitude.AddMslAltitudeToLocationResponse;
+
+@VintfStability
+interface IAltitudeService {
+
+    /**
+     * Calls {@link android.location.altitude.AltitudeConverter#addMslAltitudeToLocation(
+     * android.content.Context, android.location.Location)} via system service.
+     */
+    AddMslAltitudeToLocationResponse addMslAltitudeToLocation(
+            in AddMslAltitudeToLocationRequest request);
+}
diff --git a/location/altitude/aidl/vts/functional/Android.bp b/location/altitude/aidl/vts/functional/Android.bp
new file mode 100644
index 0000000..69b9a7c
--- /dev/null
+++ b/location/altitude/aidl/vts/functional/Android.bp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_test {
+    name: "VtsHalAltitudeServiceTargetTest",
+    defaults: [
+        "VtsHalTargetTestDefaults",
+        "use_libaidlvintf_gtest_helper_static",
+    ],
+    tidy_timeout_srcs: [
+        "VtsHalAltitudeServiceTargetTest.cpp",
+    ],
+    srcs: [
+        "VtsHalAltitudeServiceTargetTest.cpp",
+    ],
+    static_libs: [
+        "android.frameworks.location.altitude-V1-ndk",
+        "libgmock",
+    ],
+    shared_libs: [
+        "libbinder_ndk",
+    ],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
+}
diff --git a/location/altitude/aidl/vts/functional/VtsHalAltitudeServiceTargetTest.cpp b/location/altitude/aidl/vts/functional/VtsHalAltitudeServiceTargetTest.cpp
new file mode 100644
index 0000000..eee98d6
--- /dev/null
+++ b/location/altitude/aidl/vts/functional/VtsHalAltitudeServiceTargetTest.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationRequest.h>
+#include <aidl/android/frameworks/location/altitude/AddMslAltitudeToLocationResponse.h>
+#include <aidl/android/frameworks/location/altitude/IAltitudeService.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+using ::aidl::android::frameworks::location::altitude::AddMslAltitudeToLocationRequest;
+using ::aidl::android::frameworks::location::altitude::AddMslAltitudeToLocationResponse;
+using ::aidl::android::frameworks::location::altitude::IAltitudeService;
+using ::android::getAidlHalInstanceNames;
+using ::android::PrintInstanceNameToString;
+using ndk::SpAIBinder;
+using ::testing::Eq;
+using ::testing::InitGoogleTest;
+using ::testing::TestWithParam;
+using ::testing::ValuesIn;
+
+class AltitudeServiceTest : public TestWithParam<std::string> {
+   public:
+    void SetUp() override {
+        SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
+        service = IAltitudeService::fromBinder(binder);
+        ASSERT_NE(service, nullptr);
+    }
+    std::shared_ptr<IAltitudeService> service;
+};
+
+TEST_P(AltitudeServiceTest, TestGetDistanceBasedExpiringGeoidHeight) {
+    // Test known location near Hawaii.
+    AddMslAltitudeToLocationRequest request;
+    request.latitudeDegrees = 19.545519;
+    request.longitudeDegrees = -155.998774;
+    request.altitudeMeters = -1;
+    request.verticalAccuracyMeters = 1;
+
+    AddMslAltitudeToLocationResponse response;
+    service->addMslAltitudeToLocation(request, &response);
+    ASSERT_NEAR(response.mslAltitudeMeters, -19.2359, 2);
+    ASSERT_NEAR(response.mslAltitudeAccuracyMeters, 1.05f, 0.5f);
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AltitudeServiceTest);
+INSTANTIATE_TEST_SUITE_P(AltitudeService, AltitudeServiceTest,
+                         ValuesIn(getAidlHalInstanceNames(IAltitudeService::descriptor)),
+                         PrintInstanceNameToString);
+
+int main(int argc, char** argv) {
+    InitGoogleTest(&argc, argv);
+    ABinderProcess_setThreadPoolMaxThreadCount(1);
+    ABinderProcess_startThreadPool();
+    return RUN_ALL_TESTS();
+}