mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 20:45:31 -04:00
universal7885: format code using clang-format-15
This commit is contained in:
parent
bfcbd0d355
commit
cb072badd5
55 changed files with 3946 additions and 3783 deletions
|
|
@ -17,10 +17,11 @@
|
|||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
|
||||
|
||||
|
||||
using android::sp;
|
||||
using vendor::eureka::hardware::fmradio::V1_2::IFMRadio;
|
||||
using vendor::eureka::hardware::fmradio::V1_0::Direction;
|
||||
using vendor::eureka::hardware::fmradio::V1_1::Status;
|
||||
using vendor::eureka::hardware::fmradio::V1_2::IFMRadio;
|
||||
|
||||
// #define DEBUG
|
||||
#define TRACK_SIZE 30
|
||||
|
|
@ -35,8 +36,7 @@ int open_fm_device(){
|
|||
}
|
||||
return fd;
|
||||
}
|
||||
static int fm_radio_get_frequency(int fd, long *channel)
|
||||
{
|
||||
static int fm_radio_get_frequency(int fd, long *channel) {
|
||||
struct v4l2_frequency freq {};
|
||||
int ret;
|
||||
|
||||
|
|
@ -54,8 +54,7 @@ static int fm_radio_get_frequency(int fd, long *channel)
|
|||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
static int fm_radio_set_frequency(int fd, long channel)
|
||||
{
|
||||
static int fm_radio_set_frequency(int fd, long channel) {
|
||||
struct v4l2_frequency freq {};
|
||||
int ret;
|
||||
|
||||
|
|
@ -72,8 +71,7 @@ static int fm_radio_set_frequency(int fd, long channel)
|
|||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
static int fm_radio_set_control(int fd, unsigned int id, long val)
|
||||
{
|
||||
static int fm_radio_set_control(int fd, unsigned int id, long val) {
|
||||
struct v4l2_control ctrl {};
|
||||
int ret;
|
||||
#ifdef DEBUG
|
||||
|
|
@ -94,8 +92,9 @@ static int fm_radio_set_control(int fd, unsigned int id, long val)
|
|||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
static int fm_radio_seek_frequency(int fd, unsigned int upward, unsigned int wrap_around, unsigned int spacing)
|
||||
{
|
||||
static int fm_radio_seek_frequency(int fd, unsigned int upward,
|
||||
unsigned int wrap_around,
|
||||
unsigned int spacing) {
|
||||
struct v4l2_hw_freq_seek seek {};
|
||||
int ret;
|
||||
|
||||
|
|
@ -113,11 +112,13 @@ static int fm_radio_seek_frequency(int fd, unsigned int upward, unsigned int wra
|
|||
|
||||
return FM_SUCCESS;
|
||||
}
|
||||
static int fm_radio_channel_searching(int fd, unsigned int upward, unsigned int wrap_around, unsigned int spacing, long *channel)
|
||||
{
|
||||
static int fm_radio_channel_searching(int fd, unsigned int upward,
|
||||
unsigned int wrap_around,
|
||||
unsigned int spacing, long *channel) {
|
||||
int ret;
|
||||
|
||||
ret = fm_radio_set_control(fd, V4L2_CID_S610_SEEK_MODE, FM_TUNER_AUTONOMOUS_SEARCH_MODE);
|
||||
ret = fm_radio_set_control(fd, V4L2_CID_S610_SEEK_MODE,
|
||||
FM_TUNER_AUTONOMOUS_SEARCH_MODE);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -131,8 +132,7 @@ static int fm_radio_channel_searching(int fd, unsigned int upward, unsigned int
|
|||
|
||||
return ret;
|
||||
}
|
||||
static int fm_radio_set_tuner(int fd, unsigned int mode)
|
||||
{
|
||||
static int fm_radio_set_tuner(int fd, unsigned int mode) {
|
||||
struct v4l2_tuner tuner {};
|
||||
int ret;
|
||||
|
||||
|
|
@ -148,8 +148,7 @@ static int fm_radio_set_tuner(int fd, unsigned int mode)
|
|||
|
||||
return FM_SUCCESS;
|
||||
}
|
||||
static int fm_radio_get_tuner(int fd)
|
||||
{
|
||||
static int fm_radio_get_tuner(int fd) {
|
||||
struct v4l2_tuner tuner {};
|
||||
int ret;
|
||||
|
||||
|
|
@ -164,10 +163,10 @@ static int fm_radio_get_tuner(int fd)
|
|||
return tuner.audmode;
|
||||
}
|
||||
|
||||
static int fm_radio_set_mute(int fd, bool mute)
|
||||
{
|
||||
static int fm_radio_set_mute(int fd, bool mute) {
|
||||
int muteint = 1;
|
||||
if (mute) muteint = 0;
|
||||
if (mute)
|
||||
muteint = 0;
|
||||
int ret = fm_radio_set_control(fd, V4L2_CID_AUDIO_MUTE, muteint);
|
||||
if (ret < 0) {
|
||||
printf("FmRadioController: failed to set mute\n");
|
||||
|
|
@ -177,8 +176,7 @@ static int fm_radio_set_mute(int fd, bool mute)
|
|||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
static int fm_radio_set_volume(int fd, int volume /* 1 ~ 15 */)
|
||||
{
|
||||
static int fm_radio_set_volume(int fd, int volume /* 1 ~ 15 */) {
|
||||
int ret = fm_radio_set_control(fd, V4L2_CID_AUDIO_VOLUME, volume);
|
||||
if (ret < 0) {
|
||||
printf("FmRadioController: failed to set volume\n");
|
||||
|
|
@ -188,8 +186,9 @@ static int fm_radio_set_volume(int fd, int volume /* 1 ~ 15 */)
|
|||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
template<class C, typename T>
|
||||
bool contains(C&& c, T e) { return std::find(std::begin(c), std::end(c), e) != std::end(c); }
|
||||
template <class C, typename T> bool contains(C &&c, T e) {
|
||||
return std::find(std::begin(c), std::end(c), e) != std::end(c);
|
||||
}
|
||||
|
||||
static long fm_radio_get_freqs(int fd) {
|
||||
long ret = 0;
|
||||
|
|
@ -203,7 +202,8 @@ static long fm_radio_get_freqs(int fd){
|
|||
} else {
|
||||
fm_radio_channel_searching(fd, 1, 0, FM_CHANNEL_SPACING_50KHZ, &ret);
|
||||
}
|
||||
if (contains(tracks, ret)) break;
|
||||
if (contains(tracks, ret))
|
||||
break;
|
||||
track = ret;
|
||||
printf("Found Freq %ld\n", ret);
|
||||
}
|
||||
|
|
@ -211,8 +211,7 @@ static long fm_radio_get_freqs(int fd){
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int fm_radio_poll(int fd, struct pollfd *poll_fd)
|
||||
{
|
||||
static int fm_radio_poll(int fd, struct pollfd *poll_fd) {
|
||||
int ret;
|
||||
|
||||
poll_fd->fd = fd;
|
||||
|
|
@ -239,8 +238,7 @@ static int fm_radio_poll(int fd, struct pollfd *poll_fd)
|
|||
return FM_FAILURE - 1;
|
||||
}
|
||||
|
||||
static int fm_radio_read(int fd, unsigned char *buf)
|
||||
{
|
||||
static int fm_radio_read(int fd, unsigned char *buf) {
|
||||
int ret;
|
||||
|
||||
ret = read(fd, buf, FM_RADIO_RDS_DATA_MAX);
|
||||
|
|
@ -252,8 +250,7 @@ static int fm_radio_read(int fd, unsigned char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int fm_radio_thread(int fd)
|
||||
{
|
||||
static int fm_radio_thread(int fd) {
|
||||
struct pollfd radio_poll {};
|
||||
unsigned char read_buf[FM_RADIO_RDS_DATA_MAX];
|
||||
int ret;
|
||||
|
|
@ -273,8 +270,7 @@ static int fm_radio_thread(int fd)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
static unsigned int fm_radio_get_upperband_limit(int fd)
|
||||
{
|
||||
static unsigned int fm_radio_get_upperband_limit(int fd) {
|
||||
int ret;
|
||||
struct v4l2_tuner tuner {};
|
||||
unsigned int freq;
|
||||
|
|
@ -288,8 +284,7 @@ static unsigned int fm_radio_get_upperband_limit(int fd)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned int fm_radio_get_lowerband_limit(int fd)
|
||||
{
|
||||
static unsigned int fm_radio_get_lowerband_limit(int fd) {
|
||||
int ret;
|
||||
unsigned int freq;
|
||||
struct v4l2_tuner tuner {};
|
||||
|
|
@ -303,8 +298,7 @@ static unsigned int fm_radio_get_lowerband_limit(int fd)
|
|||
return freq;
|
||||
}
|
||||
}
|
||||
static long fm_radio_get_rmssi(int fd)
|
||||
{
|
||||
static long fm_radio_get_rmssi(int fd) {
|
||||
struct v4l2_tuner tuner {};
|
||||
int ret;
|
||||
long rmssi;
|
||||
|
|
@ -326,60 +320,61 @@ static int fm_radio_set_rssi(int fd, long rssi){
|
|||
}
|
||||
return FM_SUCCESS;
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_openFMDevice
|
||||
(__unused JNIEnv *env, __unused jobject thiz) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_openFMDevice(
|
||||
__unused JNIEnv *env, __unused jobject thiz) {
|
||||
return open_fm_device();
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFMFreq
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFMFreq(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
long freq;
|
||||
fm_radio_get_frequency(fd, &freq);
|
||||
return freq;
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMFreq
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd, jint freq) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMFreq(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd, jint freq) {
|
||||
return fm_radio_set_frequency(fd, freq);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMVolume
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd, jint volume) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMVolume(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd,
|
||||
jint volume) {
|
||||
return fm_radio_set_volume(fd, volume);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMMute
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd, jboolean mute) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMMute(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd,
|
||||
jboolean mute) {
|
||||
return fm_radio_set_mute(fd, mute);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFmUpper
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFmUpper(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
return fm_radio_get_upperband_limit(fd);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFMLower
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFMLower(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
return fm_radio_get_lowerband_limit(fd);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getRMSSI
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getRMSSI(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
return fm_radio_get_rmssi(fd);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jlongArray JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFMTracks
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jlongArray JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getFMTracks(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
fm_radio_get_freqs(fd);
|
||||
jlongArray result;
|
||||
result = (*env).NewLongArray(TRACK_SIZE);
|
||||
|
|
@ -390,28 +385,30 @@ Java_com_eurekateam_fmradio_NativeFMInterface_getFMTracks
|
|||
// fill a temp structure to use to populate the java int array
|
||||
jlong fill[TRACK_SIZE];
|
||||
for (i = 0; i < TRACK_SIZE; i++) {
|
||||
fill[i] = tracks[i]; // put whatever logic you want to populate the values here.
|
||||
fill[i] =
|
||||
tracks[i]; // put whatever logic you want to populate the values here.
|
||||
}
|
||||
// move from the temp structure to the java structure
|
||||
(*env).SetLongArrayRegion(result, 0, TRACK_SIZE, fill);
|
||||
return result;
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMStereo
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMStereo(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
return fm_radio_set_tuner(fd, 1);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMMono
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMMono(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
return fm_radio_set_tuner(fd, 0);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMThread
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd, jboolean run) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMThread(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd,
|
||||
jboolean run) {
|
||||
if (run) {
|
||||
FMThread = true;
|
||||
fm_radio_thread(fd);
|
||||
|
|
@ -421,22 +418,25 @@ Java_com_eurekateam_fmradio_NativeFMInterface_setFMThread
|
|||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMBoot
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMBoot(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd) {
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_IF_COUNT1, 4800); // SetIFCount 1
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_IF_COUNT2, 5600); // SetIFCount 2
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_SOFT_STEREO_BLEND, 3172); // Set Soft Stereo Blend
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_SOFT_MUTE_COEFF, 16); // SetSoftMuteCoeff
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_CH_BAND, S610_BAND_FM); // Set Band (To FM)
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_CH_SPACING, FM_CHANNEL_SPACING_50KHZ); // Spacing 5kHz
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_SOFT_STEREO_BLEND,
|
||||
3172); // Set Soft Stereo Blend
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_SOFT_MUTE_COEFF,
|
||||
16); // SetSoftMuteCoeff
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_CH_BAND,
|
||||
S610_BAND_FM); // Set Band (To FM)
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_CH_SPACING,
|
||||
FM_CHANNEL_SPACING_50KHZ); // Spacing 5kHz
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_RDS_ON, FM_RDS_ENABLE); // RDS on
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getNextChannel
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getNextChannel(
|
||||
__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
long ret;
|
||||
sp<IFMRadio> service = IFMRadio::getService();
|
||||
bool mSysfs = service->isAvailable() == Status::YES;
|
||||
|
|
@ -448,10 +448,9 @@ Java_com_eurekateam_fmradio_NativeFMInterface_getNextChannel
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getBeforeChannel
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getBeforeChannel(
|
||||
__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
long ret;
|
||||
sp<IFMRadio> service = IFMRadio::getService();
|
||||
bool mSysfs = service->isAvailable() == Status::YES;
|
||||
|
|
@ -464,10 +463,9 @@ Java_com_eurekateam_fmradio_NativeFMInterface_getBeforeChannel
|
|||
return ret;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getAudioChannel
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getAudioChannel(
|
||||
__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
int channel = fm_radio_get_tuner(fd);
|
||||
if (channel == V4L2_TUNER_MODE_STEREO) {
|
||||
return true; // Is EarPhones
|
||||
|
|
@ -475,28 +473,25 @@ Java_com_eurekateam_fmradio_NativeFMInterface_getAudioChannel
|
|||
return false; // Is Speaker
|
||||
}
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_stopSearching
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_stopSearching(
|
||||
__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
fm_radio_set_control(fd, V4L2_CID_S610_SEEK_CANCEL, 1);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMRSSI
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd, jlong rssi) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setFMRSSI(__unused JNIEnv *env,
|
||||
__unused jobject thiz,
|
||||
jint fd, jlong rssi) {
|
||||
return fm_radio_set_rssi(fd, rssi);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_closeFMDevice
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_closeFMDevice(
|
||||
__unused JNIEnv *env, __unused jobject thiz, jint fd) {
|
||||
close(fd);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getSysfsSupport
|
||||
(__unused JNIEnv *env, __unused jobject thiz) {
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_getSysfsSupport(
|
||||
__unused JNIEnv *env, __unused jobject thiz) {
|
||||
sp<IFMRadio> service = IFMRadio::getService();
|
||||
return service->isAvailable() == Status::YES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,20 +14,20 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <media/IAudioFlinger.h>
|
||||
#include <media/AudioSystem.h>
|
||||
#include <media/IAudioFlinger.h>
|
||||
|
||||
#define FM_FAILURE -1
|
||||
#define FM_SUCCESS 0
|
||||
#define IOHANDLE 13
|
||||
using namespace android;
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setAudioRoute
|
||||
(__unused JNIEnv *env, __unused jobject thiz, jboolean speaker) {
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setAudioRoute(
|
||||
__unused JNIEnv *env, __unused jobject thiz, jboolean speaker) {
|
||||
const sp<IAudioFlinger> &af = AudioSystem::get_audio_flinger();
|
||||
if (af == 0) return PERMISSION_DENIED;
|
||||
if (af == 0)
|
||||
return PERMISSION_DENIED;
|
||||
if (speaker) {
|
||||
af->setParameters(IOHANDLE, String8("routing=2"));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -38,17 +38,10 @@ enum fm_channel_spacing {
|
|||
};
|
||||
|
||||
/* Mute modes */
|
||||
enum fm_mute_mode {
|
||||
FM_MUTE_ON = 0,
|
||||
FM_MUTE_OFF = 1,
|
||||
FM_MUTE_ATTENUATE = 2
|
||||
};
|
||||
enum fm_mute_mode { FM_MUTE_ON = 0, FM_MUTE_OFF = 1, FM_MUTE_ATTENUATE = 2 };
|
||||
|
||||
/* FM RDS modes */
|
||||
enum fm_rds_mode {
|
||||
FM_RDS_DISABLE = 0,
|
||||
FM_RDS_ENABLE = 1
|
||||
};
|
||||
enum fm_rds_mode { FM_RDS_DISABLE = 0, FM_RDS_ENABLE = 1 };
|
||||
|
||||
#define FM_RADIO_RDS_DATA_MAX 48
|
||||
|
||||
|
|
@ -61,5 +54,3 @@ enum s610_aud_mode {
|
|||
S610_AUD_ENABLE = 1,
|
||||
S610_AUD_DISABLE = 0,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ struct v4l2_frequency {
|
|||
__u32 reserved[8];
|
||||
};
|
||||
|
||||
|
||||
struct v4l2_hw_freq_seek {
|
||||
__u32 tuner;
|
||||
__u32 type; /* enum v4l2_tuner_type */
|
||||
|
|
@ -48,7 +47,8 @@ struct v4l2_control {
|
|||
__s32 value;
|
||||
};
|
||||
/**
|
||||
* struct v4l2_capability - Describes V4L2 device caps returned by VIDIOC_QUERYCAP
|
||||
* struct v4l2_capability - Describes V4L2 device caps returned by
|
||||
* VIDIOC_QUERYCAP
|
||||
*
|
||||
* @driver: name of the driver module (e.g. "bttv")
|
||||
* @card: name of the card (e.g. "Hauppauge WinTV")
|
||||
|
|
@ -121,5 +121,3 @@ struct v4l2_buffer {
|
|||
#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
|
||||
#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE + 5)
|
||||
#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE + 9)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "jni.h"
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
#include "jni.h"
|
||||
|
||||
using android::sp;
|
||||
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
||||
|
|
@ -12,9 +12,8 @@ using vendor::eureka::hardware::parts::V1_0::SysfsType;
|
|||
|
||||
static android::sp<IBatteryStats> service = IBatteryStats::getService();
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs(JNIEnv* env,
|
||||
__unused jclass obj,
|
||||
jint enable) {
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs(
|
||||
JNIEnv *env, __unused jclass obj, jint enable) {
|
||||
if (enable == 1) {
|
||||
service->setBatteryWritable(SysfsType::CHARGE, Number::ENABLE);
|
||||
} else {
|
||||
|
|
@ -23,16 +22,15 @@ Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs(JNIEnv* env,
|
|||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getChargeSysfs(JNIEnv* env,
|
||||
__unused jclass obj) {
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getChargeSysfs(
|
||||
JNIEnv *env, __unused jclass obj) {
|
||||
int ret = service->getBatteryStats(SysfsType::CHARGE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setFastCharge(JNIEnv* env,
|
||||
__unused jobject obj,
|
||||
jint enable) {
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setFastCharge(
|
||||
JNIEnv *env, __unused jobject obj, jint enable) {
|
||||
if (enable == 1) {
|
||||
service->setBatteryWritable(SysfsType::FASTCHARGE, Number::ENABLE);
|
||||
} else {
|
||||
|
|
@ -40,15 +38,14 @@ Java_com_eurekateam_samsungextras_interfaces_Battery_setFastCharge(JNIEnv* env,
|
|||
}
|
||||
}
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getFastChargeSysfs(JNIEnv* env,
|
||||
__unused jclass obj) {
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getFastChargeSysfs(
|
||||
JNIEnv *env, __unused jclass obj) {
|
||||
int ret = service->getBatteryStats(SysfsType::FASTCHARGE);
|
||||
return ret;
|
||||
}
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getGeneralBatteryStats(JNIEnv* env,
|
||||
__unused jobject obj,
|
||||
jint id) {
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getGeneralBatteryStats(
|
||||
JNIEnv *env, __unused jobject obj, jint id) {
|
||||
/**
|
||||
* id:
|
||||
* 1 = BATTERY_CAPACITY_MAX
|
||||
|
|
|
|||
|
|
@ -1,30 +1,31 @@
|
|||
#include "jni.h"
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
#include "jni.h"
|
||||
|
||||
using android::sp;
|
||||
using vendor::eureka::hardware::parts::V1_0::Number;
|
||||
using vendor::eureka::hardware::parts::V1_0::Display;
|
||||
using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
|
||||
using vendor::eureka::hardware::parts::V1_0::Number;
|
||||
|
||||
static android::sp<IDisplayConfigs> service = IDisplayConfigs::getService();
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Display_setDT2W(JNIEnv* env, jclass clazz, jboolean enable) {
|
||||
Java_com_eurekateam_samsungextras_interfaces_Display_setDT2W(JNIEnv *env,
|
||||
jclass clazz,
|
||||
jboolean enable) {
|
||||
if (enable) {
|
||||
service->writeDisplay(Number::ENABLE,
|
||||
Display::DOUBLE_TAP);
|
||||
service->writeDisplay(Number::ENABLE, Display::DOUBLE_TAP);
|
||||
} else {
|
||||
service->writeDisplay(Number::DISABLE,
|
||||
Display::DOUBLE_TAP);
|
||||
service->writeDisplay(Number::DISABLE, Display::DOUBLE_TAP);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Display_setGloveMode(JNIEnv* env, jclass clazz, jboolean enable) {
|
||||
Java_com_eurekateam_samsungextras_interfaces_Display_setGloveMode(
|
||||
JNIEnv *env, jclass clazz, jboolean enable) {
|
||||
if (enable) {
|
||||
service->writeDisplay(Number::ENABLE, Display::GLOVE_MODE);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
#include "jni.h"
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
#include "jni.h"
|
||||
|
||||
using android::sp;
|
||||
using vendor::eureka::hardware::parts::V1_0::Device;
|
||||
using vendor::eureka::hardware::parts::V1_0::Value;
|
||||
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::Number;
|
||||
using vendor::eureka::hardware::parts::V1_0::Value;
|
||||
|
||||
static android::sp<IFlashBrightness> service = IFlashBrightness::getService();
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_eurekateam_samsungextras_interfaces_Flashlight_setFlash(
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_setFlash(
|
||||
JNIEnv *env, __unused jobject obj, jint value) {
|
||||
service->setFlashlightEnable(Number::ENABLE);
|
||||
switch (value) {
|
||||
|
|
@ -51,8 +52,10 @@ extern "C" JNIEXPORT void JNICALL Java_com_eurekateam_samsungextras_interfaces_F
|
|||
break;
|
||||
}
|
||||
}
|
||||
extern "C" JNIEXPORT jint JNICALL Java_com_eurekateam_samsungextras_interfaces_Flashlight_getFlash(
|
||||
JNIEnv* env, jobject clazz, jint isA10) {
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_getFlash(JNIEnv *env,
|
||||
jobject clazz,
|
||||
jint isA10) {
|
||||
int ret;
|
||||
if (isA10 == 1) {
|
||||
ret = service->readFlashlightstats(Device::A10);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,16 @@ static inline const char* BtmGetDefaultName() {
|
|||
char product_device[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.product.device", product_device, "");
|
||||
|
||||
if (strstr(product_device, "a10")) return "Galaxy A10";
|
||||
if (strstr(product_device, "a20e")) return "Galaxy A20e";
|
||||
if (strstr(product_device, "a20")) return "Galaxy A20";
|
||||
if (strstr(product_device, "a30")) return "Galaxy A30";
|
||||
if (strstr(product_device, "a40")) return "Galaxy A40";
|
||||
if (strstr(product_device, "a10"))
|
||||
return "Galaxy A10";
|
||||
if (strstr(product_device, "a20e"))
|
||||
return "Galaxy A20e";
|
||||
if (strstr(product_device, "a20"))
|
||||
return "Galaxy A20";
|
||||
if (strstr(product_device, "a30"))
|
||||
return "Galaxy A30";
|
||||
if (strstr(product_device, "a40"))
|
||||
return "Galaxy A40";
|
||||
// Fallback to Generic
|
||||
return "Samsung Galaxy";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static int mChannelSpacing = 3;
|
||||
|
||||
|
|
@ -66,15 +66,19 @@ Return<int32_t> FMRadio::getFreqFromSysfs(){
|
|||
}
|
||||
Return<V1_2::Space> FMRadio::getChannelSpacing() {
|
||||
switch (mChannelSpacing) {
|
||||
case 1: return V1_2::Space::CHANNEL_SPACING_10HZ;
|
||||
case 2: return V1_2::Space::CHANNEL_SPACING_20HZ;
|
||||
case 3: return V1_2::Space::CHANNEL_SPACING_30HZ;
|
||||
case 4: return V1_2::Space::CHANNEL_SPACING_40HZ;
|
||||
case 5: return V1_2::Space::CHANNEL_SPACING_50HZ;
|
||||
default: return V1_2::Space::CHANNEL_SPACING_30HZ;
|
||||
case 1:
|
||||
return V1_2::Space::CHANNEL_SPACING_10HZ;
|
||||
case 2:
|
||||
return V1_2::Space::CHANNEL_SPACING_20HZ;
|
||||
case 3:
|
||||
return V1_2::Space::CHANNEL_SPACING_30HZ;
|
||||
case 4:
|
||||
return V1_2::Space::CHANNEL_SPACING_40HZ;
|
||||
case 5:
|
||||
return V1_2::Space::CHANNEL_SPACING_50HZ;
|
||||
default:
|
||||
return V1_2::Space::CHANNEL_SPACING_30HZ;
|
||||
}
|
||||
}
|
||||
IFMRadio* FMRadio::getInstance(void) {
|
||||
return new FMRadio();
|
||||
}
|
||||
} // namespace vendor::eureka::hardware::fmradio::V1_0
|
||||
IFMRadio *FMRadio::getInstance(void) { return new FMRadio(); }
|
||||
} // namespace vendor::eureka::hardware::fmradio::V1_2
|
||||
|
|
|
|||
|
|
@ -41,4 +41,4 @@ struct FMRadio : public IFMRadio {
|
|||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IFMRadio *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
} // namespace vendor::eureka::hardware::fmradio::V1_2
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "Battery.h"
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace vendor::eureka::hardware::parts::V1_0 {
|
||||
|
||||
|
|
@ -41,7 +41,8 @@ Return<int32_t> BatteryStats::getBatteryStats(parts::V1_0::SysfsType stats) {
|
|||
filename = "/sys/class/sec/switch/afc_disable";
|
||||
break;
|
||||
case SysfsType::CHARGE:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
filename =
|
||||
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
|
|
@ -83,13 +84,15 @@ Return<void> BatteryStats::setBatteryWritable(parts::V1_0::SysfsType stats,
|
|||
FastCharge = true;
|
||||
break;
|
||||
case SysfsType::CHARGE:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
filename =
|
||||
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
break;
|
||||
}
|
||||
if (FastCharge) seteuid(ANDROID_SYSTEM_UID);
|
||||
if (FastCharge)
|
||||
seteuid(ANDROID_SYSTEM_UID);
|
||||
file.open(filename);
|
||||
int write;
|
||||
if (value == Number::ENABLE) {
|
||||
|
|
@ -99,11 +102,10 @@ Return<void> BatteryStats::setBatteryWritable(parts::V1_0::SysfsType stats,
|
|||
}
|
||||
file << write;
|
||||
file.close();
|
||||
if (FastCharge) seteuid(ANDROID_ROOT_UID);
|
||||
if (FastCharge)
|
||||
seteuid(ANDROID_ROOT_UID);
|
||||
return Void();
|
||||
}
|
||||
|
||||
IBatteryStats* BatteryStats::getInstance(void) {
|
||||
return new BatteryStats();
|
||||
}
|
||||
IBatteryStats *BatteryStats::getInstance(void) { return new BatteryStats(); }
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
#include <sstream>
|
||||
namespace vendor::eureka::hardware::parts::V1_0 {
|
||||
|
||||
Return<void> DisplayConfigs::writeDisplay(parts::V1_0::Number enable, parts::V1_0::Display type) {
|
||||
Return<void> DisplayConfigs::writeDisplay(parts::V1_0::Number enable,
|
||||
parts::V1_0::Display type) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
if (type == Display::DOUBLE_TAP) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::Void;
|
||||
|
||||
struct DisplayConfigs : public IDisplayConfigs {
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs follow.
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs
|
||||
// follow.
|
||||
Return<void> writeDisplay(Number enable, Display type);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IDisplayConfigs *getInstance(void);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ Return<void> FlashBrightness::setFlashlightWritable(parts::V1_0::Value value) {
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<int32_t> FlashBrightness::readFlashlightstats(parts::V1_0::Device device) {
|
||||
Return<int32_t>
|
||||
FlashBrightness::readFlashlightstats(parts::V1_0::Device device) {
|
||||
std::ifstream file;
|
||||
std::string value;
|
||||
int32_t intvalue;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::Void;
|
||||
|
||||
struct FlashBrightness : public IFlashBrightness {
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness follow.
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness
|
||||
// follow.
|
||||
Return<void> setFlashlightEnable(Number enable);
|
||||
Return<void> setFlashlightWritable(Value value);
|
||||
Return<int32_t> readFlashlightstats(Device device);
|
||||
|
|
|
|||
|
|
@ -14,29 +14,30 @@
|
|||
|
||||
#define LOG_TAG "vendor.eureka.hardware.parts@1.0-service"
|
||||
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
|
||||
#include "Battery.h"
|
||||
#include "FlashLight.h"
|
||||
#include "Display.h"
|
||||
#include "FlashLight.h"
|
||||
|
||||
using android::sp;
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using vendor::eureka::hardware::parts::V1_0::BatteryStats;
|
||||
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
||||
using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::DisplayConfigs;
|
||||
using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
||||
using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
|
||||
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
android::sp<IBatteryStats> mBatteryService = BatteryStats::getInstance();
|
||||
android::sp<IFlashBrightness> mFlashLightService = FlashBrightness::getInstance();
|
||||
android::sp<IFlashBrightness> mFlashLightService =
|
||||
FlashBrightness::getInstance();
|
||||
android::sp<IDisplayConfigs> mDisplayService = DisplayConfigs::getInstance();
|
||||
configureRpcThreadpool(4, true /*callerWillJoin*/);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,12 @@ namespace light {
|
|||
/*
|
||||
* Write value to path and close file.
|
||||
*/
|
||||
template <typename T>
|
||||
static void set(const std::string& path, const T& value) {
|
||||
template <typename T> static void set(const std::string &path, const T &value) {
|
||||
std::ofstream file(path);
|
||||
file << value << std::endl;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T get(const std::string& path, const T& def) {
|
||||
template <typename T> static T get(const std::string &path, const T &def) {
|
||||
std::ifstream file(path);
|
||||
T result;
|
||||
|
||||
|
|
@ -38,23 +36,25 @@ static T get(const std::string& path, const T& def) {
|
|||
}
|
||||
|
||||
Lights::Lights() {
|
||||
mLights.emplace(LightType::BACKLIGHT,
|
||||
std::bind(&Lights::handleBacklight, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::BACKLIGHT, std::bind(&Lights::handleBacklight,
|
||||
this, std::placeholders::_1));
|
||||
#ifdef BUTTON_BRIGHTNESS_NODE
|
||||
mLights.emplace(LightType::BUTTONS,
|
||||
std::bind(&Lights::handleButtons, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::BUTTONS, std::bind(&Lights::handleButtons, this,
|
||||
std::placeholders::_1));
|
||||
#endif /* BUTTON_BRIGHTNESS_NODE */
|
||||
#ifdef LED_BLINK_NODE
|
||||
mLights.emplace(LightType::BATTERY,
|
||||
std::bind(&Lights::handleBattery, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::NOTIFICATIONS,
|
||||
mLights.emplace(LightType::BATTERY, std::bind(&Lights::handleBattery, this,
|
||||
std::placeholders::_1));
|
||||
mLights.emplace(
|
||||
LightType::NOTIFICATIONS,
|
||||
std::bind(&Lights::handleNotifications, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::ATTENTION,
|
||||
std::bind(&Lights::handleAttention, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::ATTENTION, std::bind(&Lights::handleAttention,
|
||||
this, std::placeholders::_1));
|
||||
#endif /* LED_BLINK_NODE */
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Lights::setLightState(int32_t id, const HwLightState& state) {
|
||||
ndk::ScopedAStatus Lights::setLightState(int32_t id,
|
||||
const HwLightState &state) {
|
||||
LightType type = static_cast<LightType>(id);
|
||||
auto it = mLights.find(type);
|
||||
|
||||
|
|
@ -73,7 +73,8 @@ ndk::ScopedAStatus Lights::setLightState(int32_t id, const HwLightState& state)
|
|||
}
|
||||
|
||||
void Lights::handleBacklight(const HwLightState &state) {
|
||||
uint32_t max_brightness = get(PANEL_MAX_BRIGHTNESS_NODE, MAX_INPUT_BRIGHTNESS);
|
||||
uint32_t max_brightness =
|
||||
get(PANEL_MAX_BRIGHTNESS_NODE, MAX_INPUT_BRIGHTNESS);
|
||||
uint32_t brightness = rgbToBrightness(state);
|
||||
|
||||
if (max_brightness != MAX_INPUT_BRIGHTNESS) {
|
||||
|
|
@ -128,7 +129,8 @@ void Lights::setNotificationLED() {
|
|||
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
|
||||
state = mAttentionState;
|
||||
if (state.flashMode == FlashMode::HARDWARE) {
|
||||
if (state.flashOnMs > 0 && state.flashOffMs == 0) state.flashMode = FlashMode::NONE;
|
||||
if (state.flashOnMs > 0 && state.flashOffMs == 0)
|
||||
state.flashMode = FlashMode::NONE;
|
||||
state.color = 0x000000ff;
|
||||
}
|
||||
if (state.flashMode == FlashMode::NONE) {
|
||||
|
|
@ -148,8 +150,9 @@ void Lights::setNotificationLED() {
|
|||
}
|
||||
|
||||
state.color = calibrateColor(state.color & COLOR_MASK, adjusted_brightness);
|
||||
set(LED_BLINK_NODE, ::android::base::StringPrintf("0x%08x %d %d", state.color, state.flashOnMs,
|
||||
state.flashOffMs));
|
||||
set(LED_BLINK_NODE,
|
||||
::android::base::StringPrintf("0x%08x %d %d", state.color,
|
||||
state.flashOnMs, state.flashOffMs));
|
||||
|
||||
#ifdef LED_BLN_NODE
|
||||
if (bln) {
|
||||
|
|
@ -163,8 +166,8 @@ uint32_t Lights::calibrateColor(uint32_t color, int32_t brightness) {
|
|||
uint32_t green = ((color >> 8) & 0xFF) * LED_ADJUSTMENT_G;
|
||||
uint32_t blue = (color & 0xFF) * LED_ADJUSTMENT_B;
|
||||
|
||||
return (((red * brightness) / 255) << 16) + (((green * brightness) / 255) << 8) +
|
||||
((blue * brightness) / 255);
|
||||
return (((red * brightness) / 255) << 16) +
|
||||
(((green * brightness) / 255) << 8) + ((blue * brightness) / 255);
|
||||
}
|
||||
#endif /* LED_BLINK_NODE */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "samsung_lights.h"
|
||||
#include <aidl/android/hardware/light/BnLights.h>
|
||||
#include <unordered_map>
|
||||
#include "samsung_lights.h"
|
||||
|
||||
using ::aidl::android::hardware::light::HwLight;
|
||||
using ::aidl::android::hardware::light::HwLightState;
|
||||
|
|
@ -22,7 +22,8 @@ class Lights : public BnLights {
|
|||
public:
|
||||
Lights();
|
||||
|
||||
ndk::ScopedAStatus setLightState(int32_t id, const HwLightState& state) override;
|
||||
ndk::ScopedAStatus setLightState(int32_t id,
|
||||
const HwLightState &state) override;
|
||||
ndk::ScopedAStatus getLights(std::vector<HwLight> *_aidl_return) override;
|
||||
|
||||
private:
|
||||
|
|
@ -45,7 +46,8 @@ class Lights : public BnLights {
|
|||
uint32_t rgbToBrightness(const HwLightState &state);
|
||||
|
||||
std::mutex mLock;
|
||||
std::unordered_map<LightType, std::function<void(const HwLightState&)>> mLights;
|
||||
std::unordered_map<LightType, std::function<void(const HwLightState &)>>
|
||||
mLights;
|
||||
};
|
||||
|
||||
} // namespace light
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ int main() {
|
|||
std::shared_ptr<Lights> lights = ndk::SharedRefBase::make<Lights>();
|
||||
|
||||
const std::string instance = std::string() + Lights::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(lights->asBinder().get(), instance.c_str());
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(lights->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <poll.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Trace.h>
|
||||
#include <memory>
|
||||
|
||||
#include "InteractionHandler.h"
|
||||
|
||||
|
|
@ -33,26 +33,24 @@
|
|||
#define MSINSEC 1000L
|
||||
#define USINMS 1000000L
|
||||
|
||||
static const std::vector<std::string> fb_idle_patch = {"/sys/class/drm/card0/device/idle_state",
|
||||
static const std::vector<std::string> fb_idle_patch = {
|
||||
"/sys/class/drm/card0/device/idle_state",
|
||||
"/sys/class/graphics/fb0/idle_state"};
|
||||
|
||||
InteractionHandler::InteractionHandler(std::shared_ptr<HintManager> const& hint_manager)
|
||||
: mState(INTERACTION_STATE_UNINITIALIZED),
|
||||
mWaitMs(100),
|
||||
mMinDurationMs(1400),
|
||||
mMaxDurationMs(5650),
|
||||
mDurationMs(0),
|
||||
InteractionHandler::InteractionHandler(
|
||||
std::shared_ptr<HintManager> const &hint_manager)
|
||||
: mState(INTERACTION_STATE_UNINITIALIZED), mWaitMs(100),
|
||||
mMinDurationMs(1400), mMaxDurationMs(5650), mDurationMs(0),
|
||||
mHintManager(hint_manager) {}
|
||||
|
||||
InteractionHandler::~InteractionHandler() {
|
||||
Exit();
|
||||
}
|
||||
InteractionHandler::~InteractionHandler() { Exit(); }
|
||||
|
||||
static int fb_idle_open(void) {
|
||||
int fd;
|
||||
for (auto &path : fb_idle_patch) {
|
||||
fd = open(path.c_str(), O_RDONLY);
|
||||
if (fd >= 0) return fd;
|
||||
if (fd >= 0)
|
||||
return fd;
|
||||
}
|
||||
ALOGE("Unable to open fb idle state path (%d)", errno);
|
||||
return -1;
|
||||
|
|
@ -61,7 +59,8 @@ static int fb_idle_open(void) {
|
|||
bool InteractionHandler::Init() {
|
||||
std::lock_guard<std::mutex> lk(mLock);
|
||||
|
||||
if (mState != INTERACTION_STATE_UNINITIALIZED) return true;
|
||||
if (mState != INTERACTION_STATE_UNINITIALIZED)
|
||||
return true;
|
||||
|
||||
mIdleFd = fb_idle_open();
|
||||
|
||||
|
|
@ -75,14 +74,16 @@ bool InteractionHandler::Init() {
|
|||
}
|
||||
|
||||
mState = INTERACTION_STATE_IDLE;
|
||||
mThread = std::unique_ptr<std::thread>(new std::thread(&InteractionHandler::Routine, this));
|
||||
mThread = std::unique_ptr<std::thread>(
|
||||
new std::thread(&InteractionHandler::Routine, this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InteractionHandler::Exit() {
|
||||
std::unique_lock<std::mutex> lk(mLock);
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED) return;
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED)
|
||||
return;
|
||||
|
||||
AbortWaitLocked();
|
||||
mState = INTERACTION_STATE_UNINITIALIZED;
|
||||
|
|
@ -113,7 +114,8 @@ void InteractionHandler::PerfRel() {
|
|||
ATRACE_INT("interaction_lock", 0);
|
||||
}
|
||||
|
||||
size_t InteractionHandler::CalcTimespecDiffMs(struct timespec start, struct timespec end) {
|
||||
size_t InteractionHandler::CalcTimespecDiffMs(struct timespec start,
|
||||
struct timespec end) {
|
||||
size_t diff_in_us = 0;
|
||||
diff_in_us += (end.tv_sec - start.tv_sec) * MSINSEC;
|
||||
diff_in_us += (end.tv_nsec - start.tv_nsec) / USINMS;
|
||||
|
|
@ -144,8 +146,9 @@ void InteractionHandler::Acquire(int32_t duration) {
|
|||
size_t elapsed_time = CalcTimespecDiffMs(mLastTimespec, cur_timespec);
|
||||
// don't hint if previous hint's duration covers this hint's duration
|
||||
if (elapsed_time <= (mDurationMs - finalDuration)) {
|
||||
ALOGV("%s: Previous duration (%d) cover this (%d) elapsed: %lld", __func__,
|
||||
static_cast<int>(mDurationMs), static_cast<int>(finalDuration),
|
||||
ALOGV("%s: Previous duration (%d) cover this (%d) elapsed: %lld",
|
||||
__func__, static_cast<int>(mDurationMs),
|
||||
static_cast<int>(finalDuration),
|
||||
static_cast<long long>(elapsed_time));
|
||||
return;
|
||||
}
|
||||
|
|
@ -175,7 +178,8 @@ void InteractionHandler::Release() {
|
|||
uint64_t val;
|
||||
ssize_t ret = read(mEventFd, &val, sizeof(val));
|
||||
|
||||
ALOGW_IF(ret < 0, "%s: failed to clear eventfd (%zd, %d)", __func__, ret, errno);
|
||||
ALOGW_IF(ret < 0, "%s: failed to clear eventfd (%zd, %d)", __func__, ret,
|
||||
errno);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +187,8 @@ void InteractionHandler::Release() {
|
|||
void InteractionHandler::AbortWaitLocked() {
|
||||
uint64_t val = 1;
|
||||
ssize_t ret = write(mEventFd, &val, sizeof(val));
|
||||
if (ret != sizeof(val)) ALOGW("Unable to write to event fd (%zd)", ret);
|
||||
if (ret != sizeof(val))
|
||||
ALOGW("Unable to write to event fd (%zd)", ret);
|
||||
}
|
||||
|
||||
void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) {
|
||||
|
|
@ -249,7 +254,8 @@ void InteractionHandler::Routine() {
|
|||
while (true) {
|
||||
lk.lock();
|
||||
mCond.wait(lk, [&] { return mState != INTERACTION_STATE_IDLE; });
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED) return;
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED)
|
||||
return;
|
||||
mState = INTERACTION_STATE_WAITING;
|
||||
lk.unlock();
|
||||
|
||||
|
|
|
|||
|
|
@ -42,9 +42,7 @@ constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
|||
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
||||
|
||||
Power::Power(std::shared_ptr<HintManager> hm)
|
||||
: mHintManager(hm),
|
||||
mInteractionHandler(nullptr),
|
||||
mVRModeOn(false),
|
||||
: mHintManager(hm), mInteractionHandler(nullptr), mVRModeOn(false),
|
||||
mSustainedPerfModeOn(false) {
|
||||
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
|
||||
mInteractionHandler->Init();
|
||||
|
|
@ -185,13 +183,15 @@ ndk::ScopedAStatus Power::isModeSupported(Mode type, bool* _aidl_return) {
|
|||
break;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Power mode " << toString(type) << " isModeSupported: " << supported;
|
||||
LOG(INFO) << "Power mode " << toString(type)
|
||||
<< " isModeSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
||||
LOG(DEBUG) << "Power setBoost: " << toString(type) << " duration: " << durationMs;
|
||||
LOG(DEBUG) << "Power setBoost: " << toString(type)
|
||||
<< " duration: " << durationMs;
|
||||
ATRACE_INT(toString(type).c_str(), durationMs);
|
||||
switch (type) {
|
||||
case Boost::INTERACTION:
|
||||
|
|
@ -215,7 +215,8 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
|||
break;
|
||||
}
|
||||
if (durationMs > 0) {
|
||||
mHintManager->DoHint(toString(type), std::chrono::milliseconds(durationMs));
|
||||
mHintManager->DoHint(toString(type),
|
||||
std::chrono::milliseconds(durationMs));
|
||||
} else if (durationMs == 0) {
|
||||
mHintManager->DoHint(toString(type));
|
||||
} else {
|
||||
|
|
@ -229,14 +230,13 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
|||
|
||||
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
||||
LOG(INFO) << "Power boost " << toString(type) << " isBoostSupported: " << supported;
|
||||
LOG(INFO) << "Power boost " << toString(type)
|
||||
<< " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
constexpr const char* boolToString(bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
constexpr const char *boolToString(bool b) { return b ? "true" : "false"; }
|
||||
|
||||
binder_status_t Power::dump(int fd, const char **, uint32_t) {
|
||||
std::string buf(::android::base::StringPrintf(
|
||||
|
|
|
|||
|
|
@ -50,14 +50,16 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string& mode, bool enabled) {
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string& mode, bool* _aidl_return) {
|
||||
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode,
|
||||
bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(mode);
|
||||
LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::setBoost(const std::string& boost, int32_t durationMs) {
|
||||
ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost,
|
||||
int32_t durationMs) {
|
||||
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
|
||||
ATRACE_INT(boost.c_str(), durationMs);
|
||||
|
||||
|
|
@ -72,7 +74,8 @@ ndk::ScopedAStatus PowerExt::setBoost(const std::string& boost, int32_t duration
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string& boost, bool* _aidl_return) {
|
||||
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost,
|
||||
bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(boost);
|
||||
LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
|
|
|
|||
|
|
@ -32,13 +32,17 @@ namespace pixel {
|
|||
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
|
||||
class PowerExt
|
||||
: public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
|
||||
public:
|
||||
PowerExt(std::shared_ptr<HintManager> hm) : mHintManager(hm) {}
|
||||
ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
|
||||
ndk::ScopedAStatus isModeSupported(const std::string& mode, bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(const std::string& boost, int32_t durationMs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(const std::string& boost, bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus isModeSupported(const std::string &mode,
|
||||
bool *_aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(const std::string &boost,
|
||||
int32_t durationMs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(const std::string &boost,
|
||||
bool *_aidl_return) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ int main() {
|
|||
LOG(INFO) << "Pixel Power HAL AIDL Service with Extension is starting.";
|
||||
|
||||
// Parse config but do not start the looper
|
||||
std::shared_ptr<HintManager> hm = HintManager::GetFromJSON(kPowerHalConfigPath, false);
|
||||
std::shared_ptr<HintManager> hm =
|
||||
HintManager::GetFromJSON(kPowerHalConfigPath, false);
|
||||
if (!hm) {
|
||||
LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath;
|
||||
}
|
||||
|
|
@ -53,10 +54,12 @@ int main() {
|
|||
std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>(hm);
|
||||
|
||||
// attach the extension to the same binder we will be registering
|
||||
CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
|
||||
CHECK(STATUS_OK ==
|
||||
AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
|
||||
|
||||
const std::string instance = std::string() + Power::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(pw->asBinder().get(), instance.c_str());
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(pw->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
LOG(INFO) << "Pixel Power HAL AIDL Service with Extension is started.";
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,11 @@ namespace android {
|
|||
namespace hardware {
|
||||
namespace vibrator {
|
||||
|
||||
static std::map<Effect, int> CP_TRIGGER_EFFECTS {
|
||||
{ Effect::CLICK, 10 },
|
||||
static std::map<Effect, int> CP_TRIGGER_EFFECTS{{Effect::CLICK, 10},
|
||||
{Effect::DOUBLE_CLICK, 14},
|
||||
{Effect::HEAVY_CLICK, 23},
|
||||
{Effect::TEXTURE_TICK, 50},
|
||||
{ Effect::TICK, 50 }
|
||||
};
|
||||
{Effect::TICK, 50}};
|
||||
|
||||
/*
|
||||
* Write value to path and close file.
|
||||
|
|
@ -61,9 +59,11 @@ Vibrator::Vibrator() {
|
|||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) {
|
||||
*_aidl_return = IVibrator::CAP_ON_CALLBACK | IVibrator::CAP_PERFORM_CALLBACK |
|
||||
*_aidl_return =
|
||||
IVibrator::CAP_ON_CALLBACK | IVibrator::CAP_PERFORM_CALLBACK |
|
||||
IVibrator::CAP_EXTERNAL_CONTROL /*| IVibrator::CAP_COMPOSE_EFFECTS |
|
||||
IVibrator::CAP_ALWAYS_ON_CONTROL*/;
|
||||
IVibrator::CAP_ALWAYS_ON_CONTROL*/
|
||||
;
|
||||
|
||||
if (mHasTimedOutIntensity) {
|
||||
*_aidl_return = *_aidl_return | IVibrator::CAP_AMPLITUDE_CONTROL |
|
||||
|
|
@ -73,11 +73,11 @@ ndk::ScopedAStatus Vibrator::getCapabilities(int32_t* _aidl_return) {
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::off() {
|
||||
return activate(0);
|
||||
}
|
||||
ndk::ScopedAStatus Vibrator::off() { return activate(0); }
|
||||
|
||||
ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr<IVibratorCallback>& callback) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::on(int32_t timeoutMs,
|
||||
const std::shared_ptr<IVibratorCallback> &callback) {
|
||||
ndk::ScopedAStatus status;
|
||||
|
||||
if (mHasTimedOutEffect)
|
||||
|
|
@ -99,7 +99,10 @@ ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr<IVibrat
|
|||
return status;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, const std::shared_ptr<IVibratorCallback>& callback, int32_t* _aidl_return) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::perform(Effect effect, EffectStrength strength,
|
||||
const std::shared_ptr<IVibratorCallback> &callback,
|
||||
int32_t *_aidl_return) {
|
||||
ndk::ScopedAStatus status;
|
||||
uint32_t amplitude = strengthToAmplitude(strength, &status);
|
||||
uint32_t ms = 1000;
|
||||
|
|
@ -110,7 +113,8 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, con
|
|||
activate(0);
|
||||
setAmplitude(amplitude);
|
||||
|
||||
if (mHasTimedOutEffect && CP_TRIGGER_EFFECTS.find(effect) != CP_TRIGGER_EFFECTS.end()) {
|
||||
if (mHasTimedOutEffect &&
|
||||
CP_TRIGGER_EFFECTS.find(effect) != CP_TRIGGER_EFFECTS.end()) {
|
||||
writeNode(VIBRATOR_CP_TRIGGER_PATH, CP_TRIGGER_EFFECTS[effect]);
|
||||
} else {
|
||||
if (mHasTimedOutEffect)
|
||||
|
|
@ -137,15 +141,17 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, con
|
|||
return status;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect>* _aidl_return) {
|
||||
*_aidl_return = {Effect::CLICK, Effect::DOUBLE_CLICK, Effect::HEAVY_CLICK,
|
||||
Effect::TICK, Effect::TEXTURE_TICK, Effect::THUD, Effect::POP,
|
||||
Effect::RINGTONE_1, Effect::RINGTONE_2, Effect::RINGTONE_3,
|
||||
Effect::RINGTONE_4, Effect::RINGTONE_5, Effect::RINGTONE_6,
|
||||
Effect::RINGTONE_7, Effect::RINGTONE_7, Effect::RINGTONE_8,
|
||||
Effect::RINGTONE_9, Effect::RINGTONE_10, Effect::RINGTONE_11,
|
||||
Effect::RINGTONE_12, Effect::RINGTONE_13, Effect::RINGTONE_14,
|
||||
Effect::RINGTONE_15};
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getSupportedEffects(std::vector<Effect> *_aidl_return) {
|
||||
*_aidl_return = {
|
||||
Effect::CLICK, Effect::DOUBLE_CLICK, Effect::HEAVY_CLICK,
|
||||
Effect::TICK, Effect::TEXTURE_TICK, Effect::THUD,
|
||||
Effect::POP, Effect::RINGTONE_1, Effect::RINGTONE_2,
|
||||
Effect::RINGTONE_3, Effect::RINGTONE_4, Effect::RINGTONE_5,
|
||||
Effect::RINGTONE_6, Effect::RINGTONE_7, Effect::RINGTONE_7,
|
||||
Effect::RINGTONE_8, Effect::RINGTONE_9, Effect::RINGTONE_10,
|
||||
Effect::RINGTONE_11, Effect::RINGTONE_12, Effect::RINGTONE_13,
|
||||
Effect::RINGTONE_14, Effect::RINGTONE_15};
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +189,8 @@ ndk::ScopedAStatus Vibrator::setExternalControl(bool enabled) {
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getCompositionDelayMax(int32_t* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getCompositionDelayMax(int32_t * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
|
|
@ -191,23 +198,30 @@ ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t* /*_aidl_return*/) {
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimitive>* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(
|
||||
std::vector<CompositePrimitive> * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive /*primitive*/, int32_t* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getPrimitiveDuration(CompositePrimitive /*primitive*/,
|
||||
int32_t * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& /*composite*/, const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::compose(const std::vector<CompositeEffect> & /*composite*/,
|
||||
const std::shared_ptr<IVibratorCallback> & /*callback*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect>* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect> * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/, EffectStrength /*strength*/) {
|
||||
ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/,
|
||||
EffectStrength /*strength*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
|
|
@ -231,23 +245,29 @@ ndk::ScopedAStatus Vibrator::getFrequencyMinimum(float* /*_aidl_return*/) {
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getBandwidthAmplitudeMap(std::vector<float>* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getBandwidthAmplitudeMap(std::vector<float> * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getPwlePrimitiveDurationMax(int32_t* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getPwlePrimitiveDurationMax(int32_t * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getPwleCompositionSizeMax(int32_t* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getPwleCompositionSizeMax(int32_t * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedBraking(std::vector<Braking>* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::getSupportedBraking(std::vector<Braking> * /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle>& /*composite*/, const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
ndk::ScopedAStatus
|
||||
Vibrator::composePwle(const std::vector<PrimitivePwle> & /*composite*/,
|
||||
const std::shared_ptr<IVibratorCallback> & /*callback*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +280,8 @@ ndk::ScopedAStatus Vibrator::activate(uint32_t timeoutMs) {
|
|||
return writeNode(VIBRATOR_TIMEOUT_PATH, timeoutMs);
|
||||
}
|
||||
|
||||
uint8_t Vibrator::strengthToAmplitude(EffectStrength strength, ndk::ScopedAStatus* status) {
|
||||
uint8_t Vibrator::strengthToAmplitude(EffectStrength strength,
|
||||
ndk::ScopedAStatus *status) {
|
||||
*status = ndk::ScopedAStatus::ok();
|
||||
|
||||
switch (strength) {
|
||||
|
|
|
|||
|
|
@ -14,14 +14,15 @@
|
|||
|
||||
#define VIBRATOR_TIMEOUT_PATH "/sys/class/timed_output/vibrator/enable"
|
||||
#define VIBRATOR_INTENSITY_PATH "/sys/class/timed_output/vibrator/intensity"
|
||||
#define VIBRATOR_CP_TRIGGER_PATH "/sys/class/timed_output/vibrator/cp_trigger_index"
|
||||
#define VIBRATOR_CP_TRIGGER_PATH \
|
||||
"/sys/class/timed_output/vibrator/cp_trigger_index"
|
||||
|
||||
using ::aidl::android::hardware::vibrator::IVibratorCallback;
|
||||
using ::aidl::android::hardware::vibrator::Braking;
|
||||
using ::aidl::android::hardware::vibrator::Effect;
|
||||
using ::aidl::android::hardware::vibrator::EffectStrength;
|
||||
using ::aidl::android::hardware::vibrator::CompositeEffect;
|
||||
using ::aidl::android::hardware::vibrator::CompositePrimitive;
|
||||
using ::aidl::android::hardware::vibrator::Effect;
|
||||
using ::aidl::android::hardware::vibrator::EffectStrength;
|
||||
using ::aidl::android::hardware::vibrator::IVibratorCallback;
|
||||
using ::aidl::android::hardware::vibrator::PrimitivePwle;
|
||||
|
||||
namespace aidl {
|
||||
|
|
@ -34,33 +35,50 @@ public:
|
|||
Vibrator();
|
||||
ndk::ScopedAStatus getCapabilities(int32_t *_aidl_return) override;
|
||||
ndk::ScopedAStatus off() override;
|
||||
ndk::ScopedAStatus on(int32_t timeoutMs, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus perform(Effect effect, EffectStrength strength, const std::shared_ptr<IVibratorCallback>& callback, int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedEffects(std::vector<Effect>* _aidl_return) override;
|
||||
ndk::ScopedAStatus
|
||||
on(int32_t timeoutMs,
|
||||
const std::shared_ptr<IVibratorCallback> &callback) override;
|
||||
ndk::ScopedAStatus perform(Effect effect, EffectStrength strength,
|
||||
const std::shared_ptr<IVibratorCallback> &callback,
|
||||
int32_t *_aidl_return) override;
|
||||
ndk::ScopedAStatus
|
||||
getSupportedEffects(std::vector<Effect> *_aidl_return) override;
|
||||
ndk::ScopedAStatus setAmplitude(float amplitude) override;
|
||||
ndk::ScopedAStatus setExternalControl(bool enabled) override;
|
||||
ndk::ScopedAStatus getCompositionDelayMax(int32_t *_aidl_return) override;
|
||||
ndk::ScopedAStatus getCompositionSizeMax(int32_t *_aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedPrimitives(std::vector<CompositePrimitive>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive, int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus compose(const std::vector<CompositeEffect>& composite, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus getSupportedAlwaysOnEffects(std::vector<Effect>* _aidl_return) override;
|
||||
ndk::ScopedAStatus alwaysOnEnable(int32_t id, Effect effect, EffectStrength strength) override;
|
||||
ndk::ScopedAStatus getSupportedPrimitives(
|
||||
std::vector<CompositePrimitive> *_aidl_return) override;
|
||||
ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive,
|
||||
int32_t *_aidl_return) override;
|
||||
ndk::ScopedAStatus
|
||||
compose(const std::vector<CompositeEffect> &composite,
|
||||
const std::shared_ptr<IVibratorCallback> &callback) override;
|
||||
ndk::ScopedAStatus
|
||||
getSupportedAlwaysOnEffects(std::vector<Effect> *_aidl_return) override;
|
||||
ndk::ScopedAStatus alwaysOnEnable(int32_t id, Effect effect,
|
||||
EffectStrength strength) override;
|
||||
ndk::ScopedAStatus alwaysOnDisable(int32_t id) override;
|
||||
ndk::ScopedAStatus getResonantFrequency(float *_aidl_return) override;
|
||||
ndk::ScopedAStatus getQFactor(float *_aidl_return) override;
|
||||
ndk::ScopedAStatus getFrequencyResolution(float *_aidl_return) override;
|
||||
ndk::ScopedAStatus getFrequencyMinimum(float *_aidl_return) override;
|
||||
ndk::ScopedAStatus getBandwidthAmplitudeMap(std::vector<float>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPwlePrimitiveDurationMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus
|
||||
getBandwidthAmplitudeMap(std::vector<float> *_aidl_return) override;
|
||||
ndk::ScopedAStatus
|
||||
getPwlePrimitiveDurationMax(int32_t *_aidl_return) override;
|
||||
ndk::ScopedAStatus getPwleCompositionSizeMax(int32_t *_aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedBraking(std::vector<Braking>* _aidl_return) override;
|
||||
ndk::ScopedAStatus composePwle(const std::vector<PrimitivePwle>& composite, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus
|
||||
getSupportedBraking(std::vector<Braking> *_aidl_return) override;
|
||||
ndk::ScopedAStatus
|
||||
composePwle(const std::vector<PrimitivePwle> &composite,
|
||||
const std::shared_ptr<IVibratorCallback> &callback) override;
|
||||
|
||||
private:
|
||||
ndk::ScopedAStatus activate(uint32_t ms);
|
||||
static uint32_t effectToMs(Effect effect, ndk::ScopedAStatus *status);
|
||||
static uint8_t strengthToAmplitude(EffectStrength strength, ndk::ScopedAStatus* status);
|
||||
static uint8_t strengthToAmplitude(EffectStrength strength,
|
||||
ndk::ScopedAStatus *status);
|
||||
|
||||
bool mEnabled{false};
|
||||
bool mExternalControl{false};
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include "Vibrator.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
using ::aidl::android::hardware::vibrator::Vibrator;
|
||||
|
||||
|
|
@ -16,8 +16,10 @@ int main() {
|
|||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<Vibrator> vibrator = ndk::SharedRefBase::make<Vibrator>();
|
||||
|
||||
const std::string instance = std::string() + Vibrator::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(vibrator->asBinder().get(), instance.c_str());
|
||||
const std::string instance =
|
||||
std::string() + Vibrator::descriptor + "/default";
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(vibrator->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@
|
|||
using ::android::NO_ERROR;
|
||||
using ::android::OK;
|
||||
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
const int kMaxCameraIdLen = 16;
|
||||
|
||||
SamsungCameraProvider::SamsungCameraProvider() : LegacyCameraProviderImpl_2_5() {
|
||||
SamsungCameraProvider::SamsungCameraProvider()
|
||||
: LegacyCameraProviderImpl_2_5() {
|
||||
mExtraIDs.push_back(50);
|
||||
mDisabledIDs.push_back(2);
|
||||
if (!mInitFailed) {
|
||||
|
|
@ -68,18 +69,22 @@ Return<void> SamsungCameraProvider::getCameraIdList(
|
|||
std::vector<hidl_string> deviceNameList;
|
||||
for (auto const &deviceNamePair : mCameraDeviceNames) {
|
||||
int id = std::stoi(deviceNamePair.first);
|
||||
if (id >= mNumberOfLegacyCameras || std::find(mDisabledIDs.begin(), mDisabledIDs.end(), id) != mDisabledIDs.end()) {
|
||||
// External camera devices must be reported through the device status change callback,
|
||||
// not in this list.
|
||||
// Linux4: Also skip disabled camera IDs.
|
||||
if (id >= mNumberOfLegacyCameras ||
|
||||
std::find(mDisabledIDs.begin(), mDisabledIDs.end(), id) !=
|
||||
mDisabledIDs.end()) {
|
||||
// External camera devices must be reported through the device status
|
||||
// change callback, not in this list. Linux4: Also skip disabled camera
|
||||
// IDs.
|
||||
continue;
|
||||
}
|
||||
if (mCameraStatusMap[deviceNamePair.first] == CAMERA_DEVICE_STATUS_PRESENT) {
|
||||
if (mCameraStatusMap[deviceNamePair.first] ==
|
||||
CAMERA_DEVICE_STATUS_PRESENT) {
|
||||
deviceNameList.push_back(deviceNamePair.second);
|
||||
}
|
||||
}
|
||||
hidl_vec<hidl_string> hidlDeviceNameList(deviceNameList);
|
||||
_hidl_cb(::android::hardware::camera::common::V1_0::Status::OK, hidlDeviceNameList);
|
||||
_hidl_cb(::android::hardware::camera::common::V1_0::Status::OK,
|
||||
hidlDeviceNameList);
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@
|
|||
|
||||
#define SAMSUNG_CAMERA_DEBUG
|
||||
|
||||
using ::android::hardware::camera::provider::V2_5::ICameraProvider;
|
||||
using ::android::hardware::camera::provider::V2_5::implementation::LegacyCameraProviderImpl_2_5;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::camera::provider::V2_5::ICameraProvider;
|
||||
using ::android::hardware::camera::provider::V2_5::implementation::
|
||||
LegacyCameraProviderImpl_2_5;
|
||||
|
||||
class SamsungCameraProvider : public LegacyCameraProviderImpl_2_5 {
|
||||
public:
|
||||
|
|
@ -30,6 +31,7 @@ public:
|
|||
~SamsungCameraProvider();
|
||||
|
||||
Return<void> getCameraIdList(ICameraProvider::getCameraIdList_cb _hidl_cb);
|
||||
|
||||
private:
|
||||
std::vector<int> mExtraIDs;
|
||||
std::vector<int> mDisabledIDs;
|
||||
|
|
|
|||
|
|
@ -28,19 +28,20 @@
|
|||
using android::status_t;
|
||||
using android::hardware::camera::provider::V2_5::ICameraProvider;
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
using namespace android::hardware::camera::provider::V2_5::implementation;
|
||||
|
||||
ALOGI("CameraProvider@2.5 legacy service is starting.");
|
||||
|
||||
::android::hardware::configureRpcThreadpool(/*threads*/ HWBINDER_THREAD_COUNT, /*willJoin*/ true);
|
||||
::android::hardware::configureRpcThreadpool(/*threads*/ HWBINDER_THREAD_COUNT,
|
||||
/*willJoin*/ true);
|
||||
|
||||
::android::sp<ICameraProvider> provider = new CameraProvider<SamsungCameraProvider>();
|
||||
::android::sp<ICameraProvider> provider =
|
||||
new CameraProvider<SamsungCameraProvider>();
|
||||
|
||||
status_t status = provider->registerAsService("legacy/0");
|
||||
LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering provider service: %d",
|
||||
status);
|
||||
LOG_ALWAYS_FATAL_IF(status != android::OK,
|
||||
"Error while registering provider service: %d", status);
|
||||
|
||||
::android::hardware::joinRpcThreadpool();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
#include <hardware/hw_auth_token.h>
|
||||
|
||||
#include "BiometricsFingerprint.h"
|
||||
#include <hardware/fingerprint.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include "BiometricsFingerprint.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <fstream>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef HAS_FINGERPRINT_GESTURES
|
||||
#include <fcntl.h>
|
||||
|
|
@ -39,7 +39,8 @@ namespace fingerprint {
|
|||
namespace V2_3 {
|
||||
namespace implementation {
|
||||
|
||||
using RequestStatus = android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
using RequestStatus =
|
||||
android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
|
||||
BiometricsFingerprint *BiometricsFingerprint::sInstance = nullptr;
|
||||
|
||||
|
|
@ -58,7 +59,8 @@ BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr) {
|
|||
return;
|
||||
}
|
||||
|
||||
int err = ioctl(uinputFd, UI_SET_EVBIT, EV_KEY) | ioctl(uinputFd, UI_SET_KEYBIT, KEY_UP) |
|
||||
int err = ioctl(uinputFd, UI_SET_EVBIT, EV_KEY) |
|
||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_UP) |
|
||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_DOWN);
|
||||
if (err != 0) {
|
||||
LOG(ERROR) << "Unable to enable key events";
|
||||
|
|
@ -99,13 +101,12 @@ Return<bool> BiometricsFingerprint::isUdfps(uint32_t) {
|
|||
return false;
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) {
|
||||
Return<void> BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float,
|
||||
float) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerUp() {
|
||||
return Void();
|
||||
}
|
||||
Return<void> BiometricsFingerprint::onFingerUp() { return Void(); }
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::ErrorFilter(int32_t error) {
|
||||
switch (error) {
|
||||
|
|
@ -134,14 +135,16 @@ Return<RequestStatus> BiometricsFingerprint::ErrorFilter(int32_t error) {
|
|||
case -110:
|
||||
return RequestStatus::SYS_ETIMEDOUT;
|
||||
default:
|
||||
LOG(ERROR) << "An unknown error returned from fingerprint vendor library: " << error;
|
||||
LOG(ERROR) << "An unknown error returned from fingerprint vendor library: "
|
||||
<< error;
|
||||
return RequestStatus::SYS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// Translate from errors returned by traditional HAL (see fingerprint.h) to
|
||||
// HIDL-compliant FingerprintError.
|
||||
FingerprintError BiometricsFingerprint::VendorErrorFilter(int32_t error, int32_t* vendorCode) {
|
||||
FingerprintError BiometricsFingerprint::VendorErrorFilter(int32_t error,
|
||||
int32_t *vendorCode) {
|
||||
*vendorCode = 0;
|
||||
switch (error) {
|
||||
case FINGERPRINT_ERROR_HW_UNAVAILABLE:
|
||||
|
|
@ -171,8 +174,8 @@ FingerprintError BiometricsFingerprint::VendorErrorFilter(int32_t error, int32_t
|
|||
|
||||
// Translate acquired messages returned by traditional HAL (see fingerprint.h)
|
||||
// to HIDL-compliant FingerprintAcquiredInfo.
|
||||
FingerprintAcquiredInfo BiometricsFingerprint::VendorAcquiredFilter(int32_t info,
|
||||
int32_t* vendorCode) {
|
||||
FingerprintAcquiredInfo
|
||||
BiometricsFingerprint::VendorAcquiredFilter(int32_t info, int32_t *vendorCode) {
|
||||
*vendorCode = 0;
|
||||
switch (info) {
|
||||
case FINGERPRINT_ACQUIRED_GOOD:
|
||||
|
|
@ -213,9 +216,11 @@ Return<uint64_t> BiometricsFingerprint::preEnroll() {
|
|||
return ss_fingerprint_pre_enroll();
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat,
|
||||
uint32_t gid, uint32_t timeoutSec) {
|
||||
const hw_auth_token_t* authToken = reinterpret_cast<const hw_auth_token_t*>(hat.data());
|
||||
Return<RequestStatus>
|
||||
BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69> &hat, uint32_t gid,
|
||||
uint32_t timeoutSec) {
|
||||
const hw_auth_token_t *authToken =
|
||||
reinterpret_cast<const hw_auth_token_t *>(hat.data());
|
||||
|
||||
return ErrorFilter(ss_fingerprint_enroll(authToken, gid, timeoutSec));
|
||||
}
|
||||
|
|
@ -251,11 +256,13 @@ Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
|||
return RequestStatus::SYS_UNKNOWN;
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
|
||||
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid,
|
||||
uint32_t fid) {
|
||||
return ErrorFilter(ss_fingerprint_remove(gid, fid));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
||||
Return<RequestStatus>
|
||||
BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
||||
const hidl_string &storePath) {
|
||||
if (storePath.size() >= PATH_MAX || storePath.size() <= 0) {
|
||||
LOG(ERROR) << "Bad path length: " << storePath.size();
|
||||
|
|
@ -269,7 +276,8 @@ Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
|||
return ErrorFilter(ss_fingerprint_set_active_group(gid, storePath.c_str()));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) {
|
||||
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId,
|
||||
uint32_t gid) {
|
||||
return ErrorFilter(ss_fingerprint_authenticate(operationId, gid));
|
||||
}
|
||||
|
||||
|
|
@ -287,28 +295,34 @@ bool BiometricsFingerprint::openHal() {
|
|||
|
||||
ss_fingerprint_close = reinterpret_cast<typeof(ss_fingerprint_close)>(
|
||||
dlsym(handle, "ss_fingerprint_close"));
|
||||
ss_fingerprint_open =
|
||||
reinterpret_cast<typeof(ss_fingerprint_open)>(dlsym(handle, "ss_fingerprint_open"));
|
||||
ss_fingerprint_open = reinterpret_cast<typeof(ss_fingerprint_open)>(
|
||||
dlsym(handle, "ss_fingerprint_open"));
|
||||
|
||||
ss_set_notify_callback = reinterpret_cast<typeof(ss_set_notify_callback)>(
|
||||
dlsym(handle, "ss_set_notify_callback"));
|
||||
ss_fingerprint_pre_enroll = reinterpret_cast<typeof(ss_fingerprint_pre_enroll)>(
|
||||
ss_fingerprint_pre_enroll =
|
||||
reinterpret_cast<typeof(ss_fingerprint_pre_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_pre_enroll"));
|
||||
ss_fingerprint_enroll = reinterpret_cast<typeof(ss_fingerprint_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_enroll"));
|
||||
ss_fingerprint_post_enroll = reinterpret_cast<typeof(ss_fingerprint_post_enroll)>(
|
||||
ss_fingerprint_post_enroll =
|
||||
reinterpret_cast<typeof(ss_fingerprint_post_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_post_enroll"));
|
||||
ss_fingerprint_get_auth_id = reinterpret_cast<typeof(ss_fingerprint_get_auth_id)>(
|
||||
ss_fingerprint_get_auth_id =
|
||||
reinterpret_cast<typeof(ss_fingerprint_get_auth_id)>(
|
||||
dlsym(handle, "ss_fingerprint_get_auth_id"));
|
||||
ss_fingerprint_cancel = reinterpret_cast<typeof(ss_fingerprint_cancel)>(
|
||||
dlsym(handle, "ss_fingerprint_cancel"));
|
||||
ss_fingerprint_enumerate = reinterpret_cast<typeof(ss_fingerprint_enumerate)>(
|
||||
ss_fingerprint_enumerate =
|
||||
reinterpret_cast<typeof(ss_fingerprint_enumerate)>(
|
||||
dlsym(handle, "ss_fingerprint_enumerate"));
|
||||
ss_fingerprint_remove = reinterpret_cast<typeof(ss_fingerprint_remove)>(
|
||||
dlsym(handle, "ss_fingerprint_remove"));
|
||||
ss_fingerprint_set_active_group = reinterpret_cast<typeof(ss_fingerprint_set_active_group)>(
|
||||
ss_fingerprint_set_active_group =
|
||||
reinterpret_cast<typeof(ss_fingerprint_set_active_group)>(
|
||||
dlsym(handle, "ss_fingerprint_set_active_group"));
|
||||
ss_fingerprint_authenticate = reinterpret_cast<typeof(ss_fingerprint_authenticate)>(
|
||||
ss_fingerprint_authenticate =
|
||||
reinterpret_cast<typeof(ss_fingerprint_authenticate)>(
|
||||
dlsym(handle, "ss_fingerprint_authenticate"));
|
||||
ss_fingerprint_request = reinterpret_cast<typeof(ss_fingerprint_request)>(
|
||||
dlsym(handle, "ss_fingerprint_request"));
|
||||
|
|
@ -319,7 +333,8 @@ bool BiometricsFingerprint::openHal() {
|
|||
}
|
||||
|
||||
if ((err = ss_set_notify_callback(BiometricsFingerprint::notify)) != 0) {
|
||||
LOG(ERROR) << "Can't register fingerprint module callback, error: " << err;
|
||||
LOG(ERROR) << "Can't register fingerprint module callback, error: "
|
||||
<< err;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -330,11 +345,12 @@ bool BiometricsFingerprint::openHal() {
|
|||
}
|
||||
|
||||
void BiometricsFingerprint::notify(const fingerprint_msg_t *msg) {
|
||||
BiometricsFingerprint* thisPtr =
|
||||
static_cast<BiometricsFingerprint*>(BiometricsFingerprint::getInstance());
|
||||
BiometricsFingerprint *thisPtr = static_cast<BiometricsFingerprint *>(
|
||||
BiometricsFingerprint::getInstance());
|
||||
std::lock_guard<std::mutex> lock(thisPtr->mClientCallbackMutex);
|
||||
if (thisPtr == nullptr || thisPtr->mClientCallback == nullptr) {
|
||||
LOG(ERROR) << "Receiving callbacks before the client callback is registered.";
|
||||
LOG(ERROR)
|
||||
<< "Receiving callbacks before the client callback is registered.";
|
||||
return;
|
||||
}
|
||||
const uint64_t devId = 1;
|
||||
|
|
@ -356,7 +372,8 @@ void BiometricsFingerprint::notify(const fingerprint_msg_t* msg) {
|
|||
FingerprintAcquiredInfo result =
|
||||
VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode);
|
||||
LOG(DEBUG) << "onAcquired(" << static_cast<int>(result) << ")";
|
||||
if (!thisPtr->mClientCallback->onAcquired(devId, result, vendorCode).isOk()) {
|
||||
if (!thisPtr->mClientCallback->onAcquired(devId, result, vendorCode)
|
||||
.isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onAcquired callback";
|
||||
}
|
||||
} break;
|
||||
|
|
@ -397,7 +414,8 @@ void BiometricsFingerprint::notify(const fingerprint_msg_t* msg) {
|
|||
LOG(DEBUG) << "onAuthenticated(fid=" << msg->data.authenticated.finger.fid
|
||||
<< ", gid=" << msg->data.authenticated.finger.gid << ")";
|
||||
if (msg->data.authenticated.finger.fid != 0) {
|
||||
const uint8_t* hat = reinterpret_cast<const uint8_t*>(&msg->data.authenticated.hat);
|
||||
const uint8_t *hat =
|
||||
reinterpret_cast<const uint8_t *>(&msg->data.authenticated.hat);
|
||||
const hidl_vec<uint8_t> token(
|
||||
std::vector<uint8_t>(hat, hat + sizeof(msg->data.authenticated.hat)));
|
||||
if (!thisPtr->mClientCallback
|
||||
|
|
@ -438,7 +456,8 @@ void BiometricsFingerprint::handleEvent(int eventCode) {
|
|||
case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_DOWN:
|
||||
case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP:
|
||||
struct input_event event {};
|
||||
int keycode = eventCode == SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP ? KEY_UP : KEY_DOWN;
|
||||
int keycode =
|
||||
eventCode == SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP ? KEY_UP : KEY_DOWN;
|
||||
int err;
|
||||
|
||||
// Report the key
|
||||
|
|
@ -488,7 +507,8 @@ void BiometricsFingerprint::handleEvent(int eventCode) {
|
|||
int BiometricsFingerprint::request(int cmd, int param) {
|
||||
// TO-DO: input, output handling not implemented
|
||||
int result = ss_fingerprint_request(cmd, nullptr, 0, nullptr, 0, param);
|
||||
LOG(INFO) << "request(cmd=" << cmd << ", param=" << param << ", result=" << result << ")";
|
||||
LOG(INFO) << "request(cmd=" << cmd << ", param=" << param
|
||||
<< ", result=" << result << ")";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,14 @@ using ::android::hardware::hidl_string;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::
|
||||
FingerprintAcquiredInfo;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintError;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::
|
||||
IBiometricsFingerprintClientCallback;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_3::
|
||||
IBiometricsFingerprint;
|
||||
|
||||
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||
BiometricsFingerprint();
|
||||
|
|
@ -60,7 +63,8 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|||
// Method to wrap legacy HAL with BiometricsFingerprint class
|
||||
static IBiometricsFingerprint *getInstance();
|
||||
|
||||
// Methods from ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint
|
||||
// Methods from
|
||||
// ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint
|
||||
// follow.
|
||||
Return<uint64_t> setNotify(
|
||||
const sp<IBiometricsFingerprintClientCallback> &clientCallback) override;
|
||||
|
|
@ -72,10 +76,13 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|||
Return<RequestStatus> cancel() override;
|
||||
Return<RequestStatus> enumerate() override;
|
||||
Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
|
||||
Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
|
||||
Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
|
||||
Return<RequestStatus> setActiveGroup(uint32_t gid,
|
||||
const hidl_string &storePath) override;
|
||||
Return<RequestStatus> authenticate(uint64_t operationId,
|
||||
uint32_t gid) override;
|
||||
Return<bool> isUdfps(uint32_t sensorID) override;
|
||||
Return<void> onFingerDown(uint32_t x, uint32_t y, float minor, float major) override;
|
||||
Return<void> onFingerDown(uint32_t x, uint32_t y, float minor,
|
||||
float major) override;
|
||||
Return<void> onFingerUp() override;
|
||||
Return<void> onShowUdfpsOverlay() { return Void(); }
|
||||
Return<void> onHideUdfpsOverlay() { return Void(); }
|
||||
|
|
@ -83,13 +90,16 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|||
private:
|
||||
bool openHal();
|
||||
int request(int cmd, int param);
|
||||
int waitForSensor(std::chrono::milliseconds pollWait, std::chrono::milliseconds timeOut);
|
||||
static void notify(
|
||||
const fingerprint_msg_t* msg); /* Static callback for legacy HAL implementation */
|
||||
int waitForSensor(std::chrono::milliseconds pollWait,
|
||||
std::chrono::milliseconds timeOut);
|
||||
static void
|
||||
notify(const fingerprint_msg_t
|
||||
*msg); /* Static callback for legacy HAL implementation */
|
||||
void handleEvent(int eventCode);
|
||||
static Return<RequestStatus> ErrorFilter(int32_t error);
|
||||
static FingerprintError VendorErrorFilter(int32_t error, int32_t *vendorCode);
|
||||
static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
|
||||
static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error,
|
||||
int32_t *vendorCode);
|
||||
static BiometricsFingerprint *sInstance;
|
||||
|
||||
std::mutex mClientCallbackMutex;
|
||||
|
|
@ -104,7 +114,8 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|||
|
||||
int (*ss_set_notify_callback)(fingerprint_notify_t notify);
|
||||
uint64_t (*ss_fingerprint_pre_enroll)();
|
||||
int (*ss_fingerprint_enroll)(const hw_auth_token_t* hat, uint32_t gid, uint32_t timeout_sec);
|
||||
int (*ss_fingerprint_enroll)(const hw_auth_token_t *hat, uint32_t gid,
|
||||
uint32_t timeout_sec);
|
||||
int (*ss_fingerprint_post_enroll)();
|
||||
uint64_t (*ss_fingerprint_get_auth_id)();
|
||||
int (*ss_fingerprint_cancel)();
|
||||
|
|
@ -112,7 +123,8 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|||
int (*ss_fingerprint_remove)(uint32_t gid, uint32_t fid);
|
||||
int (*ss_fingerprint_set_active_group)(uint32_t gid, const char *store_path);
|
||||
int (*ss_fingerprint_authenticate)(uint64_t operation_id, uint32_t gid);
|
||||
int (*ss_fingerprint_request)(uint32_t cmd, char* inBuf, uint32_t inBuf_length, char* outBuf,
|
||||
int (*ss_fingerprint_request)(uint32_t cmd, char *inBuf,
|
||||
uint32_t inBuf_length, char *outBuf,
|
||||
uint32_t outBuf_length, uint32_t param);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,13 +26,15 @@ using android::hardware::configureRpcThreadpool;
|
|||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
using android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
|
||||
using android::hardware::biometrics::fingerprint::V2_3::implementation::BiometricsFingerprint;
|
||||
using android::hardware::biometrics::fingerprint::V2_3::implementation::
|
||||
BiometricsFingerprint;
|
||||
|
||||
using android::OK;
|
||||
using android::sp;
|
||||
|
||||
int main() {
|
||||
android::sp<IBiometricsFingerprint> bio = BiometricsFingerprint::getInstance();
|
||||
android::sp<IBiometricsFingerprint> bio =
|
||||
BiometricsFingerprint::getInstance();
|
||||
|
||||
configureRpcThreadpool(1, true);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
// #define VERBOSE
|
||||
|
||||
#include "Sensors.h"
|
||||
#include <sensors/convert.h>
|
||||
#include "multihal.h"
|
||||
#include <sensors/convert.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
|
|
@ -55,12 +55,14 @@ static Result ResultFromStatus(status_t err) {
|
|||
}
|
||||
}
|
||||
|
||||
Sensors::Sensors() : mInitCheck(NO_INIT), mSensorModule(nullptr), mSensorDevice(nullptr) {
|
||||
Sensors::Sensors()
|
||||
: mInitCheck(NO_INIT), mSensorModule(nullptr), mSensorDevice(nullptr) {
|
||||
status_t err = OK;
|
||||
if (UseMultiHal()) {
|
||||
mSensorModule = ::get_multi_hal_module_info();
|
||||
} else {
|
||||
err = hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&mSensorModule);
|
||||
err = hw_get_module(SENSORS_HARDWARE_MODULE_ID,
|
||||
(hw_module_t const **)&mSensorModule);
|
||||
}
|
||||
if (mSensorModule == NULL) {
|
||||
err = UNKNOWN_ERROR;
|
||||
|
|
@ -77,8 +79,8 @@ Sensors::Sensors() : mInitCheck(NO_INIT), mSensorModule(nullptr), mSensorDevice(
|
|||
err = sensors_open_1(&mSensorModule->common, &mSensorDevice);
|
||||
|
||||
if (err != OK) {
|
||||
LOG(ERROR) << "Couldn't open device for module " << SENSORS_HARDWARE_MODULE_ID << " ("
|
||||
<< strerror(-err) << ")";
|
||||
LOG(ERROR) << "Couldn't open device for module "
|
||||
<< SENSORS_HARDWARE_MODULE_ID << " (" << strerror(-err) << ")";
|
||||
|
||||
mInitCheck = err;
|
||||
return;
|
||||
|
|
@ -90,10 +92,12 @@ Sensors::Sensors() : mInitCheck(NO_INIT), mSensorModule(nullptr), mSensorDevice(
|
|||
|
||||
if (getHalDeviceVersion() == SENSORS_DEVICE_API_VERSION_1_4) {
|
||||
if (mSensorDevice->inject_sensor_data == nullptr) {
|
||||
LOG(ERROR) << "HAL specifies version 1.4, but does not implement inject_sensor_data()";
|
||||
LOG(ERROR) << "HAL specifies version 1.4, but does not implement "
|
||||
"inject_sensor_data()";
|
||||
}
|
||||
if (mSensorModule->set_operation_mode == nullptr) {
|
||||
LOG(ERROR) << "HAL specifies version 1.4, but does not implement set_operation_mode()";
|
||||
LOG(ERROR) << "HAL specifies version 1.4, but does not implement "
|
||||
"set_operation_mode()";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,9 +107,7 @@ Sensors::Sensors() : mInitCheck(NO_INIT), mSensorModule(nullptr), mSensorDevice(
|
|||
mInitCheck = OK;
|
||||
}
|
||||
|
||||
status_t Sensors::initCheck() const {
|
||||
return mInitCheck;
|
||||
}
|
||||
status_t Sensors::initCheck() const { return mInitCheck; }
|
||||
|
||||
Return<void> Sensors::getSensorsList(getSensorsList_cb _hidl_cb) {
|
||||
sensor_t const *list;
|
||||
|
|
@ -164,7 +166,8 @@ Return<Result> Sensors::setOperationMode(OperationMode mode) {
|
|||
|
||||
Return<Result> Sensors::activate(int32_t sensor_handle, bool enabled) {
|
||||
return ResultFromStatus(mSensorDevice->activate(
|
||||
reinterpret_cast<sensors_poll_device_t*>(mSensorDevice), sensor_handle, enabled));
|
||||
reinterpret_cast<sensors_poll_device_t *>(mSensorDevice), sensor_handle,
|
||||
enabled));
|
||||
}
|
||||
|
||||
Return<void> Sensors::poll(int32_t maxCount, poll_cb _hidl_cb) {
|
||||
|
|
@ -176,29 +179,33 @@ Return<void> Sensors::poll(int32_t maxCount, poll_cb _hidl_cb) {
|
|||
|
||||
{ // scope of reentry lock
|
||||
|
||||
// This enforces a single client, meaning that a maximum of one client can call poll().
|
||||
// If this function is re-entred, it means that we are stuck in a state that may prevent
|
||||
// the system from proceeding normally.
|
||||
// This enforces a single client, meaning that a maximum of one client can
|
||||
// call poll(). If this function is re-entred, it means that we are stuck in
|
||||
// a state that may prevent the system from proceeding normally.
|
||||
//
|
||||
// Exit and let the system restart the sensor-hal-implementation hidl service.
|
||||
// Exit and let the system restart the sensor-hal-implementation hidl
|
||||
// service.
|
||||
//
|
||||
// This function must not call _hidl_cb(...) or return until there is no risk of blocking.
|
||||
// This function must not call _hidl_cb(...) or return until there is no
|
||||
// risk of blocking.
|
||||
std::unique_lock<std::mutex> lock(mPollLock, std::try_to_lock);
|
||||
if (!lock.owns_lock()) {
|
||||
// cannot get the lock, hidl service will go into deadlock if it is not restarted.
|
||||
// This is guaranteed to not trigger in passthrough mode.
|
||||
LOG(ERROR)
|
||||
<< "ISensors::poll() re-entry. I do not know what to do except killing myself.";
|
||||
// cannot get the lock, hidl service will go into deadlock if it is not
|
||||
// restarted. This is guaranteed to not trigger in passthrough mode.
|
||||
LOG(ERROR) << "ISensors::poll() re-entry. I do not know what to do "
|
||||
"except killing myself.";
|
||||
::exit(-1);
|
||||
}
|
||||
|
||||
if (maxCount <= 0) {
|
||||
err = android::BAD_VALUE;
|
||||
} else {
|
||||
int bufferSize = maxCount <= kPollMaxBufferSize ? maxCount : kPollMaxBufferSize;
|
||||
int bufferSize =
|
||||
maxCount <= kPollMaxBufferSize ? maxCount : kPollMaxBufferSize;
|
||||
data.reset(new sensors_event_t[bufferSize]);
|
||||
err = mSensorDevice->poll(reinterpret_cast<sensors_poll_device_t*>(mSensorDevice),
|
||||
data.get(), bufferSize);
|
||||
err = mSensorDevice->poll(
|
||||
reinterpret_cast<sensors_poll_device_t *>(mSensorDevice), data.get(),
|
||||
bufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +248,8 @@ Return<void> Sensors::poll(int32_t maxCount, poll_cb _hidl_cb) {
|
|||
|
||||
Return<Result> Sensors::batch(int32_t sensor_handle, int64_t sampling_period_ns,
|
||||
int64_t max_report_latency_ns) {
|
||||
return ResultFromStatus(mSensorDevice->batch(mSensorDevice, sensor_handle, 0, /*flags*/
|
||||
return ResultFromStatus(
|
||||
mSensorDevice->batch(mSensorDevice, sensor_handle, 0, /*flags*/
|
||||
sampling_period_ns, max_report_latency_ns));
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +266,8 @@ Return<Result> Sensors::injectSensorData(const Event& event) {
|
|||
sensors_event_t out;
|
||||
convertToSensorEvent(event, &out);
|
||||
|
||||
return ResultFromStatus(mSensorDevice->inject_sensor_data(mSensorDevice, &out));
|
||||
return ResultFromStatus(
|
||||
mSensorDevice->inject_sensor_data(mSensorDevice, &out));
|
||||
}
|
||||
|
||||
Return<void> Sensors::registerDirectChannel(const SharedMemInfo &mem,
|
||||
|
|
@ -299,8 +308,9 @@ Return<Result> Sensors::unregisterDirectChannel(int32_t channelHandle) {
|
|||
return Result::OK;
|
||||
}
|
||||
|
||||
Return<void> Sensors::configDirectReport(int32_t sensorHandle, int32_t channelHandle,
|
||||
RateLevel rate, configDirectReport_cb _hidl_cb) {
|
||||
Return<void> Sensors::configDirectReport(int32_t sensorHandle,
|
||||
int32_t channelHandle, RateLevel rate,
|
||||
configDirectReport_cb _hidl_cb) {
|
||||
if (mSensorDevice->register_direct_channel == nullptr ||
|
||||
mSensorDevice->config_direct_report == nullptr) {
|
||||
// HAL does not support
|
||||
|
|
@ -314,7 +324,8 @@ Return<void> Sensors::configDirectReport(int32_t sensorHandle, int32_t channelHa
|
|||
return Void();
|
||||
}
|
||||
|
||||
int err = mSensorDevice->config_direct_report(mSensorDevice, sensorHandle, channelHandle, &cfg);
|
||||
int err = mSensorDevice->config_direct_report(mSensorDevice, sensorHandle,
|
||||
channelHandle, &cfg);
|
||||
|
||||
if (rate == RateLevel::STOP) {
|
||||
_hidl_cb(ResultFromStatus(err), -1);
|
||||
|
|
@ -325,7 +336,8 @@ Return<void> Sensors::configDirectReport(int32_t sensorHandle, int32_t channelHa
|
|||
}
|
||||
|
||||
// static
|
||||
void Sensors::convertFromSensorEvents(size_t count, const sensors_event_t* srcArray,
|
||||
void Sensors::convertFromSensorEvents(size_t count,
|
||||
const sensors_event_t *srcArray,
|
||||
hidl_vec<Event> *dstVec) {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
const sensors_event_t &src = srcArray[i];
|
||||
|
|
|
|||
|
|
@ -49,12 +49,14 @@ struct Sensors : public ::android::hardware::sensors::V1_0::ISensors {
|
|||
|
||||
Return<Result> injectSensorData(const Event &event) override;
|
||||
|
||||
Return<void> registerDirectChannel(const SharedMemInfo& mem,
|
||||
Return<void>
|
||||
registerDirectChannel(const SharedMemInfo &mem,
|
||||
registerDirectChannel_cb _hidl_cb) override;
|
||||
|
||||
Return<Result> unregisterDirectChannel(int32_t channelHandle) override;
|
||||
|
||||
Return<void> configDirectReport(int32_t sensorHandle, int32_t channelHandle, RateLevel rate,
|
||||
Return<void> configDirectReport(int32_t sensorHandle, int32_t channelHandle,
|
||||
RateLevel rate,
|
||||
configDirectReport_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ Return<void> Usb::queryPortStatus() {
|
|||
|
||||
pthread_mutex_lock(&mLock);
|
||||
if (mCallback != NULL) {
|
||||
Return<void> ret = mCallback->notifyPortStatusChange(currentPortStatus, Status::SUCCESS);
|
||||
Return<void> ret =
|
||||
mCallback->notifyPortStatusChange(currentPortStatus, Status::SUCCESS);
|
||||
if (!ret.isOk()) {
|
||||
LOG(ERROR) << "queryPortStatus error " << ret.description();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ using ::android::hardware::usb::V1_0::PortRole;
|
|||
using ::android::hidl::base::V1_0::IBase;
|
||||
|
||||
struct Usb : public IUsb {
|
||||
Return<void> switchRole(const hidl_string& portName, const PortRole& role) override;
|
||||
Return<void> switchRole(const hidl_string &portName,
|
||||
const PortRole &role) override;
|
||||
Return<void> setCallback(const sp<IUsbCallback> &callback) override;
|
||||
Return<void> queryPortStatus() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Usb.h"
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include "Usb.h"
|
||||
|
||||
using android::sp;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@
|
|||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <assert.h>
|
||||
#include <chrono>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <regex>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <chrono>
|
||||
#include <regex>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <cutils/uevent.h>
|
||||
|
|
@ -55,8 +55,7 @@ Return<bool> Usb::enableUsbDataSignal(bool enable) {
|
|||
ALOGE("Not able to turn on usb connection notification");
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!WriteStringToFile("0", USB_DATA_PATH)) {
|
||||
ALOGE("Not able to turn off usb connection notification");
|
||||
result = false;
|
||||
|
|
@ -70,7 +69,8 @@ Return<bool> Usb::enableUsbDataSignal(bool enable) {
|
|||
volatile bool destroyThread;
|
||||
|
||||
bool moistureDetectionEnabled = true;
|
||||
constexpr char kContaminantDetectionPath[] = "/sys/devices/virtual/sec/ccic/water";
|
||||
constexpr char kContaminantDetectionPath[] =
|
||||
"/sys/devices/virtual/sec/ccic/water";
|
||||
constexpr char kTypecPath[] = "/sys/class/typec";
|
||||
constexpr char kDisableContaminantDetection[] = "vendor.usb.contaminantdisable";
|
||||
|
||||
|
|
@ -113,7 +113,8 @@ int32_t writeFile(const std::string &filename, const std::string &contents) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
Status queryMoistureDetectionStatus(hidl_vec<PortStatus> *currentPortStatus_1_2) {
|
||||
Status
|
||||
queryMoistureDetectionStatus(hidl_vec<PortStatus> *currentPortStatus_1_2) {
|
||||
std::string enabled, status, path, DetectedPath;
|
||||
|
||||
if (currentPortStatus_1_2 == NULL || currentPortStatus_1_2->size() == 0) {
|
||||
|
|
@ -124,10 +125,13 @@ Status queryMoistureDetectionStatus(hidl_vec<PortStatus> *currentPortStatus_1_2)
|
|||
(*currentPortStatus_1_2)[0].supportedContaminantProtectionModes = 0;
|
||||
(*currentPortStatus_1_2)[0].supportedContaminantProtectionModes |=
|
||||
V1_2::ContaminantProtectionMode::FORCE_SINK;
|
||||
(*currentPortStatus_1_2)[0].contaminantProtectionStatus = V1_2::ContaminantProtectionStatus::NONE;
|
||||
(*currentPortStatus_1_2)[0].contaminantDetectionStatus = V1_2::ContaminantDetectionStatus::DISABLED;
|
||||
(*currentPortStatus_1_2)[0].contaminantProtectionStatus =
|
||||
V1_2::ContaminantProtectionStatus::NONE;
|
||||
(*currentPortStatus_1_2)[0].contaminantDetectionStatus =
|
||||
V1_2::ContaminantDetectionStatus::DISABLED;
|
||||
(*currentPortStatus_1_2)[0].supportsEnableContaminantPresenceDetection = true;
|
||||
(*currentPortStatus_1_2)[0].supportsEnableContaminantPresenceProtection = false;
|
||||
(*currentPortStatus_1_2)[0].supportsEnableContaminantPresenceProtection =
|
||||
false;
|
||||
|
||||
if (moistureDetectionEnabled) {
|
||||
if (readFile(kContaminantDetectionPath, &status)) {
|
||||
|
|
@ -151,7 +155,8 @@ Status queryMoistureDetectionStatus(hidl_vec<PortStatus> *currentPortStatus_1_2)
|
|||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
std::string appendRoleNodeHelper(const std::string &portName, PortRoleType type) {
|
||||
std::string appendRoleNodeHelper(const std::string &portName,
|
||||
PortRoleType type) {
|
||||
std::string node("/sys/class/typec/" + portName);
|
||||
|
||||
switch (type) {
|
||||
|
|
@ -198,7 +203,8 @@ void extractRole(std::string *roleName) {
|
|||
}
|
||||
|
||||
void switchToDrp(const std::string &portName) {
|
||||
std::string filename = appendRoleNodeHelper(std::string(portName.c_str()), PortRoleType::MODE);
|
||||
std::string filename =
|
||||
appendRoleNodeHelper(std::string(portName.c_str()), PortRoleType::MODE);
|
||||
FILE *fp;
|
||||
|
||||
if (filename != "") {
|
||||
|
|
@ -216,8 +222,10 @@ void switchToDrp(const std::string &portName) {
|
|||
}
|
||||
}
|
||||
|
||||
bool switchMode(const hidl_string &portName, const PortRole &newRole, struct Usb *usb) {
|
||||
std::string filename = appendRoleNodeHelper(std::string(portName.c_str()), newRole.type);
|
||||
bool switchMode(const hidl_string &portName, const PortRole &newRole,
|
||||
struct Usb *usb) {
|
||||
std::string filename =
|
||||
appendRoleNodeHelper(std::string(portName.c_str()), newRole.type);
|
||||
std::string written;
|
||||
FILE *fp;
|
||||
bool roleSwitch = false;
|
||||
|
|
@ -246,7 +254,8 @@ bool switchMode(const hidl_string &portName, const PortRole &newRole, struct Usb
|
|||
to.tv_sec = now.tv_sec + PORT_TYPE_TIMEOUT;
|
||||
to.tv_nsec = now.tv_nsec;
|
||||
|
||||
int err = pthread_cond_timedwait(&usb->mPartnerCV, &usb->mPartnerLock, &to);
|
||||
int err =
|
||||
pthread_cond_timedwait(&usb->mPartnerCV, &usb->mPartnerLock, &to);
|
||||
// There are no uevent signals which implies role swap timed out.
|
||||
if (err == ETIMEDOUT) {
|
||||
ALOGI("uevents wait timedout");
|
||||
|
|
@ -272,8 +281,7 @@ bool switchMode(const hidl_string &portName, const PortRole &newRole, struct Usb
|
|||
Usb::Usb()
|
||||
: mLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
mRoleSwitchLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
mPartnerLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
mPartnerUp(false) {
|
||||
mPartnerLock(PTHREAD_MUTEX_INITIALIZER), mPartnerUp(false) {
|
||||
pthread_condattr_t attr;
|
||||
if (pthread_condattr_init(&attr)) {
|
||||
ALOGE("pthread_condattr_init failed: %s", strerror(errno));
|
||||
|
|
@ -293,8 +301,10 @@ Usb::Usb()
|
|||
}
|
||||
}
|
||||
|
||||
Return<void> Usb::switchRole(const hidl_string &portName, const V1_0::PortRole &newRole) {
|
||||
std::string filename = appendRoleNodeHelper(std::string(portName.c_str()), newRole.type);
|
||||
Return<void> Usb::switchRole(const hidl_string &portName,
|
||||
const V1_0::PortRole &newRole) {
|
||||
std::string filename =
|
||||
appendRoleNodeHelper(std::string(portName.c_str()), newRole.type);
|
||||
std::string written;
|
||||
FILE *fp;
|
||||
bool roleSwitch = false;
|
||||
|
|
@ -306,7 +316,8 @@ Return<void> Usb::switchRole(const hidl_string &portName, const V1_0::PortRole &
|
|||
|
||||
pthread_mutex_lock(&mRoleSwitchLock);
|
||||
|
||||
ALOGI("filename write: %s role:%s", filename.c_str(), convertRoletoString(newRole).c_str());
|
||||
ALOGI("filename write: %s role:%s", filename.c_str(),
|
||||
convertRoletoString(newRole).c_str());
|
||||
|
||||
if (newRole.type == PortRoleType::MODE) {
|
||||
roleSwitch = switchMode(portName, newRole, this);
|
||||
|
|
@ -346,19 +357,22 @@ Return<void> Usb::switchRole(const hidl_string &portName, const V1_0::PortRole &
|
|||
return Void();
|
||||
}
|
||||
|
||||
Status getAccessoryConnected(const std::string &portName, std::string *accessory) {
|
||||
std::string filename = "/sys/class/typec/" + portName + "-partner/accessory_mode";
|
||||
Status getAccessoryConnected(const std::string &portName,
|
||||
std::string *accessory) {
|
||||
std::string filename =
|
||||
"/sys/class/typec/" + portName + "-partner/accessory_mode";
|
||||
|
||||
if (readFile(filename, accessory)) {
|
||||
ALOGE("getAccessoryConnected: Failed to open filesystem node: %s", filename.c_str());
|
||||
ALOGE("getAccessoryConnected: Failed to open filesystem node: %s",
|
||||
filename.c_str());
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
Status getCurrentRoleHelper(const std::string &portName, bool connected, PortRoleType type,
|
||||
uint32_t *currentRole) {
|
||||
Status getCurrentRoleHelper(const std::string &portName, bool connected,
|
||||
PortRoleType type, uint32_t *currentRole) {
|
||||
std::string filename;
|
||||
std::string roleName;
|
||||
std::string accessory;
|
||||
|
|
@ -395,7 +409,8 @@ Status getCurrentRoleHelper(const std::string &portName, bool connected, PortRol
|
|||
}
|
||||
|
||||
if (readFile(filename, &roleName)) {
|
||||
ALOGE("getCurrentRole: Failed to open filesystem node: %s", filename.c_str());
|
||||
ALOGE("getCurrentRole: Failed to open filesystem node: %s",
|
||||
filename.c_str());
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +469,8 @@ Status getTypeCPortNamesHelper(std::unordered_map<std::string, bool> *names) {
|
|||
}
|
||||
|
||||
bool canSwitchRoleHelper(const std::string &portName, PortRoleType /*type*/) {
|
||||
std::string filename = "/sys/class/typec/" + portName + "-partner/supports_usb_power_delivery";
|
||||
std::string filename =
|
||||
"/sys/class/typec/" + portName + "-partner/supports_usb_power_delivery";
|
||||
std::string supportsPD;
|
||||
|
||||
if (!readFile(filename, &supportsPD)) {
|
||||
|
|
@ -471,7 +487,8 @@ bool canSwitchRoleHelper(const std::string &portName, PortRoleType /*type*/) {
|
|||
* The caller of this method would reconstruct the V1_0::PortStatus
|
||||
* object if required.
|
||||
*/
|
||||
Status getPortStatusHelper(hidl_vec<PortStatus> *currentPortStatus_1_2, HALVersion version) {
|
||||
Status getPortStatusHelper(hidl_vec<PortStatus> *currentPortStatus_1_2,
|
||||
HALVersion version) {
|
||||
std::unordered_map<std::string, bool> names;
|
||||
Status result = getTypeCPortNamesHelper(&names);
|
||||
int i = -1;
|
||||
|
|
@ -484,7 +501,8 @@ Status getPortStatusHelper(hidl_vec<PortStatus> *currentPortStatus_1_2, HALVersi
|
|||
(*currentPortStatus_1_2)[i].status_1_1.status.portName = port.first;
|
||||
|
||||
uint32_t currentRole;
|
||||
if (getCurrentRoleHelper(port.first, port.second, PortRoleType::POWER_ROLE,
|
||||
if (getCurrentRoleHelper(port.first, port.second,
|
||||
PortRoleType::POWER_ROLE,
|
||||
¤tRole) == Status::SUCCESS) {
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.currentPowerRole =
|
||||
static_cast<PortPowerRole>(currentRole);
|
||||
|
|
@ -502,8 +520,8 @@ Status getPortStatusHelper(hidl_vec<PortStatus> *currentPortStatus_1_2, HALVersi
|
|||
goto done;
|
||||
}
|
||||
|
||||
if (getCurrentRoleHelper(port.first, port.second, PortRoleType::MODE, ¤tRole) ==
|
||||
Status::SUCCESS) {
|
||||
if (getCurrentRoleHelper(port.first, port.second, PortRoleType::MODE,
|
||||
¤tRole) == Status::SUCCESS) {
|
||||
(*currentPortStatus_1_2)[i].status_1_1.currentMode =
|
||||
static_cast<PortMode_1_1>(currentRole);
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.currentMode =
|
||||
|
|
@ -515,25 +533,32 @@ Status getPortStatusHelper(hidl_vec<PortStatus> *currentPortStatus_1_2, HALVersi
|
|||
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.canChangeMode = true;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.canChangeDataRole =
|
||||
port.second ? canSwitchRoleHelper(port.first, PortRoleType::DATA_ROLE) : false;
|
||||
port.second ? canSwitchRoleHelper(port.first, PortRoleType::DATA_ROLE)
|
||||
: false;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.canChangePowerRole =
|
||||
port.second ? canSwitchRoleHelper(port.first, PortRoleType::POWER_ROLE) : false;
|
||||
port.second
|
||||
? canSwitchRoleHelper(port.first, PortRoleType::POWER_ROLE)
|
||||
: false;
|
||||
|
||||
if (version == HALVersion::V1_0) {
|
||||
ALOGI("HAL version V1_0");
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.supportedModes = V1_0::PortMode::DRP;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.supportedModes =
|
||||
V1_0::PortMode::DRP;
|
||||
} else {
|
||||
if (version == HALVersion::V1_1)
|
||||
ALOGI("HAL version V1_1");
|
||||
else
|
||||
ALOGI("HAL version V1_2");
|
||||
(*currentPortStatus_1_2)[i].status_1_1.supportedModes = 0 | PortMode_1_1::DRP;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.supportedModes = V1_0::PortMode::NONE;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.currentMode = V1_0::PortMode::NONE;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.supportedModes =
|
||||
0 | PortMode_1_1::DRP;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.supportedModes =
|
||||
V1_0::PortMode::NONE;
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.currentMode =
|
||||
V1_0::PortMode::NONE;
|
||||
}
|
||||
|
||||
ALOGI(
|
||||
"%d:%s connected:%d canChangeMode:%d canChagedata:%d canChangePower:%d "
|
||||
ALOGI("%d:%s connected:%d canChangeMode:%d canChagedata:%d "
|
||||
"canChangePower:%d "
|
||||
"supportedModes:%d",
|
||||
i, port.first.c_str(), port.second,
|
||||
(*currentPortStatus_1_2)[i].status_1_1.status.canChangeMode,
|
||||
|
|
@ -552,7 +577,8 @@ void queryVersionHelper(android::hardware::usb::V1_3::implementation::Usb *usb,
|
|||
hidl_vec<V1_1::PortStatus_1_1> currentPortStatus_1_1;
|
||||
hidl_vec<V1_0::PortStatus> currentPortStatus;
|
||||
Status status;
|
||||
sp<V1_1::IUsbCallback> callback_V1_1 = V1_1::IUsbCallback::castFrom(usb->mCallback_1_0);
|
||||
sp<V1_1::IUsbCallback> callback_V1_1 =
|
||||
V1_1::IUsbCallback::castFrom(usb->mCallback_1_0);
|
||||
sp<IUsbCallback> callback_V1_2 = IUsbCallback::castFrom(usb->mCallback_1_0);
|
||||
|
||||
pthread_mutex_lock(&usb->mLock);
|
||||
|
|
@ -576,11 +602,14 @@ void queryVersionHelper(android::hardware::usb::V1_3::implementation::Usb *usb,
|
|||
Return<void> ret;
|
||||
|
||||
if (callback_V1_2 != NULL)
|
||||
ret = callback_V1_2->notifyPortStatusChange_1_2(*currentPortStatus_1_2, status);
|
||||
ret = callback_V1_2->notifyPortStatusChange_1_2(*currentPortStatus_1_2,
|
||||
status);
|
||||
else if (callback_V1_1 != NULL)
|
||||
ret = callback_V1_1->notifyPortStatusChange_1_1(currentPortStatus_1_1, status);
|
||||
ret = callback_V1_1->notifyPortStatusChange_1_1(currentPortStatus_1_1,
|
||||
status);
|
||||
else
|
||||
ret = usb->mCallback_1_0->notifyPortStatusChange(currentPortStatus, status);
|
||||
ret =
|
||||
usb->mCallback_1_0->notifyPortStatusChange(currentPortStatus, status);
|
||||
|
||||
if (!ret.isOk())
|
||||
ALOGE("queryPortStatus_1_2 error %s", ret.description().c_str());
|
||||
|
|
@ -597,7 +626,8 @@ Return<void> Usb::queryPortStatus() {
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Usb::enableContaminantPresenceDetection(const hidl_string & /*portName*/,
|
||||
Return<void>
|
||||
Usb::enableContaminantPresenceDetection(const hidl_string & /*portName*/,
|
||||
bool enable) {
|
||||
std::string disable = GetProperty(kDisableContaminantDetection, "");
|
||||
|
||||
|
|
@ -610,7 +640,8 @@ Return<void> Usb::enableContaminantPresenceDetection(const hidl_string & /*portN
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Usb::enableContaminantPresenceProtection(const hidl_string & /*portName*/,
|
||||
Return<void>
|
||||
Usb::enableContaminantPresenceProtection(const hidl_string & /*portName*/,
|
||||
bool /*enable*/) {
|
||||
hidl_vec<PortStatus> currentPortStatus_1_2;
|
||||
|
||||
|
|
@ -653,8 +684,8 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) {
|
|||
// Role switch is not in progress and port is in disconnected state
|
||||
if (!pthread_mutex_trylock(&payload->usb->mRoleSwitchLock)) {
|
||||
for (unsigned long i = 0; i < currentPortStatus_1_2.size(); i++) {
|
||||
DIR *dp =
|
||||
opendir(std::string("/sys/class/typec/" +
|
||||
DIR *dp = opendir(
|
||||
std::string("/sys/class/typec/" +
|
||||
std::string(currentPortStatus_1_2[i]
|
||||
.status_1_1.status.portName.c_str()) +
|
||||
"-partner")
|
||||
|
|
@ -723,8 +754,8 @@ void *work(void *param) {
|
|||
|
||||
for (int n = 0; n < nevents; ++n) {
|
||||
if (events[n].data.ptr)
|
||||
(*(void (*)(int, struct data *payload))events[n].data.ptr)(events[n].events,
|
||||
&payload);
|
||||
(*(void (*)(int, struct data *payload))events[n].data.ptr)(
|
||||
events[n].events, &payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android/hardware/usb/1.3/IUsb.h>
|
||||
#include <android/hardware/usb/1.2/types.h>
|
||||
#include <android/hardware/usb/1.2/IUsbCallback.h>
|
||||
#include <android/hardware/usb/1.2/types.h>
|
||||
#include <android/hardware/usb/1.3/IUsb.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
|
|
@ -36,47 +36,44 @@ namespace usb {
|
|||
namespace V1_3 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::base::WriteStringToFile;
|
||||
using ::android::sp;
|
||||
using ::android::base::ReadFileToString;
|
||||
using ::android::base::WriteStringToFile;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::usb::V1_0::PortRole;
|
||||
using ::android::hardware::usb::V1_0::PortRoleType;
|
||||
using ::android::hardware::usb::V1_0::PortDataRole;
|
||||
using ::android::hardware::usb::V1_0::PortPowerRole;
|
||||
using ::android::hardware::usb::V1_0::PortRole;
|
||||
using ::android::hardware::usb::V1_0::PortRoleType;
|
||||
using ::android::hardware::usb::V1_0::Status;
|
||||
using ::android::hardware::usb::V1_3::IUsb;
|
||||
using ::android::hardware::usb::V1_2::IUsbCallback;
|
||||
using ::android::hardware::usb::V1_2::PortStatus;
|
||||
using ::android::hardware::usb::V1_1::PortMode_1_1;
|
||||
using ::android::hardware::usb::V1_1::PortStatus_1_1;
|
||||
using ::android::hardware::usb::V1_2::IUsbCallback;
|
||||
using ::android::hardware::usb::V1_2::PortStatus;
|
||||
using ::android::hardware::usb::V1_3::IUsb;
|
||||
using ::android::hidl::base::V1_0::DebugInfo;
|
||||
using ::android::hidl::base::V1_0::IBase;
|
||||
using ::android::sp;
|
||||
|
||||
enum class HALVersion{
|
||||
V1_0,
|
||||
V1_1,
|
||||
V1_2,
|
||||
V1_3
|
||||
};
|
||||
enum class HALVersion { V1_0, V1_1, V1_2, V1_3 };
|
||||
|
||||
#define USB_DATA_PATH "/sys/devices/virtual/usb_notify/usb_control/usb_data_enabled"
|
||||
#define USB_DATA_PATH \
|
||||
"/sys/devices/virtual/usb_notify/usb_control/usb_data_enabled"
|
||||
|
||||
struct Usb : public IUsb {
|
||||
Usb();
|
||||
|
||||
Return<void> switchRole(const hidl_string &portName, const PortRole &role) override;
|
||||
Return<void> switchRole(const hidl_string &portName,
|
||||
const PortRole &role) override;
|
||||
Return<void> setCallback(const sp<V1_0::IUsbCallback> &callback) override;
|
||||
Return<void> queryPortStatus() override;
|
||||
Return<void> enableContaminantPresenceDetection(const hidl_string &portName, bool enable);
|
||||
Return<void> enableContaminantPresenceProtection(const hidl_string &portName, bool enable);
|
||||
Return<void> enableContaminantPresenceDetection(const hidl_string &portName,
|
||||
bool enable);
|
||||
Return<void> enableContaminantPresenceProtection(const hidl_string &portName,
|
||||
bool enable);
|
||||
Return<bool> enableUsbDataSignal(bool enable) override;
|
||||
|
||||
sp<V1_0::IUsbCallback> mCallback_1_0;
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#define LOG_TAG "android.hardware.usb@1.3-service.samsung"
|
||||
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include "Usb.h"
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
using android::sp;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@
|
|||
|
||||
void LoadProperties(std::string data) {
|
||||
for (std::string line : android::base::Split(data, "\n")) {
|
||||
if (line == "\0") break;
|
||||
if (line == "\0")
|
||||
break;
|
||||
|
||||
std::vector<std::string> parts = android::base::Split(line, "=");
|
||||
if (parts.size() == 2) {
|
||||
|
|
@ -45,7 +46,8 @@ void LoadProperties(std::string data) {
|
|||
int main(int argc, char *argv[]) {
|
||||
std::string prop = FACTORY_PROP;
|
||||
|
||||
if (argc > 1 && std::string(argv[1]) == "NetworkConfig") prop = TELEPHONY_PROP;
|
||||
if (argc > 1 && std::string(argv[1]) == "NetworkConfig")
|
||||
prop = TELEPHONY_PROP;
|
||||
|
||||
std::ifstream in(EFS_NEW + prop);
|
||||
if (in.good()) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ void property_override(char const prop[], char const value[], bool add = true) {
|
|||
__system_property_add(prop, strlen(prop), value, strlen(value));
|
||||
}
|
||||
|
||||
void set_ro_build_prop(const std::string& prop, const std::string& value, bool product = true) {
|
||||
void set_ro_build_prop(const std::string &prop, const std::string &value,
|
||||
bool product = true) {
|
||||
string prop_name;
|
||||
|
||||
for (const auto &source : ro_props_default_source_order) {
|
||||
|
|
@ -68,8 +69,8 @@ void set_ro_build_prop(const std::string& prop, const std::string& value, bool p
|
|||
|
||||
bool hasEnding(std::string const &fullString, std::string const &ending) {
|
||||
if (fullString.length() >= ending.length()) {
|
||||
return (0 ==
|
||||
fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
|
||||
return (0 == fullString.compare(fullString.length() - ending.length(),
|
||||
ending.length(), ending));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
#ifndef ANDROID_HARDWARE_CAM_DEVICE_V3_2_CAMERADEVICE_H
|
||||
#define ANDROID_HARDWARE_CAM_DEVICE_V3_2_CAMERADEVICE_H
|
||||
|
||||
#include "utils/Mutex.h"
|
||||
#include "CameraModule.h"
|
||||
#include "CameraMetadata.h"
|
||||
#include "CameraDeviceSession.h"
|
||||
#include "CameraMetadata.h"
|
||||
#include "CameraModule.h"
|
||||
#include "utils/Mutex.h"
|
||||
|
||||
#include <android/hardware/camera/device/3.2/ICameraDevice.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
|
|
@ -33,20 +33,20 @@ namespace device {
|
|||
namespace V3_2 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::camera::device::V3_2::RequestTemplate;
|
||||
using ::android::hardware::camera::device::V3_2::ICameraDevice;
|
||||
using ::android::hardware::camera::device::V3_2::ICameraDeviceCallback;
|
||||
using ::android::hardware::camera::device::V3_2::ICameraDeviceSession;
|
||||
using ::android::Mutex;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::camera::common::V1_0::CameraResourceCost;
|
||||
using ::android::hardware::camera::common::V1_0::Status;
|
||||
using ::android::hardware::camera::common::V1_0::TorchMode;
|
||||
using ::android::hardware::camera::common::V1_0::helper::CameraModule;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
using ::android::Mutex;
|
||||
using ::android::hardware::camera::device::V3_2::ICameraDevice;
|
||||
using ::android::hardware::camera::device::V3_2::ICameraDeviceCallback;
|
||||
using ::android::hardware::camera::device::V3_2::ICameraDeviceSession;
|
||||
using ::android::hardware::camera::device::V3_2::RequestTemplate;
|
||||
|
||||
/*
|
||||
* The camera device HAL implementation is opened lazily (via the open call)
|
||||
|
|
@ -57,13 +57,14 @@ struct CameraDevice : public virtual RefBase {
|
|||
// trying to access the same physical camera.
|
||||
// Also, provider will have to keep track of all CameraDevice objects in
|
||||
// order to notify CameraDevice when the underlying camera is detached
|
||||
CameraDevice(sp<CameraModule> module,
|
||||
const std::string& cameraId,
|
||||
const SortedVector<std::pair<std::string, std::string>>& cameraDeviceNames);
|
||||
CameraDevice(sp<CameraModule> module, const std::string &cameraId,
|
||||
const SortedVector<std::pair<std::string, std::string>>
|
||||
&cameraDeviceNames);
|
||||
virtual ~CameraDevice();
|
||||
|
||||
// Retrieve the HIDL interface, split into its own class to avoid inheritance issues when
|
||||
// dealing with minor version revs and simultaneous implementation and interface inheritance
|
||||
// Retrieve the HIDL interface, split into its own class to avoid inheritance
|
||||
// issues when dealing with minor version revs and simultaneous implementation
|
||||
// and interface inheritance
|
||||
virtual sp<ICameraDevice> getInterface() {
|
||||
return new TrampolineDeviceInterface_3_2(this);
|
||||
}
|
||||
|
|
@ -73,26 +74,32 @@ struct CameraDevice : public virtual RefBase {
|
|||
// Used by provider HAL to signal external camera disconnected
|
||||
void setConnectionStatus(bool connected);
|
||||
|
||||
/* Methods from ::android::hardware::camera::device::V3_2::ICameraDevice follow. */
|
||||
/* Methods from ::android::hardware::camera::device::V3_2::ICameraDevice
|
||||
* follow. */
|
||||
// The following method can be called without opening the actual camera device
|
||||
Return<void> getResourceCost(ICameraDevice::getResourceCost_cb _hidl_cb);
|
||||
Return<void> getCameraCharacteristics(ICameraDevice::getCameraCharacteristics_cb _hidl_cb);
|
||||
Return<void> getEurekaCharacteristics(ICameraDevice::getCameraCharacteristics_cb _hidl_cb);
|
||||
Return<void>
|
||||
getCameraCharacteristics(ICameraDevice::getCameraCharacteristics_cb _hidl_cb);
|
||||
Return<void>
|
||||
getEurekaCharacteristics(ICameraDevice::getCameraCharacteristics_cb _hidl_cb);
|
||||
Return<Status> setTorchMode(TorchMode mode);
|
||||
|
||||
// Open the device HAL and also return a default capture session
|
||||
Return<void> open(const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb);
|
||||
Return<void> nuke(const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb);
|
||||
Return<void> open(const sp<ICameraDeviceCallback> &callback,
|
||||
ICameraDevice::open_cb _hidl_cb);
|
||||
Return<void> nuke(const sp<ICameraDeviceCallback> &callback,
|
||||
ICameraDevice::open_cb _hidl_cb);
|
||||
|
||||
// Forward the dump call to the opened session, or do nothing
|
||||
Return<void> dumpState(const ::android::hardware::hidl_handle &fd);
|
||||
/* End of Methods from ::android::hardware::camera::device::V3_2::ICameraDevice */
|
||||
/* End of Methods from
|
||||
* ::android::hardware::camera::device::V3_2::ICameraDevice */
|
||||
|
||||
protected:
|
||||
|
||||
// Overridden by child implementations for returning different versions of CameraDeviceSession
|
||||
virtual sp<CameraDeviceSession> createSession(camera3_device_t*,
|
||||
const camera_metadata_t* deviceInfo,
|
||||
// Overridden by child implementations for returning different versions of
|
||||
// CameraDeviceSession
|
||||
virtual sp<CameraDeviceSession>
|
||||
createSession(camera3_device_t *, const camera_metadata_t *deviceInfo,
|
||||
const sp<ICameraDeviceCallback> &);
|
||||
|
||||
const sp<CameraModule> mModule;
|
||||
|
|
@ -117,11 +124,10 @@ protected:
|
|||
|
||||
private:
|
||||
struct TrampolineDeviceInterface_3_2 : public ICameraDevice {
|
||||
TrampolineDeviceInterface_3_2(sp<CameraDevice> parent) :
|
||||
mParent(parent) {}
|
||||
TrampolineDeviceInterface_3_2(sp<CameraDevice> parent) : mParent(parent) {}
|
||||
|
||||
virtual Return<void> getResourceCost(V3_2::ICameraDevice::getResourceCost_cb _hidl_cb)
|
||||
override {
|
||||
virtual Return<void>
|
||||
getResourceCost(V3_2::ICameraDevice::getResourceCost_cb _hidl_cb) override {
|
||||
return mParent->getResourceCost(_hidl_cb);
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +152,6 @@ private:
|
|||
private:
|
||||
sp<CameraDevice> mParent;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
|
|
|||
|
|
@ -21,13 +21,15 @@ namespace implementation {
|
|||
|
||||
using ::android::hardware::camera::common::V1_0::Status;
|
||||
|
||||
Return<void> CameraDevice::getCameraCharacteristics(ICameraDevice::getCameraCharacteristics_cb _hidl_cb) {
|
||||
Return<void> CameraDevice::getCameraCharacteristics(
|
||||
ICameraDevice::getCameraCharacteristics_cb _hidl_cb) {
|
||||
Status status = initStatus();
|
||||
CameraMetadata cameraCharacteristics;
|
||||
if (status == Status::OK) {
|
||||
// Module 2.1+ codepath.
|
||||
struct camera_info info;
|
||||
if (mCameraIdInt == 1) mCameraIdInt = 2;
|
||||
if (mCameraIdInt == 1)
|
||||
mCameraIdInt = 2;
|
||||
int ret = mModule->getCameraInfo(mCameraIdInt, &info);
|
||||
if (ret == OK) {
|
||||
convertToHidl(info.static_camera_characteristics, &cameraCharacteristics);
|
||||
|
|
@ -40,7 +42,8 @@ Return<void> CameraDevice::getCameraCharacteristics(ICameraDevice::getCameraChar
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<void> CameraDevice::getEurekaCharacteristics(ICameraDevice::getCameraCharacteristics_cb _hidl_cb) {
|
||||
Return<void> CameraDevice::getEurekaCharacteristics(
|
||||
ICameraDevice::getCameraCharacteristics_cb _hidl_cb) {
|
||||
return CameraDevice::getCameraCharacteristics(_hidl_cb);
|
||||
}
|
||||
|
||||
|
|
@ -50,8 +53,8 @@ Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
|||
sp<CameraDeviceSession> session = nullptr;
|
||||
|
||||
if (callback == nullptr) {
|
||||
ALOGE("%s: cannot open camera %s. callback is null!",
|
||||
__FUNCTION__, mCameraId.c_str());
|
||||
ALOGE("%s: cannot open camera %s. callback is null!", __FUNCTION__,
|
||||
mCameraId.c_str());
|
||||
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
|
@ -59,8 +62,8 @@ Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
|||
if (status != Status::OK) {
|
||||
// Provider will never pass initFailed device to client, so
|
||||
// this must be a disconnected camera
|
||||
ALOGE("%s: cannot open camera %s. camera is disconnected!",
|
||||
__FUNCTION__, mCameraId.c_str());
|
||||
ALOGE("%s: cannot open camera %s. camera is disconnected!", __FUNCTION__,
|
||||
mCameraId.c_str());
|
||||
_hidl_cb(Status::CAMERA_DISCONNECTED, nullptr);
|
||||
return Void();
|
||||
} else {
|
||||
|
|
@ -80,8 +83,10 @@ Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
|||
camera3_device_t *device;
|
||||
|
||||
std::string mCameraID = mCameraId;
|
||||
if (mCameraIdInt == 1) mCameraIdInt = 2;
|
||||
if (mCameraID == "1") mCameraID = "2";
|
||||
if (mCameraIdInt == 1)
|
||||
mCameraIdInt = 2;
|
||||
if (mCameraID == "1")
|
||||
mCameraID = "2";
|
||||
|
||||
res = mModule->open(mCameraID.c_str(),
|
||||
reinterpret_cast<hw_device_t **>(&device));
|
||||
|
|
@ -96,8 +101,7 @@ Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
|||
if (device->common.version < CAMERA_DEVICE_API_VERSION_3_2) {
|
||||
ALOGE("%s: Could not open camera: "
|
||||
"Camera device should be at least %x, reports %x instead",
|
||||
__FUNCTION__,
|
||||
CAMERA_DEVICE_API_VERSION_3_2,
|
||||
__FUNCTION__, CAMERA_DEVICE_API_VERSION_3_2,
|
||||
device->common.version);
|
||||
device->common.close(&device->common);
|
||||
mLock.unlock();
|
||||
|
|
@ -115,8 +119,8 @@ Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
|||
return Void();
|
||||
}
|
||||
|
||||
session = createSession(
|
||||
device, info.static_camera_characteristics, callback);
|
||||
session =
|
||||
createSession(device, info.static_camera_characteristics, callback);
|
||||
if (session == nullptr) {
|
||||
ALOGE("%s: camera device session allocation failed", __FUNCTION__);
|
||||
mLock.unlock();
|
||||
|
|
@ -133,8 +137,9 @@ Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
|||
mSession = session;
|
||||
|
||||
IF_ALOGV() {
|
||||
session->getInterface()->interfaceChain([](
|
||||
::android::hardware::hidl_vec<::android::hardware::hidl_string> interfaceChain) {
|
||||
session->getInterface()->interfaceChain(
|
||||
[](::android::hardware::hidl_vec<::android::hardware::hidl_string>
|
||||
interfaceChain) {
|
||||
ALOGV("Session interface chain:");
|
||||
for (const auto &iface : interfaceChain) {
|
||||
ALOGV(" %s", iface.c_str());
|
||||
|
|
@ -156,4 +161,3 @@ Return<void> CameraDevice::nuke(const sp<ICameraDeviceCallback>& callback,
|
|||
} // namespace camera
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,9 @@ extern "C" int ALooper_release_forCamera(ALooper* sLooper) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int ALooper_pollOnce_camera(ALooper* sLooper, int timeoutMillis, int* outFd,
|
||||
int* outEvents, void** outData) {
|
||||
extern "C" int ALooper_pollOnce_camera(ALooper *sLooper, int timeoutMillis,
|
||||
int *outFd, int *outEvents,
|
||||
void **outData) {
|
||||
int res = sLooper->pollOnce(timeoutMillis, outFd, outEvents, outData);
|
||||
LOG(VERBOSE) << "ALooper_pollOnce_camera => " << res;
|
||||
return res;
|
||||
|
|
|
|||
Loading…
Reference in a new issue