sm8350-common: Switch to hardware/oneplus components
Change-Id: I26ba94eac5d7a0cdad07559afe55e6cabe2e161e
This commit is contained in:
parent
df5fdce826
commit
34972ef817
78 changed files with 40 additions and 4891 deletions
|
@ -129,9 +129,9 @@ TARGET_ENABLE_MEDIADRM_64 := true
|
||||||
TARGET_FS_CONFIG_GEN := $(COMMON_PATH)/config.fs
|
TARGET_FS_CONFIG_GEN := $(COMMON_PATH)/config.fs
|
||||||
|
|
||||||
# Fingerprint
|
# Fingerprint
|
||||||
SOONG_CONFIG_NAMESPACES += ONEPLUS_LAHAINA_FOD
|
SOONG_CONFIG_NAMESPACES += ONEPLUS_FOD
|
||||||
SOONG_CONFIG_ONEPLUS_LAHAINA_FOD := POS_X POS_Y SIZE
|
SOONG_CONFIG_ONEPLUS_FOD := POS_X POS_Y SIZE
|
||||||
TARGET_SURFACEFLINGER_FOD_LIB := //$(COMMON_PATH):libfod_extension.oneplus_lahaina
|
TARGET_SURFACEFLINGER_FOD_LIB := //hardware/oneplus:libfod_extension.oneplus
|
||||||
|
|
||||||
# HIDL
|
# HIDL
|
||||||
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := \
|
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := \
|
||||||
|
@ -174,6 +174,11 @@ TARGET_COPY_OUT_VENDOR := vendor
|
||||||
# Power
|
# Power
|
||||||
TARGET_TAP_TO_WAKE_NODE := "/proc/touchpanel/double_tap_enable"
|
TARGET_TAP_TO_WAKE_NODE := "/proc/touchpanel/double_tap_enable"
|
||||||
|
|
||||||
|
# PowerShare
|
||||||
|
SOONG_CONFIG_NAMESPACES += ONEPLUS_POWERSHARE
|
||||||
|
SOONG_CONFIG_ONEPLUS_POWERSHARE := WIRELESS_TX_ENABLE_PATH
|
||||||
|
SOONG_CONFIG_ONEPLUS_POWERSHARE_WIRELESS_TX_ENABLE_PATH := /sys/class/oplus_chg/wireless/trx_online
|
||||||
|
|
||||||
# Recovery
|
# Recovery
|
||||||
BOARD_INCLUDE_DTB_IN_BOOTIMG := true
|
BOARD_INCLUDE_DTB_IN_BOOTIMG := true
|
||||||
BOARD_USES_RECOVERY_AS_BOOT := true
|
BOARD_USES_RECOVERY_AS_BOOT := true
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (C) 2018 The LineageOS Project
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
|
||||||
LOCAL_PACKAGE_NAME := KeyHandler
|
|
||||||
|
|
||||||
LOCAL_CERTIFICATE := platform
|
|
||||||
LOCAL_PRIVATE_PLATFORM_APIS := true
|
|
||||||
LOCAL_PRIVILEGED_MODULE := true
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
|
||||||
|
|
||||||
LOCAL_PROGUARD_ENABLED := disabled
|
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
|
|
@ -1,83 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.device;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.os.VibrationEffect;
|
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
|
|
||||||
import com.android.internal.os.DeviceKeyHandler;
|
|
||||||
|
|
||||||
public class KeyHandler implements DeviceKeyHandler {
|
|
||||||
private static final String TAG = KeyHandler.class.getSimpleName();
|
|
||||||
|
|
||||||
// Slider key codes
|
|
||||||
private static final int MODE_NORMAL = 601;
|
|
||||||
private static final int MODE_VIBRATION = 602;
|
|
||||||
private static final int MODE_SILENCE = 603;
|
|
||||||
|
|
||||||
// Vibration effects
|
|
||||||
private static final VibrationEffect MODE_NORMAL_EFFECT =
|
|
||||||
VibrationEffect.get(VibrationEffect.EFFECT_HEAVY_CLICK);
|
|
||||||
private static final VibrationEffect MODE_VIBRATION_EFFECT =
|
|
||||||
VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK);
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
private final AudioManager mAudioManager;
|
|
||||||
private final Vibrator mVibrator;
|
|
||||||
|
|
||||||
public KeyHandler(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
|
|
||||||
mAudioManager = mContext.getSystemService(AudioManager.class);
|
|
||||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyEvent handleKeyEvent(KeyEvent event) {
|
|
||||||
if (event.getAction() != KeyEvent.ACTION_DOWN) {
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
int scanCode = event.getScanCode();
|
|
||||||
|
|
||||||
switch (scanCode) {
|
|
||||||
case MODE_NORMAL:
|
|
||||||
mAudioManager.setRingerModeInternal(AudioManager.RINGER_MODE_NORMAL);
|
|
||||||
doHapticFeedback(MODE_NORMAL_EFFECT);
|
|
||||||
break;
|
|
||||||
case MODE_VIBRATION:
|
|
||||||
mAudioManager.setRingerModeInternal(AudioManager.RINGER_MODE_VIBRATE);
|
|
||||||
doHapticFeedback(MODE_VIBRATION_EFFECT);
|
|
||||||
break;
|
|
||||||
case MODE_SILENCE:
|
|
||||||
mAudioManager.setRingerModeInternal(AudioManager.RINGER_MODE_SILENT);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doHapticFeedback(VibrationEffect effect) {
|
|
||||||
if (mVibrator != null && mVibrator.hasVibrator()) {
|
|
||||||
mVibrator.vibrate(effect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright 2020-2021 The LineageOS Project
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE := audio_amplifier.$(TARGET_BOARD_PLATFORM)
|
|
||||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
|
||||||
LOCAL_SRC_FILES := audio_amplifier.c
|
|
||||||
LOCAL_VENDOR_MODULE := true
|
|
||||||
|
|
||||||
LOCAL_C_INCLUDES += \
|
|
||||||
$(call include-path-for, audio-route) \
|
|
||||||
$(call include-path-for, audio-utils) \
|
|
||||||
$(call project-path-for, qcom-audio)/hal \
|
|
||||||
$(call project-path-for, qcom-audio)/hal/audio_extn \
|
|
||||||
$(call project-path-for, qcom-audio)/hal/msm8974 \
|
|
||||||
external/tinycompress/include
|
|
||||||
|
|
||||||
LOCAL_HEADER_LIBRARIES += \
|
|
||||||
generated_kernel_headers \
|
|
||||||
libhardware_headers
|
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES += \
|
|
||||||
audio.primary.$(TARGET_BOARD_PLATFORM) \
|
|
||||||
libcutils \
|
|
||||||
liblog \
|
|
||||||
libtinyalsa
|
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
|
|
@ -1,232 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 The CyanogenMod Project
|
|
||||||
* Copyright (C) 2020 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "audio_amplifier"
|
|
||||||
//#define LOG_NDEBUG 0
|
|
||||||
|
|
||||||
#include <cutils/str_parms.h>
|
|
||||||
#include <hardware/audio_amplifier.h>
|
|
||||||
#include <hardware/hardware.h>
|
|
||||||
#include <log/log.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/* clang-format off */
|
|
||||||
#include "audio_hw.h"
|
|
||||||
#include "platform.h"
|
|
||||||
#include "platform_api.h"
|
|
||||||
/* clang-format on */
|
|
||||||
|
|
||||||
#define UNUSED __attribute__((unused))
|
|
||||||
|
|
||||||
typedef struct amp_device {
|
|
||||||
amplifier_device_t amp_dev;
|
|
||||||
struct audio_device* adev;
|
|
||||||
struct audio_usecase* usecase_tx;
|
|
||||||
struct pcm* tfa98xx_out;
|
|
||||||
} tfa_t;
|
|
||||||
|
|
||||||
static tfa_t* tfa_dev = NULL;
|
|
||||||
|
|
||||||
static int is_speaker(uint32_t snd_device) {
|
|
||||||
int speaker = 0;
|
|
||||||
switch (snd_device) {
|
|
||||||
case SND_DEVICE_OUT_SPEAKER:
|
|
||||||
case SND_DEVICE_OUT_SPEAKER_REVERSE:
|
|
||||||
case SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES:
|
|
||||||
case SND_DEVICE_OUT_VOICE_SPEAKER:
|
|
||||||
case SND_DEVICE_OUT_VOICE_SPEAKER_2:
|
|
||||||
case SND_DEVICE_OUT_SPEAKER_AND_HDMI:
|
|
||||||
case SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET:
|
|
||||||
case SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET:
|
|
||||||
speaker = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return speaker;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tfa98xx_start_feedback(void* adev, uint32_t snd_device) {
|
|
||||||
tfa_dev->adev = (struct audio_device*)adev;
|
|
||||||
int pcm_dev_tx_id = 0, rc = 0;
|
|
||||||
struct pcm_config pcm_config_tfa98xx = {
|
|
||||||
.channels = 2,
|
|
||||||
.rate = 48000,
|
|
||||||
.period_size = 256,
|
|
||||||
.period_count = 4,
|
|
||||||
.format = PCM_FORMAT_S16_LE,
|
|
||||||
.start_threshold = 0,
|
|
||||||
.stop_threshold = INT_MAX,
|
|
||||||
.silence_threshold = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!tfa_dev) {
|
|
||||||
ALOGE("%d: Invalid params", __LINE__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tfa_dev->tfa98xx_out || !is_speaker(snd_device)) return 0;
|
|
||||||
|
|
||||||
tfa_dev->usecase_tx = (struct audio_usecase*)calloc(1, sizeof(struct audio_usecase));
|
|
||||||
if (!tfa_dev->usecase_tx) {
|
|
||||||
ALOGE("%d: failed to allocate usecase", __LINE__);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
tfa_dev->usecase_tx->id = USECASE_AUDIO_SPKR_CALIB_TX;
|
|
||||||
tfa_dev->usecase_tx->type = PCM_CAPTURE;
|
|
||||||
tfa_dev->usecase_tx->in_snd_device = SND_DEVICE_IN_CAPTURE_VI_FEEDBACK;
|
|
||||||
list_init(&tfa_dev->usecase_tx->device_list);
|
|
||||||
|
|
||||||
list_add_tail(&tfa_dev->adev->usecase_list, &tfa_dev->usecase_tx->list);
|
|
||||||
enable_snd_device(tfa_dev->adev, tfa_dev->usecase_tx->in_snd_device);
|
|
||||||
enable_audio_route(tfa_dev->adev, tfa_dev->usecase_tx);
|
|
||||||
|
|
||||||
pcm_dev_tx_id = platform_get_pcm_device_id(tfa_dev->usecase_tx->id, tfa_dev->usecase_tx->type);
|
|
||||||
ALOGD("pcm_dev_tx_id = %d", pcm_dev_tx_id);
|
|
||||||
if (pcm_dev_tx_id < 0) {
|
|
||||||
ALOGE("%d: Invalid pcm device for usecase (%d)", __LINE__, tfa_dev->usecase_tx->id);
|
|
||||||
rc = -ENODEV;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
tfa_dev->tfa98xx_out =
|
|
||||||
pcm_open(tfa_dev->adev->snd_card, pcm_dev_tx_id, PCM_IN, &pcm_config_tfa98xx);
|
|
||||||
if (!(tfa_dev->tfa98xx_out || pcm_is_ready(tfa_dev->tfa98xx_out))) {
|
|
||||||
ALOGE("%d: %s", __LINE__, pcm_get_error(tfa_dev->tfa98xx_out));
|
|
||||||
rc = -EIO;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = pcm_start(tfa_dev->tfa98xx_out);
|
|
||||||
if (rc < 0) {
|
|
||||||
ALOGE("%d: pcm start for TX failed", __LINE__);
|
|
||||||
rc = -EINVAL;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
ALOGE("%s: error case", __func__);
|
|
||||||
if (tfa_dev->tfa98xx_out != 0) {
|
|
||||||
pcm_close(tfa_dev->tfa98xx_out);
|
|
||||||
tfa_dev->tfa98xx_out = NULL;
|
|
||||||
}
|
|
||||||
list_remove(&tfa_dev->usecase_tx->list);
|
|
||||||
disable_snd_device(tfa_dev->adev, tfa_dev->usecase_tx->in_snd_device);
|
|
||||||
disable_audio_route(tfa_dev->adev, tfa_dev->usecase_tx);
|
|
||||||
free(tfa_dev->usecase_tx);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tfa98xx_stop_feedback(void* adev, uint32_t snd_device) {
|
|
||||||
tfa_dev->adev = (struct audio_device*)adev;
|
|
||||||
if (!tfa_dev) {
|
|
||||||
ALOGE("%s: Invalid params", __func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_speaker(snd_device)) return;
|
|
||||||
|
|
||||||
if (tfa_dev->tfa98xx_out) {
|
|
||||||
pcm_close(tfa_dev->tfa98xx_out);
|
|
||||||
tfa_dev->tfa98xx_out = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
disable_snd_device(tfa_dev->adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
|
|
||||||
|
|
||||||
tfa_dev->usecase_tx = get_usecase_from_list(tfa_dev->adev, USECASE_AUDIO_SPKR_CALIB_TX);
|
|
||||||
if (tfa_dev->usecase_tx) {
|
|
||||||
list_remove(&tfa_dev->usecase_tx->list);
|
|
||||||
disable_audio_route(tfa_dev->adev, tfa_dev->usecase_tx);
|
|
||||||
free(tfa_dev->usecase_tx);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int amp_set_feedback(UNUSED amplifier_device_t* device, void* adev, uint32_t devices,
|
|
||||||
bool enable) {
|
|
||||||
tfa_dev->adev = (struct audio_device*)adev;
|
|
||||||
if (enable) {
|
|
||||||
tfa98xx_start_feedback(tfa_dev->adev, devices);
|
|
||||||
} else {
|
|
||||||
tfa98xx_stop_feedback(tfa_dev->adev, devices);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int amp_dev_close(hw_device_t* device) {
|
|
||||||
tfa_t* dev = (tfa_t*)device;
|
|
||||||
if (dev) free(dev);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int amp_module_open(const hw_module_t* module, const char* name, hw_device_t** device) {
|
|
||||||
if (strcmp(name, AMPLIFIER_HARDWARE_INTERFACE)) {
|
|
||||||
ALOGE("%s:%d: %s does not match amplifier hardware interface name\n", __func__, __LINE__,
|
|
||||||
name);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
tfa_dev = calloc(1, sizeof(tfa_t));
|
|
||||||
if (!tfa_dev) {
|
|
||||||
ALOGE("%s:%d: Unable to allocate memory for amplifier device\n", __func__, __LINE__);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
tfa_dev->amp_dev.common.tag = HARDWARE_DEVICE_TAG;
|
|
||||||
tfa_dev->amp_dev.common.module = (hw_module_t*)module;
|
|
||||||
tfa_dev->amp_dev.common.version = HARDWARE_DEVICE_API_VERSION(1, 0);
|
|
||||||
tfa_dev->amp_dev.common.close = amp_dev_close;
|
|
||||||
|
|
||||||
tfa_dev->amp_dev.set_input_devices = NULL;
|
|
||||||
tfa_dev->amp_dev.set_output_devices = NULL;
|
|
||||||
tfa_dev->amp_dev.enable_output_devices = NULL;
|
|
||||||
tfa_dev->amp_dev.enable_input_devices = NULL;
|
|
||||||
tfa_dev->amp_dev.set_mode = NULL;
|
|
||||||
tfa_dev->amp_dev.output_stream_start = NULL;
|
|
||||||
tfa_dev->amp_dev.input_stream_start = NULL;
|
|
||||||
tfa_dev->amp_dev.output_stream_standby = NULL;
|
|
||||||
tfa_dev->amp_dev.input_stream_standby = NULL;
|
|
||||||
tfa_dev->amp_dev.set_parameters = NULL;
|
|
||||||
tfa_dev->amp_dev.out_set_parameters = NULL;
|
|
||||||
tfa_dev->amp_dev.in_set_parameters = NULL;
|
|
||||||
tfa_dev->amp_dev.set_feedback = amp_set_feedback;
|
|
||||||
|
|
||||||
*device = (hw_device_t*)tfa_dev;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct hw_module_methods_t hal_module_methods = {
|
|
||||||
.open = amp_module_open,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* clang-format off */
|
|
||||||
amplifier_module_t HAL_MODULE_INFO_SYM = {
|
|
||||||
.common = {
|
|
||||||
.tag = HARDWARE_MODULE_TAG,
|
|
||||||
.module_api_version = AMPLIFIER_MODULE_API_VERSION_0_1,
|
|
||||||
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
|
||||||
.id = AMPLIFIER_HARDWARE_MODULE_ID,
|
|
||||||
.name = "TFA98XX audio amplifier HAL",
|
|
||||||
.author = "The LineageOS Project",
|
|
||||||
.methods = &hal_module_methods,
|
|
||||||
},
|
|
||||||
};
|
|
22
common.mk
22
common.mk
|
@ -300,10 +300,8 @@ PRODUCT_PACKAGES += \
|
||||||
|
|
||||||
# Fingerprint
|
# Fingerprint
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
android.hardware.biometrics.fingerprint@2.1-service.oneplus_lahaina \
|
android.hardware.biometrics.fingerprint@2.1-service.oneplus \
|
||||||
vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.oneplus_lahaina \
|
vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.oneplus
|
||||||
vendor.oneplus.fingerprint.extension@1.0 \
|
|
||||||
vendor.oneplus.hardware.display@1.0
|
|
||||||
|
|
||||||
# GPS
|
# GPS
|
||||||
PRODUCT_COPY_FILES += \
|
PRODUCT_COPY_FILES += \
|
||||||
|
@ -338,7 +336,7 @@ PRODUCT_PACKAGES += \
|
||||||
|
|
||||||
# LiveDisplay
|
# LiveDisplay
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
vendor.lineage.livedisplay@2.1-service.oneplus_lahaina
|
vendor.lineage.livedisplay@2.1-service.oneplus
|
||||||
|
|
||||||
# Media
|
# Media
|
||||||
PRODUCT_COPY_FILES += \
|
PRODUCT_COPY_FILES += \
|
||||||
|
@ -398,10 +396,10 @@ PRODUCT_PACKAGES += \
|
||||||
|
|
||||||
# OnePlus
|
# OnePlus
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
oneplus-fwk.oneplus_lahaina
|
oneplus-fwk
|
||||||
|
|
||||||
PRODUCT_BOOT_JARS += \
|
PRODUCT_BOOT_JARS += \
|
||||||
oneplus-fwk.oneplus_lahaina
|
oneplus-fwk
|
||||||
|
|
||||||
# Power
|
# Power
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
|
@ -412,7 +410,7 @@ PRODUCT_PACKAGES += \
|
||||||
|
|
||||||
# PowerShare
|
# PowerShare
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
vendor.lineage.powershare@1.0-service.oneplus_lahaina
|
vendor.lineage.powershare@1.0-service.oneplus
|
||||||
|
|
||||||
# QMI
|
# QMI
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
|
@ -442,7 +440,7 @@ PRODUCT_PACKAGES += \
|
||||||
# Soong namespaces
|
# Soong namespaces
|
||||||
PRODUCT_SOONG_NAMESPACES += \
|
PRODUCT_SOONG_NAMESPACES += \
|
||||||
$(LOCAL_PATH) \
|
$(LOCAL_PATH) \
|
||||||
device/oneplus/common
|
hardware/oneplus
|
||||||
|
|
||||||
# Telephony
|
# Telephony
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
|
@ -466,12 +464,12 @@ PRODUCT_PACKAGES += \
|
||||||
|
|
||||||
# Touch
|
# Touch
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
vendor.lineage.touch@1.0-service.oneplus_lahaina
|
vendor.lineage.touch@1.0-service.oneplus
|
||||||
|
|
||||||
# tri-state-key
|
# tri-state-key
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
KeyHandler \
|
KeyHandler \
|
||||||
tri-state-key_daemon
|
tri-state-key_daemon.vendor
|
||||||
|
|
||||||
# Trust HAL
|
# Trust HAL
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
|
@ -500,7 +498,7 @@ PRODUCT_PACKAGES += \
|
||||||
|
|
||||||
# Vibrator
|
# Vibrator
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
vendor.qti.hardware.vibrator.service.oneplus_lahaina
|
vendor.qti.hardware.vibrator.service.oneplus
|
||||||
|
|
||||||
PRODUCT_COPY_FILES += \
|
PRODUCT_COPY_FILES += \
|
||||||
vendor/qcom/opensource/vibrator/excluded-input-devices.xml:$(TARGET_COPY_OUT_VENDOR)/etc/excluded-input-devices.xml
|
vendor/qcom/opensource/vibrator/excluded-input-devices.xml:$(TARGET_COPY_OUT_VENDOR)/etc/excluded-input-devices.xml
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := OnePlusDoze
|
|
||||||
LOCAL_CERTIFICATE := platform
|
|
||||||
LOCAL_PRIVATE_PLATFORM_APIS := true
|
|
||||||
LOCAL_PRIVILEGED_MODULE := true
|
|
||||||
|
|
||||||
LOCAL_USE_AAPT2 := true
|
|
||||||
|
|
||||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
|
||||||
androidx.core_core \
|
|
||||||
androidx.preference_preference
|
|
||||||
|
|
||||||
LOCAL_RESOURCE_DIR := \
|
|
||||||
$(LOCAL_PATH)/res \
|
|
||||||
$(TOP)/packages/resources/devicesettings/res
|
|
||||||
|
|
||||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
|
||||||
|
|
||||||
include frameworks/base/packages/SettingsLib/common.mk
|
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
|
|
@ -1,59 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2015-2016 The CyanogenMod Project
|
|
||||||
2017 The LineageOS Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="org.lineageos.settings.doze"
|
|
||||||
android:versionCode="1"
|
|
||||||
android:versionName="1.0"
|
|
||||||
android:sharedUserId="android.uid.system">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
||||||
|
|
||||||
<protected-broadcast android:name="com.android.systemui.doze.pulse" />
|
|
||||||
|
|
||||||
<uses-sdk
|
|
||||||
android:minSdkVersion="24"
|
|
||||||
android:targetSdkVersion="24"/>
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:label="@string/device_settings_app_name"
|
|
||||||
android:persistent="true">
|
|
||||||
|
|
||||||
<receiver android:name=".BootCompletedReceiver">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
<service android:name=".DozeService"
|
|
||||||
android:permission="OneplusDozeService">
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".DozeSettingsActivity"
|
|
||||||
android:label="@string/ambient_display_title"
|
|
||||||
android:theme="@style/Theme.Main">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="org.lineageos.settings.device.DOZE_SETTINGS" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
</manifest>
|
|
|
@ -1,8 +0,0 @@
|
||||||
-keepclasseswithmembers class * {
|
|
||||||
public <init>(android.content.Context, android.util.AttributeSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
-keep class ** extends android.support.v14.preference.PreferenceFragment
|
|
||||||
-keep class org.lineageos.settings.doze.* {
|
|
||||||
*;
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
<!-- drawable/arrow_decision_outline.xml -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:height="24dp"
|
|
||||||
android:width="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24"
|
|
||||||
android:tint="?android:attr/colorControlNormal" >
|
|
||||||
<path android:fillColor="#000" android:pathData="M9.64,13.4C8.63,12.5 7.34,12.03 6,12V15L2,11L6,7V10C7.67,10 9.3,10.57 10.63,11.59C10.22,12.15 9.89,12.76 9.64,13.4M18,15V12C17.5,12 13.5,12.16 13.05,16.2C14.61,16.75 15.43,18.47 14.88,20.03C14.33,21.59 12.61,22.41 11.05,21.86C9.5,21.3 8.67,19.59 9.22,18.03C9.5,17.17 10.2,16.5 11.05,16.2C11.34,12.61 14.4,9.88 18,10V7L22,11L18,15M13,19A1,1 0 0,0 12,18A1,1 0 0,0 11,19A1,1 0 0,0 12,20A1,1 0 0,0 13,19M11,11.12C11.58,10.46 12.25,9.89 13,9.43V5H16L12,1L8,5H11V11.12Z" />
|
|
||||||
</vector>
|
|
|
@ -1,9 +0,0 @@
|
||||||
<!-- drawable/pocket.xml -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:height="24dp"
|
|
||||||
android:width="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24"
|
|
||||||
android:tint="?android:attr/colorControlNormal" >
|
|
||||||
<path android:fillColor="#000" android:pathData="M21.9,4.26C21.64,3.55 20.96,3.07 20.2,3.07H20.19L18.46,3.07H3.81C3.07,3.07 2.39,3.54 2.12,4.24C2.04,4.45 2,4.66 2,4.88V10.92L2.07,12.12C2.36,14.85 3.78,17.23 5.97,18.9C6,18.93 6.05,18.96 6.09,19H6.11C7.29,19.86 8.6,20.44 10,20.73C10.68,20.86 11.35,20.93 12,20.93C12.63,20.93 13.25,20.87 13.85,20.76C13.93,20.75 14,20.73 14.07,20.72C14.09,20.71 14.11,20.7 14.14,20.69C15.5,20.4 16.76,19.83 17.89,19H17.91C17.95,18.96 18,18.93 18.03,18.9C20.22,17.23 21.64,14.85 21.93,12.12L22,10.92V4.88C22,4.68 21.97,4.47 21.9,4.26M17.67,10.55L12.96,15.06C12.7,15.32 12.35,15.44 12,15.44C11.67,15.44 11.33,15.32 11.06,15.06L6.36,10.55C5.81,10.03 5.79,9.16 6.32,8.61C6.84,8.06 7.71,8.05 8.26,8.57L12,12.17L15.77,8.57C16.31,8.05 17.18,8.07 17.71,8.61C18.23,9.16 18.21,10.03 17.67,10.55Z" />
|
|
||||||
</vector>
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
** Copyright 2014, The Android Open Source Project
|
|
||||||
**
|
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
** you may not use this file except in compliance with the License.
|
|
||||||
** You may obtain a copy of the License at
|
|
||||||
**
|
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
**
|
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
** See the License for the specific language governing permissions and
|
|
||||||
** limitations under the License.
|
|
||||||
*/
|
|
||||||
-->
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<include layout="@layout/switch_bar" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2021 The LineageOS Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License"
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<resources>
|
|
||||||
<!-- Pickup gesture -->
|
|
||||||
<string-array name="pick_up_gesture_entries" translatable="false">
|
|
||||||
<item>@string/disabled</item>
|
|
||||||
<item>@string/pick_up_gesture_summary</item>
|
|
||||||
<item>@string/pick_up_wake_gesture_summary</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="pick_up_gesture_values" translatable="false">
|
|
||||||
<item>0</item>
|
|
||||||
<item>1</item>
|
|
||||||
<item>2</item>
|
|
||||||
</string-array>
|
|
||||||
</resources>
|
|
|
@ -1,55 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2015 The CyanogenMod Project
|
|
||||||
2018-2019 The LineageOS Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License"
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="always_on_display"
|
|
||||||
android:disableDependentsState="true"
|
|
||||||
android:title="@string/ambient_display_always_on_title"
|
|
||||||
android:summary="@string/ambient_display_always_on_summary"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="pickup_sensor"
|
|
||||||
android:title="@string/pickup_sensor_title">
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:key="gesture_pick_up_type"
|
|
||||||
android:defaultValue="0"
|
|
||||||
android:icon="@drawable/ic_pickup"
|
|
||||||
android:title="@string/pick_up_gesture_title"
|
|
||||||
android:summary="%s"
|
|
||||||
android:entries="@array/pick_up_gesture_entries"
|
|
||||||
android:entryValues="@array/pick_up_gesture_values" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="proximity_sensor"
|
|
||||||
android:title="@string/proximity_sensor_title">
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="gesture_pocket"
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:icon="@drawable/ic_pocket"
|
|
||||||
android:title="@string/pocket_gesture_title"
|
|
||||||
android:summary="@string/pocket_gesture_summary" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 The CyanogenMod Project
|
|
||||||
* 2017 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.doze;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
private static final String TAG = "OnePlusDoze";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(final Context context, Intent intent) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Received boot completed intent");
|
|
||||||
Utils.checkDozeService(context);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2015 The CyanogenMod Project
|
|
||||||
* 2017-2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.doze;
|
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class DozeService extends Service {
|
|
||||||
private static final String TAG = "DozeService";
|
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
|
|
||||||
private PickupSensor mPickupSensor;
|
|
||||||
private PocketSensor mPocketSensor;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Creating service");
|
|
||||||
mPickupSensor = new PickupSensor(this);
|
|
||||||
mPocketSensor = new PocketSensor(this);
|
|
||||||
|
|
||||||
IntentFilter screenStateFilter = new IntentFilter();
|
|
||||||
screenStateFilter.addAction(Intent.ACTION_SCREEN_ON);
|
|
||||||
screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
|
||||||
registerReceiver(mScreenStateReceiver, screenStateFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Starting service");
|
|
||||||
return START_STICKY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Destroying service");
|
|
||||||
super.onDestroy();
|
|
||||||
this.unregisterReceiver(mScreenStateReceiver);
|
|
||||||
mPickupSensor.disable();
|
|
||||||
mPocketSensor.disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDisplayOn() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Display on");
|
|
||||||
if (Utils.isPickUpEnabled(this)) {
|
|
||||||
mPickupSensor.disable();
|
|
||||||
}
|
|
||||||
if (Utils.isPocketEnabled(this)) {
|
|
||||||
mPocketSensor.disable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDisplayOff() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Display off");
|
|
||||||
if (Utils.isPickUpEnabled(this)) {
|
|
||||||
mPickupSensor.enable();
|
|
||||||
}
|
|
||||||
if (Utils.isPocketEnabled(this)) {
|
|
||||||
mPocketSensor.enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
|
|
||||||
onDisplayOn();
|
|
||||||
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
|
||||||
onDisplayOff();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015-2016 The CyanogenMod Project
|
|
||||||
* 2017 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.doze;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
|
|
||||||
public class DozeSettingsActivity extends PreferenceActivity {
|
|
||||||
|
|
||||||
private static final String TAG_DOZE = "doze";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
getFragmentManager().beginTransaction().replace(android.R.id.content,
|
|
||||||
new DozeSettingsFragment(), TAG_DOZE).commit();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,188 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 The CyanogenMod Project
|
|
||||||
* 2017-2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.doze;
|
|
||||||
|
|
||||||
import android.app.ActionBar;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.DialogFragment;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.preference.ListPreference;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
|
||||||
import androidx.preference.PreferenceCategory;
|
|
||||||
import androidx.preference.PreferenceFragment;
|
|
||||||
import androidx.preference.SwitchPreference;
|
|
||||||
|
|
||||||
public class DozeSettingsFragment extends PreferenceFragment implements OnPreferenceChangeListener,
|
|
||||||
CompoundButton.OnCheckedChangeListener {
|
|
||||||
|
|
||||||
private TextView mTextView;
|
|
||||||
private View mSwitchBar;
|
|
||||||
|
|
||||||
private SwitchPreference mAlwaysOnDisplayPreference;
|
|
||||||
|
|
||||||
private ListPreference mPickUpPreference;
|
|
||||||
private SwitchPreference mPocketPreference;
|
|
||||||
|
|
||||||
private Handler mHandler = new Handler();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
|
||||||
addPreferencesFromResource(R.xml.doze_settings);
|
|
||||||
final ActionBar actionBar = getActivity().getActionBar();
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
|
|
||||||
SharedPreferences prefs = getActivity().getSharedPreferences("doze_settings",
|
|
||||||
Activity.MODE_PRIVATE);
|
|
||||||
if (savedInstanceState == null && !prefs.getBoolean("first_help_shown", false)) {
|
|
||||||
showHelp();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean dozeEnabled = Utils.isDozeEnabled(getActivity());
|
|
||||||
|
|
||||||
mAlwaysOnDisplayPreference = (SwitchPreference) findPreference(Utils.ALWAYS_ON_DISPLAY);
|
|
||||||
mAlwaysOnDisplayPreference.setEnabled(dozeEnabled);
|
|
||||||
mAlwaysOnDisplayPreference.setChecked(Utils.isAlwaysOnEnabled(getActivity()));
|
|
||||||
mAlwaysOnDisplayPreference.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
PreferenceCategory pickupSensorCategory = (PreferenceCategory) getPreferenceScreen().
|
|
||||||
findPreference(Utils.CATEG_PICKUP_SENSOR);
|
|
||||||
PreferenceCategory proximitySensorCategory = (PreferenceCategory) getPreferenceScreen().
|
|
||||||
findPreference(Utils.CATEG_PROX_SENSOR);
|
|
||||||
|
|
||||||
mPickUpPreference = (ListPreference) findPreference(Utils.GESTURE_PICK_UP_KEY);
|
|
||||||
mPickUpPreference.setEnabled(dozeEnabled);
|
|
||||||
mPickUpPreference.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
mPocketPreference = (SwitchPreference) findPreference(Utils.GESTURE_POCKET_KEY);
|
|
||||||
mPocketPreference.setEnabled(dozeEnabled);
|
|
||||||
mPocketPreference.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
// Hide AOD if not supported and set all its dependents otherwise
|
|
||||||
if (!Utils.alwaysOnDisplayAvailable(getActivity())) {
|
|
||||||
getPreferenceScreen().removePreference(mAlwaysOnDisplayPreference);
|
|
||||||
} else {
|
|
||||||
pickupSensorCategory.setDependency(Utils.ALWAYS_ON_DISPLAY);
|
|
||||||
proximitySensorCategory.setDependency(Utils.ALWAYS_ON_DISPLAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
final View view = LayoutInflater.from(getContext()).inflate(R.layout.doze, container, false);
|
|
||||||
((ViewGroup) view).addView(super.onCreateView(inflater, container, savedInstanceState));
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
|
|
||||||
boolean dozeEnabled = Utils.isDozeEnabled(getActivity());
|
|
||||||
|
|
||||||
mTextView = view.findViewById(R.id.switch_text);
|
|
||||||
mTextView.setText(getString(dozeEnabled ?
|
|
||||||
R.string.switch_bar_on : R.string.switch_bar_off));
|
|
||||||
|
|
||||||
mSwitchBar = view.findViewById(R.id.switch_bar);
|
|
||||||
Switch switchWidget = mSwitchBar.findViewById(android.R.id.switch_widget);
|
|
||||||
switchWidget.setChecked(dozeEnabled);
|
|
||||||
switchWidget.setOnCheckedChangeListener(this);
|
|
||||||
mSwitchBar.setActivated(dozeEnabled);
|
|
||||||
mSwitchBar.setOnClickListener(v -> {
|
|
||||||
switchWidget.setChecked(!switchWidget.isChecked());
|
|
||||||
mSwitchBar.setActivated(switchWidget.isChecked());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
if (Utils.ALWAYS_ON_DISPLAY.equals(preference.getKey())) {
|
|
||||||
Utils.enableAlwaysOn(getActivity(), (Boolean) newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
mHandler.post(() -> Utils.checkDozeService(getActivity()));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
|
||||||
Utils.enableDoze(getActivity(), isChecked);
|
|
||||||
Utils.checkDozeService(getActivity());
|
|
||||||
|
|
||||||
mTextView.setText(getString(isChecked ? R.string.switch_bar_on : R.string.switch_bar_off));
|
|
||||||
mSwitchBar.setActivated(isChecked);
|
|
||||||
|
|
||||||
if (!isChecked) {
|
|
||||||
Utils.enableAlwaysOn(getActivity(), false);
|
|
||||||
mAlwaysOnDisplayPreference.setChecked(false);
|
|
||||||
}
|
|
||||||
mAlwaysOnDisplayPreference.setEnabled(isChecked);
|
|
||||||
|
|
||||||
mPickUpPreference.setEnabled(isChecked);
|
|
||||||
mPocketPreference.setEnabled(isChecked);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (item.getItemId() == android.R.id.home) {
|
|
||||||
getActivity().onBackPressed();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class HelpDialogFragment extends DialogFragment {
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
return new AlertDialog.Builder(getActivity())
|
|
||||||
.setTitle(R.string.doze_settings_help_title)
|
|
||||||
.setMessage(R.string.doze_settings_help_text)
|
|
||||||
.setNegativeButton(R.string.dialog_ok, (dialog, which) -> dialog.cancel())
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
getActivity().getSharedPreferences("doze_settings", Activity.MODE_PRIVATE)
|
|
||||||
.edit()
|
|
||||||
.putBoolean("first_help_shown", true)
|
|
||||||
.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showHelp() {
|
|
||||||
HelpDialogFragment fragment = new HelpDialogFragment();
|
|
||||||
fragment.show(getFragmentManager(), "help_dialog");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2015 The CyanogenMod Project
|
|
||||||
* 2017-2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.doze;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.os.PowerManager.WakeLock;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
public class PickupSensor implements SensorEventListener {
|
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
private static final String TAG = "PickupSensor";
|
|
||||||
|
|
||||||
private static final int MIN_PULSE_INTERVAL_MS = 2500;
|
|
||||||
private static final int MIN_WAKEUP_INTERVAL_MS = 1000;
|
|
||||||
private static final int WAKELOCK_TIMEOUT_MS = 300;
|
|
||||||
|
|
||||||
private PowerManager mPowerManager;
|
|
||||||
private SensorManager mSensorManager;
|
|
||||||
private Sensor mSensor;
|
|
||||||
private WakeLock mWakeLock;
|
|
||||||
private Context mContext;
|
|
||||||
private ExecutorService mExecutorService;
|
|
||||||
|
|
||||||
private long mEntryTimestamp;
|
|
||||||
|
|
||||||
public PickupSensor(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
mPowerManager = mContext.getSystemService(PowerManager.class);
|
|
||||||
mSensorManager = mContext.getSystemService(SensorManager.class);
|
|
||||||
mSensor = Utils.getSensor(mSensorManager, "oneplus.sensor.op_motion_detect");
|
|
||||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
|
|
||||||
mExecutorService = Executors.newSingleThreadExecutor();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Future<?> submit(Runnable runnable) {
|
|
||||||
return mExecutorService.submit(runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSensorChanged(SensorEvent event) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Got sensor event: " + event.values[0]);
|
|
||||||
|
|
||||||
long delta = SystemClock.elapsedRealtime() - mEntryTimestamp;
|
|
||||||
if (delta < MIN_PULSE_INTERVAL_MS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mEntryTimestamp = SystemClock.elapsedRealtime();
|
|
||||||
|
|
||||||
if (event.values[0] == 1) {
|
|
||||||
if (Utils.isPickUpSetToWake(mContext)) {
|
|
||||||
mWakeLock.acquire(WAKELOCK_TIMEOUT_MS);
|
|
||||||
mPowerManager.wakeUpWithProximityCheck(SystemClock.uptimeMillis(),
|
|
||||||
PowerManager.WAKE_REASON_GESTURE, TAG);
|
|
||||||
} else {
|
|
||||||
Utils.launchDozePulse(mContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
||||||
/* Empty */
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void enable() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Enabling");
|
|
||||||
submit(() -> {
|
|
||||||
mEntryTimestamp = SystemClock.elapsedRealtime();
|
|
||||||
mSensorManager.registerListener(this, mSensor,
|
|
||||||
SensorManager.SENSOR_DELAY_NORMAL);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void disable() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Disabling");
|
|
||||||
submit(() -> {
|
|
||||||
mSensorManager.unregisterListener(this, mSensor);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2016 The CyanogenMod Project
|
|
||||||
* Copyright (c) 2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.doze;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
public class PocketSensor implements SensorEventListener {
|
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
private static final String TAG = "PocketSensor";
|
|
||||||
|
|
||||||
private static final int MIN_PULSE_INTERVAL_MS = 2500;
|
|
||||||
|
|
||||||
private SensorManager mSensorManager;
|
|
||||||
private Sensor mSensor;
|
|
||||||
private Context mContext;
|
|
||||||
private ExecutorService mExecutorService;
|
|
||||||
|
|
||||||
private long mEntryTimestamp;
|
|
||||||
|
|
||||||
public PocketSensor(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
mSensorManager = mContext.getSystemService(SensorManager.class);
|
|
||||||
mSensor = Utils.getSensor(mSensorManager, "oneplus.sensor.pocket");
|
|
||||||
mExecutorService = Executors.newSingleThreadExecutor();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Future<?> submit(Runnable runnable) {
|
|
||||||
return mExecutorService.submit(runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSensorChanged(SensorEvent event) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Got sensor event: " + event.values[0]);
|
|
||||||
|
|
||||||
long delta = SystemClock.elapsedRealtime() - mEntryTimestamp;
|
|
||||||
if (delta < MIN_PULSE_INTERVAL_MS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mEntryTimestamp = SystemClock.elapsedRealtime();
|
|
||||||
|
|
||||||
if (event.values[0] == 0.0) {
|
|
||||||
Utils.launchDozePulse(mContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
||||||
/* Empty */
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void enable() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Enabling");
|
|
||||||
submit(() -> {
|
|
||||||
mEntryTimestamp = SystemClock.elapsedRealtime();
|
|
||||||
mSensorManager.registerListener(this, mSensor,
|
|
||||||
SensorManager.SENSOR_DELAY_NORMAL);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void disable() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Disabling");
|
|
||||||
submit(() -> {
|
|
||||||
mSensorManager.unregisterListener(this, mSensor);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 The CyanogenMod Project
|
|
||||||
* 2017-2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.doze;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.hardware.display.AmbientDisplayConfiguration;
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.DOZE_ALWAYS_ON;
|
|
||||||
import static android.provider.Settings.Secure.DOZE_ENABLED;
|
|
||||||
|
|
||||||
public final class Utils {
|
|
||||||
|
|
||||||
private static final String TAG = "DozeUtils";
|
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
|
|
||||||
private static final String DOZE_INTENT = "com.android.systemui.doze.pulse";
|
|
||||||
|
|
||||||
protected static final String ALWAYS_ON_DISPLAY = "always_on_display";
|
|
||||||
|
|
||||||
protected static final String CATEG_PICKUP_SENSOR = "pickup_sensor";
|
|
||||||
protected static final String CATEG_PROX_SENSOR = "proximity_sensor";
|
|
||||||
|
|
||||||
protected static final String GESTURE_PICK_UP_KEY = "gesture_pick_up_type";
|
|
||||||
protected static final String GESTURE_POCKET_KEY = "gesture_pocket";
|
|
||||||
|
|
||||||
protected static void startService(Context context) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Starting service");
|
|
||||||
context.startServiceAsUser(new Intent(context, DozeService.class),
|
|
||||||
UserHandle.CURRENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void stopService(Context context) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Stopping service");
|
|
||||||
context.stopServiceAsUser(new Intent(context, DozeService.class),
|
|
||||||
UserHandle.CURRENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void checkDozeService(Context context) {
|
|
||||||
if (isDozeEnabled(context) && !isAlwaysOnEnabled(context) && areGesturesEnabled(context)) {
|
|
||||||
startService(context);
|
|
||||||
} else {
|
|
||||||
stopService(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isDozeEnabled(Context context) {
|
|
||||||
return Settings.Secure.getInt(context.getContentResolver(),
|
|
||||||
DOZE_ENABLED, 1) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean enableDoze(Context context, boolean enable) {
|
|
||||||
return Settings.Secure.putInt(context.getContentResolver(),
|
|
||||||
DOZE_ENABLED, enable ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void launchDozePulse(Context context) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Launch doze pulse");
|
|
||||||
context.sendBroadcastAsUser(new Intent(DOZE_INTENT),
|
|
||||||
new UserHandle(UserHandle.USER_CURRENT));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean enableAlwaysOn(Context context, boolean enable) {
|
|
||||||
return Settings.Secure.putIntForUser(context.getContentResolver(),
|
|
||||||
DOZE_ALWAYS_ON, enable ? 1 : 0, UserHandle.USER_CURRENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isAlwaysOnEnabled(Context context) {
|
|
||||||
return Settings.Secure.getIntForUser(context.getContentResolver(),
|
|
||||||
DOZE_ALWAYS_ON, 0, UserHandle.USER_CURRENT) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean alwaysOnDisplayAvailable(Context context) {
|
|
||||||
return new AmbientDisplayConfiguration(context).alwaysOnAvailable();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isGestureEnabled(Context context, String gesture) {
|
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getBoolean(gesture, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isPickUpEnabled(Context context) {
|
|
||||||
return !PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getString(GESTURE_PICK_UP_KEY, "0").equals("0");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isPickUpSetToWake(Context context) {
|
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getString(GESTURE_PICK_UP_KEY, "0").equals("2");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isPocketEnabled(Context context) {
|
|
||||||
return isGestureEnabled(context, GESTURE_POCKET_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean areGesturesEnabled(Context context) {
|
|
||||||
return isPickUpEnabled(context) || isPocketEnabled(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static Sensor getSensor(SensorManager sm, String type) {
|
|
||||||
for (Sensor sensor : sm.getSensorList(Sensor.TYPE_ALL)) {
|
|
||||||
if (type.equals(sensor.getStringType())) {
|
|
||||||
return sensor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
cc_binary {
|
|
||||||
name: "android.hardware.biometrics.fingerprint@2.1-service.oneplus_lahaina",
|
|
||||||
defaults: ["hidl_defaults"],
|
|
||||||
init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.oneplus_lahaina.rc"],
|
|
||||||
vintf_fragments: ["android.hardware.biometrics.fingerprint@2.1-service.oneplus_lahaina.xml"],
|
|
||||||
vendor: true,
|
|
||||||
relative_install_path: "hw",
|
|
||||||
srcs: [
|
|
||||||
"BiometricsFingerprint.cpp",
|
|
||||||
"service.cpp",
|
|
||||||
],
|
|
||||||
|
|
||||||
shared_libs: [
|
|
||||||
"libcutils",
|
|
||||||
"liblog",
|
|
||||||
"libhidlbase",
|
|
||||||
"libhardware",
|
|
||||||
"libutils",
|
|
||||||
"android.hardware.biometrics.fingerprint@2.1",
|
|
||||||
],
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,367 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service"
|
|
||||||
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service"
|
|
||||||
|
|
||||||
#include <hardware/hw_auth_token.h>
|
|
||||||
|
|
||||||
#include <hardware/hardware.h>
|
|
||||||
#include <hardware/fingerprint.h>
|
|
||||||
#include "BiometricsFingerprint.h"
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
namespace hardware {
|
|
||||||
namespace biometrics {
|
|
||||||
namespace fingerprint {
|
|
||||||
namespace V2_1 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
// Supported fingerprint HAL version
|
|
||||||
static const uint16_t kVersion = HARDWARE_MODULE_API_VERSION(2, 1);
|
|
||||||
|
|
||||||
using RequestStatus =
|
|
||||||
android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
|
||||||
|
|
||||||
BiometricsFingerprint *BiometricsFingerprint::sInstance = nullptr;
|
|
||||||
|
|
||||||
BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr), mDevice(nullptr) {
|
|
||||||
sInstance = this; // keep track of the most recent instance
|
|
||||||
mDevice = openHal();
|
|
||||||
if (!mDevice) {
|
|
||||||
ALOGE("Can't open HAL module");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BiometricsFingerprint::~BiometricsFingerprint() {
|
|
||||||
ALOGV("~BiometricsFingerprint()");
|
|
||||||
if (mDevice == nullptr) {
|
|
||||||
ALOGE("No valid device");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int err;
|
|
||||||
if (0 != (err = mDevice->common.close(
|
|
||||||
reinterpret_cast<hw_device_t*>(mDevice)))) {
|
|
||||||
ALOGE("Can't close fingerprint module, error: %d", err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mDevice = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::ErrorFilter(int32_t error) {
|
|
||||||
switch(error) {
|
|
||||||
case 0: return RequestStatus::SYS_OK;
|
|
||||||
case -2: return RequestStatus::SYS_ENOENT;
|
|
||||||
case -4: return RequestStatus::SYS_EINTR;
|
|
||||||
case -5: return RequestStatus::SYS_EIO;
|
|
||||||
case -11: return RequestStatus::SYS_EAGAIN;
|
|
||||||
case -12: return RequestStatus::SYS_ENOMEM;
|
|
||||||
case -13: return RequestStatus::SYS_EACCES;
|
|
||||||
case -14: return RequestStatus::SYS_EFAULT;
|
|
||||||
case -16: return RequestStatus::SYS_EBUSY;
|
|
||||||
case -22: return RequestStatus::SYS_EINVAL;
|
|
||||||
case -28: return RequestStatus::SYS_ENOSPC;
|
|
||||||
case -110: return RequestStatus::SYS_ETIMEDOUT;
|
|
||||||
default:
|
|
||||||
ALOGE("An unknown error returned from fingerprint vendor library: %d", 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) {
|
|
||||||
*vendorCode = 0;
|
|
||||||
switch(error) {
|
|
||||||
case FINGERPRINT_ERROR_HW_UNAVAILABLE:
|
|
||||||
return FingerprintError::ERROR_HW_UNAVAILABLE;
|
|
||||||
case FINGERPRINT_ERROR_UNABLE_TO_PROCESS:
|
|
||||||
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
|
|
||||||
case FINGERPRINT_ERROR_TIMEOUT:
|
|
||||||
return FingerprintError::ERROR_TIMEOUT;
|
|
||||||
case FINGERPRINT_ERROR_NO_SPACE:
|
|
||||||
return FingerprintError::ERROR_NO_SPACE;
|
|
||||||
case FINGERPRINT_ERROR_CANCELED:
|
|
||||||
return FingerprintError::ERROR_CANCELED;
|
|
||||||
case FINGERPRINT_ERROR_UNABLE_TO_REMOVE:
|
|
||||||
return FingerprintError::ERROR_UNABLE_TO_REMOVE;
|
|
||||||
case FINGERPRINT_ERROR_LOCKOUT:
|
|
||||||
return FingerprintError::ERROR_LOCKOUT;
|
|
||||||
default:
|
|
||||||
if (error >= FINGERPRINT_ERROR_VENDOR_BASE) {
|
|
||||||
// vendor specific code.
|
|
||||||
*vendorCode = error - FINGERPRINT_ERROR_VENDOR_BASE;
|
|
||||||
return FingerprintError::ERROR_VENDOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ALOGE("Unknown error from fingerprint vendor library: %d", error);
|
|
||||||
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Translate acquired messages returned by traditional HAL (see fingerprint.h)
|
|
||||||
// to HIDL-compliant FingerprintAcquiredInfo.
|
|
||||||
FingerprintAcquiredInfo BiometricsFingerprint::VendorAcquiredFilter(
|
|
||||||
int32_t info, int32_t* vendorCode) {
|
|
||||||
*vendorCode = 0;
|
|
||||||
switch(info) {
|
|
||||||
case FINGERPRINT_ACQUIRED_GOOD:
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_GOOD;
|
|
||||||
case FINGERPRINT_ACQUIRED_PARTIAL:
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_PARTIAL;
|
|
||||||
case FINGERPRINT_ACQUIRED_INSUFFICIENT:
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
|
|
||||||
case FINGERPRINT_ACQUIRED_IMAGER_DIRTY:
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY;
|
|
||||||
case FINGERPRINT_ACQUIRED_TOO_SLOW:
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW;
|
|
||||||
case FINGERPRINT_ACQUIRED_TOO_FAST:
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_TOO_FAST;
|
|
||||||
default:
|
|
||||||
if (info >= FINGERPRINT_ACQUIRED_VENDOR_BASE) {
|
|
||||||
// vendor specific code.
|
|
||||||
*vendorCode = info - FINGERPRINT_ACQUIRED_VENDOR_BASE;
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_VENDOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ALOGE("Unknown acquiredmsg from fingerprint vendor library: %d", info);
|
|
||||||
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<uint64_t> BiometricsFingerprint::setNotify(
|
|
||||||
const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
|
|
||||||
std::lock_guard<std::mutex> lock(mClientCallbackMutex);
|
|
||||||
mClientCallback = clientCallback;
|
|
||||||
// This is here because HAL 2.1 doesn't have a way to propagate a
|
|
||||||
// unique token for its driver. Subsequent versions should send a unique
|
|
||||||
// token for each call to setNotify(). This is fine as long as there's only
|
|
||||||
// one fingerprint device on the platform.
|
|
||||||
return reinterpret_cast<uint64_t>(mDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<uint64_t> BiometricsFingerprint::preEnroll() {
|
|
||||||
return mDevice->pre_enroll(mDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
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(mDevice->enroll(mDevice, authToken, gid, timeoutSec));
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::postEnroll() {
|
|
||||||
return ErrorFilter(mDevice->post_enroll(mDevice));
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
|
|
||||||
return mDevice->get_authenticator_id(mDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
|
||||||
return ErrorFilter(mDevice->cancel(mDevice));
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
|
||||||
return ErrorFilter(mDevice->enumerate(mDevice));
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
|
|
||||||
return ErrorFilter(mDevice->remove(mDevice, gid, fid));
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
|
||||||
const hidl_string& storePath) {
|
|
||||||
if (storePath.size() >= PATH_MAX || storePath.size() <= 0) {
|
|
||||||
ALOGE("Bad path length: %zd", storePath.size());
|
|
||||||
return RequestStatus::SYS_EINVAL;
|
|
||||||
}
|
|
||||||
if (access(storePath.c_str(), W_OK)) {
|
|
||||||
return RequestStatus::SYS_EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ErrorFilter(mDevice->set_active_group(mDevice, gid,
|
|
||||||
storePath.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId,
|
|
||||||
uint32_t gid) {
|
|
||||||
return ErrorFilter(mDevice->authenticate(mDevice, operationId, gid));
|
|
||||||
}
|
|
||||||
|
|
||||||
IBiometricsFingerprint* BiometricsFingerprint::getInstance() {
|
|
||||||
if (!sInstance) {
|
|
||||||
sInstance = new BiometricsFingerprint();
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* BiometricsFingerprint::getModuleId() {
|
|
||||||
int sensor_version = -1;
|
|
||||||
std::ifstream file("/sys/devices/platform/soc/soc:fingerprint_detect/sensor_version");
|
|
||||||
file >> sensor_version;
|
|
||||||
ALOGI("fp sensor version is: 0x%x", sensor_version);
|
|
||||||
return sensor_version == 0x9638 ? "goodix.g6.fod" : "goodix.fod";
|
|
||||||
}
|
|
||||||
|
|
||||||
fingerprint_device_t* BiometricsFingerprint::openHal() {
|
|
||||||
int err;
|
|
||||||
const hw_module_t *hw_mdl = nullptr;
|
|
||||||
ALOGD("Opening fingerprint hal library...");
|
|
||||||
if (0 != (err = hw_get_module(getModuleId(), &hw_mdl))) {
|
|
||||||
ALOGE("Can't open fingerprint HW Module, error: %d", err);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hw_mdl == nullptr) {
|
|
||||||
ALOGE("No valid fingerprint module");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
fingerprint_module_t const *module =
|
|
||||||
reinterpret_cast<const fingerprint_module_t*>(hw_mdl);
|
|
||||||
if (module->common.methods->open == nullptr) {
|
|
||||||
ALOGE("No valid open method");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
hw_device_t *device = nullptr;
|
|
||||||
|
|
||||||
if (0 != (err = module->common.methods->open(hw_mdl, nullptr, &device))) {
|
|
||||||
ALOGE("Can't open fingerprint methods, error: %d", err);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kVersion != device->version) {
|
|
||||||
// enforce version on new devices because of HIDL@2.1 translation layer
|
|
||||||
ALOGE("Wrong fp version. Expected %d, got %d", kVersion, device->version);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
fingerprint_device_t* fp_device =
|
|
||||||
reinterpret_cast<fingerprint_device_t*>(device);
|
|
||||||
|
|
||||||
if (0 != (err =
|
|
||||||
fp_device->set_notify(fp_device, BiometricsFingerprint::notify))) {
|
|
||||||
ALOGE("Can't register fingerprint module callback, error: %d", err);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fp_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BiometricsFingerprint::notify(const fingerprint_msg_t *msg) {
|
|
||||||
BiometricsFingerprint* thisPtr = static_cast<BiometricsFingerprint*>(
|
|
||||||
BiometricsFingerprint::getInstance());
|
|
||||||
std::lock_guard<std::mutex> lock(thisPtr->mClientCallbackMutex);
|
|
||||||
if (thisPtr == nullptr || thisPtr->mClientCallback == nullptr) {
|
|
||||||
ALOGE("Receiving callbacks before the client callback is registered.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const uint64_t devId = reinterpret_cast<uint64_t>(thisPtr->mDevice);
|
|
||||||
switch (msg->type) {
|
|
||||||
case FINGERPRINT_ERROR: {
|
|
||||||
int32_t vendorCode = 0;
|
|
||||||
FingerprintError result = VendorErrorFilter(msg->data.error, &vendorCode);
|
|
||||||
ALOGD("onError(%d)", result);
|
|
||||||
if (!thisPtr->mClientCallback->onError(devId, result, vendorCode).isOk()) {
|
|
||||||
ALOGE("failed to invoke fingerprint onError callback");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FINGERPRINT_ACQUIRED: {
|
|
||||||
int32_t vendorCode = 0;
|
|
||||||
FingerprintAcquiredInfo result =
|
|
||||||
VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode);
|
|
||||||
ALOGD("onAcquired(%d)", result);
|
|
||||||
if (!thisPtr->mClientCallback->onAcquired(devId, result, vendorCode).isOk()) {
|
|
||||||
ALOGE("failed to invoke fingerprint onAcquired callback");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FINGERPRINT_TEMPLATE_ENROLLING:
|
|
||||||
ALOGD("onEnrollResult(fid=%d, gid=%d, rem=%d)",
|
|
||||||
msg->data.enroll.finger.fid,
|
|
||||||
msg->data.enroll.finger.gid,
|
|
||||||
msg->data.enroll.samples_remaining);
|
|
||||||
if (!thisPtr->mClientCallback->onEnrollResult(devId,
|
|
||||||
msg->data.enroll.finger.fid,
|
|
||||||
msg->data.enroll.finger.gid,
|
|
||||||
msg->data.enroll.samples_remaining).isOk()) {
|
|
||||||
ALOGE("failed to invoke fingerprint onEnrollResult callback");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FINGERPRINT_TEMPLATE_REMOVED:
|
|
||||||
ALOGD("onRemove(fid=%d, gid=%d, rem=%d)",
|
|
||||||
msg->data.removed.finger.fid,
|
|
||||||
msg->data.removed.finger.gid,
|
|
||||||
msg->data.removed.remaining_templates);
|
|
||||||
if (!thisPtr->mClientCallback->onRemoved(devId,
|
|
||||||
msg->data.removed.finger.fid,
|
|
||||||
msg->data.removed.finger.gid,
|
|
||||||
msg->data.removed.remaining_templates).isOk()) {
|
|
||||||
ALOGE("failed to invoke fingerprint onRemoved callback");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FINGERPRINT_AUTHENTICATED:
|
|
||||||
if (msg->data.authenticated.finger.fid != 0) {
|
|
||||||
ALOGD("onAuthenticated(fid=%d, gid=%d)",
|
|
||||||
msg->data.authenticated.finger.fid,
|
|
||||||
msg->data.authenticated.finger.gid);
|
|
||||||
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->onAuthenticated(devId,
|
|
||||||
msg->data.authenticated.finger.fid,
|
|
||||||
msg->data.authenticated.finger.gid,
|
|
||||||
token).isOk()) {
|
|
||||||
ALOGE("failed to invoke fingerprint onAuthenticated callback");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Not a recognized fingerprint
|
|
||||||
if (!thisPtr->mClientCallback->onAuthenticated(devId,
|
|
||||||
msg->data.authenticated.finger.fid,
|
|
||||||
msg->data.authenticated.finger.gid,
|
|
||||||
hidl_vec<uint8_t>()).isOk()) {
|
|
||||||
ALOGE("failed to invoke fingerprint onAuthenticated callback");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FINGERPRINT_TEMPLATE_ENUMERATING:
|
|
||||||
ALOGD("onEnumerate(fid=%d, gid=%d, rem=%d)",
|
|
||||||
msg->data.enumerated.finger.fid,
|
|
||||||
msg->data.enumerated.finger.gid,
|
|
||||||
msg->data.enumerated.remaining_templates);
|
|
||||||
if (!thisPtr->mClientCallback->onEnumerate(devId,
|
|
||||||
msg->data.enumerated.finger.fid,
|
|
||||||
msg->data.enumerated.finger.gid,
|
|
||||||
msg->data.enumerated.remaining_templates).isOk()) {
|
|
||||||
ALOGE("failed to invoke fingerprint onEnumerate callback");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_1
|
|
||||||
} // namespace fingerprint
|
|
||||||
} // namespace biometrics
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
|
@ -1,85 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
|
|
||||||
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
|
|
||||||
|
|
||||||
#include <log/log.h>
|
|
||||||
#include <android/log.h>
|
|
||||||
#include <hardware/hardware.h>
|
|
||||||
#include <hardware/fingerprint.h>
|
|
||||||
#include <hidl/MQDescriptor.h>
|
|
||||||
#include <hidl/Status.h>
|
|
||||||
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
namespace hardware {
|
|
||||||
namespace biometrics {
|
|
||||||
namespace fingerprint {
|
|
||||||
namespace V2_1 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
|
|
||||||
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
|
|
||||||
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
using ::android::hardware::hidl_vec;
|
|
||||||
using ::android::hardware::hidl_string;
|
|
||||||
using ::android::sp;
|
|
||||||
|
|
||||||
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|
||||||
public:
|
|
||||||
BiometricsFingerprint();
|
|
||||||
~BiometricsFingerprint();
|
|
||||||
|
|
||||||
// Method to wrap legacy HAL with BiometricsFingerprint class
|
|
||||||
static IBiometricsFingerprint* getInstance();
|
|
||||||
|
|
||||||
// Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
|
|
||||||
Return<uint64_t> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
|
|
||||||
Return<uint64_t> preEnroll() override;
|
|
||||||
Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
|
|
||||||
Return<RequestStatus> postEnroll() override;
|
|
||||||
Return<uint64_t> getAuthenticatorId() override;
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static const char* getModuleId();
|
|
||||||
static fingerprint_device_t* openHal();
|
|
||||||
static void notify(const fingerprint_msg_t *msg); /* Static callback for legacy HAL implementation */
|
|
||||||
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 BiometricsFingerprint* sInstance;
|
|
||||||
|
|
||||||
std::mutex mClientCallbackMutex;
|
|
||||||
sp<IBiometricsFingerprintClientCallback> mClientCallback;
|
|
||||||
fingerprint_device_t *mDevice;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_1
|
|
||||||
} // namespace fingerprint
|
|
||||||
} // namespace biometrics
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
||||||
|
|
||||||
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
|
|
|
@ -1,8 +0,0 @@
|
||||||
service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.oneplus_lahaina
|
|
||||||
# "class hal" causes a race condition on some devices due to files created
|
|
||||||
# in /data. As a workaround, postpone startup until later in boot once
|
|
||||||
# /data is mounted.
|
|
||||||
class late_start
|
|
||||||
user system
|
|
||||||
group system input uhid
|
|
||||||
#writepid /dev/cpuset/system-background/tasks
|
|
|
@ -1,11 +0,0 @@
|
||||||
<manifest version="1.0" type="device">
|
|
||||||
<hal format="hidl">
|
|
||||||
<name>android.hardware.biometrics.fingerprint</name>
|
|
||||||
<transport>hwbinder</transport>
|
|
||||||
<version>2.1</version>
|
|
||||||
<interface>
|
|
||||||
<name>IBiometricsFingerprint</name>
|
|
||||||
<instance>default</instance>
|
|
||||||
</interface>
|
|
||||||
</hal>
|
|
||||||
</manifest>
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service"
|
|
||||||
|
|
||||||
#include <android/log.h>
|
|
||||||
#include <hidl/HidlSupport.h>
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
|
|
||||||
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
|
|
||||||
#include "BiometricsFingerprint.h"
|
|
||||||
|
|
||||||
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
|
|
||||||
using android::hardware::biometrics::fingerprint::V2_1::implementation::BiometricsFingerprint;
|
|
||||||
using android::hardware::configureRpcThreadpool;
|
|
||||||
using android::hardware::joinRpcThreadpool;
|
|
||||||
using android::sp;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
android::sp<IBiometricsFingerprint> bio = BiometricsFingerprint::getInstance();
|
|
||||||
|
|
||||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
|
||||||
|
|
||||||
if (bio != nullptr) {
|
|
||||||
if (::android::OK != bio->registerAsService()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ALOGE("Can't create instance of BiometricsFingerprint, nullptr");
|
|
||||||
}
|
|
||||||
|
|
||||||
joinRpcThreadpool();
|
|
||||||
|
|
||||||
return 0; // should never get here
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (C) 2019-2021 The LineageOS Project
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
soong_config_module_type {
|
|
||||||
name: "oneplus_lahaina_fod_hal_cc_defaults",
|
|
||||||
module_type: "cc_defaults",
|
|
||||||
config_namespace: "ONEPLUS_LAHAINA_FOD",
|
|
||||||
value_variables: ["POS_X", "POS_Y", "SIZE"],
|
|
||||||
properties: ["cppflags"],
|
|
||||||
}
|
|
||||||
|
|
||||||
oneplus_lahaina_fod_hal_cc_defaults {
|
|
||||||
name: "oneplus_lahaina_fod_hal_defaults",
|
|
||||||
soong_config_variables: {
|
|
||||||
POS_X: {
|
|
||||||
cppflags: ["-DFOD_POS_X=%s"],
|
|
||||||
},
|
|
||||||
POS_Y: {
|
|
||||||
cppflags: ["-DFOD_POS_Y=%s"],
|
|
||||||
},
|
|
||||||
SIZE: {
|
|
||||||
cppflags: ["-DFOD_SIZE=%s"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
name: "vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.oneplus_lahaina",
|
|
||||||
defaults: [
|
|
||||||
"hidl_defaults",
|
|
||||||
"oneplus_lahaina_fod_hal_defaults",
|
|
||||||
],
|
|
||||||
relative_install_path: "hw",
|
|
||||||
init_rc: ["vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.oneplus_lahaina.rc"],
|
|
||||||
vintf_fragments: ["vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.oneplus_lahaina.xml"],
|
|
||||||
srcs: ["service.cpp", "FingerprintInscreen.cpp"],
|
|
||||||
shared_libs: [
|
|
||||||
"libbase",
|
|
||||||
"libhardware",
|
|
||||||
"libhidlbase",
|
|
||||||
"liblog",
|
|
||||||
"libutils",
|
|
||||||
"vendor.lineage.biometrics.fingerprint.inscreen@1.0",
|
|
||||||
"//device/oneplus/common:vendor.oneplus.fingerprint.extension@1.0",
|
|
||||||
"//device/oneplus/common:vendor.oneplus.hardware.display@1.0",
|
|
||||||
],
|
|
||||||
proprietary: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_library_static {
|
|
||||||
name: "libfod_extension.oneplus_lahaina",
|
|
||||||
srcs: ["FodExtension.cpp"],
|
|
||||||
include_dirs: [
|
|
||||||
"frameworks/native/services/surfaceflinger/CompositionEngine/include"
|
|
||||||
],
|
|
||||||
}
|
|
|
@ -1,182 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "FingerprintInscreenService"
|
|
||||||
|
|
||||||
#include "FingerprintInscreen.h"
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#define FINGERPRINT_ACQUIRED_VENDOR 6
|
|
||||||
#define FINGERPRINT_ERROR_VENDOR 8
|
|
||||||
|
|
||||||
#define OP_ENABLE_FP_LONGPRESS 3
|
|
||||||
#define OP_DISABLE_FP_LONGPRESS 4
|
|
||||||
#define OP_RESUME_FP_ENROLL 8
|
|
||||||
#define OP_FINISH_FP_ENROLL 10
|
|
||||||
|
|
||||||
#define OP_DISPLAY_AOD_MODE 8
|
|
||||||
#define OP_DISPLAY_NOTIFY_PRESS 9
|
|
||||||
#define OP_DISPLAY_SET_DIM 10
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace biometrics {
|
|
||||||
namespace fingerprint {
|
|
||||||
namespace inscreen {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write value to path and close file.
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
static void set(const std::string& path, const T& value) {
|
|
||||||
std::ofstream file(path);
|
|
||||||
file << value;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static T get(const std::string& path, const T& def) {
|
|
||||||
std::ifstream file(path);
|
|
||||||
T result;
|
|
||||||
|
|
||||||
file >> result;
|
|
||||||
return file.fail() ? def : result;
|
|
||||||
}
|
|
||||||
|
|
||||||
FingerprintInscreen::FingerprintInscreen() {
|
|
||||||
this->mFodCircleVisible = false;
|
|
||||||
this->mVendorFpService = IVendorFingerprintExtensions::getService();
|
|
||||||
this->mVendorDisplayService = IOneplusDisplay::getService();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::onStartEnroll() {
|
|
||||||
this->mVendorFpService->updateStatus(OP_DISABLE_FP_LONGPRESS);
|
|
||||||
this->mVendorFpService->updateStatus(OP_RESUME_FP_ENROLL);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::onFinishEnroll() {
|
|
||||||
this->mVendorFpService->updateStatus(OP_FINISH_FP_ENROLL);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::onPress() {
|
|
||||||
this->mVendorDisplayService->setMode(OP_DISPLAY_NOTIFY_PRESS, 1);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::onRelease() {
|
|
||||||
this->mVendorDisplayService->setMode(OP_DISPLAY_NOTIFY_PRESS, 0);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::onShowFODView() {
|
|
||||||
this->mFodCircleVisible = true;
|
|
||||||
this->mVendorDisplayService->setMode(OP_DISPLAY_SET_DIM, 1);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::onHideFODView() {
|
|
||||||
this->mFodCircleVisible = false;
|
|
||||||
this->mVendorDisplayService->setMode(OP_DISPLAY_AOD_MODE, 0);
|
|
||||||
this->mVendorDisplayService->setMode(OP_DISPLAY_SET_DIM, 0);
|
|
||||||
this->mVendorDisplayService->setMode(OP_DISPLAY_NOTIFY_PRESS, 0);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) {
|
|
||||||
std::lock_guard<std::mutex> _lock(mCallbackLock);
|
|
||||||
if (mCallback == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acquiredInfo == FINGERPRINT_ACQUIRED_VENDOR) {
|
|
||||||
if (mFodCircleVisible && vendorCode == 0) {
|
|
||||||
Return<void> ret = mCallback->onFingerDown();
|
|
||||||
if (!ret.isOk()) {
|
|
||||||
LOG(ERROR) << "FingerDown() error: " << ret.description();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mFodCircleVisible && vendorCode == 1) {
|
|
||||||
Return<void> ret = mCallback->onFingerUp();
|
|
||||||
if (!ret.isOk()) {
|
|
||||||
LOG(ERROR) << "FingerUp() error: " << ret.description();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> FingerprintInscreen::handleError(int32_t error, int32_t vendorCode) {
|
|
||||||
return error == FINGERPRINT_ERROR_VENDOR && vendorCode == 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::setLongPressEnabled(bool enabled) {
|
|
||||||
this->mVendorFpService->updateStatus(
|
|
||||||
enabled ? OP_ENABLE_FP_LONGPRESS : OP_DISABLE_FP_LONGPRESS);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<int32_t> FingerprintInscreen::getDimAmount(int32_t) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> FingerprintInscreen::shouldBoostBrightness() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> FingerprintInscreen::setCallback(const sp<IFingerprintInscreenCallback>& callback) {
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> _lock(mCallbackLock);
|
|
||||||
mCallback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<int32_t> FingerprintInscreen::getPositionX() {
|
|
||||||
return FOD_POS_X;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<int32_t> FingerprintInscreen::getPositionY() {
|
|
||||||
return FOD_POS_Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<int32_t> FingerprintInscreen::getSize() {
|
|
||||||
return FOD_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace inscreen
|
|
||||||
} // namespace fingerprint
|
|
||||||
} // namespace biometrics
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
#ifndef VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
|
|
||||||
#define VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
|
|
||||||
|
|
||||||
#include <vendor/lineage/biometrics/fingerprint/inscreen/1.0/IFingerprintInscreen.h>
|
|
||||||
#include <vendor/oneplus/fingerprint/extension/1.0/IVendorFingerprintExtensions.h>
|
|
||||||
#include <vendor/oneplus/hardware/display/1.0/IOneplusDisplay.h>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace biometrics {
|
|
||||||
namespace fingerprint {
|
|
||||||
namespace inscreen {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::sp;
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
using ::vendor::oneplus::fingerprint::extension::V1_0::IVendorFingerprintExtensions;
|
|
||||||
using ::vendor::oneplus::hardware::display::V1_0::IOneplusDisplay;
|
|
||||||
|
|
||||||
class FingerprintInscreen : public IFingerprintInscreen {
|
|
||||||
public:
|
|
||||||
FingerprintInscreen();
|
|
||||||
|
|
||||||
Return<void> onStartEnroll() override;
|
|
||||||
Return<void> onFinishEnroll() override;
|
|
||||||
Return<void> onPress() override;
|
|
||||||
Return<void> onRelease() override;
|
|
||||||
Return<void> onShowFODView() override;
|
|
||||||
Return<void> onHideFODView() override;
|
|
||||||
Return<bool> handleAcquired(int32_t acquiredInfo, int32_t vendorCode) override;
|
|
||||||
Return<bool> handleError(int32_t error, int32_t vendorCode) override;
|
|
||||||
Return<void> setLongPressEnabled(bool enabled) override;
|
|
||||||
Return<int32_t> getDimAmount(int32_t cur_brightness) override;
|
|
||||||
Return<bool> shouldBoostBrightness() override;
|
|
||||||
Return<void> setCallback(const sp<IFingerprintInscreenCallback>& callback) override;
|
|
||||||
Return<int32_t> getPositionX() override;
|
|
||||||
Return<int32_t> getPositionY() override;
|
|
||||||
Return<int32_t> getSize() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool mFodCircleVisible;
|
|
||||||
|
|
||||||
sp<IOneplusDisplay> mVendorDisplayService;
|
|
||||||
sp<IVendorFingerprintExtensions> mVendorFpService;
|
|
||||||
|
|
||||||
std::mutex mCallbackLock;
|
|
||||||
sp<IFingerprintInscreenCallback> mCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace inscreen
|
|
||||||
} // namespace fingerprint
|
|
||||||
} // namespace biometrics
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
|
|
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <compositionengine/FodExtension.h>
|
|
||||||
|
|
||||||
uint32_t getFodZOrder(uint32_t z, bool touched) {
|
|
||||||
return touched ? 0xfc8 : z;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t getFodUsageBits(uint64_t usageBits, bool) {
|
|
||||||
return usageBits;
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.oneplus_lahaina"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
|
|
||||||
#include "FingerprintInscreen.h"
|
|
||||||
|
|
||||||
using android::hardware::configureRpcThreadpool;
|
|
||||||
using android::hardware::joinRpcThreadpool;
|
|
||||||
|
|
||||||
using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreen;
|
|
||||||
using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::implementation::FingerprintInscreen;
|
|
||||||
|
|
||||||
using android::OK;
|
|
||||||
using android::status_t;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
android::sp<IFingerprintInscreen> service = new FingerprintInscreen();
|
|
||||||
|
|
||||||
configureRpcThreadpool(1, true);
|
|
||||||
|
|
||||||
status_t status = service->registerAsService();
|
|
||||||
if (status != OK) {
|
|
||||||
LOG(ERROR) << "Cannot register FOD HAL service.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(INFO) << "FOD HAL service ready.";
|
|
||||||
|
|
||||||
joinRpcThreadpool();
|
|
||||||
|
|
||||||
LOG(ERROR) << "FOD HAL service failed to join thread pool.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
service vendor.fingerprint-inscreen-1-0 /vendor/bin/hw/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.oneplus_lahaina
|
|
||||||
interface vendor.lineage.biometrics.fingerprint.inscreen@1.0::IFingerprintInscreen default
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group system
|
|
||||||
shutdown critical
|
|
|
@ -1,11 +0,0 @@
|
||||||
<manifest version="1.0" type="device">
|
|
||||||
<hal format="hidl">
|
|
||||||
<name>vendor.lineage.biometrics.fingerprint.inscreen</name>
|
|
||||||
<transport>hwbinder</transport>
|
|
||||||
<version>1.0</version>
|
|
||||||
<interface>
|
|
||||||
<name>IFingerprintInscreen</name>
|
|
||||||
<instance>default</instance>
|
|
||||||
</interface>
|
|
||||||
</hal>
|
|
||||||
</manifest>
|
|
|
@ -1,7 +1,7 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"repository": "android_device_oneplus_common",
|
"repository": "android_hardware_oneplus",
|
||||||
"target_path": "device/oneplus/common"
|
"target_path": "hardware/oneplus"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"repository": "android_kernel_oneplus_sm8350",
|
"repository": "android_kernel_oneplus_sm8350",
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
BasedOnStyle: Google
|
|
||||||
AccessModifierOffset: -2
|
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
|
||||||
ColumnLimit: 100
|
|
||||||
CommentPragmas: NOLINT:.*
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
IndentWidth: 4
|
|
||||||
PointerAlignment: Left
|
|
||||||
TabWidth: 4
|
|
||||||
UseTab: Never
|
|
||||||
PenaltyExcessCharacter: 32
|
|
|
@ -1,41 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (C) 2019 The LineageOS Project
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
name: "vendor.lineage.livedisplay@2.1-service.oneplus_lahaina",
|
|
||||||
init_rc: ["vendor.lineage.livedisplay@2.1-service.oneplus_lahaina.rc"],
|
|
||||||
vintf_fragments: ["vendor.lineage.livedisplay@2.1-service.oneplus_lahaina.xml"],
|
|
||||||
defaults: ["hidl_defaults"],
|
|
||||||
relative_install_path: "hw",
|
|
||||||
srcs: [
|
|
||||||
":vendor.lineage.livedisplay@2.0-sdm-pa",
|
|
||||||
":vendor.lineage.livedisplay@2.0-sdm-utils",
|
|
||||||
"AntiFlicker.cpp",
|
|
||||||
"SunlightEnhancement.cpp",
|
|
||||||
"service.cpp",
|
|
||||||
],
|
|
||||||
shared_libs: [
|
|
||||||
"libbase",
|
|
||||||
"libbinder",
|
|
||||||
"libhidlbase",
|
|
||||||
"libutils",
|
|
||||||
"vendor.lineage.livedisplay@2.0",
|
|
||||||
"vendor.lineage.livedisplay@2.1",
|
|
||||||
],
|
|
||||||
header_libs: [
|
|
||||||
"vendor.lineage.livedisplay@2.0-sdm-headers",
|
|
||||||
],
|
|
||||||
proprietary: true,
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2021 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "AntiFlickerService"
|
|
||||||
|
|
||||||
#include "AntiFlicker.h"
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_1 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
static constexpr const char* kDcDimmingPath =
|
|
||||||
"/sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/dimlayer_bl_en";
|
|
||||||
|
|
||||||
Return<bool> AntiFlicker::isEnabled() {
|
|
||||||
std::ifstream file(kDcDimmingPath);
|
|
||||||
int result = -1;
|
|
||||||
file >> result;
|
|
||||||
LOG(DEBUG) << "Got result " << result << " fail " << file.fail();
|
|
||||||
return !file.fail() && result > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> AntiFlicker::setEnabled(bool enabled) {
|
|
||||||
std::ofstream file(kDcDimmingPath);
|
|
||||||
file << (enabled ? "1" : "0");
|
|
||||||
LOG(DEBUG) << "setEnabled fail " << file.fail();
|
|
||||||
return !file.fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_1
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2021 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H
|
|
||||||
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H
|
|
||||||
|
|
||||||
#include <hidl/MQDescriptor.h>
|
|
||||||
#include <hidl/Status.h>
|
|
||||||
#include <vendor/lineage/livedisplay/2.1/IAntiFlicker.h>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_1 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
using ::android::sp;
|
|
||||||
|
|
||||||
class AntiFlicker : public IAntiFlicker {
|
|
||||||
public:
|
|
||||||
// Methods from ::vendor::lineage::livedisplay::V2_1::IAntiFlicker follow.
|
|
||||||
Return<bool> isEnabled() override;
|
|
||||||
Return<bool> setEnabled(bool enabled) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_1
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "SunlightEnhancementService"
|
|
||||||
|
|
||||||
#include "SunlightEnhancement.h"
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_1 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
static constexpr const char* kHbmPath =
|
|
||||||
"/sys/class/drm/card0-DSI-1/hbm";
|
|
||||||
|
|
||||||
Return<bool> SunlightEnhancement::isEnabled() {
|
|
||||||
std::ifstream file(kHbmPath);
|
|
||||||
int result = -1;
|
|
||||||
file >> result;
|
|
||||||
LOG(DEBUG) << "Got result " << result << " fail " << file.fail();
|
|
||||||
return !file.fail() && result > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> SunlightEnhancement::setEnabled(bool enabled) {
|
|
||||||
std::ofstream file(kHbmPath);
|
|
||||||
file << (enabled ? "5" : "0");
|
|
||||||
LOG(DEBUG) << "setEnabled fail " << file.fail();
|
|
||||||
return !file.fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_1
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H
|
|
||||||
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H
|
|
||||||
|
|
||||||
#include <hidl/MQDescriptor.h>
|
|
||||||
#include <hidl/Status.h>
|
|
||||||
#include <vendor/lineage/livedisplay/2.1/ISunlightEnhancement.h>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_1 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
using ::android::sp;
|
|
||||||
|
|
||||||
class SunlightEnhancement : public ISunlightEnhancement {
|
|
||||||
public:
|
|
||||||
// Methods from ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement follow.
|
|
||||||
Return<bool> isEnabled() override;
|
|
||||||
Return<bool> setEnabled(bool enabled) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_1
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H
|
|
|
@ -1,85 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "vendor.lineage.livedisplay@2.1-service.oneplus_lahaina"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <binder/ProcessState.h>
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
#include <livedisplay/sdm/PictureAdjustment.h>
|
|
||||||
#include <vendor/lineage/livedisplay/2.1/IPictureAdjustment.h>
|
|
||||||
|
|
||||||
#include "AntiFlicker.h"
|
|
||||||
#include "SunlightEnhancement.h"
|
|
||||||
|
|
||||||
using android::OK;
|
|
||||||
using android::sp;
|
|
||||||
using android::status_t;
|
|
||||||
using android::hardware::configureRpcThreadpool;
|
|
||||||
using android::hardware::joinRpcThreadpool;
|
|
||||||
|
|
||||||
using ::vendor::lineage::livedisplay::V2_0::sdm::PictureAdjustment;
|
|
||||||
using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController;
|
|
||||||
using ::vendor::lineage::livedisplay::V2_1::IAntiFlicker;
|
|
||||||
using ::vendor::lineage::livedisplay::V2_1::IPictureAdjustment;
|
|
||||||
using ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement;
|
|
||||||
using ::vendor::lineage::livedisplay::V2_1::implementation::AntiFlicker;
|
|
||||||
using ::vendor::lineage::livedisplay::V2_1::implementation::SunlightEnhancement;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
status_t status = OK;
|
|
||||||
|
|
||||||
android::ProcessState::initWithDriver("/dev/vndbinder");
|
|
||||||
|
|
||||||
LOG(INFO) << "LiveDisplay HAL service is starting.";
|
|
||||||
|
|
||||||
std::shared_ptr<SDMController> controller = std::make_shared<SDMController>();
|
|
||||||
sp<AntiFlicker> af = new AntiFlicker();
|
|
||||||
sp<PictureAdjustment> pa = new PictureAdjustment(controller);
|
|
||||||
sp<SunlightEnhancement> se = new SunlightEnhancement();
|
|
||||||
|
|
||||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
|
||||||
|
|
||||||
status = af->registerAsService();
|
|
||||||
if (status != OK) {
|
|
||||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL AntiFlicker Iface ("
|
|
||||||
<< status << ")";
|
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = pa->registerAsService();
|
|
||||||
if (status != OK) {
|
|
||||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL PictureAdjustment Iface ("
|
|
||||||
<< status << ")";
|
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = se->registerAsService();
|
|
||||||
if (status != OK) {
|
|
||||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface ("
|
|
||||||
<< status << ")";
|
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(INFO) << "LiveDisplay HAL service is ready.";
|
|
||||||
joinRpcThreadpool();
|
|
||||||
// Should not pass this line
|
|
||||||
|
|
||||||
shutdown:
|
|
||||||
// In normal operation, we don't expect the thread pool to shutdown
|
|
||||||
LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
on init
|
|
||||||
chown system graphics /sys/class/drm/card0-DSI-1/dimlayer_bl_en
|
|
||||||
chown system graphics /sys/class/drm/card0-DSI-1/hbm
|
|
||||||
chmod 0666 /sys/class/drm/card0-DSI-1/dimlayer_bl_en
|
|
||||||
chmod 0666 /sys/class/drm/card0-DSI-1/hbm
|
|
||||||
|
|
||||||
service vendor.livedisplay-hal-2-1 /vendor/bin/hw/vendor.lineage.livedisplay@2.1-service.oneplus_lahaina
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group system
|
|
|
@ -1,16 +0,0 @@
|
||||||
<manifest version="1.0" type="device">
|
|
||||||
<hal format="hidl">
|
|
||||||
<name>vendor.lineage.livedisplay</name>
|
|
||||||
<transport>hwbinder</transport>
|
|
||||||
<version>2.1</version>
|
|
||||||
<interface>
|
|
||||||
<name>IAntiFlicker</name>
|
|
||||||
<instance>default</instance>
|
|
||||||
</interface>
|
|
||||||
<interface>
|
|
||||||
<name>ISunlightEnhancement</name>
|
|
||||||
<instance>default</instance>
|
|
||||||
</interface>
|
|
||||||
<fqname>@2.0::IPictureAdjustment/default</fqname>
|
|
||||||
</hal>
|
|
||||||
</manifest>
|
|
|
@ -1,8 +0,0 @@
|
||||||
java_library {
|
|
||||||
name: "oneplus-fwk.oneplus_lahaina",
|
|
||||||
installable: true,
|
|
||||||
|
|
||||||
srcs: [
|
|
||||||
"src/**/*.java",
|
|
||||||
],
|
|
||||||
}
|
|
|
@ -1,418 +0,0 @@
|
||||||
package android.util;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.BitSet;
|
|
||||||
|
|
||||||
public final class OpFeatures {
|
|
||||||
|
|
||||||
private static String LOG_TAG = OpFeatures.class.getSimpleName();
|
|
||||||
|
|
||||||
public static final int OP_FEATURE_SKU_CHINA = 0;
|
|
||||||
public static final int OP_FEATURE_SKU_GLOBAL = 1;
|
|
||||||
public static final int OP_FEATURE_MDM = 2;
|
|
||||||
public static final int OP_FEATURE_AUTO_STARTUP = 3;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_LTM = 4;
|
|
||||||
public static final int OP_FEATURE_OP_KEYGUARD = 5;
|
|
||||||
public static final int OP_FEATURE_FASTPAIR = 6;
|
|
||||||
public static final int OP_FEATURE_TURNOFF_LOADING = 7;
|
|
||||||
public static final int OP_FEATURE_MM_DISPLAY_COLOR_SCREEN_MODE = 8;
|
|
||||||
public static final int OP_FEATURE_SWAP_KEYS = 9;
|
|
||||||
public static final int OP_FEATURE_KEY_LOCK = 10;
|
|
||||||
public static final int OP_FEATURE_CTA_PERMISSION_CONTROL = 11;
|
|
||||||
public static final int OP_FEATURE_GESTURE_SCREENSHOT = 12;
|
|
||||||
public static final int OP_FEATURE_BG_DETECTION = 13;
|
|
||||||
public static final int OP_FEATURE_BLACK_GESTURE = 14;
|
|
||||||
public static final int OP_FEATURE_RESERVE_APP = 15;
|
|
||||||
public static final int OP_FEATURE_OPEN_ID = 16;
|
|
||||||
public static final int OP_FEATURE_URL_INSTANT_APP_AND_HEYTAP_BUSINESS = 17;
|
|
||||||
public static final int OP_FEATURE_CHANGE_PACKAGE_NAME = 18;
|
|
||||||
public static final int OP_FEATURE_APP_BOOT_MANAGER = 19;
|
|
||||||
public static final int OP_FEATURE_MEMORY_TRACKER = 20;
|
|
||||||
public static final int OP_FEATURE_APPRECORD = 21;
|
|
||||||
public static final int OP_FEATURE_APP_LOCKER = 22;
|
|
||||||
public static final int OP_FEATURE_LONG_SCREENSHOT = 23;
|
|
||||||
public static final int OP_FEATURE_SCENE_MODES = 24;
|
|
||||||
public static final int OP_FEATURE_QUICK_PAY = 25;
|
|
||||||
public static final int OP_FEATURE_PARALLEL_APP = 26;
|
|
||||||
public static final int OP_FEATURE_ONEPLUS_BOOTANIMATION = 27;
|
|
||||||
public static final int OP_FEATURE_UXREALM = 28;
|
|
||||||
public static final int OP_FEATURE_HIDE_NAVBAR = 29;
|
|
||||||
public static final int OP_FEATURE_APP_USAGE_CLASSIFICATION = 30;
|
|
||||||
public static final int OP_FEATURE_SCREEN_COMPAT = 31;
|
|
||||||
public static final int OP_FEATURE_QUICK_REPLY = 32;
|
|
||||||
public static final int OP_FEATURE_OTG_AUTO_SHUTDOWN = 33;
|
|
||||||
public static final int OP_FEATURE_FACE_UNLOCK = 34;
|
|
||||||
public static final int OP_FEATURE_BOOT_ENTER_BOUNCER = 35;
|
|
||||||
public static final int OP_FEATURE_VIBRATION_INTENSITY = 36;
|
|
||||||
public static final int OP_FEATURE_CUSTOM_STATUS_BAR = 37;
|
|
||||||
public static final int OP_FEATURE_NEW_PLAN_POWEWR_OFF_ALARM = 38;
|
|
||||||
public static final int OP_FEATURE_PCB_WATER_MARK = 39;
|
|
||||||
public static final int OP_FEATURE_SYSTEM_UPDATE_BY_AB = 40;
|
|
||||||
public static final int OP_FEATURE_ENABLE_AD = 41;
|
|
||||||
public static final int OP_FEATURE_ENABLE_EU = 42;
|
|
||||||
public static final int OP_FEATURE_ALWAYS_ON_DISPLAY = 43;
|
|
||||||
public static final int OP_FEATURE_SHOW_MULTI_VOLTE = 44;
|
|
||||||
public static final int OP_FEATURE_GESTURE_BUTTON = 45;
|
|
||||||
public static final int OP_FEATURE_HEARING_AID = 46;
|
|
||||||
public static final int OP_FEATURE_MM_AUDIO_OZO = 47;
|
|
||||||
public static final int OP_FEATURE_BLUETOOTH_HEADSET = 48;
|
|
||||||
public static final int OP_FEATURE_CAMERA_NOTCH = 49;
|
|
||||||
public static final int OP_FEATURE_HIDE_CAMERA_NOTCH = 50;
|
|
||||||
public static final int OP_FEATURE_CUSTOM_NAVBAR = 51;
|
|
||||||
public static final int OP_FEATURE_SHOW_HD_FOR_CT = 52;
|
|
||||||
public static final int OP_FEATURE_OPDIAGNOSE = 53;
|
|
||||||
public static final int OP_FEATURE_SETTINGS_QUICKPAY_ANIM_FOR_ENCHILADA = 54;
|
|
||||||
public static final int OP_FEATURE_ENABLE_FALSINGTOUCH = 55;
|
|
||||||
public static final int OP_FEATURE_GAMEMODE_NETBOOST = 56;
|
|
||||||
public static final int OP_FEATURE_GAMEMODE_POWERSAVER = 57;
|
|
||||||
public static final int OP_FEATURE_ENABLE_FINGERPRINT_VENDOR_MOUDLE = 58;
|
|
||||||
public static final int OP_FEATURE_SMALL_BOARD_CHECK_FAJITA = 59;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_CUSTOM_FINGERPRINT = 60;
|
|
||||||
public static final int OP_FEATURE_ENABLE_FINGERPRINT_POCKET = 61;
|
|
||||||
public static final int OP_FEATURE_SHUTDOWN_ANIMATION = 62;
|
|
||||||
public static final int OP_FEATURE_NETWORK_MODE_DISABLE_2G = 63;
|
|
||||||
public static final int OP_FEATURE_HEADSET_IMPEDANCE_DETECTION = 64;
|
|
||||||
public static final int OP_FEATURE_REMOVE_ROAMING_ICON = 65;
|
|
||||||
public static final int OP_FEATURE_DATA_ROAMING_ENABLE_MESSAGE = 66;
|
|
||||||
public static final int OP_FEATURE_OIMC = 67;
|
|
||||||
public static final int OP_FEATURE_APP_STATE_BROADCAST = 68;
|
|
||||||
public static final int OP_FEATURE_OPSM = 69;
|
|
||||||
public static final int OP_FEATURE_SHOW_4G_LTE = 70;
|
|
||||||
public static final int OP_FEATURE_RTT = 71;
|
|
||||||
public static final int OP_FEATURE_ANT_MODE_1X1 = 72;
|
|
||||||
public static final int OP_FEATURE_UST_MODE = 73;
|
|
||||||
public static final int OP_FEATURE_CUSTOM_BLINK_LIGHT = 74;
|
|
||||||
public static final int OP_FEATURE_AGGRESSIVE_DOZE = 75;
|
|
||||||
public static final int OP_FEATURE_SMART_POWER_CONTROL = 76;
|
|
||||||
public static final int OP_FEATURE_ALARM_ALIGNMENT = 77;
|
|
||||||
public static final int OP_FEATURE_BACKGROUND_PROCESS_FROZEN = 78;
|
|
||||||
public static final int OP_FEATURE_DEEP_TASK_CLEANER = 79;
|
|
||||||
public static final int OP_FEATURE_BGC = 80;
|
|
||||||
public static final int OP_FEATURE_OPCS_RECORD_SCREENON_TIME = 81;
|
|
||||||
public static final int OP_FEATURE_OHPD = 82;
|
|
||||||
public static final int OP_FEATURE_OHPD_CLEAN_LOW = 83;
|
|
||||||
public static final int OP_FEATURE_MM_SCREENOFF_WAKEUP = 84;
|
|
||||||
public static final int OP_FEATURE_FROZEN = 85;
|
|
||||||
public static final int OP_FEATURE_QUICK_LAUNCH = 86;
|
|
||||||
public static final int OP_FEATURE_SWEET_MOMENTS = 87;
|
|
||||||
public static final int OP_FEATURE_COLOR_MODE_FB0 = 88;
|
|
||||||
public static final int OP_FEATURE_MAX_BACKLIGHT = 89;
|
|
||||||
public static final int OP_FEATURE_CUSTOME_ANIMATION = 90;
|
|
||||||
public static final int OP_FEATURE_MOTOR_CONTROL = 91;
|
|
||||||
public static final int OP_FEATURE_SHOW_NOTIFICATION_BAR_BY_FINGERPRINT_SENSOR = 92;
|
|
||||||
public static final int OP_FEATURE_PROCESS_RESIDENT = 93;
|
|
||||||
public static final int OP_FEATURE_PARAM_BUILD_SERVICE = 94;
|
|
||||||
public static final int OP_FEATURE_OPERATOR_GPS_E911 = 95;
|
|
||||||
public static final int OP_FEATURE_SCREEN_REFRESH_RATE = 96;
|
|
||||||
public static final int OP_FEATURE_X_LINEAR_VIBRATION_MOTOR = 97;
|
|
||||||
public static final int OP_FEATURE_HBM_AUTO_ADJUST = 98;
|
|
||||||
public static final int OP_FEATURE_BOOST_BRIGHTNESS = 99;
|
|
||||||
public static final int OP_FEATURE_EN_P_SENSOR_IN_AB = 100;
|
|
||||||
public static final int OP_FEATURE_CN_GOOGLEPLAY_SERVICE = 101;
|
|
||||||
public static final int OP_FEATURE_FAKE_PROXIMITY = 102;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_5G = 103;
|
|
||||||
public static final int OP_FEATURE_PRELOAD_APP_TO_DATA = 104;
|
|
||||||
public static final int OP_FEATURE_SMART_BOOST = 105;
|
|
||||||
public static final int OP_FEATURE_NOTIFICATION_LIGHT = 106;
|
|
||||||
public static final int OP_FEATURE_IME_LAND_PADDING = 107;
|
|
||||||
public static final int OP_FEATURE_AD_MODE = 108;
|
|
||||||
public static final int OP_FEATURE_INSTALL_FROM_MARKET = 109;
|
|
||||||
public static final int OP_FEATURE_APP_PREDICTION = 110;
|
|
||||||
public static final int OP_FEATURE_MISTOUCH_PREVENTION = 111;
|
|
||||||
public static final int OP_FEATURE_READING_MODE_INTERPOLATER = 112;
|
|
||||||
public static final int OP_FEATURE_UPDATE_RESERVE = 113;
|
|
||||||
public static final int OP_FEATURE_SYSTEM_OVERLAY = 114;
|
|
||||||
public static final int OP_FEATURE_EARPHONE_MODE = 115;
|
|
||||||
public static final int OP_FEATURE_ENABLE_POCKETMODE_SWITCH = 116;
|
|
||||||
public static final int OP_FEATURE_RESRTICT_PKG_BASE_ON_NETWORK = 117;
|
|
||||||
public static final int OP_FEATURE_PREBUILD_NETFLIX = 118;
|
|
||||||
public static final int OP_FEATURE_APPS_DISPLAY_IN_FULLSCREEN = 119;
|
|
||||||
public static final int OP_FEATURE_CTA_USE_PACKAGEINSTALLER_PERMISSION = 120;
|
|
||||||
public static final int OP_FEATURE_WARP_CHARGE_5V6A = 121;
|
|
||||||
public static final int OP_FEATURE_SPRINT = 122;
|
|
||||||
public static final int OP_FEATURE_SPRINT_HIDDENMENU = 123;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_CUSTOMIZE_CLIENTID_MS = 124;
|
|
||||||
public static final int OP_FEATURE_OVERHEAT_ENABLE = 125;
|
|
||||||
public static final int OP_FEATURE_OVERHEAT_SKIN = 126;
|
|
||||||
public static final int OP_FEATURE_HIGH_VSYNC = 127;
|
|
||||||
public static final int OP_FEATURE_USS = 128;
|
|
||||||
public static final int OP_FEATURE_USS_HIDDENMENU = 129;
|
|
||||||
public static final int OP_FEATURE_POWER_CONSUMPTION_STATISTICS = 130;
|
|
||||||
public static final int OP_FEATURE_POWER_CONTROLLER = 131;
|
|
||||||
public static final int OP_FEATURE_COLOR_DISPLAY = 132;
|
|
||||||
public static final int OP_FEATURE_OVERHEAT_DIAGNOSIS = 133;
|
|
||||||
public static final int OP_FEATURE_OEMEX_SERVICE = 134;
|
|
||||||
public static final int OP_FEATURE_STANDBY_DETECTION = 135;
|
|
||||||
public static final int OP_FEATURE_ONEPLUS_SERVICE = 136;
|
|
||||||
public static final int OP_FEATURE_FAST_CHARGE = 137;
|
|
||||||
public static final int OP_FEATURE_MM_ALERTSLIDER = 138;
|
|
||||||
public static final int OP_FEATURE_MM_LOG = 139;
|
|
||||||
public static final int OP_FEATURE_MM_RESTORE_MODE = 140;
|
|
||||||
public static final int OP_FEATURE_MM_HEADSET_PROFILE = 141;
|
|
||||||
public static final int OP_FEATURE_MM_REDUCE_SAR = 142;
|
|
||||||
public static final int OP_FEATURE_MM_TA = 143;
|
|
||||||
public static final int OP_FEATURE_MM_SPECIAL_APP_SOUND_REDUCE = 144;
|
|
||||||
public static final int OP_FEATURE_MM_WIDEVINE_DRM_L1 = 145;
|
|
||||||
public static final int OP_FEATURE_MM_ULTRASOUND = 146;
|
|
||||||
public static final int OP_FEATURE_MM_EU_ACDB_LOADER = 147;
|
|
||||||
public static final int OP_FEATURE_MM_ENGINEERING_MODE = 148;
|
|
||||||
public static final int OP_FEATURE_DEVICE_DEFAULT_WALLPAPER = 149;
|
|
||||||
public static final int OP_FEATURE_WIFI_SERVICE = 150;
|
|
||||||
public static final int OP_FEATURE_MM_AW = 151;
|
|
||||||
public static final int OP_FEATURE_MM_CH_SWITCH = 152;
|
|
||||||
public static final int OP_FEATURE_MM_AUDIO_DIAGNOSIS = 153;
|
|
||||||
public static final int OP_FEATURE_PERF_MANAGER = 154;
|
|
||||||
public static final int OP_FEATURE_NEW_MEMORY_OPTIMIZATION = 155;
|
|
||||||
public static final int OP_FEATURE_OPUTIL = 156;
|
|
||||||
public static final int OP_FEATURE_SKIP_UIDIDLE = 157;
|
|
||||||
public static final int OP_FEATURE_SCREENSHOT_IMPROVEMENT = 158;
|
|
||||||
public static final int OP_FEATURE_GPS_NOTIFICATION = 159;
|
|
||||||
public static final int OP_FEATURE_ZEN_MODE = 160;
|
|
||||||
public static final int OP_FEATURE_TCP_CONTROL = 161;
|
|
||||||
public static final int OP_FEATURE_LOD_SWITCH = 162;
|
|
||||||
public static final int OP_FEATURE_TCS3701_HBR_ENABLED = 163;
|
|
||||||
public static final int OP_FEATURE_MM_HAC = 164;
|
|
||||||
public static final int OP_FEATURE_MM_MODECLIENT = 165;
|
|
||||||
public static final int OP_FEATURE_MM_RECODER_CH_SWITCH = 166;
|
|
||||||
public static final int OP_FEATURE_MM_RECORDING_SCREEN = 167;
|
|
||||||
public static final int OP_FEATURE_MM_AUDIO_CGROUP = 168;
|
|
||||||
public static final int OP_FEATURE_MM_WECHAT_NS = 169;
|
|
||||||
public static final int OP_FEATURE_MM_NS_AEC = 170;
|
|
||||||
public static final int OP_FEATURE_DEXOPT = 171;
|
|
||||||
public static final int OP_FEATURE_SKIP_DOFRAME = 172;
|
|
||||||
public static final int OP_FEATURE_PROCESS_ADJ_CONTROL = 173;
|
|
||||||
public static final int OP_FEATURE_SCREEN_ROTATION_IMPROVEMENT = 174;
|
|
||||||
public static final int OP_FEATURE_JANKMANAGER = 175;
|
|
||||||
public static final int OP_FEATURE_LANDSCAPE_APP_ANIMATION_IMPROVEMENT = 176;
|
|
||||||
public static final int OP_FEATURE_HWUI_SKIA_REDUCE_OVERDRAW = 177;
|
|
||||||
public static final int OP_FEATURE_MM_MDM = 178;
|
|
||||||
public static final int OP_FEATURE_MM_AUDIO_ELEVOC_ECNS = 179;
|
|
||||||
public static final int OP_FEATURE_MM_LOW_KING_VOLUME = 180;
|
|
||||||
public static final int OP_FEATURE_AI_GESTURE = 181;
|
|
||||||
public static final int OP_FEATURE_MM_VIDEO_ENHANCEMENT = 182;
|
|
||||||
public static final int OP_FEATURE_UNIFIED_DEVICE = 183;
|
|
||||||
public static final int OP_FEATURE_REDSCREEN_ASSERTION = 184;
|
|
||||||
public static final int OP_FEATURE_INFRARED_POWER_CONTROL = 185;
|
|
||||||
public static final int OP_FEATURE_OPSLA = 186;
|
|
||||||
public static final int OP_FEATURE_OPSLM = 187;
|
|
||||||
public static final int OP_FEATURE_SYNTHETIC_PASSWORD_DISABLED = 188;
|
|
||||||
public static final int OP_FEATURE_SYSTEM_PRODUCTION_RINGTONE = 189;
|
|
||||||
public static final int OP_FEATURE_APP_PRELOAD = 190;
|
|
||||||
public static final int OP_FEATURE_VERIFICATION_BUBBLE = 191;
|
|
||||||
public static final int OP_FEATURE_Z_VIBRATION_MOTOR = 192;
|
|
||||||
public static final int OP_FEATURE_DUAL_CAMERA = 193;
|
|
||||||
public static final int OP_FEATURE_TRIPLE_CAMERA = 194;
|
|
||||||
public static final int OP_FEATURE_QUAD_CAMERA = 195;
|
|
||||||
public static final int OP_FEATURE_FRONT_DUAL_CAMERA = 196;
|
|
||||||
public static final int OP_FEATURE_REPORT_WIFI_GENERATION_INFO = 197;
|
|
||||||
public static final int OP_FEATURE_BAS_WHITELIST = 198;
|
|
||||||
public static final int OP_FEATURE_ENABLE_UNDERSCREEN_SENSOR = 199;
|
|
||||||
public static final int OP_FEATURE_CUSTOM_GAME_CENTER = 200;
|
|
||||||
public static final int OP_FEATURE_CUSTOM_ONEPLUS_WALLET = 201;
|
|
||||||
public static final int OP_FEATURE_ENABLE_GAMUT_MAPPING = 202;
|
|
||||||
public static final int OP_FEATURE_ENABLE_GAME_VIBRATE = 203;
|
|
||||||
public static final int OP_FEATURE_ENABLE_ICON_DETECTION = 204;
|
|
||||||
public static final int OP_FEATURE_ENABLE_ANTI_BURN = 205;
|
|
||||||
public static final int OP_FEATURE_DIM_MODE_GESTURE = 206;
|
|
||||||
public static final int OP_FEATURE_UPDATE_INDIA = 207;
|
|
||||||
public static final int OP_FEATURE_USE_AUDIO_STATE = 208;
|
|
||||||
public static final int OP_FEATURE_SCREEN_ON_USE_INFRARED = 209;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_COLOR_READ_MODE = 210;
|
|
||||||
public static final int OP_FEATURE_SCREEN_AOD_USE_ULTRASOUND = 211;
|
|
||||||
public static final int OP_FEATURE_SCREEN_OFF_USE_ULTRASOUND = 212;
|
|
||||||
public static final int OP_FEATURE_SCREEN_OFF_USE_INFRARED = 213;
|
|
||||||
public static final int OP_FEATURE_INFRARED_PROXIMITY_SUPPORT = 214;
|
|
||||||
public static final int OP_FEATURE_SAR_TEST_SUPPORT = 215;
|
|
||||||
public static final int OP_FEATURE_COLOR_ADS = 216;
|
|
||||||
public static final int OP_FEATURE_PWM_UNDER_SCREEN_LIGHT = 217;
|
|
||||||
public static final int OP_FEATURE_MM_LIMIT_SVA_BARGIN = 218;
|
|
||||||
public static final int OP_FEATURE_MM_CLOSE_PA = 219;
|
|
||||||
public static final int OP_FEATURE_GESTURE_DEPRECATED = 220;
|
|
||||||
public static final int OP_FEATURE_ONE_HAND_MODE = 221;
|
|
||||||
public static final int OP_FEATURE_DAILY_PROTO_REPORTING = 222;
|
|
||||||
public static final int OP_FEATURE_MCL_FONT = 223;
|
|
||||||
public static final int OP_FEATURE_CUSTOM_BROWSER_APP_INFO = 224;
|
|
||||||
public static final int OP_FEATURE_DECR_BL_CJ = 225;
|
|
||||||
public static final int OP_FEATURE_OPRECOVERY_BOOT_REASON = 226;
|
|
||||||
public static final int OP_FEATURE_KTV_LOOPBACK = 227;
|
|
||||||
public static final int OP_FEATURE_DYNAMIC_RESOLUTION = 228;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_5G_LTE = 229;
|
|
||||||
public static final int OP_FEATURE_HOLE_PUNCH_FRONT_CAM = 230;
|
|
||||||
public static final int OP_FEATURE_USV_MODE = 231;
|
|
||||||
public static final int OP_FEATURE_USVIS_MODE = 232;
|
|
||||||
public static final int OP_FEATURE_MM_ABANDON_DELAY = 233;
|
|
||||||
public static final int OP_FEATURE_GPS_NFW_OTA_PATCH = 234;
|
|
||||||
public static final int OP_FEATURE_PIXELWORKS_BRIGHTNESS_SMOOTH = 235;
|
|
||||||
public static final int OP_FEATURE_FORCE_DARK = 236;
|
|
||||||
public static final int OP_FEATURE_WIRELESS_CHARGE = 237;
|
|
||||||
public static final int OP_FEATURE_SWARP_CHARGE = 238;
|
|
||||||
public static final int OP_FEATURE_MM_FAST_WHITELIST = 239;
|
|
||||||
public static final int OP_FEATURE_AI_BOOST_PACKAGE = 240;
|
|
||||||
public static final int OP_FEATURE_CARRIER_3_BROADCAST_CUST = 241;
|
|
||||||
public static final int OP_FEATURE_CARRIER_3_DEMO_MODE_CUST = 242;
|
|
||||||
public static final int OP_FEATURE_CARRIER_3_SAFEMODE_CUST = 243;
|
|
||||||
public static final int OP_FEATURE_APPDIED_STATISTICE = 244;
|
|
||||||
public static final int OP_FEATURE_SECOND_PRIVATE_PASSWORD = 245;
|
|
||||||
public static final int OP_FEATURE_OMM = 246;
|
|
||||||
public static final int OP_FEATURE_ORM = 247;
|
|
||||||
public static final int OP_FEATURE_OMM_KILL = 248;
|
|
||||||
public static final int OP_FEATURE_OMM_RECLAIM = 249;
|
|
||||||
public static final int OP_FEATURE_CARRIER_3_TALKBACK_CUST = 250;
|
|
||||||
public static final int OP_FEATURE_UST_MAAP = 251;
|
|
||||||
public static final int OP_FEATURE_CARRIER_3_UNIFIED_SETTINGS_CUST = 252;
|
|
||||||
public static final int OP_FEATURE_CARRIER_3_LLK_AGENT_CUST = 253;
|
|
||||||
public static final int OP_FEATURE_STA_SAP = 254;
|
|
||||||
public static final int OP_FEATURE_ONEPLUS_SHARE = 255;
|
|
||||||
public static final int OP_FEATURE_SAP_WPA3_SUPPORT = 256;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_RELLOADSPLASH = 257;
|
|
||||||
public static final int OP_FEATURE_STARTING_WINDOW = 258;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_REDEFINE_POWER_BUTTON = 259;
|
|
||||||
public static final int OP_FEATURE_AER_ZEROTOUCH = 260;
|
|
||||||
public static final int OP_FEATURE_FACE_UNLOCK_SUPPORT_PASSIVE_WAKEUP = 261;
|
|
||||||
public static final int OP_FEATURE_SMART_DOZE = 262;
|
|
||||||
public static final int OP_FEATURE_WEAK_FACE_UNLOCK = 263;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_GCP = 264;
|
|
||||||
public static final int OP_FEATURE_UIFIRST = 265;
|
|
||||||
public static final int OP_FEATURE_GPS_SPRINT_SUPL = 266;
|
|
||||||
public static final int OP_FEATURE_GAME_TP = 267;
|
|
||||||
public static final int OP_FEATURE_TGPA = 268;
|
|
||||||
public static final int OP_FEATURE_CHARGE_OPTIMIZATED = 269;
|
|
||||||
public static final int OP_FEATURE_CARRIER_3_OVERHEAT_CUST = 270;
|
|
||||||
public static final int OP_FEATURE_BOOTANIMATION_CUST_INSET = 271;
|
|
||||||
public static final int OP_FEATURE_WARP_CHARGING_ANIM = 272;
|
|
||||||
public static final int OP_FEATURE_DOUBLE_TAP_POWER_KEY_ALEXA = 273;
|
|
||||||
public static final int OP_FEATURE_MM_GAME_DOLBY_WHITELIST = 274;
|
|
||||||
public static final int OP_FEATURE_QPOWER = 275;
|
|
||||||
public static final int OP_FEATURE_ENABLE_TAP_COEXIST = 276;
|
|
||||||
public static final int OP_FEATURE_CUST_FAILED_PW_WIPE = 277;
|
|
||||||
public static final int OP_FEATURE_COLLECT_BATTERYSTATS = 278;
|
|
||||||
public static final int OP_FEATURE_NOMEDIA_WHITELIST = 279;
|
|
||||||
public static final int OP_FEATURE_EXTREME_VSYNC = 280;
|
|
||||||
public static final int OP_FEATURE_PROXIMITY_CONTROLLER = 281;
|
|
||||||
public static final int OP_FEATURE_GAMEMODE_BOOST = 282;
|
|
||||||
public static final int OP_FEATURE_QUICK_REPLY_BUBBLE = 283;
|
|
||||||
public static final int OP_FEATURE_BLUETOOTH_UART_LOG = 284;
|
|
||||||
public static final int OP_FEATURE_FUSIONLIGHT_SCREENSHOT_DISABLED = 285;
|
|
||||||
public static final int OP_FEATURE_RECOVERY_FORMAT_WARNING = 286;
|
|
||||||
public static final int OP_FEATURE_BUILDING_CUSTOM_PRODUCT_IMAGE = 287;
|
|
||||||
public static final int OP_FEATURE_WIRELESS_CHARGE_DISCONNECT_DETECTOR = 288;
|
|
||||||
public static final int OP_FEATURE_DYNAMIC_FONT = 289;
|
|
||||||
public static final int OP_FEATURE_PERF_LOG = 290;
|
|
||||||
public static final int OP_FEATURE_ENABLE_EMERGENCY_PANEL = 291;
|
|
||||||
public static final int OP_FEATURE_MM_IRIS_CHIP_SUPPORT = 292;
|
|
||||||
public static final int OP_FEATURE_MM_SOFT_IRIS_SUPPORT = 293;
|
|
||||||
public static final int OP_FEATURE_ENABLE_HEACTE_SCREEN = 294;
|
|
||||||
public static final int OP_FEATURE_PERF_MEMEX = 295;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_MIPI = 296;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_OSC = 297;
|
|
||||||
public static final int OP_FEATURE_MM_DISPLAY_COLORTEMPRATURE_6000K_8000K = 298;
|
|
||||||
public static final int OP_FEATURE_LITE_OOS = 299;
|
|
||||||
public static final int OP_FEATURE_AOD_ALWAYS_ON = 300;
|
|
||||||
public static final int OP_FEATURE_VIP_BROADCAST = 301;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_REAL_AOD = 302;
|
|
||||||
public static final int OP_FEATURE_UST_NVVM = 303;
|
|
||||||
public static final int OP_FEATURE_UST_EC = 304;
|
|
||||||
public static final int OP_FEATURE_CHARGING_ANIM = 305;
|
|
||||||
public static final int OP_FEATURE_OD_OPDMC = 306;
|
|
||||||
public static final int OP_FEATURE_DISPLAY_DYNAMIC_RESOLUTION = 307;
|
|
||||||
public static final int OP_FEATURE_WIRELESS_FAST_CHARGE = 308;
|
|
||||||
public static final int OP_FEATURE_COTA = 309;
|
|
||||||
public static final int OP_FEATURE_FLASH_BACK = 310;
|
|
||||||
public static final int OP_FEATURE_GOOGLE_COMM_SUIT = 311;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_5G_5G = 312;
|
|
||||||
public static final int OP_FEATURE_INPUTMETHOD_SHOWANIMATION = 313;
|
|
||||||
public static final int OP_FEATURE_GOTA = 314;
|
|
||||||
public static final int OP_FEATURE_MM_DC_SUPPORT = 315;
|
|
||||||
public static final int OP_FEATURE_MM_DIRAC_SUPPORT = 316;
|
|
||||||
public static final int OP_FEATURE_MM_AUDIO_BOOTANIMATION = 317;
|
|
||||||
public static final int OP_FEATURE_MM_VZW_CUSTOMIZATION = 318;
|
|
||||||
public static final int OP_FEATURE_MAX_BACKLIGHT_2047 = 319;
|
|
||||||
public static final int OP_FEATURE_MM_DOLBY = 320;
|
|
||||||
public static final int OP_FEATURE_MM_DIMMING = 321;
|
|
||||||
public static final int OP_FEATURE_MM_DITHER_CONTROLLER = 322;
|
|
||||||
public static final int OP_FEATURE_CANVAS_AOD_ENABLED = 323;
|
|
||||||
public static final int OP_FEATURE_CURVED_DISPLAY_SCREEN = 324;
|
|
||||||
public static final int OP_FEATURE_MM_WIDEVINE_OTA = 325;
|
|
||||||
public static final int OP_FEATURE_MM_ADAPTIVE_COLOR_GAMUT_WHITELIST = 326;
|
|
||||||
public static final int OP_FEATURE_MM_ADFR = 327;
|
|
||||||
public static final int OP_FEATURE_MM_COLOR_SATURATION_ADJUSTMENT = 328;
|
|
||||||
public static final int OP_FEATURE_ZOOM_WINDOW = 329;
|
|
||||||
public static final int OP_FEATURE_MM_LOADINGEFFECT = 330;
|
|
||||||
public static final int OP_FEATURE_MM_COLOR_TONE_ADJUSTMENT = 331;
|
|
||||||
public static final int OP_FEATURE_MM_COLOR_MODE_SET_MODEID = 332;
|
|
||||||
public static final int OP_FEATURE_RPM_SUB_SYSTEM_NEW_FORMAT = 333;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_ICHARGER_SERVICE = 334;
|
|
||||||
public static final int OP_FEATURE_UFSTW = 335;
|
|
||||||
public static final int OP_FEATURE_UST_ECHOLOCATE = 336;
|
|
||||||
public static final int OP_FEATURE_LDEV = 337;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_5G_SA = 338;
|
|
||||||
public static final int OP_FEATURE_UPDATE_AB_STANVBK = 339;
|
|
||||||
public static final int OP_FEATURE_DISABLE_WAKINGUP_ANIMATION = 340;
|
|
||||||
public static final int OP_FEATURE_NFW_LOCATION_NOTIFICATION = 341;
|
|
||||||
public static final int OP_FEATURE_RICHTAP_SUPPORT = 342;
|
|
||||||
public static final int OP_FEATURE_SES_AUTH = 343;
|
|
||||||
public static final int OP_FEATURE_MBN_RESET = 344;
|
|
||||||
public static final int OP_FEATURE_MM_OFFLOAD_BLACKLIST = 345;
|
|
||||||
public static final int OP_FEATURE_TELEPHONY_SCENE_DETECT = 346;
|
|
||||||
public static final int OP_FEATURE_COTA_CONFIG_CONTROLLER = 347;
|
|
||||||
public static final int OP_FEATURE_MM_VIDEO_SR = 348;
|
|
||||||
public static final int OP_FEATURE_RECOVERY_WARNING_SCREEN = 349;
|
|
||||||
public static final int OP_FEATURE_IRIS_HQV = 350;
|
|
||||||
public static final int OP_FEATURE_ANTENNA_REPORT = 351;
|
|
||||||
public static final int OP_FEATURE_TGPA_GAME_LATENCY = 352;
|
|
||||||
public static final int OP_FEATURE_CAMERA_CPUSET = 353;
|
|
||||||
public static final int OP_FEATURE_SUPPORT_MSD_AOD_INFO = 354;
|
|
||||||
public static final int OP_FEATURE_HYPNUS = 355;
|
|
||||||
public static final int OP_FEATURE_OPEN_ID_NEW = 356;
|
|
||||||
public static final int OP_FEATURE_HIGH_TEMPERATURE = 357;
|
|
||||||
public static final int OP_FEATURE_NRCA_SUPPORT = 358;
|
|
||||||
public static final int OP_FEATURE_IMS_RECOVERY = 359;
|
|
||||||
public static final int OP_FEATURE_SMART_WIFI_CALLING_MODE = 360;
|
|
||||||
public static final int OP_FEATURE_AOD_ALWAYS_ON_IN_LABORATORY = 361;
|
|
||||||
public static final int OP_FEATURE_USKU = 362;
|
|
||||||
public static final int OP_FEATURE_DEFAULT_HIDE_VOLTE_FOR_EU = 363;
|
|
||||||
public static final int OP_FEATURE_GPS_ENABLE_LPP_UP_FOR_TMO = 364;
|
|
||||||
public static final int OP_FEATURE_CHARGING_ANIM_P3_REPEAT_MAX_COUNT_4 = 365;
|
|
||||||
public static final int OP_FEATURE_DISPLAY_LCD = 366;
|
|
||||||
public static final int OP_FEATURE_NEW_BATTERY_FILE_NODE_PATH = 367;
|
|
||||||
public static final int OP_FEATURE_MM_MUTE_DELAY_SWITCH = 368;
|
|
||||||
public static final int OP_FEATURE_ONLINE_CONFIG_NETWORK = 369;
|
|
||||||
public static final int OP_FEATURE_KEEP_HIGH_VSYNC = 370;
|
|
||||||
public static final int OP_FEATURE_MM_SYNC_ACDB_ID_FROM_Q = 371;
|
|
||||||
public static final int OP_FEATURE_BITMOJI_AOD_ENABLED = 372;
|
|
||||||
|
|
||||||
private static final BitSet sFeatures = new BitSet(374);
|
|
||||||
|
|
||||||
static {
|
|
||||||
File file = new File("/odm/etc/odm_feature_list");
|
|
||||||
|
|
||||||
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
|
|
||||||
for (String line = br.readLine(); line != null; line = br.readLine()) {
|
|
||||||
String[] values = line.split(" ");
|
|
||||||
if (values.length == 4 && values[3].equals("true")) {
|
|
||||||
String id = values[0].replaceAll("[^0-9]", "");
|
|
||||||
if (id.length() != 0) {
|
|
||||||
sFeatures.set(Integer.parseInt(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(LOG_TAG, "Failed to read odm feature list file", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSupport(int... features) {
|
|
||||||
for (int feature : features) {
|
|
||||||
if (feature < 0 || feature > sFeatures.length()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!sFeatures.get(feature)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (C) 2018 The LineageOS Project
|
Copyright (C) 2021 The LineageOS Project
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License"
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
@ -14,8 +14,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<resources>
|
||||||
android:sharedUserId="android.uid.system"
|
<!-- Sensor types -->
|
||||||
package="org.lineageos.settings.device">
|
<string name="pickup_sensor_type">oneplus.sensor.op_motion_detect</string>
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
</resources>
|
||||||
</manifest>
|
|
|
@ -25,7 +25,7 @@
|
||||||
<!-- Paths to the libraries that contain device specific key handlers -->
|
<!-- Paths to the libraries that contain device specific key handlers -->
|
||||||
<string-array name="config_deviceKeyHandlerLibs" translatable="false">
|
<string-array name="config_deviceKeyHandlerLibs" translatable="false">
|
||||||
<item>/system/priv-app/LineageParts/LineageParts.apk</item>
|
<item>/system/priv-app/LineageParts/LineageParts.apk</item>
|
||||||
<item>/system/priv-app/KeyHandler/KeyHandler.apk</item>
|
<item>/system_ext/app/KeyHandler/KeyHandler.apk</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Names of the key handler classes -->
|
<!-- Names of the key handler classes -->
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (C) 2020 The LineageOS Project
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
relative_install_path: "hw",
|
|
||||||
defaults: ["hidl_defaults"],
|
|
||||||
name: "vendor.lineage.powershare@1.0-service.oneplus_lahaina",
|
|
||||||
init_rc: ["vendor.lineage.powershare@1.0-service.oneplus_lahaina.rc"],
|
|
||||||
vintf_fragments: ["vendor.lineage.powershare@1.0-service.oneplus_lahaina.xml"],
|
|
||||||
srcs: ["service.cpp", "PowerShare.cpp"],
|
|
||||||
shared_libs: [
|
|
||||||
"libbase",
|
|
||||||
"libhardware",
|
|
||||||
"libhidlbase",
|
|
||||||
"liblog",
|
|
||||||
"libutils",
|
|
||||||
"vendor.lineage.powershare@1.0",
|
|
||||||
],
|
|
||||||
proprietary: true,
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "PowerShareService"
|
|
||||||
|
|
||||||
#include "PowerShare.h"
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace powershare {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
#define WIRELESS_TX_ENABLE_PATH "/sys/class/oplus_chg/wireless/trx_online"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write value to path and close file.
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
static void set(const std::string& path, const T& value) {
|
|
||||||
std::ofstream file(path);
|
|
||||||
file << value;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static T get(const std::string& path, const T& def) {
|
|
||||||
std::ifstream file(path);
|
|
||||||
T result;
|
|
||||||
|
|
||||||
file >> result;
|
|
||||||
return file.fail() ? def : result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> PowerShare::isEnabled() {
|
|
||||||
return get<int>(WIRELESS_TX_ENABLE_PATH, 0) >= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> PowerShare::setEnabled(bool enable) {
|
|
||||||
set(WIRELESS_TX_ENABLE_PATH, enable ? 1 : 0);
|
|
||||||
|
|
||||||
return isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<uint32_t> PowerShare::getMinBattery() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<uint32_t> PowerShare::setMinBattery(uint32_t) {
|
|
||||||
return getMinBattery();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace powershare
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
#ifndef VENDOR_LINEAGE_POWERSHARE_V1_0_POWERSHARE_H
|
|
||||||
#define VENDOR_LINEAGE_POWERSHARE_V1_0_POWERSHARE_H
|
|
||||||
|
|
||||||
#include <vendor/lineage/powershare/1.0/IPowerShare.h>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace powershare {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::sp;
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
|
|
||||||
class PowerShare : public IPowerShare {
|
|
||||||
public:
|
|
||||||
Return<bool> isEnabled() override;
|
|
||||||
Return<bool> setEnabled(bool enable) override;
|
|
||||||
Return<uint32_t> getMinBattery() override;
|
|
||||||
Return<uint32_t> setMinBattery(uint32_t minBattery) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace powershare
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_POWERSHARE_V1_0_POWERSHARE_H
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "vendor.lineage.powershare@1.0-service.oneplus_lahaina"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
|
|
||||||
#include "PowerShare.h"
|
|
||||||
|
|
||||||
using android::hardware::configureRpcThreadpool;
|
|
||||||
using android::hardware::joinRpcThreadpool;
|
|
||||||
|
|
||||||
using vendor::lineage::powershare::V1_0::IPowerShare;
|
|
||||||
using vendor::lineage::powershare::V1_0::implementation::PowerShare;
|
|
||||||
|
|
||||||
using android::OK;
|
|
||||||
using android::status_t;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
android::sp<IPowerShare> service = new PowerShare();
|
|
||||||
|
|
||||||
configureRpcThreadpool(1, true);
|
|
||||||
|
|
||||||
status_t status = service->registerAsService();
|
|
||||||
if (status != OK) {
|
|
||||||
LOG(ERROR) << "Cannot register PowerShare HAL service.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(INFO) << "PowerShare HAL service ready.";
|
|
||||||
|
|
||||||
joinRpcThreadpool();
|
|
||||||
|
|
||||||
LOG(ERROR) << "PowerShare HAL service failed to join thread pool.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
on init
|
|
||||||
chown system system /sys/class/oplus_chg/wireless/trx_online
|
|
||||||
chmod 0644 /sys/class/oplus_chg/wireless/trx_online
|
|
||||||
|
|
||||||
service vendor.powershare-hal-1-0 /vendor/bin/hw/vendor.lineage.powershare@1.0-service.oneplus_lahaina
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group system
|
|
|
@ -1,11 +0,0 @@
|
||||||
<manifest version="1.0" type="device">
|
|
||||||
<hal format="hidl">
|
|
||||||
<name>vendor.lineage.powershare</name>
|
|
||||||
<transport>hwbinder</transport>
|
|
||||||
<version>1.0</version>
|
|
||||||
<interface>
|
|
||||||
<name>IPowerShare</name>
|
|
||||||
<instance>default</instance>
|
|
||||||
</interface>
|
|
||||||
</hal>
|
|
||||||
</manifest>
|
|
25
sepolicy/vendor/file_contexts
vendored
25
sepolicy/vendor/file_contexts
vendored
|
@ -33,18 +33,19 @@
|
||||||
/dev/skin_thermal u:object_r:therm_device:s0
|
/dev/skin_thermal u:object_r:therm_device:s0
|
||||||
|
|
||||||
# HALs
|
# HALs
|
||||||
/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service\.oneplus_lahaina u:object_r:hal_fingerprint_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service\.oneplus u:object_r:hal_fingerprint_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.biometrics\.fingerprint\.inscreen@1\.0-service\.oneplus_lahaina u:object_r:hal_lineage_fod_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.biometrics\.fingerprint\.inscreen@1\.0-service\.oneplus u:object_r:hal_lineage_fod_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.1-service\.oneplus_lahaina u:object_r:hal_lineage_livedisplay_qti_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.1-service\.oneplus u:object_r:hal_lineage_livedisplay_qti_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.powershare@1\.0-service\.oneplus_lahaina u:object_r:hal_lineage_powershare_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.powershare@1\.0-service\.oneplus u:object_r:hal_lineage_powershare_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.oneplus_lahaina u:object_r:hal_lineage_touch_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.oneplus u:object_r:hal_lineage_touch_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.camera@1\.0-service u:object_r:hal_cameraHIDL_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.camera@1\.0-service u:object_r:hal_cameraHIDL_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.CameraMDMHIDL@1\.0-service u:object_r:hal_cameraHIDL_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.CameraMDMHIDL@1\.0-service u:object_r:hal_cameraHIDL_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.charger@1\.0-service u:object_r:hal_charger_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.charger@1\.0-service u:object_r:hal_charger_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.display@1\.0-service u:object_r:hal_display_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.display@1\.0-service u:object_r:hal_display_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.param@1\.0-service u:object_r:hal_param_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.oneplus\.hardware\.param@1\.0-service u:object_r:hal_param_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.pixelworks\.hardware\.display\.iris-service u:object_r:hal_graphics_composer_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.pixelworks\.hardware\.display\.iris-service u:object_r:hal_graphics_composer_default_exec:s0
|
||||||
/(vendor|system/vendor)/bin/hw/vendor\.pixelworks\.hardware\.feature\.irisfeature-service u:object_r:hal_graphics_composer_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/vendor\.pixelworks\.hardware\.feature\.irisfeature-service u:object_r:hal_graphics_composer_default_exec:s0
|
||||||
|
/(vendor|system/vendor)/bin/hw/vendor\.qti\.hardware\.vibrator\.service\.oneplus u:object_r:hal_vibrator_default_exec:s0
|
||||||
|
|
||||||
# Init scripts
|
# Init scripts
|
||||||
/vendor/bin/init.oplus_chg.sh u:object_r:vendor_qti_init_shell_exec:s0
|
/vendor/bin/init.oplus_chg.sh u:object_r:vendor_qti_init_shell_exec:s0
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
BasedOnStyle: Google
|
|
||||||
AccessModifierOffset: -2
|
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
|
||||||
ColumnLimit: 100
|
|
||||||
CommentPragmas: NOLINT:.*
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
IndentWidth: 4
|
|
||||||
PointerAlignment: Left
|
|
||||||
TabWidth: 4
|
|
||||||
UseTab: Never
|
|
||||||
PenaltyExcessCharacter: 32
|
|
|
@ -1,34 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (C) 2019 The LineageOS Project
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
name: "vendor.lineage.touch@1.0-service.oneplus_lahaina",
|
|
||||||
init_rc: ["vendor.lineage.touch@1.0-service.oneplus_lahaina.rc"],
|
|
||||||
vintf_fragments: ["vendor.lineage.touch@1.0-service.oneplus_lahaina.xml"],
|
|
||||||
defaults: ["hidl_defaults"],
|
|
||||||
relative_install_path: "hw",
|
|
||||||
srcs: [
|
|
||||||
"TouchscreenGesture.cpp",
|
|
||||||
"service.cpp",
|
|
||||||
],
|
|
||||||
shared_libs: [
|
|
||||||
"libbase",
|
|
||||||
"libbinder",
|
|
||||||
"libhidlbase",
|
|
||||||
"libutils",
|
|
||||||
"vendor.lineage.touch@1.0",
|
|
||||||
],
|
|
||||||
proprietary: true,
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "TouchscreenGestureService"
|
|
||||||
|
|
||||||
#include "TouchscreenGesture.h"
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace touch {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
const std::map<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kGestureInfoMap = {
|
|
||||||
{0, {251, "Two fingers down swipe", "/proc/touchpanel/double_swipe_enable"}},
|
|
||||||
{1, {252, "Down arrow", "/proc/touchpanel/down_arrow_enable"}},
|
|
||||||
{2, {253, "Left arrow", "/proc/touchpanel/left_arrow_enable"}},
|
|
||||||
{3, {254, "Right arrow", "/proc/touchpanel/right_arrow_enable"}},
|
|
||||||
{4, {247, "Letter M", "/proc/touchpanel/letter_m_enable"}},
|
|
||||||
{5, {250, "Letter O", "/proc/touchpanel/letter_o_enable"}},
|
|
||||||
{6, {248, "Letter S", "/proc/touchpanel/letter_s_enable"}},
|
|
||||||
{7, {246, "Letter W", "/proc/touchpanel/letter_w_enable"}},
|
|
||||||
{8, {255, "Single Tap", "/proc/touchpanel/single_tap_enable"}},
|
|
||||||
};
|
|
||||||
|
|
||||||
Return<void> TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) {
|
|
||||||
std::vector<Gesture> gestures;
|
|
||||||
|
|
||||||
for (const auto& entry : kGestureInfoMap) {
|
|
||||||
gestures.push_back({entry.first, entry.second.name, entry.second.keycode});
|
|
||||||
}
|
|
||||||
resultCb(gestures);
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> TouchscreenGesture::setGestureEnabled(
|
|
||||||
const ::vendor::lineage::touch::V1_0::Gesture& gesture, bool enabled) {
|
|
||||||
const auto entry = kGestureInfoMap.find(gesture.id);
|
|
||||||
if (entry == kGestureInfoMap.end()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ofstream file(entry->second.path);
|
|
||||||
file << (enabled ? "1" : "0");
|
|
||||||
LOG(DEBUG) << "Wrote file " << entry->second.path << " fail " << file.fail();
|
|
||||||
return !file.fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace touch
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H
|
|
||||||
#define VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H
|
|
||||||
|
|
||||||
#include <hidl/MQDescriptor.h>
|
|
||||||
#include <hidl/Status.h>
|
|
||||||
#include <vendor/lineage/touch/1.0/ITouchscreenGesture.h>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace touch {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
using ::android::sp;
|
|
||||||
|
|
||||||
class TouchscreenGesture : public ITouchscreenGesture {
|
|
||||||
public:
|
|
||||||
// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow.
|
|
||||||
Return<void> getSupportedGestures(getSupportedGestures_cb resultCb) override;
|
|
||||||
Return<bool> setGestureEnabled(const ::vendor::lineage::touch::V1_0::Gesture& gesture,
|
|
||||||
bool enabled) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef struct {
|
|
||||||
int32_t keycode;
|
|
||||||
const char* name;
|
|
||||||
const char* path;
|
|
||||||
} GestureInfo;
|
|
||||||
static const std::map<int32_t, GestureInfo> kGestureInfoMap; // id -> info
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace touch
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "vendor.lineage.touch@1.0-service.oneplus_lahaina"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <binder/ProcessState.h>
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
#include "TouchscreenGesture.h"
|
|
||||||
|
|
||||||
using ::vendor::lineage::touch::V1_0::ITouchscreenGesture;
|
|
||||||
using ::vendor::lineage::touch::V1_0::implementation::TouchscreenGesture;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
android::sp<ITouchscreenGesture> gestureService = new TouchscreenGesture();
|
|
||||||
|
|
||||||
android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);
|
|
||||||
|
|
||||||
if (gestureService->registerAsService() != android::OK) {
|
|
||||||
LOG(ERROR) << "Cannot register touchscreen gesture HAL service.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(INFO) << "Touchscreen HAL service ready.";
|
|
||||||
|
|
||||||
android::hardware::joinRpcThreadpool();
|
|
||||||
|
|
||||||
LOG(ERROR) << "Touchscreen HAL service failed to join thread pool.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
on boot
|
|
||||||
chmod 0660 /proc/touchpanel/double_swipe_enable
|
|
||||||
chmod 0660 /proc/touchpanel/down_arrow_enable
|
|
||||||
chmod 0660 /proc/touchpanel/left_arrow_enable
|
|
||||||
chmod 0660 /proc/touchpanel/letter_m_enable
|
|
||||||
chmod 0660 /proc/touchpanel/letter_o_enable
|
|
||||||
chmod 0660 /proc/touchpanel/letter_s_enable
|
|
||||||
chmod 0660 /proc/touchpanel/letter_w_enable
|
|
||||||
chmod 0660 /proc/touchpanel/right_arrow_enable
|
|
||||||
chmod 0660 /proc/touchpanel/single_tap_enable
|
|
||||||
chown system system /proc/touchpanel/double_swipe_enable
|
|
||||||
chown system system /proc/touchpanel/down_arrow_enable
|
|
||||||
chown system system /proc/touchpanel/left_arrow_enable
|
|
||||||
chown system system /proc/touchpanel/letter_m_enable
|
|
||||||
chown system system /proc/touchpanel/letter_o_enable
|
|
||||||
chown system system /proc/touchpanel/letter_s_enable
|
|
||||||
chown system system /proc/touchpanel/letter_w_enable
|
|
||||||
chown system system /proc/touchpanel/right_arrow_enable
|
|
||||||
chown system system /proc/touchpanel/single_tap_enable
|
|
||||||
|
|
||||||
service vendor.touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.oneplus_lahaina
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group system
|
|
|
@ -1,11 +0,0 @@
|
||||||
<manifest version="1.0" type="device">
|
|
||||||
<hal format="hidl">
|
|
||||||
<name>vendor.lineage.touch</name>
|
|
||||||
<transport>hwbinder</transport>
|
|
||||||
<version>1.0</version>
|
|
||||||
<interface>
|
|
||||||
<name>ITouchscreenGesture</name>
|
|
||||||
<instance>default</instance>
|
|
||||||
</interface>
|
|
||||||
</hal>
|
|
||||||
</manifest>
|
|
|
@ -1,11 +0,0 @@
|
||||||
BasedOnStyle: Google
|
|
||||||
AccessModifierOffset: -2
|
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
|
||||||
ColumnLimit: 100
|
|
||||||
CommentPragmas: NOLINT:.*
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
IndentWidth: 4
|
|
||||||
PointerAlignment: Left
|
|
||||||
TabWidth: 4
|
|
||||||
UseTab: Never
|
|
||||||
PenaltyExcessCharacter: 32
|
|
|
@ -1,34 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (C) 2018 The LineageOS Project
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
name: "tri-state-key_daemon",
|
|
||||||
init_rc: ["tri-state-key_daemon.rc"],
|
|
||||||
srcs: [
|
|
||||||
"main.cpp",
|
|
||||||
"uevent_listener.cpp",
|
|
||||||
],
|
|
||||||
cppflags: [
|
|
||||||
"-Wall",
|
|
||||||
"-Werror",
|
|
||||||
],
|
|
||||||
vendor: true,
|
|
||||||
shared_libs: [
|
|
||||||
"libbase",
|
|
||||||
"liblog",
|
|
||||||
"libcutils",
|
|
||||||
"libutils",
|
|
||||||
],
|
|
||||||
}
|
|
|
@ -1,158 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "tri-state-key_daemon"
|
|
||||||
|
|
||||||
#include <android-base/file.h>
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <linux/input.h>
|
|
||||||
#include <linux/uinput.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "uevent_listener.h"
|
|
||||||
|
|
||||||
#define HALL_CALIBRATION_DATA "/sys/devices/platform/soc/soc:tri_state_key/hall_data_calib"
|
|
||||||
#define HALL_PERSIST_CALIBRATION_DATA "/mnt/vendor/persist/engineermode/tri_state_hall_data"
|
|
||||||
|
|
||||||
#define KEY_MODE_NORMAL 601
|
|
||||||
#define KEY_MODE_VIBRATION 602
|
|
||||||
#define KEY_MODE_SILENCE 603
|
|
||||||
|
|
||||||
using android::base::ReadFileToString;
|
|
||||||
using android::base::WriteStringToFile;
|
|
||||||
using android::Uevent;
|
|
||||||
using android::UeventListener;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
int err;
|
|
||||||
int uinputFd;
|
|
||||||
struct uinput_user_dev uidev {};
|
|
||||||
UeventListener uevent_listener;
|
|
||||||
|
|
||||||
LOG(INFO) << "Started";
|
|
||||||
|
|
||||||
if (std::string hallData; ReadFileToString(HALL_PERSIST_CALIBRATION_DATA, &hallData)) {
|
|
||||||
std::replace(hallData.begin(), hallData.end(), ';', ',');
|
|
||||||
WriteStringToFile(hallData, HALL_CALIBRATION_DATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
uinputFd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
|
|
||||||
if (uinputFd < 0) {
|
|
||||||
LOG(ERROR) << "Unable to open uinput node";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioctl(uinputFd, UI_SET_EVBIT, EV_KEY) |
|
|
||||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_MODE_NORMAL) |
|
|
||||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_MODE_VIBRATION) |
|
|
||||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_MODE_SILENCE);
|
|
||||||
if (err != 0) {
|
|
||||||
LOG(ERROR) << "Unable to enable KEY events";
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(uidev.name, "uinput-tri-state-key");
|
|
||||||
uidev.id.bustype = BUS_VIRTUAL;
|
|
||||||
|
|
||||||
err = write(uinputFd, &uidev, sizeof(uidev));
|
|
||||||
if (err < 0) {
|
|
||||||
LOG(ERROR) << "Write user device to uinput node failed";
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioctl(uinputFd, UI_DEV_CREATE);
|
|
||||||
if (err < 0) {
|
|
||||||
LOG(ERROR) << "Unable to create uinput device";
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(INFO) << "Successfully registered uinput-tri-state-key for KEY events";
|
|
||||||
|
|
||||||
uevent_listener.Poll([&uinputFd](const Uevent& uevent) {
|
|
||||||
int err;
|
|
||||||
struct input_event event {};
|
|
||||||
|
|
||||||
if (uevent.action != "change" || uevent.name != "soc:tri_state_key") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool none = uevent.state.find("USB=0") != std::string::npos;
|
|
||||||
bool vibration = uevent.state.find("USB-HOST=0") != std::string::npos;
|
|
||||||
bool silent = uevent.state.find("null)=0") != std::string::npos;
|
|
||||||
|
|
||||||
int keyCode;
|
|
||||||
if (none && !vibration && !silent) {
|
|
||||||
keyCode = KEY_MODE_NORMAL;
|
|
||||||
} else if (!none && vibration && !silent) {
|
|
||||||
keyCode = KEY_MODE_VIBRATION;
|
|
||||||
} else if (!none && !vibration && silent) {
|
|
||||||
keyCode = KEY_MODE_SILENCE;
|
|
||||||
} else {
|
|
||||||
// Ignore intermediate states
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Report the key
|
|
||||||
event.type = EV_KEY;
|
|
||||||
event.code = keyCode;
|
|
||||||
event.value = 1;
|
|
||||||
err = write(uinputFd, &event, sizeof(event));
|
|
||||||
if (err < 0) {
|
|
||||||
LOG(ERROR) << "Write EV_KEY to uinput node failed";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force a flush with an EV_SYN
|
|
||||||
event.type = EV_SYN;
|
|
||||||
event.code = SYN_REPORT;
|
|
||||||
event.value = 0;
|
|
||||||
err = write(uinputFd, &event, sizeof(event));
|
|
||||||
if (err < 0) {
|
|
||||||
LOG(ERROR) << "Write EV_SYN to uinput node failed";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Report the key
|
|
||||||
event.type = EV_KEY;
|
|
||||||
event.code = keyCode;
|
|
||||||
event.value = 0;
|
|
||||||
err = write(uinputFd, &event, sizeof(event));
|
|
||||||
if (err < 0) {
|
|
||||||
LOG(ERROR) << "Write EV_KEY to uinput node failed";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force a flush with an EV_SYN
|
|
||||||
event.type = EV_SYN;
|
|
||||||
event.code = SYN_REPORT;
|
|
||||||
event.value = 0;
|
|
||||||
err = write(uinputFd, &event, sizeof(event));
|
|
||||||
if (err < 0) {
|
|
||||||
LOG(ERROR) << "Write EV_SYN to uinput node failed";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
out:
|
|
||||||
// Clean up
|
|
||||||
close(uinputFd);
|
|
||||||
|
|
||||||
// The loop can only be exited via failure or signal
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
on fs
|
|
||||||
chown system system /sys/devices/platform/soc/soc:tri_state_key/hall_data_calib
|
|
||||||
chown system system /mnt/vendor/persist/engineermode/tri_state_hall_data
|
|
||||||
|
|
||||||
start vendor.tri-state-key_daemon
|
|
||||||
|
|
||||||
service vendor.tri-state-key_daemon /vendor/bin/tri-state-key_daemon
|
|
||||||
class late_start
|
|
||||||
user system
|
|
||||||
group system uhid
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INIT_UEVENT_H
|
|
||||||
#define _INIT_UEVENT_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
struct Uevent {
|
|
||||||
std::string action;
|
|
||||||
std::string name;
|
|
||||||
std::string state;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace android
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,114 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "uevent_listener.h"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <cutils/uevent.h>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
static void ParseEvent(const char* msg, Uevent* uevent) {
|
|
||||||
uevent->action.clear();
|
|
||||||
uevent->name.clear();
|
|
||||||
uevent->state.clear();
|
|
||||||
|
|
||||||
while (*msg) {
|
|
||||||
if (!strncmp(msg, "ACTION=", 7)) {
|
|
||||||
msg += 7;
|
|
||||||
uevent->action = msg;
|
|
||||||
} else if (!strncmp(msg, "NAME=", 5)) {
|
|
||||||
msg += 5;
|
|
||||||
uevent->name = msg;
|
|
||||||
} else if (!strncmp(msg, "STATE=", 6)) {
|
|
||||||
msg += 6;
|
|
||||||
uevent->state = msg;
|
|
||||||
}
|
|
||||||
// advance to after the next \0
|
|
||||||
while (*msg++);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(DEBUG) << "ACTION=" << uevent->action << " NAME=" << uevent->name
|
|
||||||
<< " STATE=" << uevent->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
UeventListener::UeventListener() {
|
|
||||||
// is 256K enough? udev uses 16MB!
|
|
||||||
device_fd_.reset(uevent_open_socket(256 * 1024, true));
|
|
||||||
if (device_fd_ == -1) {
|
|
||||||
LOG(FATAL) << "Could not open uevent socket";
|
|
||||||
}
|
|
||||||
|
|
||||||
fcntl(device_fd_, F_SETFL, O_NONBLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UeventListener::ReadUevent(Uevent* uevent) const {
|
|
||||||
char msg[UEVENT_MSG_LEN + 2];
|
|
||||||
int n = uevent_kernel_multicast_recv(device_fd_, msg, UEVENT_MSG_LEN);
|
|
||||||
if (n <= 0) {
|
|
||||||
if (errno != EAGAIN && errno != EWOULDBLOCK) {
|
|
||||||
LOG(ERROR) << "Error reading from Uevent Fd";
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (n >= UEVENT_MSG_LEN) {
|
|
||||||
LOG(ERROR) << "Uevent overflowed buffer, discarding";
|
|
||||||
// Return true here even if we discard as we may have more uevents pending and we
|
|
||||||
// want to keep processing them.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg[n] = '\0';
|
|
||||||
msg[n + 1] = '\0';
|
|
||||||
|
|
||||||
ParseEvent(msg, uevent);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UeventListener::Poll(const ListenerCallback& callback) const {
|
|
||||||
pollfd ufd;
|
|
||||||
ufd.events = POLLIN;
|
|
||||||
ufd.fd = device_fd_;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
ufd.revents = 0;
|
|
||||||
|
|
||||||
int nr = poll(&ufd, 1, -1);
|
|
||||||
if (nr == 0) return;
|
|
||||||
if (nr < 0) {
|
|
||||||
PLOG(ERROR) << "poll() of uevent socket failed, continuing";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ufd.revents & POLLIN) {
|
|
||||||
// We're non-blocking, so if we receive a poll event keep processing until
|
|
||||||
// we have exhausted all uevent messages.
|
|
||||||
Uevent uevent;
|
|
||||||
while (ReadUevent(&uevent)) {
|
|
||||||
callback(uevent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace android
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INIT_UEVENT_LISTENER_H
|
|
||||||
#define _INIT_UEVENT_LISTENER_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#include <android-base/unique_fd.h>
|
|
||||||
|
|
||||||
#include "uevent.h"
|
|
||||||
|
|
||||||
#define UEVENT_MSG_LEN 2048
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
using ListenerCallback = std::function<void(const Uevent&)>;
|
|
||||||
|
|
||||||
class UeventListener {
|
|
||||||
public:
|
|
||||||
UeventListener();
|
|
||||||
|
|
||||||
void Poll(const ListenerCallback& callback) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool ReadUevent(Uevent* uevent) const;
|
|
||||||
|
|
||||||
android::base::unique_fd device_fd_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace android
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,44 +0,0 @@
|
||||||
Common_CFlags = ["-Wall"]
|
|
||||||
Common_CFlags += ["-Werror"]
|
|
||||||
|
|
||||||
cc_library_shared {
|
|
||||||
name: "vendor.qti.hardware.vibrator.impl.oneplus_lahaina",
|
|
||||||
stem: "vendor.qti.hardware.vibrator.impl",
|
|
||||||
vendor: true,
|
|
||||||
cflags: Common_CFlags,
|
|
||||||
srcs: [
|
|
||||||
"Vibrator.cpp",
|
|
||||||
],
|
|
||||||
shared_libs: [
|
|
||||||
"libcutils",
|
|
||||||
"libutils",
|
|
||||||
"liblog",
|
|
||||||
"libqtivibratoreffect",
|
|
||||||
"libbinder_ndk",
|
|
||||||
"android.hardware.vibrator-ndk_platform",
|
|
||||||
],
|
|
||||||
export_include_dirs: ["include"]
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
name: "vendor.qti.hardware.vibrator.service.oneplus_lahaina",
|
|
||||||
stem: "vendor.qti.hardware.vibrator.service",
|
|
||||||
vendor: true,
|
|
||||||
relative_install_path: "hw",
|
|
||||||
init_rc: ["vendor.qti.hardware.vibrator.service.rc"],
|
|
||||||
vintf_fragments: [
|
|
||||||
"vendor.qti.hardware.vibrator.service.xml",
|
|
||||||
],
|
|
||||||
cflags: Common_CFlags,
|
|
||||||
srcs: [
|
|
||||||
"service.cpp",
|
|
||||||
],
|
|
||||||
shared_libs: [
|
|
||||||
"libcutils",
|
|
||||||
"libutils",
|
|
||||||
"libbase",
|
|
||||||
"libbinder_ndk",
|
|
||||||
"android.hardware.vibrator-ndk_platform",
|
|
||||||
"vendor.qti.hardware.vibrator.impl",
|
|
||||||
],
|
|
||||||
}
|
|
|
@ -1,655 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided
|
|
||||||
* with the distribution.
|
|
||||||
* * Neither the name of The Linux Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
||||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "vendor.qti.vibrator"
|
|
||||||
|
|
||||||
#include <cutils/properties.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <linux/input.h>
|
|
||||||
#include <log/log.h>
|
|
||||||
#include <map>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
#include "include/Vibrator.h"
|
|
||||||
#ifdef USE_EFFECT_STREAM
|
|
||||||
#include "effect.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace aidl {
|
|
||||||
namespace android {
|
|
||||||
namespace hardware {
|
|
||||||
namespace vibrator {
|
|
||||||
|
|
||||||
#define STRONG_MAGNITUDE 0x7fff
|
|
||||||
#define MEDIUM_MAGNITUDE 0x5fff
|
|
||||||
#define LIGHT_MAGNITUDE 0x3fff
|
|
||||||
#define INVALID_VALUE -1
|
|
||||||
#define CUSTOM_DATA_LEN 3
|
|
||||||
#define NAME_BUF_SIZE 32
|
|
||||||
|
|
||||||
#define MSM_CPU_LAHAINA 415
|
|
||||||
#define APQ_CPU_LAHAINA 439
|
|
||||||
#define MSM_CPU_SHIMA 450
|
|
||||||
#define MSM_CPU_SM8325 501
|
|
||||||
#define APQ_CPU_SM8325P 502
|
|
||||||
#define MSM_CPU_YUPIK 475
|
|
||||||
|
|
||||||
#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
|
|
||||||
|
|
||||||
static const char LED_DEVICE[] = "/sys/class/leds/vibrator";
|
|
||||||
|
|
||||||
static std::map<Effect, std::vector<std::pair<std::string, std::string>>> LED_EFFECTS{
|
|
||||||
{ Effect::CLICK, {
|
|
||||||
{ "/sys/class/leds/vibrator/ignore_store", "0" },
|
|
||||||
{ "/sys/class/leds/vibrator/duration", "10" },
|
|
||||||
{ "/sys/class/leds/vibrator/vmax", "0x1f" },
|
|
||||||
{ "/sys/class/leds/vibrator/gain", "0x80" },
|
|
||||||
{ "/sys/class/leds/vibrator/seq", "0x00 0x03" },
|
|
||||||
{ "/sys/class/leds/vibrator/loop", "0x00 0x00" },
|
|
||||||
{ "/sys/class/leds/vibrator/brightness", "1" },
|
|
||||||
}},
|
|
||||||
{ Effect::DOUBLE_CLICK, {
|
|
||||||
{ "/sys/class/leds/vibrator/ignore_store", "0" },
|
|
||||||
{ "/sys/class/leds/vibrator/duration", "30" },
|
|
||||||
{ "/sys/class/leds/vibrator/vmax", "0x1f" },
|
|
||||||
{ "/sys/class/leds/vibrator/gain", "0x80" },
|
|
||||||
{ "/sys/class/leds/vibrator/seq", "0x00 0x03" },
|
|
||||||
{ "/sys/class/leds/vibrator/loop", "0x00 0x00" },
|
|
||||||
{ "/sys/class/leds/vibrator/brightness", "1" },
|
|
||||||
{ "SLEEP", "150" },
|
|
||||||
{ "/sys/class/leds/vibrator/ignore_store", "0" },
|
|
||||||
{ "/sys/class/leds/vibrator/duration", "30" },
|
|
||||||
{ "/sys/class/leds/vibrator/vmax", "0x1f" },
|
|
||||||
{ "/sys/class/leds/vibrator/gain", "0x80" },
|
|
||||||
{ "/sys/class/leds/vibrator/seq", "0x00 0x03" },
|
|
||||||
{ "/sys/class/leds/vibrator/loop", "0x00 0x00" },
|
|
||||||
{ "/sys/class/leds/vibrator/brightness", "1" },
|
|
||||||
}},
|
|
||||||
{ Effect::TICK, {
|
|
||||||
{ "/sys/class/leds/vibrator/ignore_store", "0" },
|
|
||||||
{ "/sys/class/leds/vibrator/duration", "30" },
|
|
||||||
{ "/sys/class/leds/vibrator/vmax", "0x1f" },
|
|
||||||
{ "/sys/class/leds/vibrator/gain", "0x80" },
|
|
||||||
{ "/sys/class/leds/vibrator/seq", "0x00 0x03" },
|
|
||||||
{ "/sys/class/leds/vibrator/loop", "0x00 0x00" },
|
|
||||||
{ "/sys/class/leds/vibrator/brightness", "1" },
|
|
||||||
}},
|
|
||||||
{ Effect::HEAVY_CLICK, {
|
|
||||||
{ "/sys/class/leds/vibrator/ignore_store", "0" },
|
|
||||||
{ "/sys/class/leds/vibrator/duration", "10" },
|
|
||||||
{ "/sys/class/leds/vibrator/vmax", "0x1f" },
|
|
||||||
{ "/sys/class/leds/vibrator/gain", "0x80" },
|
|
||||||
{ "/sys/class/leds/vibrator/seq", "0x00 0x03" },
|
|
||||||
{ "/sys/class/leds/vibrator/loop", "0x00 0x00" },
|
|
||||||
{ "/sys/class/leds/vibrator/brightness", "1" },
|
|
||||||
}}
|
|
||||||
};
|
|
||||||
|
|
||||||
InputFFDevice::InputFFDevice()
|
|
||||||
{
|
|
||||||
DIR *dp;
|
|
||||||
FILE *fp = NULL;
|
|
||||||
struct dirent *dir;
|
|
||||||
uint8_t ffBitmask[FF_CNT / 8];
|
|
||||||
char devicename[PATH_MAX];
|
|
||||||
const char *INPUT_DIR = "/dev/input/";
|
|
||||||
char name[NAME_BUF_SIZE];
|
|
||||||
int fd, ret;
|
|
||||||
int soc = property_get_int32("ro.vendor.qti.soc_id", -1);
|
|
||||||
|
|
||||||
mVibraFd = INVALID_VALUE;
|
|
||||||
mSupportGain = false;
|
|
||||||
mSupportEffects = false;
|
|
||||||
mSupportExternalControl = false;
|
|
||||||
mCurrAppId = INVALID_VALUE;
|
|
||||||
mCurrMagnitude = 0x7fff;
|
|
||||||
mInExternalControl = false;
|
|
||||||
|
|
||||||
dp = opendir(INPUT_DIR);
|
|
||||||
if (!dp) {
|
|
||||||
ALOGE("open %s failed, errno = %d", INPUT_DIR, errno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(ffBitmask, 0, sizeof(ffBitmask));
|
|
||||||
while ((dir = readdir(dp)) != NULL){
|
|
||||||
if (dir->d_name[0] == '.' &&
|
|
||||||
(dir->d_name[1] == '\0' ||
|
|
||||||
(dir->d_name[1] == '.' && dir->d_name[2] == '\0')))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
snprintf(devicename, PATH_MAX, "%s%s", INPUT_DIR, dir->d_name);
|
|
||||||
fd = TEMP_FAILURE_RETRY(open(devicename, O_RDWR));
|
|
||||||
if (fd < 0) {
|
|
||||||
ALOGE("open %s failed, errno = %d", devicename, errno);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = TEMP_FAILURE_RETRY(ioctl(fd, EVIOCGNAME(sizeof(name)), name));
|
|
||||||
if (ret == -1) {
|
|
||||||
ALOGE("get input device name %s failed, errno = %d\n", devicename, errno);
|
|
||||||
close(fd);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(name, "qcom-hv-haptics") && strcmp(name, "qti-haptics")) {
|
|
||||||
ALOGD("not a qcom/qti haptics device\n");
|
|
||||||
close(fd);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ALOGI("%s is detected at %s\n", name, devicename);
|
|
||||||
ret = TEMP_FAILURE_RETRY(ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffBitmask)), ffBitmask));
|
|
||||||
if (ret == -1) {
|
|
||||||
ALOGE("ioctl failed, errno = %d", errno);
|
|
||||||
close(fd);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (test_bit(FF_CONSTANT, ffBitmask) ||
|
|
||||||
test_bit(FF_PERIODIC, ffBitmask)) {
|
|
||||||
mVibraFd = fd;
|
|
||||||
if (test_bit(FF_CUSTOM, ffBitmask))
|
|
||||||
mSupportEffects = true;
|
|
||||||
if (test_bit(FF_GAIN, ffBitmask))
|
|
||||||
mSupportGain = true;
|
|
||||||
|
|
||||||
if (soc <= 0 && (fp = fopen("/sys/devices/soc0/soc_id", "r")) != NULL) {
|
|
||||||
fscanf(fp, "%u", &soc);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
switch (soc) {
|
|
||||||
case MSM_CPU_LAHAINA:
|
|
||||||
case APQ_CPU_LAHAINA:
|
|
||||||
case MSM_CPU_SHIMA:
|
|
||||||
case MSM_CPU_SM8325:
|
|
||||||
case APQ_CPU_SM8325P:
|
|
||||||
case MSM_CPU_YUPIK:
|
|
||||||
mSupportExternalControl = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mSupportExternalControl = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Play vibration
|
|
||||||
*
|
|
||||||
* @param effectId: ID of the predefined effect will be played. If effectId is valid
|
|
||||||
* (non-negative value), the timeoutMs value will be ignored, and the
|
|
||||||
* real playing length will be set in param@playLengtMs and returned
|
|
||||||
* to VibratorService. If effectId is invalid, value in param@timeoutMs
|
|
||||||
* will be used as the play length for playing a constant effect.
|
|
||||||
* @param timeoutMs: playing length, non-zero means playing, zero means stop playing.
|
|
||||||
* @param playLengthMs: the playing length in ms unit which will be returned to
|
|
||||||
* VibratorService if the request is playing a predefined effect.
|
|
||||||
* The custom_data in periodic is reused for returning the playLengthMs
|
|
||||||
* from kernel space to userspace if the pattern is defined in kernel
|
|
||||||
* driver. It's been defined with following format:
|
|
||||||
* <effect-ID, play-time-in-seconds, play-time-in-milliseconds>.
|
|
||||||
* The effect-ID is used for passing down the predefined effect to
|
|
||||||
* kernel driver, and the rest two parameters are used for returning
|
|
||||||
* back the real playing length from kernel driver.
|
|
||||||
*/
|
|
||||||
int InputFFDevice::play(int effectId, uint32_t timeoutMs, long *playLengthMs) {
|
|
||||||
struct ff_effect effect;
|
|
||||||
struct input_event play;
|
|
||||||
int16_t data[CUSTOM_DATA_LEN] = {0, 0, 0};
|
|
||||||
int ret;
|
|
||||||
#ifdef USE_EFFECT_STREAM
|
|
||||||
const struct effect_stream *stream;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For QMAA compliance, return OK even if vibrator device doesn't exist */
|
|
||||||
if (mVibraFd == INVALID_VALUE) {
|
|
||||||
if (playLengthMs != NULL)
|
|
||||||
*playLengthMs = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeoutMs != 0) {
|
|
||||||
if (mCurrAppId != INVALID_VALUE) {
|
|
||||||
ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCRMFF, mCurrAppId));
|
|
||||||
if (ret == -1) {
|
|
||||||
ALOGE("ioctl EVIOCRMFF failed, errno = %d", -errno);
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
mCurrAppId = INVALID_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&effect, 0, sizeof(effect));
|
|
||||||
if (effectId != INVALID_VALUE) {
|
|
||||||
data[0] = effectId;
|
|
||||||
effect.type = FF_PERIODIC;
|
|
||||||
effect.u.periodic.waveform = FF_CUSTOM;
|
|
||||||
effect.u.periodic.magnitude = mCurrMagnitude;
|
|
||||||
effect.u.periodic.custom_data = data;
|
|
||||||
effect.u.periodic.custom_len = sizeof(int16_t) * CUSTOM_DATA_LEN;
|
|
||||||
#ifdef USE_EFFECT_STREAM
|
|
||||||
stream = get_effect_stream(effectId);
|
|
||||||
if (stream != NULL) {
|
|
||||||
effect.u.periodic.custom_data = (int16_t *)stream;
|
|
||||||
effect.u.periodic.custom_len = sizeof(*stream);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
effect.type = FF_CONSTANT;
|
|
||||||
effect.u.constant.level = mCurrMagnitude;
|
|
||||||
effect.replay.length = timeoutMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
effect.id = mCurrAppId;
|
|
||||||
effect.replay.delay = 0;
|
|
||||||
|
|
||||||
ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCSFF, &effect));
|
|
||||||
if (ret == -1) {
|
|
||||||
ALOGE("ioctl EVIOCSFF failed, errno = %d", -errno);
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
mCurrAppId = effect.id;
|
|
||||||
if (effectId != INVALID_VALUE && playLengthMs != NULL) {
|
|
||||||
*playLengthMs = data[1] * 1000 + data[2];
|
|
||||||
#ifdef USE_EFFECT_STREAM
|
|
||||||
if (stream != NULL && stream->play_rate_hz != 0)
|
|
||||||
*playLengthMs = ((stream->length * 1000) / stream->play_rate_hz) + 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
play.value = 1;
|
|
||||||
play.type = EV_FF;
|
|
||||||
play.code = mCurrAppId;
|
|
||||||
play.time.tv_sec = 0;
|
|
||||||
play.time.tv_usec = 0;
|
|
||||||
ret = TEMP_FAILURE_RETRY(write(mVibraFd, (const void*)&play, sizeof(play)));
|
|
||||||
if (ret == -1) {
|
|
||||||
ALOGE("write failed, errno = %d\n", -errno);
|
|
||||||
ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCRMFF, mCurrAppId));
|
|
||||||
if (ret == -1)
|
|
||||||
ALOGE("ioctl EVIOCRMFF failed, errno = %d", -errno);
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
} else if (mCurrAppId != INVALID_VALUE) {
|
|
||||||
ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCRMFF, mCurrAppId));
|
|
||||||
if (ret == -1) {
|
|
||||||
ALOGE("ioctl EVIOCRMFF failed, errno = %d", -errno);
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
mCurrAppId = INVALID_VALUE;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
errout:
|
|
||||||
mCurrAppId = INVALID_VALUE;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int InputFFDevice::on(int32_t timeoutMs) {
|
|
||||||
return play(INVALID_VALUE, timeoutMs, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int InputFFDevice::off() {
|
|
||||||
return play(INVALID_VALUE, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int InputFFDevice::setAmplitude(uint8_t amplitude) {
|
|
||||||
int tmp, ret;
|
|
||||||
struct input_event ie;
|
|
||||||
|
|
||||||
/* For QMAA compliance, return OK even if vibrator device doesn't exist */
|
|
||||||
if (mVibraFd == INVALID_VALUE)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tmp = amplitude * (STRONG_MAGNITUDE - LIGHT_MAGNITUDE) / 255;
|
|
||||||
tmp += LIGHT_MAGNITUDE;
|
|
||||||
ie.type = EV_FF;
|
|
||||||
ie.code = FF_GAIN;
|
|
||||||
ie.value = tmp;
|
|
||||||
|
|
||||||
ret = TEMP_FAILURE_RETRY(write(mVibraFd, &ie, sizeof(ie)));
|
|
||||||
if (ret == -1) {
|
|
||||||
ALOGE("write FF_GAIN failed, errno = %d", -errno);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
mCurrMagnitude = tmp;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int InputFFDevice::playEffect(int effectId, EffectStrength es, long *playLengthMs) {
|
|
||||||
switch (es) {
|
|
||||||
case EffectStrength::LIGHT:
|
|
||||||
mCurrMagnitude = LIGHT_MAGNITUDE;
|
|
||||||
break;
|
|
||||||
case EffectStrength::MEDIUM:
|
|
||||||
mCurrMagnitude = MEDIUM_MAGNITUDE;
|
|
||||||
break;
|
|
||||||
case EffectStrength::STRONG:
|
|
||||||
mCurrMagnitude = STRONG_MAGNITUDE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return play(effectId, INVALID_VALUE, playLengthMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
LedVibratorDevice::LedVibratorDevice() {
|
|
||||||
char devicename[PATH_MAX];
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
mDetected = false;
|
|
||||||
|
|
||||||
snprintf(devicename, sizeof(devicename), "%s/%s", LED_DEVICE, "activate");
|
|
||||||
fd = TEMP_FAILURE_RETRY(open(devicename, O_RDWR));
|
|
||||||
if (fd < 0) {
|
|
||||||
ALOGE("open %s failed, errno = %d", devicename, errno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mDetected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LedVibratorDevice::write_value(const char *file, const char *value) {
|
|
||||||
int fd;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
fd = TEMP_FAILURE_RETRY(open(file, O_WRONLY));
|
|
||||||
if (fd < 0) {
|
|
||||||
ALOGE("open %s failed, errno = %d", file, errno);
|
|
||||||
return -errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = TEMP_FAILURE_RETRY(write(fd, value, strlen(value) + 1));
|
|
||||||
if (ret == -1) {
|
|
||||||
ret = -errno;
|
|
||||||
} else if (ret != strlen(value) + 1) {
|
|
||||||
/* even though EAGAIN is an errno value that could be set
|
|
||||||
by write() in some cases, none of them apply here. So, this return
|
|
||||||
value can be clearly identified when debugging and suggests the
|
|
||||||
caller that it may try to call vibrator_on() again */
|
|
||||||
ret = -EAGAIN;
|
|
||||||
} else {
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LedVibratorDevice::on(int32_t timeoutMs) {
|
|
||||||
char file[PATH_MAX];
|
|
||||||
char value[32];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "state");
|
|
||||||
ret = write_value(file, "1");
|
|
||||||
if (ret < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "duration");
|
|
||||||
snprintf(value, sizeof(value), "%u\n", timeoutMs);
|
|
||||||
ret = write_value(file, value);
|
|
||||||
if (ret < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "activate");
|
|
||||||
ret = write_value(file, "1");
|
|
||||||
if (ret < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
ALOGE("Failed to turn on vibrator ret: %d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LedVibratorDevice::off()
|
|
||||||
{
|
|
||||||
char file[PATH_MAX];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "activate");
|
|
||||||
ret = write_value(file, "0");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::getCapabilities(int32_t* _aidl_return) {
|
|
||||||
*_aidl_return = IVibrator::CAP_ON_CALLBACK;
|
|
||||||
|
|
||||||
if (ledVib.mDetected) {
|
|
||||||
*_aidl_return |= IVibrator::CAP_PERFORM_CALLBACK;
|
|
||||||
ALOGD("QTI Vibrator reporting capabilities: %d", *_aidl_return);
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ff.mSupportGain)
|
|
||||||
*_aidl_return |= IVibrator::CAP_AMPLITUDE_CONTROL;
|
|
||||||
if (ff.mSupportEffects)
|
|
||||||
*_aidl_return |= IVibrator::CAP_PERFORM_CALLBACK;
|
|
||||||
if (ff.mSupportExternalControl)
|
|
||||||
*_aidl_return |= IVibrator::CAP_EXTERNAL_CONTROL;
|
|
||||||
|
|
||||||
ALOGD("QTI Vibrator reporting capabilities: %d", *_aidl_return);
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::off() {
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ALOGD("QTI Vibrator off");
|
|
||||||
if (ledVib.mDetected)
|
|
||||||
ret = ledVib.off();
|
|
||||||
else
|
|
||||||
ret = ff.off();
|
|
||||||
if (ret != 0)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_SERVICE_SPECIFIC));
|
|
||||||
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs,
|
|
||||||
const std::shared_ptr<IVibratorCallback>& callback) {
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ALOGD("Vibrator on for timeoutMs: %d", timeoutMs);
|
|
||||||
if (ledVib.mDetected)
|
|
||||||
ret = ledVib.on(timeoutMs);
|
|
||||||
else
|
|
||||||
ret = ff.on(timeoutMs);
|
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_SERVICE_SPECIFIC));
|
|
||||||
|
|
||||||
if (callback != nullptr) {
|
|
||||||
std::thread([=] {
|
|
||||||
ALOGD("Starting on on another thread");
|
|
||||||
usleep(timeoutMs * 1000);
|
|
||||||
ALOGD("Notifying on complete");
|
|
||||||
if (!callback->onComplete().isOk()) {
|
|
||||||
ALOGE("Failed to call onComplete");
|
|
||||||
}
|
|
||||||
}).detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength es, const std::shared_ptr<IVibratorCallback>& callback, int32_t* _aidl_return) {
|
|
||||||
long playLengthMs;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ALOGD("Vibrator perform effect %d", effect);
|
|
||||||
|
|
||||||
if (ledVib.mDetected) {
|
|
||||||
if (const auto it = LED_EFFECTS.find(effect); it != LED_EFFECTS.end()) {
|
|
||||||
for (const auto &[path, value] : it->second) {
|
|
||||||
if (path == "SLEEP") {
|
|
||||||
usleep(atoi(value.c_str()) * 1000);
|
|
||||||
} else {
|
|
||||||
ledVib.write_value(path.c_str(), value.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore gain from persist prop
|
|
||||||
char gain[PROPERTY_VALUE_MAX]{};
|
|
||||||
property_get("persist.vendor.vib.gain", gain, "0x55");
|
|
||||||
ledVib.write_value("/sys/class/leds/vibrator/gain", gain);
|
|
||||||
|
|
||||||
// Return magic value for play length so that we won't end up calling on() / off()
|
|
||||||
playLengthMs = 150;
|
|
||||||
} else {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (effect < Effect::CLICK ||
|
|
||||||
effect > Effect::HEAVY_CLICK)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
|
|
||||||
if (es != EffectStrength::LIGHT && es != EffectStrength::MEDIUM &&
|
|
||||||
es != EffectStrength::STRONG)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
|
|
||||||
ret = ff.playEffect((static_cast<int>(effect)), es, &playLengthMs);
|
|
||||||
if (ret != 0)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_SERVICE_SPECIFIC));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callback != nullptr) {
|
|
||||||
std::thread([=] {
|
|
||||||
ALOGD("Starting perform on another thread");
|
|
||||||
usleep(playLengthMs * 1000);
|
|
||||||
ALOGD("Notifying perform complete");
|
|
||||||
callback->onComplete();
|
|
||||||
}).detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
*_aidl_return = playLengthMs;
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect>* _aidl_return) {
|
|
||||||
if (ledVib.mDetected) {
|
|
||||||
*_aidl_return = {Effect::CLICK, Effect::DOUBLE_CLICK, Effect::TICK, Effect::HEAVY_CLICK};
|
|
||||||
} else {
|
|
||||||
*_aidl_return = {Effect::CLICK, Effect::DOUBLE_CLICK, Effect::TICK, Effect::THUD,
|
|
||||||
Effect::POP, Effect::HEAVY_CLICK};
|
|
||||||
}
|
|
||||||
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) {
|
|
||||||
uint8_t tmp;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (ledVib.mDetected)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
|
|
||||||
ALOGD("Vibrator set amplitude: %f", amplitude);
|
|
||||||
|
|
||||||
if (amplitude <= 0.0f || amplitude > 1.0f)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT));
|
|
||||||
|
|
||||||
if (ff.mInExternalControl)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
|
|
||||||
tmp = (uint8_t)(amplitude * 0xff);
|
|
||||||
ret = ff.setAmplitude(tmp);
|
|
||||||
if (ret != 0)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_SERVICE_SPECIFIC));
|
|
||||||
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::setExternalControl(bool enabled) {
|
|
||||||
if (ledVib.mDetected)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
|
|
||||||
ALOGD("Vibrator set external control: %d", enabled);
|
|
||||||
if (!ff.mSupportExternalControl)
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
|
|
||||||
ff.mInExternalControl = enabled;
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::getCompositionDelayMax(int32_t* maxDelayMs __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t* maxSize __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimitive>* supported __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive primitive __unused,
|
|
||||||
int32_t* durationMs __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& composite __unused,
|
|
||||||
const std::shared_ptr<IVibratorCallback>& callback __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect>* _aidl_return __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t id __unused, Effect effect __unused,
|
|
||||||
EffectStrength strength __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus Vibrator::alwaysOnDisable(int32_t id __unused) {
|
|
||||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace vibrator
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
||||||
} // namespace aidl
|
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2018,2020, The Linux Foundation. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided
|
|
||||||
* with the distribution.
|
|
||||||
* * Neither the name of The Linux Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
||||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <aidl/android/hardware/vibrator/BnVibrator.h>
|
|
||||||
|
|
||||||
namespace aidl {
|
|
||||||
namespace android {
|
|
||||||
namespace hardware {
|
|
||||||
namespace vibrator {
|
|
||||||
|
|
||||||
class InputFFDevice {
|
|
||||||
public:
|
|
||||||
InputFFDevice();
|
|
||||||
int playEffect(int effectId, EffectStrength es, long *playLengthMs);
|
|
||||||
int on(int32_t timeoutMs);
|
|
||||||
int off();
|
|
||||||
int setAmplitude(uint8_t amplitude);
|
|
||||||
bool mSupportGain;
|
|
||||||
bool mSupportEffects;
|
|
||||||
bool mSupportExternalControl;
|
|
||||||
bool mInExternalControl;
|
|
||||||
private:
|
|
||||||
int play(int effectId, uint32_t timeoutMs, long *playLengthMs);
|
|
||||||
int mVibraFd;
|
|
||||||
int16_t mCurrAppId;
|
|
||||||
int16_t mCurrMagnitude;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LedVibratorDevice {
|
|
||||||
public:
|
|
||||||
LedVibratorDevice();
|
|
||||||
int on(int32_t timeoutMs);
|
|
||||||
int off();
|
|
||||||
bool mDetected;
|
|
||||||
int write_value(const char *file, const char *value);
|
|
||||||
};
|
|
||||||
|
|
||||||
class Vibrator : public BnVibrator {
|
|
||||||
public:
|
|
||||||
class InputFFDevice ff;
|
|
||||||
class LedVibratorDevice ledVib;
|
|
||||||
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 setAmplitude(float amplitude) override;
|
|
||||||
ndk::ScopedAStatus setExternalControl(bool enabled) override;
|
|
||||||
ndk::ScopedAStatus getCompositionDelayMax(int32_t* maxDelayMs);
|
|
||||||
ndk::ScopedAStatus getCompositionSizeMax(int32_t* maxSize);
|
|
||||||
ndk::ScopedAStatus getSupportedPrimitives(std::vector<CompositePrimitive>* supported) override;
|
|
||||||
ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive,
|
|
||||||
int32_t* durationMs) 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace vibrator
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
||||||
} // namespace aidl
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided
|
|
||||||
* with the distribution.
|
|
||||||
* * Neither the name of The Linux Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
||||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "vendor.qti.hardware.vibrator.service"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <android/binder_manager.h>
|
|
||||||
#include <android/binder_process.h>
|
|
||||||
|
|
||||||
#include "Vibrator.h"
|
|
||||||
|
|
||||||
using aidl::android::hardware::vibrator::Vibrator;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
|
||||||
std::shared_ptr<Vibrator> vib = ndk::SharedRefBase::make<Vibrator>();
|
|
||||||
|
|
||||||
const std::string instance = std::string() + Vibrator::descriptor + "/default";
|
|
||||||
binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str());
|
|
||||||
CHECK(status == STATUS_OK);
|
|
||||||
|
|
||||||
ABinderProcess_joinThreadPool();
|
|
||||||
return EXIT_FAILURE; // should not reach
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
service vendor.qti.vibrator /vendor/bin/hw/vendor.qti.hardware.vibrator.service
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group system input
|
|
|
@ -1,33 +0,0 @@
|
||||||
<!-- Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following
|
|
||||||
disclaimer in the documentation and/or other materials provided
|
|
||||||
with the distribution.
|
|
||||||
* Neither the name of The Linux Foundation nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
||||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
|
||||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
||||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
-->
|
|
||||||
<manifest version="1.0" type="device">
|
|
||||||
<hal format="aidl">
|
|
||||||
<name>android.hardware.vibrator</name>
|
|
||||||
<fqname>IVibrator/default</fqname>
|
|
||||||
</hal>
|
|
||||||
</manifest>
|
|
|
@ -1,9 +0,0 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
LOCAL_MODULE := wifi-mac-generator
|
|
||||||
LOCAL_MODULE_CLASS := ETC
|
|
||||||
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES)
|
|
||||||
LOCAL_SRC_FILES := wifi-mac-generator.sh
|
|
||||||
LOCAL_INIT_RC := wifi-mac-generator.rc
|
|
||||||
include $(BUILD_PREBUILT)
|
|
|
@ -1,9 +0,0 @@
|
||||||
service vendor.wifi-mac-generator /vendor/bin/wifi-mac-generator
|
|
||||||
class main
|
|
||||||
user wifi
|
|
||||||
group wifi
|
|
||||||
oneshot
|
|
||||||
disabled
|
|
||||||
|
|
||||||
on post-fs-data
|
|
||||||
start vendor.wifi-mac-generator
|
|
|
@ -1,43 +0,0 @@
|
||||||
#!/vendor/bin/sh
|
|
||||||
WLAN_MAC_VENDOR_PREFIX="C0EEFB"
|
|
||||||
WLAN_MAC_PERSIST_PATH="/mnt/vendor/persist/wlan_mac.bin"
|
|
||||||
|
|
||||||
function wait_for_file() {
|
|
||||||
retries=0
|
|
||||||
|
|
||||||
while [ ! -f "${1}" ]; do
|
|
||||||
retries=$((retries + 1))
|
|
||||||
|
|
||||||
if [ "${retries}" -eq 10 ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ ! -f "${WLAN_MAC_PERSIST_PATH}" ]] || [[ ! -s "${WLAN_MAC_PERSIST_PATH}" ]]; then
|
|
||||||
MAC_0_PATH="/data/vendor/oemnvitems/4678_0"
|
|
||||||
|
|
||||||
if ! wait_for_file "${MAC_0_PATH}"; then
|
|
||||||
MAC_0="${WLAN_MAC_VENDOR_PREFIX}`xxd -l 3 -p /dev/urandom | tr '[:lower:]' '[:upper:]'`"
|
|
||||||
else
|
|
||||||
MAC_0=`xxd -p "${MAC_0_PATH}" | grep -o '..' | tac | tr -d '\n' | tr '[:lower:]' '[:upper:]'`
|
|
||||||
fi
|
|
||||||
|
|
||||||
MAC_1_PATH="/data/vendor/oemnvitems/4678_1"
|
|
||||||
|
|
||||||
if ! wait_for_file "${MAC_1_PATH}"; then
|
|
||||||
MAC_1="${WLAN_MAC_VENDOR_PREFIX}`xxd -l 3 -p /dev/urandom | tr '[:lower:]' '[:upper:]'`"
|
|
||||||
else
|
|
||||||
MAC_1=`xxd -p "${MAC_1_PATH}" | grep -o '..' | tac | tr -d '\n' | tr '[:lower:]' '[:upper:]'`
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Intf0MacAddress=${MAC_0}" > "${WLAN_MAC_PERSIST_PATH}"
|
|
||||||
echo "Intf1MacAddress=${MAC_1}" >> "${WLAN_MAC_PERSIST_PATH}"
|
|
||||||
echo "Intf2MacAddress=000AF58989FD" >> "${WLAN_MAC_PERSIST_PATH}"
|
|
||||||
echo "Intf3MacAddress=000AF58989FC" >> "${WLAN_MAC_PERSIST_PATH}"
|
|
||||||
echo "END" >> "${WLAN_MAC_PERSIST_PATH}"
|
|
||||||
fi
|
|
Loading…
Reference in a new issue