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

Commit 1d1ac540 authored by Ashutosh Joshi's avatar Ashutosh Joshi
Browse files

Context hub API for applications

Adding a System API for applications to access a context hub.

The API is not expected to be exposed to third party Android
applications in the medium term.

Change-Id: Ia2222317c913de6901f3912e4c89b5cfa398be85
parent 6cfdf6b6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -187,6 +187,8 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/location/IGeofenceHardware.aidl \
	core/java/android/hardware/location/IGeofenceHardwareCallback.aidl \
	core/java/android/hardware/location/IGeofenceHardwareMonitorCallback.aidl \
	core/java/android/hardware/location/IContextHubCallback.aidl \
	core/java/android/hardware/location/IContextHubService.aidl \
	core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl \
	core/java/android/hardware/usb/IUsbManager.aidl \
	core/java/android/net/ICaptivePortal.aidl \
+143 −0
Original line number Diff line number Diff line
@@ -15055,6 +15055,66 @@ package android.hardware.input {
package android.hardware.location {
  public class ContextHubInfo {
    ctor public ContextHubInfo();
    method public int describeContents();
    method public int getId();
    method public android.hardware.location.MemoryRegion[] getMemoryRegions();
    method public java.lang.String getName();
    method public float getPeakMips();
    method public float getPeakPowerDrawMw();
    method public int getPlatformVersion();
    method public float getSleepPowerDrawMw();
    method public int getStaticSwVersion();
    method public float getStoppedPowerDrawMw();
    method public int[] getSupportedSensors();
    method public java.lang.String getToolchain();
    method public int getToolchainVersion();
    method public java.lang.String getVendor();
    method public void setId(int);
    method public void setMemoryRegions(android.hardware.location.MemoryRegion[]);
    method public void setName(java.lang.String);
    method public void setPeakMips(float);
    method public void setPeakPowerDrawMw(float);
    method public void setPlatformVersion(int);
    method public void setSleepPowerDrawMw(float);
    method public void setStaticSwVersion(int);
    method public void setStoppedPowerDrawMw(float);
    method public void setSupportedSensors(int[]);
    method public void setToolchain(java.lang.String);
    method public void setToolchainVersion(int);
    method public void setVendor(java.lang.String);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.ContextHubInfo> CREATOR;
  }
  public final class ContextHubManager {
    method public java.lang.Integer[] findNanoAppOnHub(int, android.hardware.location.NanoAppFilter);
    method public int[] getContexthubHandles();
    method public android.hardware.location.ContextHubInfo getContexthubInfo(int);
    method public android.hardware.location.NanoAppInstanceInfo getNanoAppInstanceInfo(int);
    method public int loadNanoApp(int, android.hardware.location.NanoApp);
    method public int sendMessage(int, int, android.hardware.location.ContextHubMessage);
    method public int unloadNanoApp(int);
    field public static final int ANY_HUB = -1; // 0xffffffff
    field public static final int MSG_DATA_SEND = 3; // 0x3
    field public static final int MSG_LOAD_NANO_APP = 1; // 0x1
    field public static final int MSG_UNLOAD_NANO_APP = 2; // 0x2
  }
  public class ContextHubMessage {
    ctor public ContextHubMessage(int, int, byte[]);
    method public int describeContents();
    method public byte[] getData();
    method public int getMsgType();
    method public int getVersion();
    method public void setMsgData(byte[]);
    method public void setMsgType(int);
    method public void setVersion(int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.ContextHubMessage> CREATOR;
  }
  public final class GeofenceHardware {
    ctor public GeofenceHardware(android.hardware.location.IGeofenceHardware);
    method public boolean addGeofence(int, int, android.hardware.location.GeofenceHardwareRequest, android.hardware.location.GeofenceHardwareCallback);
@@ -15171,6 +15231,89 @@ package android.hardware.location {
    method public abstract void onMonitoringSystemChange(android.hardware.location.GeofenceHardwareMonitorEvent) throws android.os.RemoteException;
  }
  public class MemoryRegion implements android.os.Parcelable {
    ctor public MemoryRegion(android.os.Parcel);
    method public int describeContents();
    method public int getCapacityBytes();
    method public int getFreeCapacityBytes();
    method public boolean isExecutable();
    method public boolean isReadable();
    method public boolean isWritable();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.MemoryRegion> CREATOR;
  }
  public class NanoApp {
    ctor public NanoApp();
    method public int describeContents();
    method public byte[] getAppBinary();
    method public int getAppId();
    method public int getAppVersion();
    method public java.lang.String getName();
    method public int getNeededExecMemBytes();
    method public int getNeededReadMemBytes();
    method public int[] getNeededSensors();
    method public int getNeededWriteMemBytes();
    method public int[] getOutputEvents();
    method public java.lang.String getPublisher();
    method public void setAppBinary(byte[]);
    method public void setAppId(int);
    method public void setAppVersion(int);
    method public void setName(java.lang.String);
    method public void setNeededExecMemBytes(int);
    method public void setNeededReadMemBytes(int);
    method public void setNeededSensors(int[]);
    method public void setNeededWriteMemBytes(int);
    method public void setOutputEvents(int[]);
    method public void setPublisher(java.lang.String);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoApp> CREATOR;
  }
  public class NanoAppFilter {
    ctor public NanoAppFilter(long, int, int, long);
    method public int describeContents();
    method public boolean testMatch(android.hardware.location.NanoAppInstanceInfo);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int APP_ANY = -1; // 0xffffffff
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoAppFilter> CREATOR;
    field public static final int FLAGS_VERSION_ANY = -1; // 0xffffffff
    field public static final int FLAGS_VERSION_GREAT_THAN = 2; // 0x2
    field public static final int FLAGS_VERSION_LESS_THAN = 4; // 0x4
    field public static final int FLAGS_VERSION_STRICTLY_EQUAL = 8; // 0x8
    field public static final int HUB_ANY = -1; // 0xffffffff
    field public static final int VENDOR_ANY = -1; // 0xffffffff
  }
  public class NanoAppInstanceInfo {
    ctor public NanoAppInstanceInfo();
    method public int describeContents();
    method public int getAppId();
    method public int getAppVersion();
    method public int getContexthubId();
    method public int getHandle();
    method public java.lang.String getName();
    method public int getNeededExecMemBytes();
    method public int getNeededReadMemBytes();
    method public int[] getNeededSensors();
    method public int getNeededWriteMemBytes();
    method public int[] getOutputEvents();
    method public java.lang.String getPublisher();
    method public void setAppId(int);
    method public void setAppVersion(int);
    method public void setContexthubId(int);
    method public void setHandle(int);
    method public void setName(java.lang.String);
    method public void setNeededExecMemBytes(int);
    method public void setNeededReadMemBytes(int);
    method public void setNeededSensors(int[]);
    method public void setNeededWriteMemBytes(int);
    method public void setOutputEvents(int[]);
    method public void setPublisher(java.lang.String);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoAppInstanceInfo> CREATOR;
  }
}
package android.hardware.radio {
+21 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.hardware.location;
/*
@hide
*/
parcelable ContextHubInfo;
+351 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.hardware.location;

import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Arrays;

/**
 * @hide
  */
@SystemApi
public class ContextHubInfo {
    private int mId;
    private String mName;
    private String mVendor;
    private String mToolchain;
    private int mPlatformVersion;
    private int mStaticSwVersion;
    private int mToolchainVersion;
    private float mPeakMips;
    private float mStoppedPowerDrawMw;
    private float mSleepPowerDrawMw;
    private float mPeakPowerDrawMw;

    private int[] mSupportedSensors;

    private MemoryRegion[] mMemoryRegions;

    public ContextHubInfo() {
    }

    /**
     * get the context hub unique identifer
     *
     * @return int - unique system wide identifier
     */
    public int getId() {
        return mId;
    }

    /**
     * set the context hub unique identifer
     *
     * @param id - unique system wide identifier for the hub
     */
    public void setId(int id) {
        mId = id;
    }

    /**
     * get a string as a hub name
     *
     * @return String - a name for the hub
     */
    public String getName() {
        return mName;
    }

    /**
     * set a string as the hub name
     *
     * @param String - the name for the hub
     */
    public void setName(String name) {
        mName = name;
    }

    /**
     * get a string as the vendor name
     *
     * @return String - a name for the vendor
     */
    public String getVendor() {
        return mVendor;
    }

    /**
     * set a string as the vendor name
     *
     * @param String - a name for the vendor
     */
    public void setVendor(String vendor) {
        mVendor = vendor;
    }

    /**
     * get tool chain string
     *
     * @return String - description of the tool chain
     */
    public String getToolchain() {
        return mToolchain;
    }

    /**
     * set tool chain string
     *
     * @param String - description of the tool chain
     */
    public void setToolchain(String toolchain) {
        mToolchain = toolchain;
    }

    /**
     * get platform version
     *
     * @return int - platform version number
     */
    public int getPlatformVersion() {
        return mPlatformVersion;
    }

    /**
     * set platform version
     *
     * @param platformVersion - platform version number
     */
    public void setPlatformVersion(int platformVersion) {
        mPlatformVersion = platformVersion;
    }

    /**
     * get static platform version number
     *
     * @return int - platform version number
     */
    public int getStaticSwVersion() {
        return mStaticSwVersion;
    }

    /**
     * set platform software version
     *
     * @param staticSwVersion - platform static s/w version number
     */
    public void setStaticSwVersion(int staticSwVersion) {
        mStaticSwVersion = staticSwVersion;
    }

    /**
     * get the tool chain version
     *
     * @return int - the tool chain version
     */
    public int getToolchainVersion() {
        return mToolchainVersion;
    }

    /**
     * set the tool chain version number
     *
     * @param toolchainVersion - tool chain version number
     */
    public void setToolchainVersion(int toolchainVersion) {
        mToolchainVersion = toolchainVersion;
    }

    /**
     * get the peak processing mips the hub can support
     *
     * @return float - peak MIPS that this hub can deliver
     */
    public float getPeakMips() {
        return mPeakMips;
    }

    /**
     * set the peak mips that this hub can support
     *
     * @param peakMips - peak mips this hub can deliver
     */
    public void setPeakMips(float peakMips) {
        mPeakMips = peakMips;
    }

    /**
     * get the stopped power draw in milliwatts
     * This assumes that the hub enter a stopped state - which is
     * different from the sleep state. Latencies on exiting the
     * sleep state are typically higher and expect to be in multiple
     * milliseconds.
     *
     * @return float - power draw by the hub in stopped state
     */
    public float getStoppedPowerDrawMw() {
        return mStoppedPowerDrawMw;
    }

    /**
     * Set the power consumed by the hub in stopped state
     *
     * @param stoppedPowerDrawMw - stopped power in milli watts
     */
    public void setStoppedPowerDrawMw(float stoppedPowerDrawMw) {
        mStoppedPowerDrawMw = stoppedPowerDrawMw;
    }

    /**
     * get the power draw of the hub in sleep mode. This assumes
     * that the hub supports a sleep mode in which the power draw is
     * lower than the power consumed when the hub is actively
     * processing. As a guideline, assume that the hub should be
     * able to enter sleep mode if it knows reliably on completion
     * of some task that the next interrupt/scheduled work item is
     * at least 250 milliseconds later.
     *
     * @return float - sleep power draw in milli watts
     */
    public float getSleepPowerDrawMw() {
        return mSleepPowerDrawMw;
    }

    /**
     * Set the sleep power draw in milliwatts
     *
     * @param sleepPowerDrawMw - sleep power draw in milliwatts.
     */
    public void setSleepPowerDrawMw(float sleepPowerDrawMw) {
        mSleepPowerDrawMw = sleepPowerDrawMw;
    }

    /**
     * get the peak powe draw of the hub. This is the power consumed
     * by the hub at maximum load.
     *
     * @return float - peak power draw
     */
    public float getPeakPowerDrawMw() {
        return mPeakPowerDrawMw;
    }

    /**
     * set the peak power draw of the hub
     *
     * @param peakPowerDrawMw - peak power draw of the hub in
     *                        milliwatts.
     */
    public void setPeakPowerDrawMw(float peakPowerDrawMw) {
        mPeakPowerDrawMw = peakPowerDrawMw;
    }

    /**
     * get the sensors supported by this hub
     *
     * @return int[] - all the supported sensors on this hub
     *
     * @see ContextHubManager
     */
    public int[] getSupportedSensors() {
        return Arrays.copyOf(mSupportedSensors, mSupportedSensors.length);
    }

    /**
     * get the various memory regions on this hub
     *
     * @return MemoryRegion[] - all the memory regions on this hub
     *
     * @see MemoryRegion
     */
    public MemoryRegion[] getMemoryRegions() {
        return Arrays.copyOf(mMemoryRegions, mMemoryRegions.length);
    }

    /**
     * set the supported sensors on this hub
     *
     * @param supportedSensors - supported sensors on this hub
     */
    public void setSupportedSensors(int[] supportedSensors) {
        mSupportedSensors = Arrays.copyOf(supportedSensors, supportedSensors.length);
    }

    /**
     * set memory regions for this hub
     *
     * @param memoryRegions - memory regions information
     *
     * @see MemoryRegion
     */
    public void setMemoryRegions(MemoryRegion[] memoryRegions) {
        mMemoryRegions = Arrays.copyOf(memoryRegions, memoryRegions.length);
    }

    private ContextHubInfo(Parcel in) {
        mId = in.readInt();
        mName = in.readString();
        mVendor = in.readString();
        mToolchain = in.readString();
        mPlatformVersion = in.readInt();
        mToolchainVersion = in.readInt();
        mStaticSwVersion = in.readInt();
        mPeakMips = in.readFloat();
        mStoppedPowerDrawMw = in.readFloat();
        mSleepPowerDrawMw = in.readFloat();
        mPeakPowerDrawMw = in.readFloat();

        int numSupportedSensors = in.readInt();
        mSupportedSensors = new int[numSupportedSensors];
        in.readIntArray(mSupportedSensors);
        mMemoryRegions = in.createTypedArray(MemoryRegion.CREATOR);
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(mId);
        out.writeString(mName);
        out.writeString(mVendor);
        out.writeString(mToolchain);
        out.writeInt(mPlatformVersion);
        out.writeInt(mToolchainVersion);
        out.writeInt(mStaticSwVersion);
        out.writeFloat(mPeakMips);
        out.writeFloat(mStoppedPowerDrawMw);
        out.writeFloat(mSleepPowerDrawMw);
        out.writeFloat(mPeakPowerDrawMw);

        out.writeInt(mSupportedSensors.length);
        out.writeIntArray(mSupportedSensors);
        out.writeTypedArray(mMemoryRegions, flags);
    }

    public static final Parcelable.Creator<ContextHubInfo> CREATOR
            = new Parcelable.Creator<ContextHubInfo>() {
        public ContextHubInfo createFromParcel(Parcel in) {
            return new ContextHubInfo(in);
        }

        public ContextHubInfo[] newArray(int size) {
            return new ContextHubInfo[size];
        }
    };
}
+278 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading