Merge changes from topic "occupant_awareness@1.0"

* changes:
  Default hal for Occupant Awareness.
  Occupant Awareness HAL definitions.
This commit is contained in:
Kathan Shukla 2019-12-04 22:16:13 +00:00 committed by Android (Google) Code Review
commit ef6d127ea8
18 changed files with 837 additions and 0 deletions

View file

@ -0,0 +1,13 @@
aidl_interface {
name: "android.hardware.automotive.occupant_awareness",
vendor_available: true,
srcs: [
"android/hardware/automotive/occupant_awareness/*.aidl",
],
stability: "vintf",
backend: {
java: {
enabled: false,
},
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
@VintfStability
@Backing(type="byte")
enum ConfidenceLevel {
/**
* No prediction could be made.
*/
NONE,
/**
* Best-guess, low-confidence prediction. Predictions exceeding this threshold are adequate
* for non-critical applications.
*/
LOW,
/**
* High-confidence prediction. Predictions exceeding this threshold are adequate for
* applications that require reliable predictions.
*/
HIGH,
/**
* Highest confidence rate achievable.
*/
MAX,
}

View file

@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
import android.hardware.automotive.occupant_awareness.ConfidenceLevel;
@VintfStability
parcelable DriverMonitoringDetection {
/*
* Confidence of the computed attention data.
*/
ConfidenceLevel confidenceScore;
/*
* Is the driver currently looking on-road?
*/
boolean isLookingOnRoad;
/*
* Duration the driver has been looking on or off road, in milliseconds.
*/
long gazeDurationMillis;
}

View file

@ -0,0 +1,57 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
import android.hardware.automotive.occupant_awareness.VehicleRegion;
import android.hardware.automotive.occupant_awareness.ConfidenceLevel;
@VintfStability
parcelable GazeDetection {
/*
* Confidence level for the gaze detection.
*/
ConfidenceLevel gazeConfidence;
/*
* Head position, in millimeters. The vehicle coordinate system is specified in the cabin space
* configuration. headPosition is double[3] array.
*/
double[] headPosition;
/*
* Unit vector for the head pose direction. The vehicle coordinate system is specified in the
* cabin space configuration. headAngleUnitVector is double[3] array.
*/
double[] headAngleUnitVector;
/*
* Unit vector for the gaze direction. The vehicle coordinate system is specified in the cabin
* space configuration. gazeAngleUnitVector is double[3] array.
*/
double[] gazeAngleUnitVector;
/*
* Current gaze target.
*/
VehicleRegion gazeTarget;
/*
* Custom gaze target string. This only need to be populated when gazeTarget is CUSTOM_TARGET.
* Vendors should use "com.vendor_name.target_name" format to avoid name collision with other
* vendors.
*/
String customGazeTarget;
/*
* Duration that the subject has been looking at the current gaze target in milliseconds.
*/
long timeOnTargetMillis;
}

View file

@ -0,0 +1,88 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
import android.hardware.automotive.occupant_awareness.OccupantAwarenessStatus;
import android.hardware.automotive.occupant_awareness.Role;
import android.hardware.automotive.occupant_awareness.IOccupantAwarenessClientCallback;
import android.hardware.automotive.occupant_awareness.OccupantDetections;
@VintfStability
interface IOccupantAwareness {
/*
* System not able to generate any occupancy awareness.
*/
const int CAP_NONE = 0;
/*
* System is able to detect the presence of humans.
*/
const int CAP_PRESENSE_DETECTION = 1 << 0;
/*
* System is able to detect the gaze of humans.
*/
const int CAP_GAZE_DETECTION = 1 << 1;
/*
* System is able to compute the attention details of humans.
*/
const int CAP_DRIVER_MONITORING_DETECTION = 1 << 2;
/**
* Starts the occupant awareness detection system. This is a non-blocking function call.
* Once system is ready, state will be modified. State update can be inrquired using callback
* or getState() function.
* @return status is the current system state.
*/
OccupantAwarenessStatus startDetection();
/**
* Stops the occupant awareness detection system. This is a non-blocking function call.
* Once system is reset, state will be modified. State update can be inrquired using callback
* or getState() function.
* @return status is the current system state.
*/
OccupantAwarenessStatus stopDetection();
/**
* Returns list of Awareness Capability supported for the given type of occupants.
*
* @param out Bitwise OR of supported capabilities (CAP_* mask).
*/
int getCapabilityForRole(in Role occupantRole);
/**
* Inquires the current state of the occupant awareness system.
* @param occupantRole specifies the role of occupants of interest.
* @param detectionCapability specifies a single detection capability (CAP_* ) of interest.
*
* @return status is the current system state.
*/
OccupantAwarenessStatus getState(in Role occupantRole, in int detectionCapability);
/**
* Registers a callback for data streaming. Only single callback is supported. setCallback()
* should replace existing callback with new callback.
* @return: returns ok if successful.
*/
void setCallback(in IOccupantAwarenessClientCallback callback);
/**
* Returns the most recent set of detections.
* @param OccupantDetections output detections.
* @return returns ok if successful.
*/
void getLatestDetection(out OccupantDetections detections);
}

View file

@ -0,0 +1,38 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
import android.hardware.automotive.occupant_awareness.OccupantAwarenessStatus;
import android.hardware.automotive.occupant_awareness.OccupantDetections;
@VintfStability
interface IOccupantAwarenessClientCallback {
/**
* A callback invoked when the system status changes.
*
* @param detectionFlags The detection subsystem(s) whose status has changed.
* @param status The new system status.
*/
oneway void onSystemStatusChanged(in int detectionFlags, in OccupantAwarenessStatus status);
/**
* A callback invoked when a new set of detections are available.
*
* @param detections Occupant detections.
*/
oneway void onDetectionEvent(in OccupantDetections detections);
}

View file

@ -0,0 +1,41 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
@VintfStability
@Backing(type="byte")
enum OccupantAwarenessStatus {
/*
* System is online and ready to serve requests.
*/
READY = 0,
/**
* Detection is not supported in this vehicle due to a permanent lack of capabilities. Clients
* need not retry.
*/
NOT_SUPPORTED = 1,
/*
* The system has not yet been initialized. No requests can be served until the
* initialization process completes. This state does not indicate any error and
* clients should retry later.
*/
NOT_INITIALIZED = 2,
/*
* A permanent failure has occurred. No detections will be provided.
*/
FAILURE = 3,
}

View file

@ -0,0 +1,50 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
import android.hardware.automotive.occupant_awareness.Role;
import android.hardware.automotive.occupant_awareness.PresenceDetection;
import android.hardware.automotive.occupant_awareness.GazeDetection;
import android.hardware.automotive.occupant_awareness.DriverMonitoringDetection;
/*
* A complete detection for a single occupant in the vehicle. Includes data about the subject's
* presence in the vehicle, gaze and attention.
*/
@VintfStability
parcelable OccupantDetection {
/*
* Role of the occupant (e.g., driver, passenger).
*/
Role role;
/*
* Occupant presence state for a single occupant.
* If the vector is empty, no data could be generated.
*/
PresenceDetection[] presenceData;
/*
* Gaze data for a single occupant.
* If the vector is empty, no data could be generated.
*/
GazeDetection[] gazeData;
/*
* Attention data for a single occupant.
* If the vector is empty, no data could be generated.
*/
DriverMonitoringDetection[] attentionData;
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
import android.hardware.automotive.occupant_awareness.OccupantDetection;
@VintfStability
parcelable OccupantDetections {
/**
* Timestamp that the underlying source image was captured, in milliseconds since Jan 1, 1970
* (Unix time).
*/
long timeStampMillis;
/**
* A vector of detections for all occupants in the vehicle. One OccupantDetection will be
* generated per detected face.
*/
OccupantDetection[] detections;
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
@VintfStability
parcelable PresenceDetection {
/*
* Boolean representing whether an occupant was detected.
*/
boolean isOccupantDetected;
/**
* Duration that a particular occupant has been continuously
* detected, in milliseconds. Will be zero duration if the occupant is not
* currently detected.
*/
long detectionDurationMillis;
}

View file

@ -0,0 +1,83 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
@VintfStability
@Backing(type="int")
enum Role {
/*
* All valid role(s) must have at least 1 bit set.
*/
INVALID = 0,
/*
* System could not determine role for this occupant.
*/
UNKNOWN = 1 << 0,
/*
* Occupants that the system detects as front seat passengers.
*/
FRONT_PASSENGER = 1 << 1,
/*
* Occupants that the system detects as driver(s).
*/
DRIVER = 1 << 2,
/*
* Occupants on left seat of row 2.
*/
ROW_2_PASSENGER_LEFT = 1 << 3,
/*
* Occupants on center seat of row 2.
*/
ROW_2_PASSENGER_CENTER = 1 << 4,
/*
* Occupants on right seat of row 2.
*/
ROW_2_PASSENGER_RIGHT = 1 << 5,
/*
* Occupants on left seat of row 3.
*/
ROW_3_PASSENGER_LEFT = 1 << 6,
/*
* Occupants on center seat of row 3.
*/
ROW_3_PASSENGER_CENTER = 1 << 7,
/*
* Occupants on right seat of row 3.
*/
ROW_3_PASSENGER_RIGHT = 1 << 8,
/*
* Occupants that the system detects as front seat occupant.
* FRONT_OCCUPANTS = DRIVER | FRONT_PASSENGER
*/
FRONT_OCCUPANTS = 1 << 1 | 1 << 2,
/*
* Occupants of row 2.
* ROW_2_OCCUPANTS = ROW_2_PASSENGER_LEFT | ROW_2_PASSENGER_CENTER | ROW_2_PASSENGER_RIGHT
*/
ROW_2_OCCUPANTS = 1 << 3 | 1 << 4 | 1 << 5,
/*
* Occupants of row 3.
* ROW_3_OCCUPANTS = ROW_3_PASSENGER_LEFT | ROW_3_PASSENGER_CENTER | ROW_3_PASSENGER_RIGHT
*/
ROW_3_OCCUPANTS = 1 << 6 | 1 << 7 | 1 << 8,
/*
* All the occupants in the vehicle.
* ALL_OCCUPANTS = UNKNOWN | FRONT_OCCUPANTS | ROW_2_OCCUPANTS | ROW_3_OCCUPANTS
*/
ALL_OCCUPANTS = 0x1FF,
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2019 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.automotive.occupant_awareness;
@VintfStability
@Backing(type="int")
enum VehicleRegion {
/*
* List of targets in the car.
*/
UNKNOWN = 0,
INSTRUMENT_CLUSTER = 1,
REAR_VIEW_MIRROR = 2,
LEFT_SIDE_MIRROR = 3,
RIGHT_SIDE_MIRROR = 4,
FORWARD_ROADWAY = 5,
LEFT_ROADWAY = 6,
RIGHT_ROADWAY = 7,
HEAD_UNIT_DISPLAY = 8,
/*
* Vendors can use this value along with customGazeTarget string to uniquely identify their
* custom region.
*/
CUSTOM_TARGET = 200,
}

View file

@ -0,0 +1,32 @@
/*
* Copyright (C) 2019 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.
*/
cc_binary {
name: "android.hardware.automotive.occupant_awareness@1.0-service",
init_rc: ["android.hardware.automotive.occupant_awareness@1.0-service.rc"],
relative_install_path: "hw",
vendor: true,
srcs: [
"service.cpp",
"OccupantAwareness.cpp",
],
shared_libs: [
"libbase",
"libbinder_ndk",
"libutils",
"android.hardware.automotive.occupant_awareness-ndk_platform",
],
}

View file

@ -0,0 +1,122 @@
/*
* Copyright (C) 2019 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 "OccupantAwareness.h"
namespace android {
namespace hardware {
namespace automotive {
namespace occupant_awareness {
namespace V1_0 {
namespace implementation {
using ndk::ScopedAStatus;
static const int32_t kAllCapabilities = OccupantAwareness::CAP_PRESENSE_DETECTION |
OccupantAwareness::CAP_GAZE_DETECTION |
OccupantAwareness::CAP_DRIVER_MONITORING_DETECTION;
ScopedAStatus OccupantAwareness::startDetection(OccupantAwarenessStatus* status) {
std::lock_guard<std::mutex> lock(mMutex);
if (mStatus != OccupantAwarenessStatus::NOT_SUPPORTED) {
mStatus = OccupantAwarenessStatus::NOT_SUPPORTED;
if (mCallback) {
mCallback->onSystemStatusChanged(kAllCapabilities,
OccupantAwarenessStatus::NOT_SUPPORTED);
}
}
*status = mStatus;
return ScopedAStatus::ok();
}
ScopedAStatus OccupantAwareness::stopDetection(OccupantAwarenessStatus* status) {
std::lock_guard<std::mutex> lock(mMutex);
if (mStatus != OccupantAwarenessStatus::NOT_INITIALIZED) {
mStatus = OccupantAwarenessStatus::NOT_INITIALIZED;
if (mCallback) {
mCallback->onSystemStatusChanged(kAllCapabilities,
OccupantAwarenessStatus::NOT_INITIALIZED);
}
}
*status = mStatus;
return ScopedAStatus::ok();
}
ScopedAStatus OccupantAwareness::getCapabilityForRole(Role occupantRole, int32_t* capabilities) {
if (!isValidRole(occupantRole)) {
return ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
}
// No awareness capability for default HAL.
*capabilities = 0;
return ScopedAStatus::ok();
}
ScopedAStatus OccupantAwareness::getState(Role occupantRole, int detectionCapability,
OccupantAwarenessStatus* status) {
if (!isValidRole(occupantRole)) {
return ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
}
if (!isValidDetectionCapabilities(detectionCapability) ||
!isSingularCapability(detectionCapability)) {
return ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
}
std::lock_guard<std::mutex> lock(mMutex);
*status = mStatus;
return ScopedAStatus::ok();
}
ScopedAStatus OccupantAwareness::setCallback(
const std::shared_ptr<IOccupantAwarenessClientCallback>& callback) {
if (callback == nullptr) {
return ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
}
std::lock_guard<std::mutex> lock(mMutex);
mCallback = callback;
return ScopedAStatus::ok();
}
ScopedAStatus OccupantAwareness::getLatestDetection(OccupantDetections* detections) {
// No detection generated for default hal.
(void)detections;
return ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
}
bool OccupantAwareness::isValidRole(Role occupantRole) {
int intVal = static_cast<int>(occupantRole);
int allOccupants = static_cast<int>(Role::ALL_OCCUPANTS);
return (occupantRole != Role::INVALID) && ((intVal & (~allOccupants)) == 0);
}
bool OccupantAwareness::isValidDetectionCapabilities(int detectionCapabilities) {
return (detectionCapabilities != CAP_NONE) &&
((detectionCapabilities & (~kAllCapabilities)) == 0);
}
bool OccupantAwareness::isSingularCapability(int detectionCapability) {
// Check whether the value is 0, or the value has only one bit set.
return (detectionCapability & (detectionCapability - 1)) == 0;
}
} // namespace implementation
} // namespace V1_0
} // namespace occupant_awareness
} // namespace automotive
} // namespace hardware
} // namespace android

View file

@ -0,0 +1,67 @@
/*
* Copyright (C) 2019 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.
*/
#pragma once
#include <aidl/android/hardware/automotive/occupant_awareness/BnOccupantAwareness.h>
#include <aidl/android/hardware/automotive/occupant_awareness/BnOccupantAwarenessClientCallback.h>
#include <utils/StrongPointer.h>
namespace android {
namespace hardware {
namespace automotive {
namespace occupant_awareness {
namespace V1_0 {
namespace implementation {
using ::aidl::android::hardware::automotive::occupant_awareness::BnOccupantAwareness;
using ::aidl::android::hardware::automotive::occupant_awareness::IOccupantAwarenessClientCallback;
using ::aidl::android::hardware::automotive::occupant_awareness::OccupantAwarenessStatus;
using ::aidl::android::hardware::automotive::occupant_awareness::OccupantDetections;
using ::aidl::android::hardware::automotive::occupant_awareness::Role;
/**
* The default HAL mimics a system which has no Occupant awareness capability. The hal does not
* do any useful work, and returns appropriate failure code / status.
**/
class OccupantAwareness : public BnOccupantAwareness {
public:
// Methods from ::android::hardware::automotive::occupant_awareness::IOccupantAwareness
// follow.
ndk::ScopedAStatus startDetection(OccupantAwarenessStatus* status) override;
ndk::ScopedAStatus stopDetection(OccupantAwarenessStatus* status) override;
ndk::ScopedAStatus getCapabilityForRole(Role occupantRole, int32_t* capabilities) override;
ndk::ScopedAStatus getState(Role occupantRole, int detectionCapability,
OccupantAwarenessStatus* status) override;
ndk::ScopedAStatus setCallback(
const std::shared_ptr<IOccupantAwarenessClientCallback>& callback) override;
ndk::ScopedAStatus getLatestDetection(OccupantDetections* detections) override;
private:
bool isValidRole(Role occupantRole);
bool isValidDetectionCapabilities(int detectionCapabilities);
bool isSingularCapability(int detectionCapability);
std::mutex mMutex;
std::shared_ptr<IOccupantAwarenessClientCallback> mCallback = nullptr;
OccupantAwarenessStatus mStatus = OccupantAwarenessStatus::NOT_INITIALIZED;
};
} // namespace implementation
} // namespace V1_0
} // namespace occupant_awareness
} // namespace automotive
} // namespace hardware
} // namespace android

View file

@ -0,0 +1,4 @@
service hal_occupant_awareness_default /vendor/bin/hw/android.hardware.automotive.occupant_awareness@1.0-service
class hal
user system
group system

View file

@ -0,0 +1,55 @@
/*
* 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.
*/
#define LOG_TAG "android.hardware.automotive.occupant_awareness@1.0-service"
#include <unistd.h>
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include "OccupantAwareness.h"
using ::aidl::android::hardware::automotive::occupant_awareness::IOccupantAwareness;
using ::android::hardware::automotive::occupant_awareness::V1_0::implementation::OccupantAwareness;
using ::ndk::ScopedAStatus;
using ::ndk::SharedRefBase;
const static char kOccupantAwarenessServiceName[] = "default";
int main() {
ABinderProcess_setThreadPoolMaxThreadCount(0);
LOG(INFO) << "Occupant Awareness service is starting";
std::shared_ptr<OccupantAwareness> occupantAwareness = SharedRefBase::make<OccupantAwareness>();
const std::string instance =
std::string() + IOccupantAwareness::descriptor + "/" + kOccupantAwarenessServiceName;
binder_status_t status =
AServiceManager_addService(occupantAwareness->asBinder().get(), instance.c_str());
if (status == STATUS_OK) {
LOG(INFO) << "Service " << kOccupantAwarenessServiceName << " is ready";
ABinderProcess_joinThreadPool();
} else {
LOG(ERROR) << "Could not register service " << kOccupantAwarenessServiceName
<< ", status: " << status;
}
// In normal operation, we don't expect the thread pool to exit.
LOG(ERROR) << "Occupant Awareness service is shutting down";
return 1;
}

View file

@ -49,6 +49,13 @@
<instance>default</instance> <instance>default</instance>
</interface> </interface>
</hal> </hal>
<hal format="aidl" optional="true">
<name>android.hardware.automotive.occupant_awareness</name>
<interface>
<name>IOccupantAwareness</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true"> <hal format="hidl" optional="true">
<name>android.hardware.automotive.vehicle</name> <name>android.hardware.automotive.vehicle</name>
<version>2.0</version> <version>2.0</version>