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

Commit 026325fe authored by Brian Julian's avatar Brian Julian Committed by Gerrit Code Review
Browse files

Merge "Backports implementation for AltitudeService to T."

parents 6f8b112b eba77a86
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -178,6 +178,10 @@ java_library {
        "service-sdksandbox.stubs.system_server",
    ],

    vintf_fragments: [
        "manifest_services.xml",
    ],

    // Uncomment to enable output of certain warnings (deprecated, unchecked)
    //javacflags: ["-Xlint"],
}
+1 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ java_library_static {
    ],

    static_libs: [
        "android.frameworks.location.altitude-V1-java", // AIDL
        "android.hardware.authsecret-V1.0-java",
        "android.hardware.boot-V1.0-java", // HIDL
        "android.hardware.boot-V1.1-java", // HIDL
+94 −0
Original line number Diff line number Diff line
/*
 * 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 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.IAltitudeService;
import android.location.Location;
import android.location.altitude.AltitudeConverter;
import android.os.RemoteException;

import com.android.server.SystemService;

import java.io.IOException;

/**
 * Manages altitude information exchange through the HAL, e.g., geoid height requests such that
 * vendors can perform altitude conversions.
 *
 * @hide
 */
public class AltitudeService extends IAltitudeService.Stub {

    private final AltitudeConverter mAltitudeConverter = new AltitudeConverter();
    private final Context mContext;

    /** @hide */
    public AltitudeService(Context context) {
        mContext = context;
    }

    @Override
    public AddMslAltitudeToLocationResponse addMslAltitudeToLocation(
            AddMslAltitudeToLocationRequest request) throws RemoteException {
        Location location = new Location("");
        location.setLatitude(request.latitudeDegrees);
        location.setLongitude(request.longitudeDegrees);
        location.setAltitude(request.altitudeMeters);
        location.setVerticalAccuracyMeters(request.verticalAccuracyMeters);
        try {
            mAltitudeConverter.addMslAltitudeToLocation(mContext, location);
        } catch (IOException e) {
            throw new RemoteException(e);
        }

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

    @Override
    public String getInterfaceHash() {
        return IAltitudeService.HASH;
    }

    @Override
    public int getInterfaceVersion() {
        return IAltitudeService.VERSION;
    }

    /** @hide */
    public static class Lifecycle extends SystemService {

        private static final String SERVICE_NAME = IAltitudeService.DESCRIPTOR + "/default";

        private AltitudeService mService;

        public Lifecycle(Context context) {
            super(context);
        }

        @Override
        public void onStart() {
            mService = new AltitudeService(getContext());
            publishBinderService(SERVICE_NAME, mService);
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ import com.android.server.integrity.AppIntegrityManagerService;
import com.android.server.lights.LightsService;
import com.android.server.locales.LocaleManagerService;
import com.android.server.location.LocationManagerService;
import com.android.server.location.altitude.AltitudeService;
import com.android.server.logcat.LogcatManagerService;
import com.android.server.media.MediaRouterService;
import com.android.server.media.metrics.MediaMetricsManagerService;
@@ -2097,6 +2098,14 @@ public final class SystemServer implements Dumpable {
            }
            t.traceEnd();

            t.traceBegin("StartAltitudeService");
            try {
                mSystemServiceManager.startService(AltitudeService.Lifecycle.class);
            } catch (Throwable e) {
                reportWtf("starting AltitudeService service", e);
            }
            t.traceEnd();

            t.traceBegin("StartLocationTimeZoneManagerService");
            try {
                mSystemServiceManager.startService(LOCATION_TIME_ZONE_MANAGER_SERVICE_CLASS);
+7 −0
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>
        <fqname>IAltitudeService/default</fqname>
    </hal>
</manifest>