Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4d0a065 authored by Brian Julian's avatar Brian Julian Committed by Android (Google) Code Review
Browse files

Merge "Adds GetGeoidHeight call to AltitudeService HAL." into main

parents 97b471bd 84b8907e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ java_library_static {
    ],

    static_libs: [
        "android.frameworks.location.altitude-V1-java", // AIDL
        "android.frameworks.location.altitude-V2-java", // AIDL
        "android.frameworks.vibrator-V1-java", // AIDL
        "android.hardware.authsecret-V1.0-java",
        "android.hardware.authsecret-V1-java",
+37 −3
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.server.location.altitude;
import android.content.Context;
import android.frameworks.location.altitude.AddMslAltitudeToLocationRequest;
import android.frameworks.location.altitude.AddMslAltitudeToLocationResponse;
import android.frameworks.location.altitude.GetGeoidHeightRequest;
import android.frameworks.location.altitude.GetGeoidHeightResponse;
import android.frameworks.location.altitude.IAltitudeService;
import android.location.Location;
import android.location.altitude.AltitudeConverter;
@@ -52,15 +54,47 @@ public class AltitudeService extends IAltitudeService.Stub {
        location.setLongitude(request.longitudeDegrees);
        location.setAltitude(request.altitudeMeters);
        location.setVerticalAccuracyMeters(request.verticalAccuracyMeters);

        AddMslAltitudeToLocationResponse response = new AddMslAltitudeToLocationResponse();
        try {
            mAltitudeConverter.addMslAltitudeToLocation(mContext, location);
        } catch (IOException e) {
            throw new RemoteException(e);
            response.success = false;
            return response;
        }

        AddMslAltitudeToLocationResponse response = new AddMslAltitudeToLocationResponse();
        response.mslAltitudeMeters = location.getMslAltitudeMeters();
        response.mslAltitudeAccuracyMeters = location.getMslAltitudeAccuracyMeters();
        response.success = true;
        return response;
    }

    @Override
    public GetGeoidHeightResponse getGeoidHeight(GetGeoidHeightRequest request)
            throws RemoteException {
        Location location = new Location("");
        location.setLatitude(request.latitudeDegrees);
        location.setLongitude(request.longitudeDegrees);
        location.setAltitude(0.0);
        location.setVerticalAccuracyMeters(0.0f);

        GetGeoidHeightResponse response = new GetGeoidHeightResponse();
        try {
            mAltitudeConverter.addMslAltitudeToLocation(mContext, location);
        } catch (IOException e) {
            response.success = false;
            return response;
        }
        // The geoid height for a location with zero WGS84 altitude is equal in value to the
        // negative of the corresponding MSL altitude.
        response.geoidHeightMeters = -location.getMslAltitudeMeters();
        // The geoid height error for a location with zero vertical accuracy is equal in value to
        // the corresponding MSL altitude accuracy.
        response.geoidHeightErrorMeters = location.getMslAltitudeAccuracyMeters();
        // The expiration distance and additional error are currently set to constants used by
        // health services.
        response.expirationDistanceMeters = 10000.0;
        response.additionalGeoidHeightErrorMeters = 0.707f;
        response.success = true;
        return response;
    }

+1 −1
Original line number Diff line number Diff line
<manifest version="1.0" type="framework">
    <hal format="aidl">
        <name>android.frameworks.location.altitude</name>
        <version>1</version>
        <version>2</version>
        <fqname>IAltitudeService/default</fqname>
    </hal>
    <hal format="aidl">