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

Commit 1af4b028 authored by destradaa's avatar destradaa
Browse files

Add FlpHal layer to support Location Batching.

Change-Id: Ia3a57d869dfb3f067a1b95fa66d54f311ddcfdc3
parent 8ffe17ae
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/display/IDisplayManagerCallback.aidl \
	core/java/android/hardware/input/IInputManager.aidl \
	core/java/android/hardware/input/IInputDevicesChangedListener.aidl \
	core/java/android/hardware/location/IFusedLocationHardware.aidl \
	core/java/android/hardware/location/IFusedLocationHardwareSink.aidl \
	core/java/android/hardware/location/IGeofenceHardware.aidl \
	core/java/android/hardware/location/IGeofenceHardwareCallback.aidl \
	core/java/android/hardware/location/IGeofenceHardwareMonitorCallback.aidl \
@@ -232,12 +234,14 @@ LOCAL_SRC_FILES += \
	keystore/java/android/security/IKeyChainService.aidl \
	location/java/android/location/ICountryDetector.aidl \
	location/java/android/location/ICountryListener.aidl \
	location/java/android/location/IFusedProvider.aidl \
	location/java/android/location/IGeocodeProvider.aidl \
	location/java/android/location/IGeofenceProvider.aidl \
	location/java/android/location/IGpsStatusListener.aidl \
	location/java/android/location/IGpsStatusProvider.aidl \
	location/java/android/location/ILocationListener.aidl \
	location/java/android/location/ILocationManager.aidl \
	location/java/android/location/IFusedGeofenceHardware.aidl \
	location/java/android/location/IGpsGeofenceHardware.aidl \
	location/java/android/location/INetInitiatedListener.aidl \
	location/java/com/android/internal/location/ILocationProvider.aidl \
@@ -379,6 +383,7 @@ aidl_files := \
	frameworks/base/location/java/android/location/Geofence.aidl \
	frameworks/base/location/java/android/location/Location.aidl \
	frameworks/base/location/java/android/location/LocationRequest.aidl \
	frameworks/base/location/java/android/location/FusedBatchOptions.aidl \
	frameworks/base/location/java/com/android/internal/location/ProviderProperties.aidl \
	frameworks/base/location/java/com/android/internal/location/ProviderRequest.aidl \
	frameworks/base/telephony/java/android/telephony/ServiceState.aidl \
+117 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013, 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/license/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.hardware.location;

import android.hardware.location.IFusedLocationHardwareSink;
import android.location.FusedBatchOptions;

/**
 * Fused Location hardware interface.
 * This interface is the basic set of supported functionality by Fused Hardware
 * modules that offer Location batching capabilities.
 *
 * @hide
 */
interface IFusedLocationHardware {
    /**
     * Registers a sink with the Location Hardware object.
     *
     * @param eventSink     The sink to register.
     */
    void registerSink(in IFusedLocationHardwareSink eventSink);

    /**
     * Unregisters a sink with the Location Hardware object.
     *
     * @param eventSink     The sink to unregister.
     */
    void unregisterSink(in IFusedLocationHardwareSink eventSink);

    /**
     * Provides access to the batch size available in Hardware.
     *
     * @return The batch size the hardware supports.
     */
    int getSupportedBatchSize();

    /**
     * Requests the Hardware to start batching locations.
     *
     * @param id            An Id associated with the request.
     * @param batchOptions  The options required for batching.
     *
     * @throws RuntimeException if the request Id exists.
     */
    void startBatching(in int id, in FusedBatchOptions batchOptions);

    /**
     * Requests the Hardware to stop batching for the given Id.
     *
     * @param id    The request that needs to be stopped.
     * @throws RuntimeException if the request Id is unknown.
     */
    void stopBatching(in int id);

    /**
     * Updates a batching operation in progress.
     *
     * @param id                The Id of the operation to update.
     * @param batchOptions     The options to apply to the given operation.
     *
     * @throws RuntimeException if the Id of the request is unknown.
     */
    void updateBatchingOptions(in int id, in FusedBatchOptions batchOptions);

    /**
     * Requests the most recent locations available in Hardware.
     * This operation does not dequeue the locations, so still other batching
     * events will continue working.
     *
     * @param batchSizeRequested    The number of locations requested.
     */
    void requestBatchOfLocations(in int batchSizeRequested);

    /**
     * Flags if the Hardware supports injection of diagnostic data.
     *
     * @return True if data injection is supported, false otherwise.
     */
    boolean supportsDiagnosticDataInjection();

    /**
     * Injects diagnostic data into the Hardware subsystem.
     *
     * @param data  The data to inject.
     * @throws RuntimeException if injection is not supported.
     */
    void injectDiagnosticData(in String data);

    /**
     * Flags if the Hardware supports injection of device context information.
     *
     * @return True if device context injection is supported, false otherwise.
     */
    boolean supportsDeviceContextInjection();

    /**
     * Injects device context information into the Hardware subsystem.
     *
     * @param deviceEnabledContext  The context to inject.
     * @throws RuntimeException if injection is not supported.
     */
    void injectDeviceContext(in int deviceEnabledContext);
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013, 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/license/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.hardware.location;

import android.location.Location;

/**
 * Fused Location hardware event sink interface.
 * This interface defines the set of events that the FusedLocationHardware provides.
 *
 * @hide
 */
interface IFusedLocationHardwareSink {
    /**
     * Event generated when a batch of location information is available.
     *
     * @param locations     The batch of location information available.
     */
    void onLocationAvailable(in Location[] locations);

    /**
     * Event generated from FLP HAL to provide diagnostic data to the platform.
     *
     * @param data      The diagnostic data provided by FLP HAL.
     */
    void onDiagnosticDataAvailable(in String data);
}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013, 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.location;

parcelable FusedBatchOptions;
 No newline at end of file
+135 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 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.location;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * A data class representing a set of options to configure batching sessions.
 * @hide
 */
public class FusedBatchOptions implements Parcelable {
    private volatile long mPeriodInNS = 0;
    private volatile int mSourcesToUse = 0;
    private volatile int mFlags = 0;

    // the default value is set to request fixes at no cost
    private volatile double mMaxPowerAllocationInMW = 0;

    /*
     * Getters and setters for properties needed to hold the options.
     */
    public void setMaxPowerAllocationInMW(double value) {
        mMaxPowerAllocationInMW = value;
    }

    public double getMaxPowerAllocationInMW() {
        return mMaxPowerAllocationInMW;
    }

    public void setPeriodInNS(long value) {
        mPeriodInNS = value;
    }

    public long getPeriodInNS() {
        return mPeriodInNS;
    }

    public void setSourceToUse(int source) {
        mSourcesToUse |= source;
    }

    public void resetSourceToUse(int source) {
        mSourcesToUse &= ~source;
    }

    public boolean isSourceToUseSet(int source) {
        return (mSourcesToUse & source) != 0;
    }

    public int getSourcesToUse() {
        return mSourcesToUse;
    }

    public void setFlag(int flag) {
        mFlags |= flag;
    }

    public void resetFlag(int flag) {
        mFlags &= ~flag;
    }

    public boolean isFlagSet(int flag) {
        return (mFlags & flag) != 0;
    }

    public int getFlags() {
        return mFlags;
    }

    /**
     * Definition of enum flag sets needed by this class.
     * Such values need to be kept in sync with the ones in fused_location.h
     */
    public static final class SourceTechnologies {
        public static int GNSS = 1<<0;
        public static int WIFI = 1<<1;
        public static int SENSORS = 1<<2;
        public static int CELL = 1<<3;
        public static int BLUETOOTH = 1<<4;
    }

    public static final class BatchFlags {
        public static int WAKEUP_ON_FIFO_FULL = 1<<0;
        public static int CALLBACK_ON_LOCATION_FIX = 1<<1;
    }

    /*
     * Method definitions to support Parcelable operations.
     */
    public static final Parcelable.Creator<FusedBatchOptions> CREATOR =
            new Parcelable.Creator<FusedBatchOptions>() {
        @Override
        public FusedBatchOptions createFromParcel(Parcel parcel) {
            FusedBatchOptions options = new FusedBatchOptions();
            options.setMaxPowerAllocationInMW(parcel.readDouble());
            options.setPeriodInNS(parcel.readLong());
            options.setSourceToUse(parcel.readInt());
            options.setFlag(parcel.readInt());
            return options;
        }

        @Override
        public FusedBatchOptions[] newArray(int size) {
            return new FusedBatchOptions[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeDouble(mMaxPowerAllocationInMW);
        parcel.writeLong(mPeriodInNS);
        parcel.writeInt(mSourcesToUse);
        parcel.writeInt(mFlags);
    }
}
Loading