Compare commits
70 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce1bf5c27f | ||
|
|
44c057f60b | ||
|
|
474ebe1722 | ||
|
|
c7abe693bd | ||
|
|
ef4647e636 | ||
|
|
4b128b05b3 | ||
|
|
6157fb0df0 | ||
|
|
d87a8f30a4 | ||
|
|
211e5f0b1a | ||
|
|
f76655d7bc | ||
|
|
0073e77169 | ||
|
|
661a74dc6a | ||
|
|
7063bcad23 | ||
|
|
00809a12b0 | ||
|
|
9d8b250ce5 | ||
|
|
8aba80de2b | ||
|
|
33f74940ad | ||
|
|
b2f5a8db8d | ||
|
|
df0812cd0b | ||
|
|
4881519b23 | ||
|
|
96cec7c200 | ||
|
|
1c29fd2599 | ||
|
|
2326b7c10b | ||
|
|
1ff326fde4 | ||
|
|
078d67d671 | ||
|
|
d29b39b66a | ||
|
|
b0416d32bc | ||
|
|
1b4d8a2b03 | ||
|
|
354ca305ca | ||
|
|
923942619f | ||
|
|
33ccfec6cf | ||
|
|
9cc8f56671 | ||
| e1ebb45e3c | |||
|
|
c65e8a6f0f | ||
|
|
699a741aa9 | ||
|
|
403a57cc0d | ||
| 08cfc0cbc2 | |||
|
|
e1873e9df4 | ||
|
|
0c4a57235f | ||
| 0426336593 | |||
|
|
04da539900 | ||
|
|
9f2dfb966f | ||
|
|
121dddc138 | ||
|
|
d72d21d4ca | ||
|
|
73dc774852 | ||
|
|
888b1252e0 | ||
|
|
4dd00a62d7 | ||
|
|
f8f8b96472 | ||
|
|
2af299f594 | ||
|
|
de83d093e6 | ||
|
|
efaf58c10a | ||
|
|
098923d64e | ||
|
|
edf680575b | ||
|
|
876585001b | ||
|
|
c111b52360 | ||
|
|
5074e1b915 | ||
|
|
608872573b | ||
|
|
d4c580a5bc | ||
|
|
1940e53398 | ||
|
|
cd805062ff | ||
|
|
ca6f97fb2d | ||
|
|
9627fa4826 | ||
|
|
e132bfadd8 | ||
|
|
f4dd7d73f4 | ||
|
|
cb586c51f4 | ||
|
|
db3ce29c77 | ||
|
|
a72f98f12b | ||
|
|
9ab477d63c | ||
|
|
25f925f7a9 | ||
|
|
38094acf43 |
@@ -1 +0,0 @@
|
||||
../../build/soong/scripts/system-clang-format
|
||||
13
.clang-format
Normal file
13
.clang-format
Normal file
@@ -0,0 +1,13 @@
|
||||
BasedOnStyle: Google
|
||||
Standard: Cpp11
|
||||
AccessModifierOffset: -2
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
ColumnLimit: 100
|
||||
CommentPragmas: NOLINT:.*
|
||||
DerivePointerAlignment: false
|
||||
IncludeBlocks: Preserve
|
||||
IndentWidth: 4
|
||||
ContinuationIndentWidth: 8
|
||||
PointerAlignment: Left
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
13
.github/workflows/build/action.yml
vendored
Normal file
13
.github/workflows/build/action.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
name: build
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: pip install pre-commit
|
||||
|
||||
- name: Lint
|
||||
shell: bash
|
||||
run: pre-commit run --all
|
||||
38
.github/workflows/gerrit.yml
vendored
Normal file
38
.github/workflows/gerrit.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: gerrit checks
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
type: string
|
||||
gerrit-ref:
|
||||
type: string
|
||||
change:
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: lineageos-infra/fetch-gerrit-change@main
|
||||
with:
|
||||
gerrit-ref: ${{ inputs.gerrit-ref }}
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- name: Check if build/action.yml exists
|
||||
id: check
|
||||
run: |
|
||||
if [ -f ./.github/workflows/build/action.yml ]; then
|
||||
echo "run=1" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Build
|
||||
if: ${{ steps.check.outputs.run }}
|
||||
uses: ./.github/workflows/build
|
||||
|
||||
- uses: lineageos-infra/gerrit-vote@main
|
||||
if: ${{ steps.check.outputs.run && always() }}
|
||||
with:
|
||||
auth: ${{ secrets.GERRIT_VOTE_CREDS }}
|
||||
change: ${{ inputs.change }}
|
||||
ref: ${{ inputs.ref }}
|
||||
20
.pre-commit-config.yaml
Normal file
20
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v6.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v21.1.8
|
||||
hooks:
|
||||
- id: clang-format
|
||||
types_or: [c, c++]
|
||||
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
||||
rev: v2.15.0
|
||||
hooks:
|
||||
- id: pretty-format-kotlin
|
||||
args: [--autofix, --ktfmt, --ktfmt-style=kotlinlang]
|
||||
@@ -27,6 +27,9 @@
|
||||
<meta-data
|
||||
android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.ia.display" />
|
||||
<meta-data
|
||||
android:name="com.android.settings.group_key"
|
||||
android:value="category_key_color" />
|
||||
<meta-data
|
||||
android:name="com.android.settings.summary"
|
||||
android:value="@string/summary_empty" />
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keep class ** extends android.support.v14.preference.PreferenceFragment
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
android:id="@+id/frameLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<string name="mdnie_scenario_title_head">תרחיש</string>
|
||||
<string name="mdnie_scenario_summary_head">הגדר תרחיש mDNIe</string>
|
||||
<string name="mdnie_accessibility_title_head">מצב נגישות</string>
|
||||
<string name="mdnie_accessibility_summary_head">הגדרת מצב הנגישות mDNIe</string>
|
||||
<string name="mdnie_scenario_ui">LineageOS (ברירת מחדל)</string>
|
||||
<string name="mdnie_scenario_video">וידאו</string>
|
||||
<string name="mdnie_scenario_video_warm">וידאו חם</string>
|
||||
@@ -37,4 +38,7 @@
|
||||
<string name="mdnie_accessibility_normal">רגיל</string>
|
||||
<string name="mdnie_accessibility_inverse">הפוך</string>
|
||||
<string name="mdnie_accessibility_color_blind">עיוור צבעים</string>
|
||||
<string name="mdnie_accessibility_screen_curtain">וילון מסך</string>
|
||||
<string name="mdnie_accessibility_grayscale">אפור</string>
|
||||
<string name="mdnie_accessibility_gray_negative">אפור הפוך</string>
|
||||
</resources>
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
<string name="category_screen_title">Tela</string>
|
||||
<string name="screen_colors_title">Cores</string>
|
||||
<string name="mdnie_scenario_title_head">Cenário</string>
|
||||
<string name="mdnie_scenario_summary_head">Defina o cenário mDNIe</string>
|
||||
<string name="mdnie_scenario_summary_head">Configure o cenário mDNIe</string>
|
||||
<string name="mdnie_accessibility_title_head">Modo de acessibilidade</string>
|
||||
<string name="mdnie_accessibility_summary_head">Definir o modo de acessibilidade do mDNIe</string>
|
||||
<string name="mdnie_accessibility_summary_head">Configure o modo de acessibilidade do mDNIe</string>
|
||||
<string name="mdnie_scenario_ui">LineageOS (padrão)</string>
|
||||
<string name="mdnie_scenario_video">Vídeo</string>
|
||||
<string name="mdnie_scenario_video_warm">Vídeo quente</string>
|
||||
|
||||
@@ -16,7 +16,27 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="app_name">Ischermu avantzadu</string>
|
||||
<string name="category_screen_title">Ischermu</string>
|
||||
<string name="screen_colors_title">Colores</string>
|
||||
<string name="mdnie_accessibility_title_head">Modalidade de atzessu fatzilitadu</string>
|
||||
<string name="mdnie_accessibility_summary_head">Cunfigura sa modalidade de atzessu fatzilitadu mDNIe</string>
|
||||
<string name="mdnie_scenario_ui">LineageOS (predefinidu)</string>
|
||||
<string name="mdnie_scenario_video">Vìdeu</string>
|
||||
<string name="mdnie_scenario_video_warm">Tonu vìdeu callente</string>
|
||||
<string name="mdnie_scenario_video_cold">Tonu vìdeu fritu</string>
|
||||
<string name="mdnie_scenario_camera">Càmera</string>
|
||||
<string name="mdnie_scenario_navigation">Navigatzione</string>
|
||||
<string name="mdnie_scenario_gallery">Galleria</string>
|
||||
<string name="mdnie_scenario_vt">Mutida de vìdeu</string>
|
||||
<string name="mdnie_scenario_browser">Navigadore</string>
|
||||
<string name="mdnie_scenario_ebook">Libru electrònicu</string>
|
||||
<string name="mdnie_scenario_email">Posta eletrònica</string>
|
||||
<string name="mdnie_scenario_tdmb">Televisione digitale</string>
|
||||
<string name="mdnie_accessibility_normal">Normale</string>
|
||||
<string name="mdnie_accessibility_inverse">Invertidu</string>
|
||||
<string name="mdnie_accessibility_color_blind">Modalidade daltònica</string>
|
||||
<string name="mdnie_accessibility_screen_curtain">Modalidade ischermu iscuru</string>
|
||||
<string name="mdnie_accessibility_grayscale">Murru</string>
|
||||
<string name="mdnie_accessibility_gray_negative">Murru invertidu</string>
|
||||
</resources>
|
||||
|
||||
@@ -25,7 +25,7 @@ public class AdvancedDisplayActivity extends CollapsingToolbarBaseActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getFragmentManager().beginTransaction().replace(
|
||||
getSupportFragmentManager().beginTransaction().replace(
|
||||
com.android.settingslib.collapsingtoolbar.R.id.content_frame,
|
||||
new AdvancedDisplayFragment()).commit();
|
||||
}
|
||||
|
||||
@@ -19,19 +19,19 @@ package org.lineageos.settings.device;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.PreferenceFragment;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import org.lineageos.settings.device.R;
|
||||
|
||||
import org.lineageos.internal.util.FileUtils;
|
||||
|
||||
public class AdvancedDisplayFragment extends PreferenceFragment {
|
||||
public class AdvancedDisplayFragment extends PreferenceFragmentCompat {
|
||||
private mDNIeScenario mmDNIeScenario;
|
||||
private mDNIeAccessibility mmDNIeAccessibility;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.screen_preferences);
|
||||
setPreferencesFromResource(R.xml.screen_preferences, rootKey);
|
||||
Resources res = getResources();
|
||||
|
||||
/* mDNIe */
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2024-2026 The LineageOS Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
cc_library_static {
|
||||
name: "android.hardware.camera.common-helper.samsung",
|
||||
defaults: [
|
||||
@@ -36,11 +41,3 @@ cc_library_static {
|
||||
],
|
||||
export_shared_lib_headers: ["libui"],
|
||||
}
|
||||
|
||||
// NOTE: Deprecated module kept for compatibility reasons.
|
||||
// Depend on "android.hardware.camera.common-helper.samsung" instead
|
||||
cc_library_static {
|
||||
name: "android.hardware.camera.common@1.0-helper.samsung",
|
||||
vendor_available: true,
|
||||
whole_static_libs: ["android.hardware.camera.common-helper.samsung"],
|
||||
}
|
||||
|
||||
@@ -66,13 +66,16 @@ ndk::ScopedAStatus CameraDevice::getCameraCharacteristics(CameraMetadata* _aidl_
|
||||
struct camera_info info;
|
||||
int ret = mModule->getCameraInfo(mCameraIdInt, &info);
|
||||
if (ret == OK && info.static_camera_characteristics != NULL) {
|
||||
common::helper::CameraMetadata metadata = (camera_metadata_t*)info.static_camera_characteristics;
|
||||
common::helper::CameraMetadata metadata =
|
||||
(camera_metadata_t*)info.static_camera_characteristics;
|
||||
camera_metadata_entry_t entry = metadata.find(ANDROID_FLASH_INFO_AVAILABLE);
|
||||
if (entry.count > 0 && *entry.data.u8 != 0 && mModule->isSetTorchModeStrengthSupported()) {
|
||||
if (entry.count > 0 && *entry.data.u8 != 0 &&
|
||||
mModule->isSetTorchModeStrengthSupported()) {
|
||||
// Samsung always has 5 supported torch strength levels
|
||||
int32_t defaultTorchStrength = 1;
|
||||
int32_t torchStrengthLevels = 5;
|
||||
metadata.update(ANDROID_FLASH_INFO_STRENGTH_DEFAULT_LEVEL, &defaultTorchStrength, 1);
|
||||
metadata.update(ANDROID_FLASH_INFO_STRENGTH_DEFAULT_LEVEL, &defaultTorchStrength,
|
||||
1);
|
||||
metadata.update(ANDROID_FLASH_INFO_STRENGTH_MAXIMUM_LEVEL, &torchStrengthLevels, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ void CameraDeviceSession::cleanupInflightFences(std::vector<int>& allFences, siz
|
||||
|
||||
CameraDeviceSession::ResultBatcher::ResultBatcher(
|
||||
const std::shared_ptr<ICameraDeviceCallback>& callback)
|
||||
: mCallback(callback){};
|
||||
: mCallback(callback) {};
|
||||
|
||||
bool CameraDeviceSession::ResultBatcher::InflightBatch::allDelivered() const {
|
||||
if (!mShutterDelivered) return false;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2024-2026 The LineageOS Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
soong_config_module_type {
|
||||
name: "samsung_camera3",
|
||||
module_type: "cc_defaults",
|
||||
|
||||
@@ -1573,7 +1573,6 @@ typedef enum camera3_stream_configuration_mode {
|
||||
* types) see the usage field below.
|
||||
*/
|
||||
typedef struct camera3_stream {
|
||||
|
||||
/*****
|
||||
* Set by framework before configure_streams()
|
||||
*/
|
||||
@@ -1674,7 +1673,7 @@ typedef struct camera3_stream {
|
||||
* A handle to HAL-private information for the stream. Will not be inspected
|
||||
* by the framework code.
|
||||
*/
|
||||
void *priv;
|
||||
void* priv;
|
||||
|
||||
/**
|
||||
* A field that describes the contents of the buffer. The format and buffer
|
||||
@@ -1760,7 +1759,7 @@ typedef struct camera3_stream {
|
||||
const char* physical_camera_id;
|
||||
|
||||
/* reserved for future use */
|
||||
void *reserved[6];
|
||||
void* reserved[6];
|
||||
|
||||
#ifdef CAMERA_NEEDS_SEC_RESERVED_FIELD
|
||||
char reserved_sec[0x28];
|
||||
@@ -1793,7 +1792,7 @@ typedef struct camera3_stream_configuration {
|
||||
* At least one output-capable stream must be defined (OUTPUT or
|
||||
* BIDIRECTIONAL).
|
||||
*/
|
||||
camera3_stream_t **streams;
|
||||
camera3_stream_t** streams;
|
||||
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_3:
|
||||
@@ -1821,7 +1820,7 @@ typedef struct camera3_stream_configuration {
|
||||
* the parameter values and configure its internal camera pipeline
|
||||
* accordingly.
|
||||
*/
|
||||
const camera_metadata_t *session_parameters;
|
||||
const camera_metadata_t* session_parameters;
|
||||
} camera3_stream_configuration_t;
|
||||
|
||||
/**
|
||||
@@ -1858,12 +1857,12 @@ typedef struct camera3_stream_buffer {
|
||||
/**
|
||||
* The handle of the stream this buffer is associated with
|
||||
*/
|
||||
camera3_stream_t *stream;
|
||||
camera3_stream_t* stream;
|
||||
|
||||
/**
|
||||
* The native handle to the buffer
|
||||
*/
|
||||
buffer_handle_t *buffer;
|
||||
buffer_handle_t* buffer;
|
||||
|
||||
/**
|
||||
* Current state of the buffer, one of the camera3_buffer_status_t
|
||||
@@ -1899,7 +1898,7 @@ typedef struct camera3_stream_buffer {
|
||||
* fences should be handled similarly to the way they are handled for output
|
||||
* buffers.
|
||||
*/
|
||||
int acquire_fence;
|
||||
int acquire_fence;
|
||||
|
||||
/**
|
||||
* The release sync fence for this buffer. The HAL must set this fence when
|
||||
@@ -1947,7 +1946,7 @@ typedef struct camera3_stream_buffer_set {
|
||||
/**
|
||||
* The stream handle for the stream these buffers belong to
|
||||
*/
|
||||
camera3_stream_t *stream;
|
||||
camera3_stream_t* stream;
|
||||
|
||||
/**
|
||||
* The number of buffers in this stream. It is guaranteed to be at least
|
||||
@@ -1961,7 +1960,7 @@ typedef struct camera3_stream_buffer_set {
|
||||
* should inspect the passed-in buffers to determine any platform-private
|
||||
* pixel format information.
|
||||
*/
|
||||
buffer_handle_t **buffers;
|
||||
buffer_handle_t** buffers;
|
||||
|
||||
} camera3_stream_buffer_set_t;
|
||||
|
||||
@@ -2105,7 +2104,7 @@ typedef struct camera3_error_msg {
|
||||
* Pointer to the stream that had a failure. NULL if the stream isn't
|
||||
* applicable to the error.
|
||||
*/
|
||||
camera3_stream_t *error_stream;
|
||||
camera3_stream_t* error_stream;
|
||||
|
||||
/**
|
||||
* The code for this error; one of the CAMERA_MSG_ERROR enum values.
|
||||
@@ -2140,7 +2139,6 @@ typedef struct camera3_shutter_msg {
|
||||
* The message structure sent to camera3_callback_ops_t.notify()
|
||||
*/
|
||||
typedef struct camera3_notify_msg {
|
||||
|
||||
/**
|
||||
* The message type. One of camera3_notify_msg_type, or a private extension.
|
||||
*/
|
||||
@@ -2166,7 +2164,6 @@ typedef struct camera3_notify_msg {
|
||||
|
||||
} camera3_notify_msg_t;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* Types definition for request_stream_buffers() callback.
|
||||
@@ -2278,7 +2275,7 @@ typedef struct camera3_buffer_request {
|
||||
/**
|
||||
* The stream HAL wants to request buffer from
|
||||
*/
|
||||
camera3_stream_t *stream;
|
||||
camera3_stream_t* stream;
|
||||
|
||||
/**
|
||||
* The number of buffers HAL requested
|
||||
@@ -2290,7 +2287,7 @@ typedef struct camera3_stream_buffer_ret {
|
||||
/**
|
||||
* The stream HAL wants to request buffer from
|
||||
*/
|
||||
camera3_stream_t *stream;
|
||||
camera3_stream_t* stream;
|
||||
|
||||
/**
|
||||
* The status of buffer request of this stream
|
||||
@@ -2309,10 +2306,9 @@ typedef struct camera3_stream_buffer_ret {
|
||||
* Caller of request_stream_buffers() should supply this with enough memory
|
||||
* (num_buffers_requested * sizeof(camera3_stream_buffer_t))
|
||||
*/
|
||||
camera3_stream_buffer_t *output_buffers;
|
||||
camera3_stream_buffer_t* output_buffers;
|
||||
} camera3_stream_buffer_ret_t;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* Capture request/result definitions for the HAL process_capture_request()
|
||||
@@ -2410,7 +2406,7 @@ typedef struct camera3_capture_request {
|
||||
* NULL buffer cannot be used as the first submitted request after a
|
||||
* configure_streams() call.
|
||||
*/
|
||||
const camera_metadata_t *settings;
|
||||
const camera_metadata_t* settings;
|
||||
|
||||
/**
|
||||
* The input stream buffer to use for this request, if any.
|
||||
@@ -2436,7 +2432,7 @@ typedef struct camera3_capture_request {
|
||||
* The buffers will not have been pre-registered with the HAL.
|
||||
* Subsequent requests may reuse buffers, or provide entirely new buffers.
|
||||
*/
|
||||
camera3_stream_buffer_t *input_buffer;
|
||||
camera3_stream_buffer_t* input_buffer;
|
||||
|
||||
/**
|
||||
* The number of output buffers for this capture request. Must be at least
|
||||
@@ -2463,7 +2459,7 @@ typedef struct camera3_capture_request {
|
||||
* Any or all of the buffers included here may be brand new in this
|
||||
* request (having never before seen by the HAL).
|
||||
*/
|
||||
const camera3_stream_buffer_t *output_buffers;
|
||||
const camera3_stream_buffer_t* output_buffers;
|
||||
|
||||
/**
|
||||
* <= CAMERA_DEVICE_API_VERISON_3_4:
|
||||
@@ -2488,7 +2484,7 @@ typedef struct camera3_capture_request {
|
||||
* In case some id is invalid, the process capture request must fail and return
|
||||
* -EINVAL.
|
||||
*/
|
||||
const char **physcam_id;
|
||||
const char** physcam_id;
|
||||
|
||||
/**
|
||||
* <= CAMERA_DEVICE_API_VERISON_3_4:
|
||||
@@ -2501,7 +2497,7 @@ typedef struct camera3_capture_request {
|
||||
* case the settings at some particular index are empty, the process capture
|
||||
* request must fail and return -EINVAL.
|
||||
*/
|
||||
const camera_metadata_t **physcam_settings;
|
||||
const camera_metadata_t** physcam_settings;
|
||||
|
||||
} camera3_capture_request_t;
|
||||
|
||||
@@ -2554,7 +2550,7 @@ typedef struct camera3_capture_result {
|
||||
* submitted request to uniquely identify this capture. It is also used to
|
||||
* identify the request in asynchronous notifications sent to
|
||||
* camera3_callback_ops_t.notify().
|
||||
*/
|
||||
*/
|
||||
uint32_t frame_number;
|
||||
|
||||
/**
|
||||
@@ -2582,7 +2578,7 @@ typedef struct camera3_capture_result {
|
||||
* If notify has been called with ERROR_RESULT, all further partial
|
||||
* results for that frame are ignored by the framework.
|
||||
*/
|
||||
const camera_metadata_t *result;
|
||||
const camera_metadata_t* result;
|
||||
|
||||
/**
|
||||
* The number of output buffers returned in this result structure. Must be
|
||||
@@ -2632,84 +2628,84 @@ typedef struct camera3_capture_result {
|
||||
* via a SHUTTER notify() call. It is highly recommended to
|
||||
* dispatch that call as early as possible.
|
||||
*/
|
||||
const camera3_stream_buffer_t *output_buffers;
|
||||
const camera3_stream_buffer_t* output_buffers;
|
||||
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_2:
|
||||
*
|
||||
* The handle for the input stream buffer for this capture. It may not
|
||||
* yet be consumed at the time the HAL calls process_capture_result(); the
|
||||
* framework will wait on the release sync fences provided by the HAL before
|
||||
* reusing the buffer.
|
||||
*
|
||||
* The HAL should handle the sync fences the same way they are done for
|
||||
* output_buffers.
|
||||
*
|
||||
* Only one input buffer is allowed to be sent per request. Similarly to
|
||||
* output buffers, the ordering of returned input buffers must be
|
||||
* maintained by the HAL.
|
||||
*
|
||||
* Performance considerations:
|
||||
*
|
||||
* The input buffer should be returned as early as possible. If the HAL
|
||||
* supports sync fences, it can call process_capture_result to hand it back
|
||||
* with sync fences being set appropriately. If the sync fences are not
|
||||
* supported, the buffer can only be returned when it is consumed, which
|
||||
* may take long time; the HAL may choose to copy this input buffer to make
|
||||
* the buffer return sooner.
|
||||
*/
|
||||
const camera3_stream_buffer_t *input_buffer;
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_2:
|
||||
*
|
||||
* The handle for the input stream buffer for this capture. It may not
|
||||
* yet be consumed at the time the HAL calls process_capture_result(); the
|
||||
* framework will wait on the release sync fences provided by the HAL before
|
||||
* reusing the buffer.
|
||||
*
|
||||
* The HAL should handle the sync fences the same way they are done for
|
||||
* output_buffers.
|
||||
*
|
||||
* Only one input buffer is allowed to be sent per request. Similarly to
|
||||
* output buffers, the ordering of returned input buffers must be
|
||||
* maintained by the HAL.
|
||||
*
|
||||
* Performance considerations:
|
||||
*
|
||||
* The input buffer should be returned as early as possible. If the HAL
|
||||
* supports sync fences, it can call process_capture_result to hand it back
|
||||
* with sync fences being set appropriately. If the sync fences are not
|
||||
* supported, the buffer can only be returned when it is consumed, which
|
||||
* may take long time; the HAL may choose to copy this input buffer to make
|
||||
* the buffer return sooner.
|
||||
*/
|
||||
const camera3_stream_buffer_t* input_buffer;
|
||||
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_2:
|
||||
*
|
||||
* In order to take advantage of partial results, the HAL must set the
|
||||
* static metadata android.request.partialResultCount to the number of
|
||||
* partial results it will send for each frame.
|
||||
*
|
||||
* Each new capture result with a partial result must set
|
||||
* this field (partial_result) to a distinct inclusive value between
|
||||
* 1 and android.request.partialResultCount.
|
||||
*
|
||||
* HALs not wishing to take advantage of this feature must not
|
||||
* set an android.request.partialResultCount or partial_result to a value
|
||||
* other than 1.
|
||||
*
|
||||
* This value must be set to 0 when a capture result contains buffers only
|
||||
* and no metadata.
|
||||
*/
|
||||
uint32_t partial_result;
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_2:
|
||||
*
|
||||
* In order to take advantage of partial results, the HAL must set the
|
||||
* static metadata android.request.partialResultCount to the number of
|
||||
* partial results it will send for each frame.
|
||||
*
|
||||
* Each new capture result with a partial result must set
|
||||
* this field (partial_result) to a distinct inclusive value between
|
||||
* 1 and android.request.partialResultCount.
|
||||
*
|
||||
* HALs not wishing to take advantage of this feature must not
|
||||
* set an android.request.partialResultCount or partial_result to a value
|
||||
* other than 1.
|
||||
*
|
||||
* This value must be set to 0 when a capture result contains buffers only
|
||||
* and no metadata.
|
||||
*/
|
||||
uint32_t partial_result;
|
||||
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_5:
|
||||
*
|
||||
* Specifies the number of physical camera metadata this capture result
|
||||
* contains. It must be equal to the number of physical cameras being
|
||||
* requested from.
|
||||
*
|
||||
* If the current camera device is not a logical multi-camera, or the
|
||||
* corresponding capture_request doesn't request on any physical camera,
|
||||
* this field must be 0.
|
||||
*/
|
||||
uint32_t num_physcam_metadata;
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_5:
|
||||
*
|
||||
* Specifies the number of physical camera metadata this capture result
|
||||
* contains. It must be equal to the number of physical cameras being
|
||||
* requested from.
|
||||
*
|
||||
* If the current camera device is not a logical multi-camera, or the
|
||||
* corresponding capture_request doesn't request on any physical camera,
|
||||
* this field must be 0.
|
||||
*/
|
||||
uint32_t num_physcam_metadata;
|
||||
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_5:
|
||||
*
|
||||
* An array of strings containing the physical camera ids for the returned
|
||||
* physical camera metadata. The length of the array is
|
||||
* num_physcam_metadata.
|
||||
*/
|
||||
const char **physcam_ids;
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_5:
|
||||
*
|
||||
* An array of strings containing the physical camera ids for the returned
|
||||
* physical camera metadata. The length of the array is
|
||||
* num_physcam_metadata.
|
||||
*/
|
||||
const char** physcam_ids;
|
||||
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_5:
|
||||
*
|
||||
* The array of physical camera metadata for the physical cameras being
|
||||
* requested upon. This array should have a 1-to-1 mapping with the
|
||||
* physcam_ids. The length of the array is num_physcam_metadata.
|
||||
*/
|
||||
const camera_metadata_t **physcam_metadata;
|
||||
/**
|
||||
* >= CAMERA_DEVICE_API_VERSION_3_5:
|
||||
*
|
||||
* The array of physical camera metadata for the physical cameras being
|
||||
* requested upon. This array should have a 1-to-1 mapping with the
|
||||
* physcam_ids. The length of the array is num_physcam_metadata.
|
||||
*/
|
||||
const camera_metadata_t** physcam_metadata;
|
||||
|
||||
} camera3_capture_result_t;
|
||||
|
||||
@@ -2726,7 +2722,6 @@ typedef struct camera3_capture_result {
|
||||
*
|
||||
*/
|
||||
typedef struct camera3_callback_ops {
|
||||
|
||||
/**
|
||||
* process_capture_result:
|
||||
*
|
||||
@@ -2794,8 +2789,8 @@ typedef struct camera3_callback_ops {
|
||||
* 4 frame intervals, and must be less than or equal to 8 frame intervals.
|
||||
*
|
||||
*/
|
||||
void (*process_capture_result)(const struct camera3_callback_ops *,
|
||||
const camera3_capture_result_t *result);
|
||||
void (*process_capture_result)(const struct camera3_callback_ops*,
|
||||
const camera3_capture_result_t* result);
|
||||
|
||||
/**
|
||||
* notify:
|
||||
@@ -2827,8 +2822,7 @@ typedef struct camera3_callback_ops {
|
||||
*
|
||||
* This is a non-blocking call. The framework will return this call in 5ms.
|
||||
*/
|
||||
void (*notify)(const struct camera3_callback_ops *,
|
||||
const camera3_notify_msg_t *msg);
|
||||
void (*notify)(const struct camera3_callback_ops*, const camera3_notify_msg_t* msg);
|
||||
|
||||
/**
|
||||
* request_stream_buffers:
|
||||
@@ -2864,11 +2858,10 @@ typedef struct camera3_callback_ops {
|
||||
* ready to fill the buffer.
|
||||
*/
|
||||
camera3_buffer_request_status_t (*request_stream_buffers)(
|
||||
const struct camera3_callback_ops *,
|
||||
uint32_t num_buffer_reqs,
|
||||
const camera3_buffer_request_t *buffer_reqs,
|
||||
/*out*/uint32_t *num_returned_buf_reqs,
|
||||
/*out*/camera3_stream_buffer_ret_t *returned_buf_reqs);
|
||||
const struct camera3_callback_ops*, uint32_t num_buffer_reqs,
|
||||
const camera3_buffer_request_t* buffer_reqs,
|
||||
/*out*/ uint32_t* num_returned_buf_reqs,
|
||||
/*out*/ camera3_stream_buffer_ret_t* returned_buf_reqs);
|
||||
|
||||
/**
|
||||
* return_stream_buffers:
|
||||
@@ -2884,10 +2877,8 @@ typedef struct camera3_callback_ops {
|
||||
* If this method is called during a configure_streams() call, it will be
|
||||
* blocked until camera service finishes the ongoing configure_streams() call.
|
||||
*/
|
||||
void (*return_stream_buffers)(
|
||||
const struct camera3_callback_ops *,
|
||||
uint32_t num_buffers,
|
||||
const camera3_stream_buffer_t* const* buffers);
|
||||
void (*return_stream_buffers)(const struct camera3_callback_ops*, uint32_t num_buffers,
|
||||
const camera3_stream_buffer_t* const* buffers);
|
||||
|
||||
} camera3_callback_ops_t;
|
||||
|
||||
@@ -2897,7 +2888,6 @@ typedef struct camera3_callback_ops {
|
||||
*
|
||||
*/
|
||||
typedef struct camera3_device_ops {
|
||||
|
||||
/**
|
||||
* initialize:
|
||||
*
|
||||
@@ -2917,8 +2907,7 @@ typedef struct camera3_device_ops {
|
||||
* -ENODEV: If initialization fails. Only close() can be called successfully
|
||||
* by the framework after this.
|
||||
*/
|
||||
int (*initialize)(const struct camera3_device *,
|
||||
const camera3_callback_ops_t *callback_ops);
|
||||
int (*initialize)(const struct camera3_device*, const camera3_callback_ops_t* callback_ops);
|
||||
|
||||
/**********************************************************************
|
||||
* Stream management
|
||||
@@ -3156,8 +3145,8 @@ typedef struct camera3_device_ops {
|
||||
* operational. Only close() can be called successfully by the
|
||||
* framework after this error is returned.
|
||||
*/
|
||||
int (*configure_streams)(const struct camera3_device *,
|
||||
camera3_stream_configuration_t *stream_list);
|
||||
int (*configure_streams)(const struct camera3_device*,
|
||||
camera3_stream_configuration_t* stream_list);
|
||||
|
||||
/**
|
||||
* register_stream_buffers:
|
||||
@@ -3210,8 +3199,8 @@ typedef struct camera3_device_ops {
|
||||
* operational. Only close() can be called successfully by the
|
||||
* framework after this error is returned.
|
||||
*/
|
||||
int (*register_stream_buffers)(const struct camera3_device *,
|
||||
const camera3_stream_buffer_set_t *buffer_set);
|
||||
int (*register_stream_buffers)(const struct camera3_device*,
|
||||
const camera3_stream_buffer_set_t* buffer_set);
|
||||
|
||||
/**********************************************************************
|
||||
* Request creation and submission
|
||||
@@ -3246,9 +3235,8 @@ typedef struct camera3_device_ops {
|
||||
* the close() method can be called successfully by the
|
||||
* framework.
|
||||
*/
|
||||
const camera_metadata_t* (*construct_default_request_settings)(
|
||||
const struct camera3_device *,
|
||||
int type);
|
||||
const camera_metadata_t* (*construct_default_request_settings)(const struct camera3_device*,
|
||||
int type);
|
||||
|
||||
/**
|
||||
* process_capture_request:
|
||||
@@ -3316,8 +3304,8 @@ typedef struct camera3_device_ops {
|
||||
* called by the framework.
|
||||
*
|
||||
*/
|
||||
int (*process_capture_request)(const struct camera3_device *,
|
||||
camera3_capture_request_t *request);
|
||||
int (*process_capture_request)(const struct camera3_device*,
|
||||
camera3_capture_request_t* request);
|
||||
|
||||
/**********************************************************************
|
||||
* Miscellaneous methods
|
||||
@@ -3338,8 +3326,7 @@ typedef struct camera3_device_ops {
|
||||
* NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h
|
||||
* instead.
|
||||
*/
|
||||
void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,
|
||||
vendor_tag_query_ops_t* ops);
|
||||
void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, vendor_tag_query_ops_t* ops);
|
||||
|
||||
/**
|
||||
* dump:
|
||||
@@ -3359,7 +3346,7 @@ typedef struct camera3_device_ops {
|
||||
* Any synchronization primitives used (such as mutex locks or semaphores)
|
||||
* should be acquired with a timeout.
|
||||
*/
|
||||
void (*dump)(const struct camera3_device *, int fd);
|
||||
void (*dump)(const struct camera3_device*, int fd);
|
||||
|
||||
/**
|
||||
* flush:
|
||||
@@ -3432,10 +3419,10 @@ typedef struct camera3_device_ops {
|
||||
* need to call process_capture_result with NULL metadata or equivalent.
|
||||
*
|
||||
* 4. If a flush() is invoked while a process_capture_request() invocation is active, that
|
||||
* process call should return as soon as possible. In addition, if a process_capture_request()
|
||||
* call is made after flush() has been invoked but before flush() has returned, the
|
||||
* capture request provided by the late process_capture_request call should be treated like
|
||||
* a pending request in case #2 above.
|
||||
* process call should return as soon as possible. In addition, if a
|
||||
* process_capture_request() call is made after flush() has been invoked but before flush() has
|
||||
* returned, the capture request provided by the late process_capture_request call should be
|
||||
* treated like a pending request in case #2 above.
|
||||
*
|
||||
* flush() should only return when there are no more outstanding buffers or
|
||||
* requests left in the HAL. The framework may call configure_streams (as
|
||||
@@ -3465,7 +3452,7 @@ typedef struct camera3_device_ops {
|
||||
* error is returned, only the close() method can be successfully
|
||||
* called by the framework.
|
||||
*/
|
||||
int (*flush)(const struct camera3_device *);
|
||||
int (*flush)(const struct camera3_device*);
|
||||
|
||||
/**
|
||||
* signal_stream_flush:
|
||||
@@ -3487,9 +3474,8 @@ typedef struct camera3_device_ops {
|
||||
* skip calling this if all buffers are already returned.
|
||||
*
|
||||
*/
|
||||
void (*signal_stream_flush)(const struct camera3_device*,
|
||||
uint32_t num_streams,
|
||||
const camera3_stream_t* const* streams);
|
||||
void (*signal_stream_flush)(const struct camera3_device*, uint32_t num_streams,
|
||||
const camera3_stream_t* const* streams);
|
||||
|
||||
/**
|
||||
* is_reconfiguration_required:
|
||||
@@ -3538,11 +3524,11 @@ typedef struct camera3_device_ops {
|
||||
* reconfiguration query.
|
||||
*/
|
||||
int (*is_reconfiguration_required)(const struct camera3_device*,
|
||||
const camera_metadata_t* old_session_params,
|
||||
const camera_metadata_t* new_session_params);
|
||||
const camera_metadata_t* old_session_params,
|
||||
const camera_metadata_t* new_session_params);
|
||||
|
||||
/* reserved for future use */
|
||||
void *reserved[6];
|
||||
void* reserved[6];
|
||||
} camera3_device_ops_t;
|
||||
|
||||
/**********************************************************************
|
||||
@@ -3563,8 +3549,8 @@ typedef struct camera3_device {
|
||||
*
|
||||
*/
|
||||
hw_device_t common;
|
||||
camera3_device_ops_t *ops;
|
||||
void *priv;
|
||||
camera3_device_ops_t* ops;
|
||||
void* priv;
|
||||
} camera3_device_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
#ifndef ANDROID_INCLUDE_CAMERA_COMMON_H
|
||||
#define ANDROID_INCLUDE_CAMERA_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <hardware/gralloc.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <system/camera.h>
|
||||
#include <system/camera_vendor_tags.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/gralloc.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@@ -162,11 +162,11 @@ __BEGIN_DECLS
|
||||
* All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
|
||||
* as CAMERA_DEVICE_API_VERSION_1_0
|
||||
*/
|
||||
#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) // DEPRECATED
|
||||
#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) // DEPRECATED
|
||||
#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) // NO LONGER SUPPORTED
|
||||
#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
|
||||
#define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3)
|
||||
#define CAMERA_DEVICE_API_VERSION_3_4 HARDWARE_DEVICE_API_VERSION(3, 4)
|
||||
@@ -262,7 +262,7 @@ typedef struct camera_info {
|
||||
* otherwise.
|
||||
*
|
||||
*/
|
||||
const camera_metadata_t *static_camera_characteristics;
|
||||
const camera_metadata_t* static_camera_characteristics;
|
||||
|
||||
/**
|
||||
* The total resource "cost" of using this camera, represented as an integer
|
||||
@@ -616,7 +616,6 @@ typedef enum torch_mode_status {
|
||||
|
||||
*/
|
||||
typedef struct camera_module_callbacks {
|
||||
|
||||
/**
|
||||
* camera_device_status_change:
|
||||
*
|
||||
@@ -637,9 +636,8 @@ typedef struct camera_module_callbacks {
|
||||
* or a platform-specific status.
|
||||
*
|
||||
*/
|
||||
void (*camera_device_status_change)(const struct camera_module_callbacks*,
|
||||
int camera_id,
|
||||
int new_status);
|
||||
void (*camera_device_status_change)(const struct camera_module_callbacks*, int camera_id,
|
||||
int new_status);
|
||||
|
||||
/**
|
||||
* torch_mode_status_change:
|
||||
@@ -660,10 +658,8 @@ typedef struct camera_module_callbacks {
|
||||
*
|
||||
* new_status: The new status code, one of the torch_mode_status_t enums.
|
||||
*/
|
||||
void (*torch_mode_status_change)(const struct camera_module_callbacks*,
|
||||
const char* camera_id,
|
||||
int new_status);
|
||||
|
||||
void (*torch_mode_status_change)(const struct camera_module_callbacks*, const char* camera_id,
|
||||
int new_status);
|
||||
|
||||
} camera_module_callbacks_t;
|
||||
|
||||
@@ -801,7 +797,7 @@ typedef struct camera_stream_combination {
|
||||
*
|
||||
* At least one output-capable stream must be defined.
|
||||
*/
|
||||
camera_stream_t *streams;
|
||||
camera_stream_t* streams;
|
||||
|
||||
/**
|
||||
* The operation mode of streams in this stream combination, one of the value
|
||||
@@ -911,7 +907,7 @@ typedef struct camera_module {
|
||||
int (*get_number_of_cameras)(void);
|
||||
|
||||
#ifdef CAMERA_NEEDS_SEC_GET_CAM_POS_V1
|
||||
/**
|
||||
/**
|
||||
* get_cam_pos:
|
||||
*
|
||||
* Unknown. Needed by prebuilt camera module from the Samsung GTO device.
|
||||
@@ -950,10 +946,10 @@ typedef struct camera_module {
|
||||
* this method with this invalid camera id will get -EINVAL and NULL camera
|
||||
* static metadata (camera_info.static_camera_characteristics).
|
||||
*/
|
||||
int (*get_camera_info)(int camera_id, struct camera_info *info);
|
||||
int (*get_camera_info)(int camera_id, struct camera_info* info);
|
||||
|
||||
#ifdef CAMERA_NEEDS_SEC_GET_CAM_POS_V2
|
||||
/**
|
||||
/**
|
||||
* get_cam_pos:
|
||||
*
|
||||
* Unknown. Needed by prebuilt camera module from the Samsung GTA4L device.
|
||||
@@ -997,7 +993,7 @@ typedef struct camera_module {
|
||||
* -EINVAL: The input arguments are invalid, i.e. the callbacks are
|
||||
* null
|
||||
*/
|
||||
int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
|
||||
int (*set_callbacks)(const camera_module_callbacks_t* callbacks);
|
||||
|
||||
/**
|
||||
* get_vendor_tag_ops:
|
||||
@@ -1063,8 +1059,8 @@ typedef struct camera_module {
|
||||
* opened concurrently were opened already, either by
|
||||
* this method or common.methods->open method.
|
||||
*/
|
||||
int (*open_legacy)(const struct hw_module_t* module, const char* id,
|
||||
uint32_t halVersion, struct hw_device_t** device);
|
||||
int (*open_legacy)(const struct hw_module_t* module, const char* id, uint32_t halVersion,
|
||||
struct hw_device_t** device);
|
||||
|
||||
/**
|
||||
* set_torch_mode:
|
||||
@@ -1180,8 +1176,7 @@ typedef struct camera_module {
|
||||
* framework. Calling this function with invalid physical_camera_id will
|
||||
* get -EINVAL, and NULL static_metadata.
|
||||
*/
|
||||
int (*get_physical_camera_info)(int physical_camera_id,
|
||||
camera_metadata_t **static_metadata);
|
||||
int (*get_physical_camera_info)(int physical_camera_id, camera_metadata_t** static_metadata);
|
||||
|
||||
/**
|
||||
* is_stream_combination_supported:
|
||||
@@ -1205,7 +1200,7 @@ typedef struct camera_module {
|
||||
* Valid to be called by the framework.
|
||||
*/
|
||||
int (*is_stream_combination_supported)(int camera_id,
|
||||
const camera_stream_combination_t *streams);
|
||||
const camera_stream_combination_t* streams);
|
||||
|
||||
/**
|
||||
* notify_device_state_change:
|
||||
|
||||
@@ -1,35 +1,18 @@
|
||||
//
|
||||
// Copyright (C) 2024 The LineageOS Project
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2024-2026 The LineageOS Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
soong_config_module_type {
|
||||
name: "extra_ids",
|
||||
module_type: "cc_defaults",
|
||||
config_namespace: "samsungCameraVars",
|
||||
value_variables: ["extra_ids"],
|
||||
properties: ["cppflags"],
|
||||
}
|
||||
|
||||
extra_ids {
|
||||
name: "extra_id_defaults",
|
||||
soong_config_variables: {
|
||||
extra_ids: {
|
||||
cppflags: ["-DEXTRA_IDS=%s"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
name: "camera_service_aidl_defaults.samsung",
|
||||
defaults: [
|
||||
"extra_id_defaults",
|
||||
"samsung_camera3_defaults",
|
||||
],
|
||||
defaults: ["samsung_camera3_defaults"],
|
||||
vintf_fragments: ["android.hardware.camera.provider-service.samsung.xml"],
|
||||
vendor: true,
|
||||
relative_install_path: "hw",
|
||||
cppflags: select(soong_config_variable("samsungCameraVars", "extra_ids"), {
|
||||
any @ flag_val: ["-DEXTRA_IDS=" + flag_val],
|
||||
default: [],
|
||||
}),
|
||||
srcs: [
|
||||
"service.cpp",
|
||||
"CameraProvider.cpp",
|
||||
|
||||
@@ -224,7 +224,7 @@ bool CameraProvider::initialize() {
|
||||
}
|
||||
std::vector<int> extraIDs = {
|
||||
#ifdef EXTRA_IDS
|
||||
EXTRA_IDS
|
||||
EXTRA_IDS
|
||||
#endif
|
||||
};
|
||||
for (int i : extraIDs) {
|
||||
|
||||
@@ -42,8 +42,7 @@ int main() {
|
||||
|
||||
binder_exception_t ret =
|
||||
AServiceManager_addService(defaultProvider->asBinder().get(), serviceName.c_str());
|
||||
LOG_ALWAYS_FATAL_IF(ret != EX_NONE, "Error while registering camera provider service: %d",
|
||||
ret);
|
||||
LOG_ALWAYS_FATAL_IF(ret != EX_NONE, "Error while registering camera provider service: %d", ret);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
|
||||
88
aidl/codec2/Android.bp
Normal file
88
aidl/codec2/Android.bp
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2019 The Android Open Source Project
|
||||
* Copyright 2025 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: "android.software.media.c2-service.samsung",
|
||||
vendor: true,
|
||||
relative_install_path: "hw",
|
||||
|
||||
init_rc: ["android.software.media.c2-service.samsung.rc"],
|
||||
|
||||
//
|
||||
// default -> For devices that already have a c2@1.2 or c2-V1 service in their vendor (QTI c2, Samsung hardware c2 etc.)
|
||||
// legacy_default0 -> For devices that already have a c2@1.0 service in their vendor (QTI c2, Samsung hardware c2 etc.)
|
||||
// legacy_default -> For devices without a c2 service in their vendor
|
||||
//
|
||||
vintf_fragments: select(soong_config_variable("samsungCodec2Vars", "c2_instance_type"), {
|
||||
any @ fragment: ["samsung_media_c2_" + fragment + ".xml"],
|
||||
default: ["samsung_media_c2_default.xml"],
|
||||
}),
|
||||
|
||||
defaults: [
|
||||
"libcodec2-hidl-defaults",
|
||||
"libcodec2-aidl-defaults",
|
||||
],
|
||||
|
||||
srcs: [
|
||||
"vendor.cpp",
|
||||
],
|
||||
|
||||
// minijail is used to protect against unexpected system calls.
|
||||
shared_libs: [
|
||||
"libavservices_minijail",
|
||||
"libbinder",
|
||||
"libbinder_ndk",
|
||||
] + select(soong_config_variable("samsungCodec2Vars", "target_componentstore_library"), {
|
||||
any @ flag_val: [flag_val],
|
||||
default: [],
|
||||
}),
|
||||
|
||||
cflags: select(soong_config_variable("samsungCodec2Vars", "uses_legacy_component_store"), {
|
||||
"true": ["-DLEGACY_COMPONENT_STORE" ],
|
||||
default: [],
|
||||
}),
|
||||
|
||||
required: ["android.software.media.c2-default-seccomp_policy"],
|
||||
}
|
||||
|
||||
prebuilt_etc {
|
||||
name: "android.software.media.c2-default-seccomp_policy",
|
||||
vendor: true,
|
||||
sub_dir: "seccomp_policy",
|
||||
|
||||
// If a specific architecture is targeted, multiple choices are not needed.
|
||||
arch: {
|
||||
arm: {
|
||||
src: "seccomp_policy/android.software.media.c2-default-arm.policy",
|
||||
},
|
||||
arm64: {
|
||||
src: "seccomp_policy/android.software.media.c2-default-arm64.policy",
|
||||
},
|
||||
riscv64: {
|
||||
src: "seccomp_policy/android.software.media.c2-default-riscv64.policy",
|
||||
},
|
||||
x86: {
|
||||
src: "seccomp_policy/android.software.media.c2-default-x86.policy",
|
||||
},
|
||||
x86_64: {
|
||||
src: "seccomp_policy/android.software.media.c2-default-x86_64.policy",
|
||||
},
|
||||
},
|
||||
|
||||
// This may be removed.
|
||||
required: ["crash_dump.policy"],
|
||||
}
|
||||
6
aidl/codec2/android.software.media.c2-service.samsung.rc
Normal file
6
aidl/codec2/android.software.media.c2-service.samsung.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
service samsung-software-media-c2-hal /vendor/bin/hw/android.software.media.c2-service.samsung
|
||||
class hal
|
||||
user mediacodec
|
||||
group camera mediadrm drmrpc
|
||||
ioprio rt 4
|
||||
task_profiles ProcessCapacityHigh
|
||||
18
aidl/codec2/samsung_media_c2_default.xml
Normal file
18
aidl/codec2/samsung_media_c2_default.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<!-- HIDL fragment -->
|
||||
<hal>
|
||||
<name>android.hardware.media.c2</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.2</version>
|
||||
<interface>
|
||||
<name>IComponentStore</name>
|
||||
<instance>default0</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<!-- AIDL fragment -->
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.media.c2</name>
|
||||
<version>1</version>
|
||||
<fqname>IComponentStore/default1</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
@@ -1,11 +1,11 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl">
|
||||
<name>vendor.lineage.fastcharge</name>
|
||||
<hal format="hidl" override="true">
|
||||
<name>android.hardware.media.c2</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IFastCharge</name>
|
||||
<name>IComponentStore</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</hal>
|
||||
</manifest>
|
||||
11
aidl/codec2/samsung_media_c2_legacy_default0.xml
Normal file
11
aidl/codec2/samsung_media_c2_legacy_default0.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl" override="true">
|
||||
<name>android.hardware.media.c2</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IComponentStore</name>
|
||||
<instance>default0</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
@@ -0,0 +1,86 @@
|
||||
# Copyright (C) 2019 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
futex: 1
|
||||
# ioctl calls are filtered via the selinux policy.
|
||||
ioctl: 1
|
||||
sched_yield: 1
|
||||
close: 1
|
||||
dup: 1
|
||||
ppoll: 1
|
||||
mprotect: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
|
||||
mmap2: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
|
||||
memfd_create: 1
|
||||
ftruncate: 1
|
||||
ftruncate64: 1
|
||||
|
||||
# mremap: Ensure |flags| are (MREMAP_MAYMOVE | MREMAP_FIXED) TODO: Once minijail
|
||||
# parser support for '<' is in this needs to be modified to also prevent
|
||||
# |old_address| and |new_address| from touching the exception vector page, which
|
||||
# on ARM is statically loaded at 0xffff 0000. See
|
||||
# http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211h/Babfeega.html
|
||||
# for more details.
|
||||
mremap: arg3 == 3
|
||||
munmap: 1
|
||||
prctl: 1
|
||||
getuid32: 1
|
||||
writev: 1
|
||||
sigaltstack: 1
|
||||
clone: 1
|
||||
exit: 1
|
||||
lseek: 1
|
||||
rt_sigprocmask: 1
|
||||
openat: 1
|
||||
open: 1
|
||||
fstat64: 1
|
||||
write: 1
|
||||
nanosleep: 1
|
||||
setpriority: 1
|
||||
set_tid_address: 1
|
||||
getdents64: 1
|
||||
readlinkat: 1
|
||||
readlink: 1
|
||||
read: 1
|
||||
pread64: 1
|
||||
fstatfs64: 1
|
||||
gettimeofday: 1
|
||||
faccessat: 1
|
||||
_llseek: 1
|
||||
fstatat64: 1
|
||||
ugetrlimit: 1
|
||||
exit_group: 1
|
||||
restart_syscall: 1
|
||||
rt_sigreturn: 1
|
||||
getrandom: 1
|
||||
madvise: 1
|
||||
|
||||
# crash dump policy additions
|
||||
sigreturn: 1
|
||||
clock_gettime: 1
|
||||
futex: 1
|
||||
getpid: 1
|
||||
gettid: 1
|
||||
pipe2: 1
|
||||
recvmsg: 1
|
||||
process_vm_readv: 1
|
||||
tgkill: 1
|
||||
rt_sigaction: 1
|
||||
rt_tgsigqueueinfo: 1
|
||||
#prctl: arg0 == PR_GET_NO_NEW_PRIVS || arg0 == 0x53564d41
|
||||
#mprotect: arg2 in 0x1|0x2
|
||||
#mmap2: arg2 in 0x1|0x2
|
||||
geteuid32: 1
|
||||
getgid32: 1
|
||||
getegid32: 1
|
||||
getgroups32: 1
|
||||
@@ -0,0 +1,80 @@
|
||||
# Copyright (C) 2021 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.
|
||||
|
||||
futex: 1
|
||||
# ioctl calls are filtered via the selinux policy.
|
||||
ioctl: 1
|
||||
sched_yield: 1
|
||||
close: 1
|
||||
dup: 1
|
||||
ppoll: 1
|
||||
mprotect: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
|
||||
mmap: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
|
||||
getuid: 1
|
||||
getrlimit: 1
|
||||
fstat: 1
|
||||
newfstatat: 1
|
||||
fstatfs: 1
|
||||
memfd_create: 1
|
||||
ftruncate: 1
|
||||
|
||||
# mremap: Ensure |flags| are (MREMAP_MAYMOVE | MREMAP_FIXED) TODO: Once minijail
|
||||
# parser support for '<' is in this needs to be modified to also prevent
|
||||
# |old_address| and |new_address| from touching the exception vector page, which
|
||||
# on ARM is statically loaded at 0xffff 0000. See
|
||||
# http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211h/Babfeega.html
|
||||
# for more details.
|
||||
mremap: arg3 == 3 || arg3 == MREMAP_MAYMOVE
|
||||
munmap: 1
|
||||
prctl: 1
|
||||
writev: 1
|
||||
sigaltstack: 1
|
||||
clone: 1
|
||||
exit: 1
|
||||
lseek: 1
|
||||
rt_sigprocmask: 1
|
||||
openat: 1
|
||||
write: 1
|
||||
nanosleep: 1
|
||||
setpriority: 1
|
||||
set_tid_address: 1
|
||||
getdents64: 1
|
||||
readlinkat: 1
|
||||
read: 1
|
||||
pread64: 1
|
||||
gettimeofday: 1
|
||||
faccessat: 1
|
||||
exit_group: 1
|
||||
restart_syscall: 1
|
||||
rt_sigreturn: 1
|
||||
getrandom: 1
|
||||
madvise: 1
|
||||
|
||||
# crash dump policy additions
|
||||
clock_gettime: 1
|
||||
getpid: 1
|
||||
gettid: 1
|
||||
pipe2: 1
|
||||
recvmsg: 1
|
||||
process_vm_readv: 1
|
||||
tgkill: 1
|
||||
rt_sigaction: 1
|
||||
rt_tgsigqueueinfo: 1
|
||||
#mprotect: arg2 in 0x1|0x2
|
||||
munmap: 1
|
||||
#mmap: arg2 in 0x1|0x2
|
||||
geteuid: 1
|
||||
getgid: 1
|
||||
getegid: 1
|
||||
getgroups: 1
|
||||
@@ -0,0 +1,74 @@
|
||||
# Copyright (C) 2019 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
futex: 1
|
||||
# ioctl calls are filtered via the selinux policy.
|
||||
ioctl: 1
|
||||
sched_yield: 1
|
||||
close: 1
|
||||
dup: 1
|
||||
ppoll: 1
|
||||
mprotect: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
|
||||
mmap: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
|
||||
getuid: 1
|
||||
getrlimit: 1
|
||||
fstat: 1
|
||||
newfstatat: 1
|
||||
fstatfs: 1
|
||||
memfd_create: 1
|
||||
ftruncate: 1
|
||||
|
||||
mremap: arg3 == 3 || arg3 == MREMAP_MAYMOVE
|
||||
munmap: 1
|
||||
prctl: 1
|
||||
writev: 1
|
||||
sigaltstack: 1
|
||||
clone: 1
|
||||
exit: 1
|
||||
lseek: 1
|
||||
rt_sigprocmask: 1
|
||||
openat: 1
|
||||
write: 1
|
||||
nanosleep: 1
|
||||
setpriority: 1
|
||||
set_tid_address: 1
|
||||
getdents64: 1
|
||||
readlinkat: 1
|
||||
read: 1
|
||||
pread64: 1
|
||||
gettimeofday: 1
|
||||
faccessat: 1
|
||||
exit_group: 1
|
||||
restart_syscall: 1
|
||||
rt_sigreturn: 1
|
||||
getrandom: 1
|
||||
madvise: 1
|
||||
|
||||
# crash dump policy additions
|
||||
clock_gettime: 1
|
||||
getpid: 1
|
||||
gettid: 1
|
||||
pipe2: 1
|
||||
recvmsg: 1
|
||||
process_vm_readv: 1
|
||||
tgkill: 1
|
||||
rt_sigaction: 1
|
||||
rt_tgsigqueueinfo: 1
|
||||
#mprotect: arg2 in 0x1|0x2
|
||||
munmap: 1
|
||||
#mmap: arg2 in 0x1|0x2
|
||||
geteuid: 1
|
||||
getgid: 1
|
||||
getegid: 1
|
||||
getgroups: 1
|
||||
@@ -0,0 +1,71 @@
|
||||
# Copyright (C) 2021 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.
|
||||
|
||||
read: 1
|
||||
mprotect: 1
|
||||
prctl: 1
|
||||
openat: 1
|
||||
open: 1
|
||||
getuid32: 1
|
||||
getuid: 1
|
||||
getrlimit: 1
|
||||
writev: 1
|
||||
ioctl: 1
|
||||
close: 1
|
||||
mmap2: 1
|
||||
mmap: 1
|
||||
fstat64: 1
|
||||
fstat: 1
|
||||
stat64: 1
|
||||
statfs64: 1
|
||||
madvise: 1
|
||||
fstatat64: 1
|
||||
newfstatat: 1
|
||||
futex: 1
|
||||
munmap: 1
|
||||
faccessat: 1
|
||||
_llseek: 1
|
||||
lseek: 1
|
||||
clone: 1
|
||||
sigaltstack: 1
|
||||
setpriority: 1
|
||||
restart_syscall: 1
|
||||
exit: 1
|
||||
exit_group: 1
|
||||
rt_sigreturn: 1
|
||||
ugetrlimit: 1
|
||||
readlink: 1
|
||||
readlinkat: 1
|
||||
_llseek: 1
|
||||
fstatfs64: 1
|
||||
fstatfs: 1
|
||||
pread64: 1
|
||||
mremap: 1
|
||||
dup: 1
|
||||
set_tid_address: 1
|
||||
write: 1
|
||||
nanosleep: 1
|
||||
sched_setscheduler: 1
|
||||
uname: 1
|
||||
memfd_create: 1
|
||||
ftruncate: 1
|
||||
ftruncate64: 1
|
||||
|
||||
# Required by AddressSanitizer
|
||||
gettid: 1
|
||||
sched_yield: 1
|
||||
getpid: 1
|
||||
gettid: 1
|
||||
|
||||
@include /system/etc/seccomp_policy/crash_dump.x86.policy
|
||||
@@ -0,0 +1,71 @@
|
||||
# Copyright (C) 2021 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.
|
||||
|
||||
read: 1
|
||||
mprotect: 1
|
||||
prctl: 1
|
||||
openat: 1
|
||||
open: 1
|
||||
getuid32: 1
|
||||
getuid: 1
|
||||
getrlimit: 1
|
||||
writev: 1
|
||||
ioctl: 1
|
||||
close: 1
|
||||
mmap2: 1
|
||||
mmap: 1
|
||||
fstat64: 1
|
||||
fstat: 1
|
||||
stat64: 1
|
||||
statfs64: 1
|
||||
madvise: 1
|
||||
fstatat64: 1
|
||||
newfstatat: 1
|
||||
futex: 1
|
||||
munmap: 1
|
||||
faccessat: 1
|
||||
_llseek: 1
|
||||
lseek: 1
|
||||
clone: 1
|
||||
sigaltstack: 1
|
||||
setpriority: 1
|
||||
restart_syscall: 1
|
||||
exit: 1
|
||||
exit_group: 1
|
||||
rt_sigreturn: 1
|
||||
ugetrlimit: 1
|
||||
readlink: 1
|
||||
readlinkat: 1
|
||||
_llseek: 1
|
||||
fstatfs64: 1
|
||||
fstatfs: 1
|
||||
pread64: 1
|
||||
mremap: 1
|
||||
dup: 1
|
||||
set_tid_address: 1
|
||||
write: 1
|
||||
nanosleep: 1
|
||||
sched_setscheduler: 1
|
||||
uname: 1
|
||||
memfd_create: 1
|
||||
ftruncate: 1
|
||||
ftruncate64: 1
|
||||
|
||||
# Required by AddressSanitizer
|
||||
gettid: 1
|
||||
sched_yield: 1
|
||||
getpid: 1
|
||||
gettid: 1
|
||||
|
||||
@include /system/etc/seccomp_policy/crash_dump.x86.policy
|
||||
100
aidl/codec2/vendor.cpp
Normal file
100
aidl/codec2/vendor.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2018 The Android Open Source Project
|
||||
* Copyright 2025 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_NDEBUG 0
|
||||
#define LOG_TAG "android.software.media.c2-service.samsung"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <minijail.h>
|
||||
|
||||
// HIDL
|
||||
#ifdef LEGACY_COMPONENT_STORE
|
||||
#include <binder/ProcessState.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#endif
|
||||
|
||||
// AIDL
|
||||
#include <codec2/aidl/ComponentStore.h>
|
||||
|
||||
// This is the absolute on-device path of the prebuild_etc module
|
||||
// "android.software.media.c2-default-seccomp_policy" in Android.bp.
|
||||
static constexpr char kBaseSeccompPolicyPath[] =
|
||||
"/vendor/etc/seccomp_policy/"
|
||||
"android.software.media.c2-default-seccomp_policy";
|
||||
|
||||
// Additional seccomp permissions can be added in this file.
|
||||
// This file does not exist by default.
|
||||
static constexpr char kExtSeccompPolicyPath[] =
|
||||
"/vendor/etc/seccomp_policy/"
|
||||
"android.software.media.c2-extended-seccomp_policy";
|
||||
|
||||
// We want multiple threads to be running so that a blocking operation
|
||||
// on one codec does not block the other codecs.
|
||||
// For HIDL: Extra threads may be needed to handle a stacked IPC sequence that
|
||||
// contains alternating binder and hwbinder calls. (See b/35283480.)
|
||||
static constexpr int kThreadCount = 8;
|
||||
|
||||
#ifndef LEGACY_COMPONENT_STORE
|
||||
extern "C" void RegisterSECCodecAidlServices();
|
||||
extern "C" void RegisterSECCodecHidlServices();
|
||||
#else
|
||||
extern "C" void RegisterSECCodecServices();
|
||||
#endif
|
||||
|
||||
void runAidlService() {
|
||||
#ifndef LEGACY_COMPONENT_STORE
|
||||
RegisterSECCodecAidlServices();
|
||||
#endif
|
||||
}
|
||||
|
||||
void runHidlService() {
|
||||
#ifdef LEGACY_COMPONENT_STORE
|
||||
using namespace ::android;
|
||||
|
||||
// Enable vndbinder to allow vendor-to-vendor binder calls.
|
||||
ProcessState::initWithDriver("/dev/vndbinder");
|
||||
|
||||
ProcessState::self()->startThreadPool();
|
||||
hardware::configureRpcThreadpool(kThreadCount, true /* callerWillJoin */);
|
||||
|
||||
RegisterSECCodecServices();
|
||||
|
||||
hardware::joinRpcThreadpool();
|
||||
#else
|
||||
RegisterSECCodecHidlServices();
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int /* argc */, char** /* argv */) {
|
||||
const bool aidlEnabled = ::aidl::android::hardware::media::c2::utils::IsSelected();
|
||||
#ifdef LEGACY_COMPONENT_STORE
|
||||
LOG(DEBUG) << "android.software.media.c2@1.0-service.samsung starting...";
|
||||
#else
|
||||
LOG(DEBUG) << "android.software.media.c2" << (aidlEnabled ? "-V1" : "@1.2")
|
||||
<< "-service.samsung starting...";
|
||||
#endif
|
||||
|
||||
// Set up minijail to limit system calls.
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
android::SetUpMinijail(kBaseSeccompPolicyPath, kExtSeccompPolicyPath);
|
||||
if (aidlEnabled) {
|
||||
runAidlService();
|
||||
} else {
|
||||
runHidlService();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -12,16 +12,14 @@ namespace hardware {
|
||||
namespace biometrics {
|
||||
namespace fingerprint {
|
||||
|
||||
CancellationSignal::CancellationSignal(Session* session)
|
||||
: mSession(session) {
|
||||
}
|
||||
CancellationSignal::CancellationSignal(Session* session) : mSession(session) {}
|
||||
|
||||
ndk::ScopedAStatus CancellationSignal::cancel() {
|
||||
return mSession->cancel();
|
||||
}
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -19,16 +19,16 @@ namespace biometrics {
|
||||
namespace fingerprint {
|
||||
|
||||
class CancellationSignal : public BnCancellationSignal {
|
||||
public:
|
||||
public:
|
||||
CancellationSignal(Session* session);
|
||||
ndk::ScopedAStatus cancel() override;
|
||||
|
||||
private:
|
||||
private:
|
||||
Session* mSession;
|
||||
};
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -37,12 +37,12 @@ constexpr char FW_VERSION[] = "1.01";
|
||||
constexpr char SERIAL_NUMBER[] = "00000001";
|
||||
constexpr char SW_COMPONENT_ID[] = "matchingAlgorithm";
|
||||
constexpr char SW_VERSION[] = "vendor/version/revision";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static Fingerprint* sInstance;
|
||||
|
||||
Fingerprint::Fingerprint() {
|
||||
sInstance = this; // keep track of the most recent instance
|
||||
sInstance = this; // keep track of the most recent instance
|
||||
if (!mHal.openHal(Fingerprint::notify)) {
|
||||
LOG(ERROR) << "Can't open HAL module";
|
||||
}
|
||||
@@ -75,9 +75,8 @@ Fingerprint::Fingerprint() {
|
||||
goto skip_uinput_setup;
|
||||
}
|
||||
|
||||
int err = ioctl(uinputFd, UI_SET_EVBIT, EV_KEY) |
|
||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_UP) |
|
||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_DOWN);
|
||||
int err = ioctl(uinputFd, UI_SET_EVBIT, EV_KEY) | ioctl(uinputFd, UI_SET_KEYBIT, KEY_UP) |
|
||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_DOWN);
|
||||
if (err != 0) {
|
||||
LOG(ERROR) << "Unable to enable key events";
|
||||
goto skip_uinput_setup;
|
||||
@@ -109,34 +108,38 @@ ndk::ScopedAStatus Fingerprint::getSensorProps(std::vector<SensorProps>* out) {
|
||||
std::vector<common::ComponentInfo> componentInfo = {
|
||||
{HW_COMPONENT_ID, HW_VERSION, FW_VERSION, SERIAL_NUMBER, "" /* softwareVersion */},
|
||||
{SW_COMPONENT_ID, "" /* hardwareVersion */, "" /* firmwareVersion */,
|
||||
"" /* serialNumber */, SW_VERSION}};
|
||||
common::CommonProps commonProps = {SENSOR_ID, SENSOR_STRENGTH,
|
||||
mMaxEnrollmentsPerUser, componentInfo};
|
||||
"" /* serialNumber */, SW_VERSION}};
|
||||
common::CommonProps commonProps = {SENSOR_ID, SENSOR_STRENGTH, mMaxEnrollmentsPerUser,
|
||||
componentInfo};
|
||||
|
||||
SensorLocation sensorLocation;
|
||||
std::vector<SensorLocation> sensorLocations;
|
||||
std::string loc = FingerprintHalProperties::sensor_location().value_or("");
|
||||
std::vector<std::string> dim = Split(loc, "|");
|
||||
if (dim.size() >= 3 && dim.size() <= 4) {
|
||||
ParseInt(dim[0], &sensorLocation.sensorLocationX);
|
||||
ParseInt(dim[1], &sensorLocation.sensorLocationY);
|
||||
ParseInt(dim[2], &sensorLocation.sensorRadius);
|
||||
std::vector<std::string> sensors = Split(loc, ";");
|
||||
|
||||
if (dim.size() >= 4)
|
||||
sensorLocation.display = dim[3];
|
||||
} else if(loc.length() > 0) {
|
||||
LOG(WARNING) << "Invalid sensor location input (x|y|radius|display): " << loc;
|
||||
for (const auto& sensor : sensors) {
|
||||
std::vector<std::string> dim = Split(sensor, "|");
|
||||
if (dim.size() >= 3 && dim.size() <= 4) {
|
||||
SensorLocation sensorLocation;
|
||||
ParseInt(dim[0], &sensorLocation.sensorLocationX);
|
||||
ParseInt(dim[1], &sensorLocation.sensorLocationY);
|
||||
ParseInt(dim[2], &sensorLocation.sensorRadius);
|
||||
|
||||
if (dim.size() == 4) {
|
||||
sensorLocation.display = dim[3];
|
||||
}
|
||||
|
||||
sensorLocations.push_back(sensorLocation);
|
||||
} else if (!sensor.empty()) {
|
||||
LOG(WARNING) << "Invalid sensor location input (x|y|radius|display): " << sensor;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(INFO) << "Sensor type: " << ::android::internal::ToString(mSensorType)
|
||||
<< " location: " << sensorLocation.toString();
|
||||
LOG(INFO) << "Sensor type: " << ::android::internal::ToString(mSensorType) << " locations:";
|
||||
for (const auto& sensorLocation : sensorLocations) {
|
||||
LOG(INFO) << sensorLocation.toString();
|
||||
}
|
||||
|
||||
*out = {{commonProps,
|
||||
mSensorType,
|
||||
{sensorLocation},
|
||||
mSupportsGestures,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
*out = {{commonProps, mSensorType, sensorLocations, mSupportsGestures, false, false, false,
|
||||
std::nullopt}};
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
@@ -157,8 +160,8 @@ ndk::ScopedAStatus Fingerprint::createSession(int32_t /*sensorId*/, int32_t user
|
||||
|
||||
void Fingerprint::notify(const fingerprint_msg_t* msg) {
|
||||
Fingerprint* thisPtr = sInstance;
|
||||
if (msg->type == FINGERPRINT_ACQUIRED
|
||||
&& msg->data.acquired.acquired_info > SEM_FINGERPRINT_EVENT_BASE) {
|
||||
if (msg->type == FINGERPRINT_ACQUIRED &&
|
||||
msg->data.acquired.acquired_info > SEM_FINGERPRINT_EVENT_BASE) {
|
||||
thisPtr->handleEvent(msg->data.acquired.acquired_info);
|
||||
return;
|
||||
}
|
||||
@@ -177,9 +180,8 @@ void Fingerprint::handleEvent(int eventCode) {
|
||||
case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP: {
|
||||
if (!mSupportsGestures) return;
|
||||
|
||||
struct input_event event {};
|
||||
int keycode = eventCode == SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP ?
|
||||
KEY_UP : KEY_DOWN;
|
||||
struct input_event event{};
|
||||
int keycode = eventCode == SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP ? KEY_UP : KEY_DOWN;
|
||||
|
||||
// Report the key
|
||||
event.type = EV_KEY;
|
||||
@@ -225,8 +227,8 @@ void Fingerprint::handleEvent(int eventCode) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -23,16 +23,16 @@ namespace biometrics {
|
||||
namespace fingerprint {
|
||||
|
||||
class Fingerprint : public BnFingerprint {
|
||||
public:
|
||||
public:
|
||||
Fingerprint();
|
||||
ndk::ScopedAStatus getSensorProps(std::vector<SensorProps>* _aidl_return) override;
|
||||
ndk::ScopedAStatus createSession(int32_t sensorId, int32_t userId,
|
||||
const std::shared_ptr<ISessionCallback>& cb,
|
||||
std::shared_ptr<ISession>* out) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
static void notify(
|
||||
const fingerprint_msg_t* msg); /* Static callback for legacy HAL implementation */
|
||||
const fingerprint_msg_t* msg); /* Static callback for legacy HAL implementation */
|
||||
void handleEvent(int eventCode);
|
||||
|
||||
LegacyHAL mHal;
|
||||
@@ -45,8 +45,8 @@ private:
|
||||
std::shared_ptr<Session> mSession;
|
||||
};
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -36,15 +36,13 @@ inline void translate(const hw_auth_token_t& hat, HardwareAuthToken& authToken)
|
||||
authToken.authenticatorId = hat.authenticator_id;
|
||||
// these are in network order: translate to host
|
||||
authToken.authenticatorType =
|
||||
static_cast<keymaster::HardwareAuthenticatorType>(
|
||||
be32toh(hat.authenticator_type));
|
||||
static_cast<keymaster::HardwareAuthenticatorType>(be32toh(hat.authenticator_type));
|
||||
authToken.timestamp.milliSeconds = be64toh(hat.timestamp);
|
||||
authToken.mac.insert(authToken.mac.begin(), std::begin(hat.hmac),
|
||||
std::end(hat.hmac));
|
||||
authToken.mac.insert(authToken.mac.begin(), std::begin(hat.hmac), std::end(hat.hmac));
|
||||
}
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -19,39 +19,40 @@ namespace fingerprint {
|
||||
bool LegacyHAL::openHal(fingerprint_notify_t notify) {
|
||||
void* handle = dlopen("libbauthserver.so", RTLD_NOW);
|
||||
|
||||
if (!handle)
|
||||
if (!handle) {
|
||||
handle = dlopen("libsfp_sensor.so", RTLD_NOW);
|
||||
}
|
||||
|
||||
if (handle) {
|
||||
int err;
|
||||
|
||||
ss_fingerprint_close =
|
||||
reinterpret_cast<typeof(ss_fingerprint_close)>(dlsym(handle, "ss_fingerprint_close"));
|
||||
ss_fingerprint_close = reinterpret_cast<typeof(ss_fingerprint_close)>(
|
||||
dlsym(handle, "ss_fingerprint_close"));
|
||||
ss_fingerprint_open =
|
||||
reinterpret_cast<typeof(ss_fingerprint_open)>(dlsym(handle, "ss_fingerprint_open"));
|
||||
reinterpret_cast<typeof(ss_fingerprint_open)>(dlsym(handle, "ss_fingerprint_open"));
|
||||
|
||||
ss_set_notify_callback = reinterpret_cast<typeof(ss_set_notify_callback)>(
|
||||
dlsym(handle, "ss_set_notify_callback"));
|
||||
dlsym(handle, "ss_set_notify_callback"));
|
||||
ss_fingerprint_pre_enroll = reinterpret_cast<typeof(ss_fingerprint_pre_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_pre_enroll"));
|
||||
ss_fingerprint_enroll =
|
||||
reinterpret_cast<typeof(ss_fingerprint_enroll)>(dlsym(handle, "ss_fingerprint_enroll"));
|
||||
dlsym(handle, "ss_fingerprint_pre_enroll"));
|
||||
ss_fingerprint_enroll = reinterpret_cast<typeof(ss_fingerprint_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_enroll"));
|
||||
ss_fingerprint_post_enroll = reinterpret_cast<typeof(ss_fingerprint_post_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_post_enroll"));
|
||||
dlsym(handle, "ss_fingerprint_post_enroll"));
|
||||
ss_fingerprint_get_auth_id = reinterpret_cast<typeof(ss_fingerprint_get_auth_id)>(
|
||||
dlsym(handle, "ss_fingerprint_get_auth_id"));
|
||||
ss_fingerprint_cancel =
|
||||
reinterpret_cast<typeof(ss_fingerprint_cancel)>(dlsym(handle, "ss_fingerprint_cancel"));
|
||||
dlsym(handle, "ss_fingerprint_get_auth_id"));
|
||||
ss_fingerprint_cancel = reinterpret_cast<typeof(ss_fingerprint_cancel)>(
|
||||
dlsym(handle, "ss_fingerprint_cancel"));
|
||||
ss_fingerprint_enumerate = reinterpret_cast<typeof(ss_fingerprint_enumerate)>(
|
||||
dlsym(handle, "ss_fingerprint_enumerate"));
|
||||
ss_fingerprint_remove =
|
||||
reinterpret_cast<typeof(ss_fingerprint_remove)>(dlsym(handle, "ss_fingerprint_remove"));
|
||||
dlsym(handle, "ss_fingerprint_enumerate"));
|
||||
ss_fingerprint_remove = reinterpret_cast<typeof(ss_fingerprint_remove)>(
|
||||
dlsym(handle, "ss_fingerprint_remove"));
|
||||
ss_fingerprint_set_active_group = reinterpret_cast<typeof(ss_fingerprint_set_active_group)>(
|
||||
dlsym(handle, "ss_fingerprint_set_active_group"));
|
||||
dlsym(handle, "ss_fingerprint_set_active_group"));
|
||||
ss_fingerprint_authenticate = reinterpret_cast<typeof(ss_fingerprint_authenticate)>(
|
||||
dlsym(handle, "ss_fingerprint_authenticate"));
|
||||
dlsym(handle, "ss_fingerprint_authenticate"));
|
||||
ss_fingerprint_request = reinterpret_cast<typeof(ss_fingerprint_request)>(
|
||||
dlsym(handle, "ss_fingerprint_request"));
|
||||
dlsym(handle, "ss_fingerprint_request"));
|
||||
|
||||
if ((err = ss_fingerprint_open(nullptr)) != 0) {
|
||||
LOG(ERROR) << "Can't open fingerprint, error: " << err;
|
||||
@@ -76,8 +77,8 @@ int LegacyHAL::request(int cmd, int param) {
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace biometrics {
|
||||
namespace fingerprint {
|
||||
|
||||
class LegacyHAL {
|
||||
public:
|
||||
public:
|
||||
bool openHal(fingerprint_notify_t notify);
|
||||
int request(int cmd, int param);
|
||||
|
||||
@@ -32,11 +32,12 @@ public:
|
||||
int (*ss_fingerprint_remove)(uint32_t gid, uint32_t fid);
|
||||
int (*ss_fingerprint_set_active_group)(uint32_t gid, const char* store_path);
|
||||
int (*ss_fingerprint_authenticate)(uint64_t operation_id, uint32_t gid);
|
||||
int (*ss_fingerprint_request)(uint32_t cmd, char *inBuf, uint32_t inBuf_length, char *outBuf, uint32_t outBuf_length, uint32_t param);
|
||||
int (*ss_fingerprint_request)(uint32_t cmd, char* inBuf, uint32_t inBuf_length, char* outBuf,
|
||||
uint32_t outBuf_length, uint32_t param);
|
||||
};
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "Fingerprint.h"
|
||||
#include "LockoutTracker.h"
|
||||
#include "Fingerprint.h"
|
||||
|
||||
#include <util/Util.h>
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace biometrics {
|
||||
namespace fingerprint {
|
||||
|
||||
void LockoutTracker::reset(bool clearAttemptCounter) {
|
||||
if (clearAttemptCounter)
|
||||
if (clearAttemptCounter) {
|
||||
mFailedCount = 0;
|
||||
}
|
||||
mLockoutTimedStart = 0;
|
||||
mCurrentMode = LockoutMode::NONE;
|
||||
}
|
||||
@@ -25,9 +26,9 @@ void LockoutTracker::reset(bool clearAttemptCounter) {
|
||||
void LockoutTracker::addFailedAttempt() {
|
||||
mFailedCount++;
|
||||
|
||||
if (mFailedCount >= LOCKOUT_PERMANENT_THRESHOLD)
|
||||
if (mFailedCount >= LOCKOUT_PERMANENT_THRESHOLD) {
|
||||
mCurrentMode = LockoutMode::PERMANENT;
|
||||
else if (mFailedCount >= LOCKOUT_TIMED_THRESHOLD) {
|
||||
} else if (mFailedCount >= LOCKOUT_TIMED_THRESHOLD) {
|
||||
mCurrentMode = LockoutMode::TIMED;
|
||||
mLockoutTimedStart = Util::getSystemNanoTime();
|
||||
}
|
||||
@@ -56,8 +57,8 @@ int64_t LockoutTracker::getLockoutTimeLeft() {
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
* Copyright (C) 2024-2025 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -16,27 +18,23 @@ namespace fingerprint {
|
||||
#define LOCKOUT_TIMED_DURATION 30 * 1000
|
||||
#define LOCKOUT_PERMANENT_THRESHOLD 20
|
||||
|
||||
enum class LockoutMode {
|
||||
NONE,
|
||||
TIMED,
|
||||
PERMANENT
|
||||
};
|
||||
enum class LockoutMode { NONE, TIMED, PERMANENT };
|
||||
|
||||
class LockoutTracker {
|
||||
public:
|
||||
public:
|
||||
void reset(bool clearAttemptCounter);
|
||||
LockoutMode getMode();
|
||||
void addFailedAttempt();
|
||||
int64_t getLockoutTimeLeft();
|
||||
|
||||
private:
|
||||
private:
|
||||
int32_t mFailedCount = 0;
|
||||
int64_t mLockoutTimedStart;
|
||||
LockoutMode mCurrentMode;
|
||||
};
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "Session.h"
|
||||
#include "CancellationSignal.h"
|
||||
#include "Legacy2Aidl.h"
|
||||
#include "Session.h"
|
||||
#include "VendorConstants.h"
|
||||
|
||||
#include <fingerprint.sysprop.h>
|
||||
@@ -36,10 +36,7 @@ void onClientDeath(void* cookie) {
|
||||
|
||||
Session::Session(LegacyHAL hal, int userId, std::shared_ptr<ISessionCallback> cb,
|
||||
LockoutTracker lockoutTracker)
|
||||
: mHal(hal),
|
||||
mLockoutTracker(lockoutTracker),
|
||||
mUserId(userId),
|
||||
mCb(cb) {
|
||||
: mHal(hal), mLockoutTracker(lockoutTracker), mUserId(userId), mCb(cb) {
|
||||
mDeathRecipient = AIBinder_DeathRecipient_new(onClientDeath);
|
||||
|
||||
char filename[64];
|
||||
@@ -122,8 +119,9 @@ ndk::ScopedAStatus Session::enumerateEnrollments() {
|
||||
|
||||
if (mHal.ss_fingerprint_enumerate) {
|
||||
int32_t error = mHal.ss_fingerprint_enumerate();
|
||||
if (error)
|
||||
if (error) {
|
||||
LOG(ERROR) << "ss_fingerprint_enumerate failed: " << error;
|
||||
}
|
||||
} else {
|
||||
std::vector<int> enrollments;
|
||||
char filename[64];
|
||||
@@ -135,8 +133,9 @@ ndk::ScopedAStatus Session::enumerateEnrollments() {
|
||||
while ((entry = readdir(directory))) {
|
||||
int uid, fid;
|
||||
if (sscanf(entry->d_name, "User_%d_%dtmpl.dat", &uid, &fid)) {
|
||||
if (uid == mUserId)
|
||||
if (uid == mUserId) {
|
||||
enrollments.push_back(fid);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(directory);
|
||||
@@ -155,8 +154,9 @@ ndk::ScopedAStatus Session::removeEnrollments(const std::vector<int32_t>& enroll
|
||||
|
||||
for (int32_t enrollment : enrollmentIds) {
|
||||
int32_t error = mHal.ss_fingerprint_remove(mUserId, enrollment);
|
||||
if (error)
|
||||
if (error) {
|
||||
LOG(ERROR) << "ss_fingerprint_remove failed: " << error;
|
||||
}
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
@@ -195,8 +195,8 @@ ndk::ScopedAStatus Session::close() {
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Session::onPointerDown(int32_t /*pointerId*/, int32_t /*x*/, int32_t /*y*/, float /*minor*/,
|
||||
float /*major*/) {
|
||||
ndk::ScopedAStatus Session::onPointerDown(int32_t /*pointerId*/, int32_t /*x*/, int32_t /*y*/,
|
||||
float /*minor*/, float /*major*/) {
|
||||
LOG(INFO) << "onPointerDown";
|
||||
|
||||
if (FingerprintHalProperties::request_touch_event().value_or(false)) {
|
||||
@@ -225,9 +225,9 @@ ndk::ScopedAStatus Session::onUiReady() {
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Session::authenticateWithContext(
|
||||
int64_t operationId, const OperationContext& /*context*/,
|
||||
std::shared_ptr<ICancellationSignal>* out) {
|
||||
ndk::ScopedAStatus Session::authenticateWithContext(int64_t operationId,
|
||||
const OperationContext& /*context*/,
|
||||
std::shared_ptr<ICancellationSignal>* out) {
|
||||
return authenticate(operationId, out);
|
||||
}
|
||||
|
||||
@@ -237,8 +237,8 @@ ndk::ScopedAStatus Session::enrollWithContext(const HardwareAuthToken& hat,
|
||||
return enroll(hat, out);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Session::detectInteractionWithContext(const OperationContext& /*context*/,
|
||||
std::shared_ptr<ICancellationSignal>* out) {
|
||||
ndk::ScopedAStatus Session::detectInteractionWithContext(
|
||||
const OperationContext& /*context*/, std::shared_ptr<ICancellationSignal>* out) {
|
||||
return detectInteraction(out);
|
||||
}
|
||||
|
||||
@@ -368,8 +368,7 @@ void Session::clearLockout(bool clearAttemptCounter) {
|
||||
|
||||
void Session::startLockoutTimer(int64_t timeout) {
|
||||
mIsLockoutTimerAborted = false;
|
||||
std::function<void()> action =
|
||||
std::bind(&Session::lockoutTimerExpired, this);
|
||||
std::function<void()> action = std::bind(&Session::lockoutTimerExpired, this);
|
||||
std::thread([timeout, action]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
|
||||
action();
|
||||
@@ -379,8 +378,9 @@ void Session::startLockoutTimer(int64_t timeout) {
|
||||
}
|
||||
|
||||
void Session::lockoutTimerExpired() {
|
||||
if (!mIsLockoutTimerAborted)
|
||||
if (!mIsLockoutTimerAborted) {
|
||||
clearLockout(false);
|
||||
}
|
||||
|
||||
mIsLockoutTimerStarted = false;
|
||||
mIsLockoutTimerAborted = false;
|
||||
@@ -397,18 +397,19 @@ void Session::notify(const fingerprint_msg_t* msg) {
|
||||
case FINGERPRINT_ACQUIRED: {
|
||||
int32_t vendorCode = 0;
|
||||
AcquiredInfo result =
|
||||
VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode);
|
||||
VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode);
|
||||
LOG(DEBUG) << "onAcquired(" << static_cast<int>(result) << ")";
|
||||
mCb->onAcquired(result, vendorCode);
|
||||
} break;
|
||||
case FINGERPRINT_TEMPLATE_ENROLLING:
|
||||
if (FingerprintHalProperties::uses_percentage_samples().value_or(false)) {
|
||||
const_cast<fingerprint_msg_t*>(msg)->data.enroll.samples_remaining =
|
||||
100 - msg->data.enroll.samples_remaining;
|
||||
100 - msg->data.enroll.samples_remaining;
|
||||
}
|
||||
if (FingerprintHalProperties::cancel_on_enroll_completion().value_or(false)) {
|
||||
if (msg->data.enroll.samples_remaining == 0)
|
||||
if (msg->data.enroll.samples_remaining == 0) {
|
||||
mHal.ss_fingerprint_cancel();
|
||||
}
|
||||
}
|
||||
LOG(DEBUG) << "onEnrollResult(fid=" << msg->data.enroll.finger.fid
|
||||
<< ", gid=" << msg->data.enroll.finger.gid
|
||||
@@ -458,8 +459,8 @@ void Session::onCaptureReady() {
|
||||
mCaptureReady = true;
|
||||
}
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace fingerprint {
|
||||
void onClientDeath(void* cookie);
|
||||
|
||||
class Session : public BnSession {
|
||||
public:
|
||||
public:
|
||||
Session(LegacyHAL hal, int userId, std::shared_ptr<ISessionCallback> cb,
|
||||
LockoutTracker lockoutTracker);
|
||||
ndk::ScopedAStatus generateChallenge() override;
|
||||
@@ -39,8 +39,7 @@ public:
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus authenticate(int64_t operationId,
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus detectInteraction(
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus detectInteraction(std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus enumerateEnrollments() override;
|
||||
ndk::ScopedAStatus removeEnrollments(const std::vector<int32_t>& enrollmentIds) override;
|
||||
ndk::ScopedAStatus getAuthenticatorId() override;
|
||||
@@ -51,15 +50,13 @@ public:
|
||||
float major) override;
|
||||
ndk::ScopedAStatus onPointerUp(int32_t pointerId) override;
|
||||
ndk::ScopedAStatus onUiReady() override;
|
||||
ndk::ScopedAStatus authenticateWithContext(
|
||||
int64_t operationId, const OperationContext& context,
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus enrollWithContext(
|
||||
const HardwareAuthToken& hat, const OperationContext& context,
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus authenticateWithContext(int64_t operationId, const OperationContext& context,
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus enrollWithContext(const HardwareAuthToken& hat,
|
||||
const OperationContext& context,
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus detectInteractionWithContext(
|
||||
const OperationContext& context,
|
||||
std::shared_ptr<ICancellationSignal>* out) override;
|
||||
const OperationContext& context, std::shared_ptr<ICancellationSignal>* out) override;
|
||||
ndk::ScopedAStatus onPointerDownWithContext(const PointerContext& context) override;
|
||||
ndk::ScopedAStatus onPointerUpWithContext(const PointerContext& context) override;
|
||||
ndk::ScopedAStatus onContextChanged(const OperationContext& context) override;
|
||||
@@ -69,11 +66,10 @@ public:
|
||||
ndk::ScopedAStatus cancel();
|
||||
binder_status_t linkToDeath(AIBinder* binder);
|
||||
bool isClosed();
|
||||
void notify(
|
||||
const fingerprint_msg_t* msg);
|
||||
void notify(const fingerprint_msg_t* msg);
|
||||
void onCaptureReady();
|
||||
|
||||
private:
|
||||
private:
|
||||
LegacyHAL mHal;
|
||||
LockoutTracker mLockoutTracker;
|
||||
bool mClosed = false;
|
||||
@@ -102,8 +98,8 @@ private:
|
||||
AIBinder_DeathRecipient* mDeathRecipient;
|
||||
};
|
||||
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "Fingerprint.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
using ::aidl::android::hardware::biometrics::fingerprint::Fingerprint;
|
||||
|
||||
@@ -17,9 +17,10 @@ int main() {
|
||||
std::shared_ptr<Fingerprint> fingerprint = ndk::SharedRefBase::make<Fingerprint>();
|
||||
|
||||
const std::string instance = std::string() + Fingerprint::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(fingerprint->asBinder().get(), instance.c_str());
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(fingerprint->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ static constexpr std::string_view gChargerArg{"--charger"};
|
||||
#if !CHARGER_FORCE_NO_UI
|
||||
namespace aidl::android::hardware::health {
|
||||
class ChargerCallbackImpl : public ChargerCallback {
|
||||
public:
|
||||
public:
|
||||
using ChargerCallback::ChargerCallback;
|
||||
bool ChargerEnableSuspend() override { return true; }
|
||||
};
|
||||
} // namespace aidl::android::hardware::health
|
||||
} // namespace aidl::android::hardware::health
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
@@ -64,7 +64,9 @@ int main(int argc, char** argv) {
|
||||
// If charger shouldn't have UI for your device, simply drop the line below
|
||||
// for your service implementation. This corresponds to
|
||||
// ro.charger.no_ui=true
|
||||
return ChargerModeMain(binder, std::make_shared<aidl::android::hardware::health::ChargerCallbackImpl>(binder));
|
||||
return ChargerModeMain(
|
||||
binder,
|
||||
std::make_shared<aidl::android::hardware::health::ChargerCallbackImpl>(binder));
|
||||
#endif
|
||||
|
||||
LOG(INFO) << "Starting charger mode without UI.";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.health</name>
|
||||
<version>1</version>
|
||||
<version>4</version>
|
||||
<fqname>IHealth/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
||||
@@ -41,10 +41,12 @@ Lights::Lights() {
|
||||
mLights.emplace(LightType::BACKLIGHT,
|
||||
std::bind(&Lights::handleBacklight, this, std::placeholders::_1));
|
||||
#ifdef BUTTON_BRIGHTNESS_NODE
|
||||
mLights.emplace(LightType::BUTTONS, std::bind(&Lights::handleButtons, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::BUTTONS,
|
||||
std::bind(&Lights::handleButtons, this, std::placeholders::_1));
|
||||
#endif /* BUTTON_BRIGHTNESS_NODE */
|
||||
#ifdef LED_BLINK_NODE
|
||||
mLights.emplace(LightType::BATTERY, std::bind(&Lights::handleBattery, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::BATTERY,
|
||||
std::bind(&Lights::handleBattery, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::NOTIFICATIONS,
|
||||
std::bind(&Lights::handleNotifications, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::ATTENTION,
|
||||
@@ -147,7 +149,7 @@ void Lights::setNotificationLED() {
|
||||
|
||||
state.color = calibrateColor(state.color & COLOR_MASK, adjusted_brightness);
|
||||
set(LED_BLINK_NODE, ::android::base::StringPrintf("0x%08x %d %d", state.color, state.flashOnMs,
|
||||
state.flashOffMs));
|
||||
state.flashOffMs));
|
||||
|
||||
#ifdef LED_BLN_NODE
|
||||
if (bln) {
|
||||
@@ -168,7 +170,7 @@ uint32_t Lights::calibrateColor(uint32_t color, int32_t brightness) {
|
||||
|
||||
#define AutoHwLight(light) {.id = (int32_t)light, .type = light, .ordinal = 0}
|
||||
|
||||
ndk::ScopedAStatus Lights::getLights(std::vector<HwLight> *_aidl_return) {
|
||||
ndk::ScopedAStatus Lights::getLights(std::vector<HwLight>* _aidl_return) {
|
||||
for (auto const& light : mLights) {
|
||||
_aidl_return->push_back(AutoHwLight(light.first));
|
||||
}
|
||||
@@ -179,11 +181,12 @@ ndk::ScopedAStatus Lights::getLights(std::vector<HwLight> *_aidl_return) {
|
||||
uint32_t Lights::rgbToBrightness(const HwLightState& state) {
|
||||
uint32_t color = state.color & COLOR_MASK;
|
||||
|
||||
return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) + (29 * (color & 0xff))) >>
|
||||
return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) +
|
||||
(29 * (color & 0xff))) >>
|
||||
8;
|
||||
}
|
||||
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
||||
using ::aidl::android::hardware::light::HwLightState;
|
||||
using ::aidl::android::hardware::light::HwLight;
|
||||
using ::aidl::android::hardware::light::HwLightState;
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
@@ -21,13 +21,13 @@ namespace hardware {
|
||||
namespace light {
|
||||
|
||||
class Lights : public BnLights {
|
||||
public:
|
||||
public:
|
||||
Lights();
|
||||
|
||||
ndk::ScopedAStatus setLightState(int32_t id, const HwLightState& state) override;
|
||||
ndk::ScopedAStatus getLights(std::vector<HwLight> *_aidl_return) override;
|
||||
ndk::ScopedAStatus getLights(std::vector<HwLight>* _aidl_return) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
void handleBacklight(const HwLightState& state);
|
||||
#ifdef BUTTON_BRIGHTNESS_NODE
|
||||
void handleButtons(const HwLightState& state);
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
std::unordered_map<LightType, std::function<void(const HwLightState&)>> mLights;
|
||||
};
|
||||
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#define LED_BLN_NODE "/sys/class/misc/backlightnotification/notification_led"
|
||||
|
||||
// Uncomment to enable variable button brightness
|
||||
//#define VAR_BUTTON_BRIGHTNESS 1
|
||||
// #define VAR_BUTTON_BRIGHTNESS 1
|
||||
|
||||
/*
|
||||
* Brightness adjustment factors
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include "Lights.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
using ::aidl::android::hardware::light::Lights;
|
||||
|
||||
@@ -23,5 +23,5 @@ int main() {
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
|
||||
55
aidl/livedisplay/AdaptiveBacklight.cpp
Normal file
55
aidl/livedisplay/AdaptiveBacklight.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <livedisplay/samsung/AdaptiveBacklight.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::Trim;
|
||||
using android::base::WriteStringToFile;
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
static constexpr const char* kBacklightPath = "/sys/class/lcd/panel/power_reduce";
|
||||
|
||||
bool AdaptiveBacklight::isSupported() {
|
||||
std::fstream file(kBacklightPath, file.in | file.out);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnAdaptiveBacklight follow.
|
||||
ndk::ScopedAStatus AdaptiveBacklight::getEnabled(bool* _aidl_return) {
|
||||
std::string tmp;
|
||||
int32_t contents = 0;
|
||||
|
||||
if (!ReadFileToString(kBacklightPath, &tmp)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
contents = std::stoi(Trim(tmp));
|
||||
|
||||
*_aidl_return = contents > 0;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus AdaptiveBacklight::setEnabled(bool enabled) {
|
||||
if (!WriteStringToFile(enabled ? "1" : "0", kBacklightPath, true)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -7,9 +7,9 @@ filegroup {
|
||||
name: "vendor.lineage.livedisplay-samsung-exynos",
|
||||
srcs: [
|
||||
"AdaptiveBacklight.cpp",
|
||||
"DisplayColorCalibrationExynos.cpp",
|
||||
"DisplayColorCalibration.cpp",
|
||||
"DisplayModes.cpp",
|
||||
"ReadingEnhancement.cpp",
|
||||
"ReadingEnhancementExynos.cpp",
|
||||
"SunlightEnhancementExynos.cpp",
|
||||
"serviceExynos.cpp",
|
||||
],
|
||||
@@ -21,7 +21,6 @@ filegroup {
|
||||
"AdaptiveBacklight.cpp",
|
||||
"DisplayColorCalibration.cpp",
|
||||
"DisplayModes.cpp",
|
||||
"ReadingEnhancement.cpp",
|
||||
"SunlightEnhancement.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
@@ -33,10 +32,10 @@ cc_defaults {
|
||||
relative_install_path: "hw",
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"libbinder",
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"vendor.lineage.livedisplay@2.0",
|
||||
"vendor.lineage.livedisplay-V1-ndk",
|
||||
],
|
||||
header_libs: [
|
||||
"vendor.lineage.livedisplay-samsung-headers",
|
||||
@@ -50,17 +49,17 @@ cc_library_headers {
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "vendor.lineage.livedisplay@2.0-service.samsung-exynos",
|
||||
name: "vendor.lineage.livedisplay-service.samsung-exynos",
|
||||
defaults: ["livedisplay_samsung_defaults"],
|
||||
init_rc: ["vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc"],
|
||||
init_rc: ["vendor.lineage.livedisplay-service.samsung-exynos.rc"],
|
||||
srcs: [":vendor.lineage.livedisplay-samsung-exynos"],
|
||||
vendor: true,
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "vendor.lineage.livedisplay@2.0-service.samsung-qcom",
|
||||
name: "vendor.lineage.livedisplay-service.samsung-qcom",
|
||||
defaults: ["livedisplay_samsung_defaults"],
|
||||
init_rc: ["vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc"],
|
||||
init_rc: ["vendor.lineage.livedisplay-service.samsung-qcom.rc"],
|
||||
srcs: [":vendor.lineage.livedisplay-samsung-qcom"],
|
||||
vendor: true,
|
||||
}
|
||||
76
aidl/livedisplay/DisplayColorCalibration.cpp
Normal file
76
aidl/livedisplay/DisplayColorCalibration.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <livedisplay/samsung/DisplayColorCalibration.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::Split;
|
||||
using android::base::Trim;
|
||||
using android::base::WriteStringToFile;
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
static constexpr const char* kRGBPath = "/sys/class/mdnie/mdnie/sensorRGB";
|
||||
|
||||
bool DisplayColorCalibration::isSupported() {
|
||||
std::fstream file(kRGBPath, file.in | file.out);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnDisplayColorCalibration follow.
|
||||
ndk::ScopedAStatus DisplayColorCalibration::getMaxValue(int32_t* _aidl_return) {
|
||||
*_aidl_return = 255;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus DisplayColorCalibration::getMinValue(int32_t* _aidl_return) {
|
||||
*_aidl_return = 1;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus DisplayColorCalibration::getCalibration(std::vector<int32_t>* _aidl_return) {
|
||||
std::vector<int32_t> rgb;
|
||||
std::string tmp;
|
||||
|
||||
if (ReadFileToString(kRGBPath, &tmp)) {
|
||||
std::vector<std::string> colors = Split(Trim(tmp), " ");
|
||||
for (const std::string& color : colors) {
|
||||
rgb.push_back(std::stoi(color));
|
||||
}
|
||||
} else {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
*_aidl_return = rgb;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus DisplayColorCalibration::setCalibration(const std::vector<int32_t>& rgb) {
|
||||
std::string contents;
|
||||
|
||||
for (const int32_t& color : rgb) {
|
||||
contents += std::to_string(color) + " ";
|
||||
}
|
||||
|
||||
if (!WriteStringToFile(Trim(contents), kRGBPath, true)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2025 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.
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "DisplayModesService"
|
||||
@@ -21,10 +10,10 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace V2_0 {
|
||||
namespace samsung {
|
||||
|
||||
static constexpr const char* kModePath = "/sys/class/mdnie/mdnie/mode";
|
||||
@@ -68,7 +57,7 @@ bool DisplayModes::isSupported() {
|
||||
}
|
||||
|
||||
// Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayModes follow.
|
||||
Return<void> DisplayModes::getDisplayModes(getDisplayModes_cb resultCb) {
|
||||
ndk::ScopedAStatus DisplayModes::getDisplayModes(std::vector<DisplayMode>* _aidl_return) {
|
||||
std::ifstream maxModeFile(kModeMaxPath);
|
||||
int value;
|
||||
std::vector<DisplayMode> modes;
|
||||
@@ -80,11 +69,12 @@ Return<void> DisplayModes::getDisplayModes(getDisplayModes_cb resultCb) {
|
||||
for (const auto& entry : kModeMap) {
|
||||
if (entry.first < value) modes.push_back({entry.first, entry.second});
|
||||
}
|
||||
resultCb(modes);
|
||||
return Void();
|
||||
|
||||
*_aidl_return = modes;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Return<void> DisplayModes::getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) {
|
||||
ndk::ScopedAStatus DisplayModes::getCurrentDisplayMode(DisplayMode* _aidl_return) {
|
||||
int32_t currentModeId = mDefaultModeId;
|
||||
std::ifstream modeFile(kModePath);
|
||||
int value;
|
||||
@@ -97,41 +87,40 @@ Return<void> DisplayModes::getCurrentDisplayMode(getCurrentDisplayMode_cb result
|
||||
}
|
||||
}
|
||||
}
|
||||
resultCb({currentModeId, kModeMap.at(currentModeId)});
|
||||
return Void();
|
||||
|
||||
*_aidl_return = DisplayMode{currentModeId, kModeMap.at(currentModeId)};
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Return<void> DisplayModes::getDefaultDisplayMode(getDefaultDisplayMode_cb resultCb) {
|
||||
resultCb({mDefaultModeId, kModeMap.at(mDefaultModeId)});
|
||||
return Void();
|
||||
ndk::ScopedAStatus DisplayModes::getDefaultDisplayMode(DisplayMode* _aidl_return) {
|
||||
*_aidl_return = DisplayMode{mDefaultModeId, kModeMap.at(mDefaultModeId)};
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Return<bool> DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) {
|
||||
ndk::ScopedAStatus DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) {
|
||||
const auto iter = kModeMap.find(modeID);
|
||||
if (iter == kModeMap.end()) {
|
||||
return false;
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
std::ofstream modeFile(kModePath);
|
||||
modeFile << iter->first;
|
||||
if (modeFile.fail()) {
|
||||
return false;
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
if (makeDefault) {
|
||||
std::ofstream defaultFile(kDefaultPath);
|
||||
defaultFile << iter->first;
|
||||
if (defaultFile.fail()) {
|
||||
return false;
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
mDefaultModeId = iter->first;
|
||||
}
|
||||
return true;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace V2_0
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
55
aidl/livedisplay/ReadingEnhancementExynos.cpp
Normal file
55
aidl/livedisplay/ReadingEnhancementExynos.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <livedisplay/samsung/ReadingEnhancementExynos.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::Trim;
|
||||
using android::base::WriteStringToFile;
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
static constexpr const char* kREPath = "/sys/class/mdnie/mdnie/accessibility";
|
||||
|
||||
bool ReadingEnhancementExynos::isSupported() {
|
||||
std::fstream file(kREPath, file.in | file.out);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnReadingEnhancement follow.
|
||||
ndk::ScopedAStatus ReadingEnhancementExynos::getEnabled(bool* _aidl_return) {
|
||||
std::string contents;
|
||||
|
||||
if (!ReadFileToString(kREPath, &contents)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
contents = Trim(contents);
|
||||
|
||||
*_aidl_return =
|
||||
!contents.compare("Current accessibility : DSI0 : GRAYSCALE") || !contents.compare("4");
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ReadingEnhancementExynos::setEnabled(bool enabled) {
|
||||
if (!WriteStringToFile(enabled ? "4" : "0", kREPath, true)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
56
aidl/livedisplay/SunlightEnhancement.cpp
Normal file
56
aidl/livedisplay/SunlightEnhancement.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <livedisplay/samsung/SunlightEnhancement.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::Trim;
|
||||
using android::base::WriteStringToFile;
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
// Note: Exynos method is also available on Qualcomm
|
||||
static constexpr const char* kSREPath = "/sys/class/mdnie/mdnie/outdoor";
|
||||
|
||||
bool SunlightEnhancement::isSupported() {
|
||||
std::fstream file(kSREPath, file.in | file.out);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnSunlightEnhancement follow.
|
||||
ndk::ScopedAStatus SunlightEnhancement::getEnabled(bool* _aidl_return) {
|
||||
std::string tmp;
|
||||
int32_t contents = 0;
|
||||
|
||||
if (!ReadFileToString(kSREPath, &tmp)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
contents = std::stoi(Trim(tmp));
|
||||
|
||||
*_aidl_return = contents == 1;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus SunlightEnhancement::setEnabled(bool enabled) {
|
||||
if (!WriteStringToFile(enabled ? "1" : "0", kSREPath, true)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
56
aidl/livedisplay/SunlightEnhancementExynos.cpp
Normal file
56
aidl/livedisplay/SunlightEnhancementExynos.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <livedisplay/samsung/SunlightEnhancementExynos.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::Trim;
|
||||
using android::base::WriteStringToFile;
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
static constexpr const char* kLUXPath = "/sys/class/mdnie/mdnie/lux";
|
||||
|
||||
bool SunlightEnhancementExynos::isSupported() {
|
||||
std::fstream file(kLUXPath, file.in | file.out);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnSunlightEnhancement follow.
|
||||
ndk::ScopedAStatus SunlightEnhancementExynos::getEnabled(bool* _aidl_return) {
|
||||
std::string tmp;
|
||||
int32_t contents = 0;
|
||||
|
||||
if (!ReadFileToString(kLUXPath, &tmp)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
contents = std::stoi(Trim(tmp));
|
||||
|
||||
*_aidl_return = contents > 0;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus SunlightEnhancementExynos::setEnabled(bool enabled) {
|
||||
/* see drivers/video/fbdev/exynos/decon_7880/panels/mdnie_lite_table*, get_hbm_index */
|
||||
if (!WriteStringToFile(enabled ? "40000" : "0", kLUXPath, true)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/livedisplay/BnAdaptiveBacklight.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
class AdaptiveBacklight : public BnAdaptiveBacklight {
|
||||
public:
|
||||
bool isSupported();
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnAdaptiveBacklight follow.
|
||||
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setEnabled(bool enabled) override;
|
||||
};
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/livedisplay/BnDisplayColorCalibration.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
class DisplayColorCalibration : public BnDisplayColorCalibration {
|
||||
public:
|
||||
bool isSupported();
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnDisplayColorCalibration follow.
|
||||
ndk::ScopedAStatus getMaxValue(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getMinValue(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getCalibration(std::vector<int32_t>* _aidl_return) override;
|
||||
ndk::ScopedAStatus setCalibration(const std::vector<int32_t>& rgb) override;
|
||||
};
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
38
aidl/livedisplay/include/livedisplay/samsung/DisplayModes.h
Normal file
38
aidl/livedisplay/include/livedisplay/samsung/DisplayModes.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/livedisplay/BnDisplayModes.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
class DisplayModes : public BnDisplayModes {
|
||||
public:
|
||||
DisplayModes();
|
||||
bool isSupported();
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnDisplayModes follow.
|
||||
ndk::ScopedAStatus getDisplayModes(std::vector<DisplayMode>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getCurrentDisplayMode(DisplayMode* _aidl_return) override;
|
||||
ndk::ScopedAStatus getDefaultDisplayMode(DisplayMode* _aidl_return) override;
|
||||
ndk::ScopedAStatus setDisplayMode(int32_t modeID, bool makeDefault) override;
|
||||
|
||||
private:
|
||||
static const std::map<int32_t, std::string> kModeMap;
|
||||
int32_t mDefaultModeId;
|
||||
};
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/livedisplay/BnReadingEnhancement.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
class ReadingEnhancementExynos : public BnReadingEnhancement {
|
||||
public:
|
||||
bool isSupported();
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnReadingEnhancement follow.
|
||||
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setEnabled(bool enabled) override;
|
||||
};
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/livedisplay/BnSunlightEnhancement.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
class SunlightEnhancement : public BnSunlightEnhancement {
|
||||
public:
|
||||
bool isSupported();
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnSunlightEnhancement follow.
|
||||
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setEnabled(bool enabled) override;
|
||||
};
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/livedisplay/BnSunlightEnhancement.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace samsung {
|
||||
|
||||
class SunlightEnhancementExynos : public BnSunlightEnhancement {
|
||||
public:
|
||||
bool isSupported();
|
||||
|
||||
// Methods from ::aidl::vendor::lineage::livedisplay::BnSunlightEnhancement follow.
|
||||
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setEnabled(bool enabled) override;
|
||||
};
|
||||
|
||||
} // namespace samsung
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
111
aidl/livedisplay/service.cpp
Normal file
111
aidl/livedisplay/service.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vendor.lineage.livedisplay-service.samsung-qcom"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <livedisplay/samsung/AdaptiveBacklight.h>
|
||||
#include <livedisplay/samsung/DisplayColorCalibration.h>
|
||||
#include <livedisplay/samsung/DisplayModes.h>
|
||||
#include <livedisplay/samsung/SunlightEnhancement.h>
|
||||
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::AdaptiveBacklight;
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::DisplayColorCalibration;
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::DisplayModes;
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::SunlightEnhancement;
|
||||
|
||||
int main() {
|
||||
android::ProcessState::self()->setThreadPoolMaxThreadCount(1);
|
||||
android::ProcessState::self()->startThreadPool();
|
||||
|
||||
std::shared_ptr<AdaptiveBacklight> adaptiveBacklight =
|
||||
ndk::SharedRefBase::make<AdaptiveBacklight>();
|
||||
std::shared_ptr<DisplayColorCalibration> displayColorCalibration =
|
||||
ndk::SharedRefBase::make<DisplayColorCalibration>();
|
||||
std::shared_ptr<DisplayModes> displayModes = ndk::SharedRefBase::make<DisplayModes>();
|
||||
std::shared_ptr<SunlightEnhancement> sunlightEnhancement =
|
||||
ndk::SharedRefBase::make<SunlightEnhancement>();
|
||||
binder_status_t status;
|
||||
|
||||
LOG(INFO) << "LiveDisplay HAL service is starting.";
|
||||
|
||||
if (adaptiveBacklight == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, "
|
||||
"exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (displayColorCalibration == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayColorCalibration "
|
||||
"Iface, exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (displayModes == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (sunlightEnhancement == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, "
|
||||
"exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (adaptiveBacklight->isSupported()) {
|
||||
std::string instance = std::string(AdaptiveBacklight::descriptor) + "/default";
|
||||
status = AServiceManager_addService(adaptiveBacklight->asBinder().get(), instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayColorCalibration->isSupported()) {
|
||||
std::string instance = std::string(DisplayColorCalibration::descriptor) + "/default";
|
||||
status = AServiceManager_addService(displayColorCalibration->asBinder().get(),
|
||||
instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayColorCalibration "
|
||||
"Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayModes->isSupported()) {
|
||||
std::string instance = std::string(DisplayModes::descriptor) + "/default";
|
||||
status = AServiceManager_addService(displayModes->asBinder().get(), instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
if (sunlightEnhancement->isSupported()) {
|
||||
std::string instance = std::string(SunlightEnhancement::descriptor) + "/default";
|
||||
status =
|
||||
AServiceManager_addService(sunlightEnhancement->asBinder().get(), instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR)
|
||||
<< "Could not register service for LiveDisplay HAL SunlightEnhancement Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(INFO) << "LiveDisplay HAL service is ready.";
|
||||
ABinderProcess_joinThreadPool();
|
||||
|
||||
shutdown:
|
||||
// In normal operation, we don't expect the thread pool to shutdown
|
||||
LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
132
aidl/livedisplay/serviceExynos.cpp
Normal file
132
aidl/livedisplay/serviceExynos.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vendor.lineage.livedisplay-service.samsung-exynos"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <livedisplay/samsung/AdaptiveBacklight.h>
|
||||
#include <livedisplay/samsung/DisplayColorCalibration.h>
|
||||
#include <livedisplay/samsung/DisplayModes.h>
|
||||
#include <livedisplay/samsung/ReadingEnhancementExynos.h>
|
||||
#include <livedisplay/samsung/SunlightEnhancementExynos.h>
|
||||
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::AdaptiveBacklight;
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::DisplayColorCalibration;
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::DisplayModes;
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::ReadingEnhancementExynos;
|
||||
using ::aidl::vendor::lineage::livedisplay::samsung::SunlightEnhancementExynos;
|
||||
|
||||
int main() {
|
||||
android::ProcessState::self()->setThreadPoolMaxThreadCount(1);
|
||||
android::ProcessState::self()->startThreadPool();
|
||||
|
||||
std::shared_ptr<AdaptiveBacklight> adaptiveBacklight =
|
||||
ndk::SharedRefBase::make<AdaptiveBacklight>();
|
||||
std::shared_ptr<DisplayColorCalibration> displayColorCalibration =
|
||||
ndk::SharedRefBase::make<DisplayColorCalibration>();
|
||||
std::shared_ptr<DisplayModes> displayModes = ndk::SharedRefBase::make<DisplayModes>();
|
||||
std::shared_ptr<ReadingEnhancementExynos> readingEnhancement =
|
||||
ndk::SharedRefBase::make<ReadingEnhancementExynos>();
|
||||
std::shared_ptr<SunlightEnhancementExynos> sunlightEnhancement =
|
||||
ndk::SharedRefBase::make<SunlightEnhancementExynos>();
|
||||
binder_status_t status;
|
||||
|
||||
LOG(INFO) << "LiveDisplay HAL service is starting.";
|
||||
|
||||
if (adaptiveBacklight == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, "
|
||||
"exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (displayColorCalibration == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayColorCalibration "
|
||||
"Iface, exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (displayModes == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (readingEnhancement == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL ReadingEnhancement Iface, "
|
||||
"exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (sunlightEnhancement == nullptr) {
|
||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, "
|
||||
"exiting.";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (adaptiveBacklight->isSupported()) {
|
||||
std::string instance = std::string(AdaptiveBacklight::descriptor) + "/default";
|
||||
status = AServiceManager_addService(adaptiveBacklight->asBinder().get(), instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayColorCalibration->isSupported()) {
|
||||
std::string instance = std::string(DisplayColorCalibration::descriptor) + "/default";
|
||||
status = AServiceManager_addService(displayColorCalibration->asBinder().get(),
|
||||
instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayColorCalibration "
|
||||
"Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayModes->isSupported()) {
|
||||
std::string instance = std::string(DisplayModes::descriptor) + "/default";
|
||||
status = AServiceManager_addService(displayModes->asBinder().get(), instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
if (readingEnhancement->isSupported()) {
|
||||
std::string instance = std::string(ReadingEnhancementExynos::descriptor) + "/default";
|
||||
status = AServiceManager_addService(readingEnhancement->asBinder().get(), instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR)
|
||||
<< "Could not register service for LiveDisplay HAL ReadingEnhancement Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
if (sunlightEnhancement->isSupported()) {
|
||||
std::string instance = std::string(SunlightEnhancementExynos::descriptor) + "/default";
|
||||
status =
|
||||
AServiceManager_addService(sunlightEnhancement->asBinder().get(), instance.c_str());
|
||||
if (status != STATUS_OK) {
|
||||
LOG(ERROR)
|
||||
<< "Could not register service for LiveDisplay HAL SunlightEnhancement Iface ("
|
||||
<< status << ")";
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(INFO) << "LiveDisplay HAL service is ready.";
|
||||
ABinderProcess_joinThreadPool();
|
||||
|
||||
shutdown:
|
||||
// In normal operation, we don't expect the thread pool to shutdown
|
||||
LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
on post-fs-data
|
||||
mkdir /data/vendor/display 0770 system system
|
||||
|
||||
service vendor.livedisplay-hal-samsung-exynos /vendor/bin/hw/vendor.lineage.livedisplay-service.samsung-exynos
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
@@ -0,0 +1,7 @@
|
||||
on post-fs-data
|
||||
mkdir /data/vendor/display 0770 system system
|
||||
|
||||
service vendor.livedisplay-hal-samsung-qcom /vendor/bin/hw/vendor.lineage.livedisplay-service.samsung-qcom
|
||||
class late_start
|
||||
user system
|
||||
group system
|
||||
@@ -38,11 +38,15 @@ uint64_t readNode(const std::string node, pid_t pid) {
|
||||
|
||||
return out;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
uint64_t GpuSysfsReader::getDmaBufGpuMem(pid_t pid) { return readNode(kDmaBufGpuMemNode, pid); }
|
||||
uint64_t GpuSysfsReader::getDmaBufGpuMem(pid_t pid) {
|
||||
return readNode(kDmaBufGpuMemNode, pid);
|
||||
}
|
||||
|
||||
uint64_t GpuSysfsReader::getGpuMemTotal(pid_t pid) { return readNode(kTotalGpuMemNode, pid); }
|
||||
uint64_t GpuSysfsReader::getGpuMemTotal(pid_t pid) {
|
||||
return readNode(kTotalGpuMemNode, pid);
|
||||
}
|
||||
|
||||
uint64_t GpuSysfsReader::getPrivateGpuMem(pid_t pid) {
|
||||
auto dma_buf_size = getDmaBufGpuMem(pid);
|
||||
|
||||
@@ -14,4 +14,4 @@ constexpr char kProcessDir[] = "kprcs";
|
||||
constexpr char kMappedDmaBufsDir[] = "dma_bufs";
|
||||
constexpr char kTotalGpuMemNode[] = "total_gpu_mem";
|
||||
constexpr char kDmaBufGpuMemNode[] = "dma_buf_gpu_mem";
|
||||
} // namespace GpuSysfsReader
|
||||
} // namespace GpuSysfsReader
|
||||
|
||||
@@ -18,22 +18,26 @@ namespace memtrack {
|
||||
|
||||
ndk::ScopedAStatus Memtrack::getMemory(int pid, MemtrackType type,
|
||||
std::vector<MemtrackRecord>* _aidl_return) {
|
||||
if (pid < 0)
|
||||
if (pid < 0) {
|
||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT));
|
||||
}
|
||||
|
||||
if (type != MemtrackType::OTHER && type != MemtrackType::GL && type != MemtrackType::GRAPHICS &&
|
||||
type != MemtrackType::MULTIMEDIA && type != MemtrackType::CAMERA)
|
||||
type != MemtrackType::MULTIMEDIA && type != MemtrackType::CAMERA) {
|
||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
||||
}
|
||||
|
||||
_aidl_return->clear();
|
||||
|
||||
// Other types are retained only for backward compatibility
|
||||
if (type != MemtrackType::GL && type != MemtrackType::GRAPHICS)
|
||||
if (type != MemtrackType::GL && type != MemtrackType::GRAPHICS) {
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
// pid 0 is only supported for GL type to report total private memory
|
||||
if (pid == 0 && type != MemtrackType::GL)
|
||||
if (pid == 0 && type != MemtrackType::GL) {
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
uint64_t size = 0;
|
||||
switch (type) {
|
||||
@@ -73,7 +77,7 @@ ndk::ScopedAStatus Memtrack::getGpuDeviceInfo(std::vector<DeviceInfo>* _aidl_ret
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace memtrack
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace memtrack
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -12,14 +12,14 @@ namespace hardware {
|
||||
namespace memtrack {
|
||||
|
||||
class Memtrack : public BnMemtrack {
|
||||
public:
|
||||
public:
|
||||
ndk::ScopedAStatus getMemory(int pid, MemtrackType type,
|
||||
std::vector<MemtrackRecord>* _aidl_return) override;
|
||||
|
||||
ndk::ScopedAStatus getGpuDeviceInfo(std::vector<DeviceInfo>* _aidl_return) override;
|
||||
};
|
||||
|
||||
} // namespace memtrack
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace memtrack
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -19,16 +19,18 @@ bool exists(const path& p) {
|
||||
|
||||
bool is_directory(const path& p) {
|
||||
struct stat s;
|
||||
if (stat(p.string().c_str(), &s))
|
||||
if (stat(p.string().c_str(), &s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return S_ISDIR(s.st_mode);
|
||||
}
|
||||
|
||||
bool is_symlink(const path& p) {
|
||||
struct stat s;
|
||||
if (lstat(p.string().c_str(), &s))
|
||||
if (lstat(p.string().c_str(), &s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return S_ISLNK(s.st_mode);
|
||||
}
|
||||
@@ -45,8 +47,9 @@ path read_symlink(const path& p) {
|
||||
}
|
||||
|
||||
std::vector<directory_entry> directory_iterator(const path& p) {
|
||||
if (!exists(p) || !is_directory(p))
|
||||
if (!exists(p) || !is_directory(p)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(p.string().c_str()), &closedir);
|
||||
if (!dir) {
|
||||
@@ -56,8 +59,9 @@ std::vector<directory_entry> directory_iterator(const path& p) {
|
||||
std::vector<directory_entry> out;
|
||||
struct dirent* dent;
|
||||
while ((dent = readdir(dir.get()))) {
|
||||
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
|
||||
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::stringstream ss(p.string());
|
||||
ss << "/" << dent->d_name;
|
||||
@@ -67,4 +71,4 @@ std::vector<directory_entry> directory_iterator(const path& p) {
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace filesystem
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
namespace filesystem {
|
||||
class path {
|
||||
public:
|
||||
public:
|
||||
path(const std::string _path) : strPath(_path) {}
|
||||
|
||||
path filename() const {
|
||||
auto pos = strPath.rfind('/');
|
||||
if (pos == std::string::npos)
|
||||
return path(strPath);
|
||||
if (pos == std::string::npos) return path(strPath);
|
||||
|
||||
pos++;
|
||||
auto l = strPath.size();
|
||||
@@ -31,19 +30,17 @@ public:
|
||||
|
||||
std::string string() const { return strPath; }
|
||||
|
||||
private:
|
||||
private:
|
||||
std::string strPath;
|
||||
};
|
||||
|
||||
class directory_entry {
|
||||
public:
|
||||
public:
|
||||
directory_entry(const std::string _path) : p(_path) {}
|
||||
|
||||
class path path() {
|
||||
return p;
|
||||
}
|
||||
class path path() { return p; }
|
||||
|
||||
private:
|
||||
private:
|
||||
class path p;
|
||||
};
|
||||
|
||||
@@ -57,4 +54,4 @@ path read_symlink(const path& p);
|
||||
|
||||
// Vector is easier to create than an iterator and serves our purposes well
|
||||
std::vector<directory_entry> directory_iterator(const path& p);
|
||||
} // namespace filesystem
|
||||
} // namespace filesystem
|
||||
|
||||
@@ -19,5 +19,5 @@ int main() {
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // Unreachable
|
||||
return EXIT_FAILURE; // Unreachable
|
||||
}
|
||||
|
||||
@@ -5,4 +5,3 @@
|
||||
<fqname>IMemtrack/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ cc_binary {
|
||||
proprietary: true,
|
||||
srcs: [
|
||||
"GloveMode.cpp",
|
||||
"HighTouchPollingRate.cpp",
|
||||
"KeyDisabler.cpp",
|
||||
"StylusMode.cpp",
|
||||
"TouchscreenGesture.cpp",
|
||||
|
||||
41
aidl/touch/HighTouchPollingRate.cpp
Normal file
41
aidl/touch/HighTouchPollingRate.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "HighTouchPollingRate.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace touch {
|
||||
|
||||
bool HighTouchPollingRate::isSupported() {
|
||||
return !mHtprCmd.empty();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus HighTouchPollingRate::getEnabled(bool* _aidl_return) {
|
||||
std::ifstream file(TSP_CMD_RESULT_NODE);
|
||||
if (file.is_open()) {
|
||||
std::string line;
|
||||
getline(file, line);
|
||||
*_aidl_return = !line.compare(mHtprCmd + ",1:OK");
|
||||
file.close();
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus HighTouchPollingRate::setEnabled(bool enabled) {
|
||||
std::ofstream file(TSP_CMD_NODE);
|
||||
file << (mHtprCmd + ",") << (enabled ? "1" : "0");
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace touch
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
46
aidl/touch/HighTouchPollingRate.h
Normal file
46
aidl/touch/HighTouchPollingRate.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/touch/BnHighTouchPollingRate.h>
|
||||
#include <samsung_touch.h>
|
||||
#include <fstream>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace touch {
|
||||
|
||||
class HighTouchPollingRate : public BnHighTouchPollingRate {
|
||||
public:
|
||||
HighTouchPollingRate() {
|
||||
std::ifstream file(TSP_CMD_LIST_NODE);
|
||||
if (file.is_open()) {
|
||||
mHtprCmd = "";
|
||||
std::string line;
|
||||
while (getline(file, line)) {
|
||||
if (!line.compare("set_game_mode") || !line.compare("set_scan_rate")) {
|
||||
mHtprCmd = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool isSupported();
|
||||
|
||||
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setEnabled(bool enabled) override;
|
||||
|
||||
private:
|
||||
std::string mHtprCmd;
|
||||
};
|
||||
|
||||
} // namespace touch
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -13,25 +13,47 @@ namespace lineage {
|
||||
namespace touch {
|
||||
|
||||
const std::map<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kGestureInfoMap = {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
{0, {0x2f1, "Swipe up stylus"}},
|
||||
{1, {0x2f2, "Swipe down stylus"}},
|
||||
{2, {0x2f3, "Swipe left stylus"}},
|
||||
{3, {0x2f4, "Swipe right stylus"}},
|
||||
{4, {0x2f5, "Long press stylus"}},
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const std::pair<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kSingleTapEntry = {
|
||||
5, {0x1c7, "Single Tap"}};
|
||||
|
||||
int32_t count = 0;
|
||||
|
||||
bool TouchscreenGesture::isSupported() {
|
||||
std::ifstream file(TOUCHSCREEN_GESTURE_NODE);
|
||||
return file.good();
|
||||
std::ifstream file(TSP_CMD_LIST_NODE);
|
||||
if (file.is_open()) {
|
||||
std::string line;
|
||||
while (getline(file, line)) {
|
||||
if (!line.compare("singletap_enable")) {
|
||||
mIsTspCmdSupported = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
return mHasEpenGestureNode || mIsTspCmdSupported;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus TouchscreenGesture::getSupportedGestures(std::vector<Gesture>* _aidl_return) {
|
||||
std::vector<Gesture> gestures;
|
||||
|
||||
for (const auto& entry : kGestureInfoMap) {
|
||||
gestures.push_back({entry.first, entry.second.name, entry.second.keycode});
|
||||
if (mHasEpenGestureNode) {
|
||||
for (const auto& entry : kGestureInfoMap) {
|
||||
gestures.push_back({count, entry.second.name, entry.second.keycode});
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (mIsTspCmdSupported) {
|
||||
gestures.push_back({count, kSingleTapEntry.second.name, kSingleTapEntry.second.keycode});
|
||||
}
|
||||
|
||||
*_aidl_return = gestures;
|
||||
@@ -39,18 +61,23 @@ ndk::ScopedAStatus TouchscreenGesture::getSupportedGestures(std::vector<Gesture>
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus TouchscreenGesture::setGestureEnabled(const Gesture& gesture, bool enabled) {
|
||||
std::fstream file(TOUCHSCREEN_GESTURE_NODE);
|
||||
int gestureMode;
|
||||
int mask = 1 << gesture.id;
|
||||
if (mIsTspCmdSupported && (gesture.id == count)) {
|
||||
std::fstream file(TSP_CMD_NODE);
|
||||
file << "singletap_enable," << (enabled ? "1" : "0");
|
||||
} else {
|
||||
std::fstream file(EPEN_GESTURE_NODE);
|
||||
int gestureMode;
|
||||
int mask = 1 << gesture.id;
|
||||
|
||||
file >> gestureMode;
|
||||
file >> gestureMode;
|
||||
|
||||
if (enabled)
|
||||
gestureMode |= mask;
|
||||
else
|
||||
gestureMode &= ~mask;
|
||||
if (enabled)
|
||||
gestureMode |= mask;
|
||||
else
|
||||
gestureMode &= ~mask;
|
||||
|
||||
file << gestureMode;
|
||||
file << gestureMode;
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/touch/BnTouchscreenGesture.h>
|
||||
#include <map>
|
||||
#include <samsung_touch.h>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
@@ -27,6 +28,10 @@ class TouchscreenGesture : public BnTouchscreenGesture {
|
||||
const char* name;
|
||||
} GestureInfo;
|
||||
static const std::map<int32_t, GestureInfo> kGestureInfoMap; // id -> info
|
||||
static const std::pair<int32_t, GestureInfo> kSingleTapEntry;
|
||||
|
||||
bool mHasEpenGestureNode = std::ifstream(EPEN_GESTURE_NODE).good();
|
||||
bool mIsTspCmdSupported = false;
|
||||
};
|
||||
|
||||
} // namespace touch
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* device tree.
|
||||
*/
|
||||
|
||||
// For GloveMode and StylusMode
|
||||
// For GloveMode, HighTouchPollingRate and StylusMode
|
||||
#define TSP_CMD_LIST_NODE "/sys/class/sec/tsp/cmd_list"
|
||||
#define TSP_CMD_RESULT_NODE "/sys/class/sec/tsp/cmd_result"
|
||||
#define TSP_CMD_NODE "/sys/class/sec/tsp/cmd"
|
||||
@@ -21,5 +21,5 @@
|
||||
// For KeyDisabler
|
||||
#define KEY_DISABLER_NODE "/sys/class/sec/sec_touchkey/input/enabled"
|
||||
|
||||
//For TouchscreenGesture
|
||||
#define TOUCHSCREEN_GESTURE_NODE "/sys/class/sec/sec_epen/epen_gestures"
|
||||
// For TouchscreenGesture
|
||||
#define EPEN_GESTURE_NODE "/sys/class/sec/sec_epen/epen_gestures"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define LOG_TAG "vendor.lineage.touch-service.samsung"
|
||||
|
||||
#include "GloveMode.h"
|
||||
#include "HighTouchPollingRate.h"
|
||||
#include "KeyDisabler.h"
|
||||
#include "StylusMode.h"
|
||||
#include "TouchscreenGesture.h"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include <android/binder_process.h>
|
||||
|
||||
using aidl::vendor::lineage::touch::GloveMode;
|
||||
using aidl::vendor::lineage::touch::HighTouchPollingRate;
|
||||
using aidl::vendor::lineage::touch::KeyDisabler;
|
||||
using aidl::vendor::lineage::touch::StylusMode;
|
||||
using aidl::vendor::lineage::touch::TouchscreenGesture;
|
||||
@@ -31,6 +33,14 @@ int main() {
|
||||
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << gm_instance << " " << status;
|
||||
}
|
||||
|
||||
std::shared_ptr<HighTouchPollingRate> htpr = ndk::SharedRefBase::make<HighTouchPollingRate>();
|
||||
if (htpr->isSupported()) {
|
||||
const std::string htpr_instance =
|
||||
std::string(HighTouchPollingRate::descriptor) + "/default";
|
||||
status = AServiceManager_addService(htpr->asBinder().get(), htpr_instance.c_str());
|
||||
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << htpr_instance << " " << status;
|
||||
}
|
||||
|
||||
std::shared_ptr<KeyDisabler> kd = ndk::SharedRefBase::make<KeyDisabler>();
|
||||
if (kd->isSupported()) {
|
||||
const std::string kd_instance = std::string(KeyDisabler::descriptor) + "/default";
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
on early-init
|
||||
chown system radio /sys/class/sec/tsp/cmd
|
||||
chmod 0664 /sys/class/sec/tsp/cmd
|
||||
|
||||
service vendor.touch-hal /vendor/bin/hw/vendor.lineage.touch-service.samsung
|
||||
class hal
|
||||
user system
|
||||
|
||||
221
aidl/usb/Usb.cpp
221
aidl/usb/Usb.cpp
@@ -54,18 +54,19 @@ constexpr char kPowerRoleNode[] = "/power_role";
|
||||
// Set by the signal handler to destroy the thread
|
||||
volatile bool destroyThread;
|
||||
|
||||
int32_t readFile(const std::string &filename, std::string *contents) {
|
||||
FILE *fp;
|
||||
int32_t readFile(const std::string& filename, std::string* contents) {
|
||||
FILE* fp;
|
||||
ssize_t read = 0;
|
||||
char *line = NULL;
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
fp = fopen(filename.c_str(), "r");
|
||||
if (fp != NULL) {
|
||||
if ((read = getline(&line, &len, fp)) != -1) {
|
||||
char *pos;
|
||||
if ((pos = strchr(line, '\n')) != NULL)
|
||||
char* pos;
|
||||
if ((pos = strchr(line, '\n')) != NULL) {
|
||||
*pos = '\0';
|
||||
}
|
||||
*contents = line;
|
||||
}
|
||||
free(line);
|
||||
@@ -78,10 +79,11 @@ int32_t readFile(const std::string &filename, std::string *contents) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void queryVersionHelper(android::hardware::usb::Usb *usb,
|
||||
std::vector<PortStatus> *currentPortStatus);
|
||||
void queryVersionHelper(android::hardware::usb::Usb* usb,
|
||||
std::vector<PortStatus>* currentPortStatus);
|
||||
|
||||
ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable, int64_t in_transactionId) {
|
||||
ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable,
|
||||
int64_t in_transactionId) {
|
||||
std::vector<PortStatus> currentPortStatus;
|
||||
bool result = true;
|
||||
|
||||
@@ -93,9 +95,10 @@ ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable, int6
|
||||
|
||||
if (mCallback != NULL) {
|
||||
ScopedAStatus ret = mCallback->notifyEnableUsbDataStatus(
|
||||
in_portName, in_enable, result ? Status::SUCCESS : Status::ERROR, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
in_portName, in_enable, result ? Status::SUCCESS : Status::ERROR, in_transactionId);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("notifyEnableUsbDataStatus error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGE("Not notifying the userspace. Callback is not set");
|
||||
}
|
||||
@@ -106,13 +109,13 @@ ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable, int6
|
||||
}
|
||||
|
||||
ScopedAStatus Usb::enableUsbDataWhileDocked(const string& in_portName, int64_t in_transactionId) {
|
||||
|
||||
pthread_mutex_lock(&mLock);
|
||||
if (mCallback != NULL) {
|
||||
ScopedAStatus ret = mCallback->notifyEnableUsbDataWhileDockedStatus(
|
||||
in_portName, Status::NOT_SUPPORTED, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
in_portName, Status::NOT_SUPPORTED, in_transactionId);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("notifyEnableUsbDataWhileDockedStatus error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGE("Not notifying the userspace. Callback is not set");
|
||||
}
|
||||
@@ -122,13 +125,13 @@ ScopedAStatus Usb::enableUsbDataWhileDocked(const string& in_portName, int64_t i
|
||||
}
|
||||
|
||||
ScopedAStatus Usb::resetUsbPort(const string& in_portName, int64_t in_transactionId) {
|
||||
|
||||
pthread_mutex_lock(&mLock);
|
||||
if (mCallback != NULL) {
|
||||
ScopedAStatus ret = mCallback->notifyResetUsbPortStatus(
|
||||
in_portName, Status::NOT_SUPPORTED, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
ScopedAStatus ret = mCallback->notifyResetUsbPortStatus(in_portName, Status::NOT_SUPPORTED,
|
||||
in_transactionId);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("notifyResetUsbPortStatus error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGE("Not notifying the userspace. Callback is not set");
|
||||
}
|
||||
@@ -137,16 +140,14 @@ ScopedAStatus Usb::resetUsbPort(const string& in_portName, int64_t in_transactio
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus) {
|
||||
Status queryMoistureDetectionStatus(std::vector<PortStatus>* currentPortStatus) {
|
||||
string enabled, status, path, DetectedPath;
|
||||
|
||||
for (int i = 0; i < currentPortStatus->size(); i++) {
|
||||
(*currentPortStatus)[i].supportedContaminantProtectionModes
|
||||
.push_back(ContaminantProtectionMode::NONE);
|
||||
(*currentPortStatus)[i].contaminantProtectionStatus
|
||||
= ContaminantProtectionStatus::NONE;
|
||||
(*currentPortStatus)[i].contaminantDetectionStatus
|
||||
= ContaminantDetectionStatus::DISABLED;
|
||||
(*currentPortStatus)[i].supportedContaminantProtectionModes.push_back(
|
||||
ContaminantProtectionMode::NONE);
|
||||
(*currentPortStatus)[i].contaminantProtectionStatus = ContaminantProtectionStatus::NONE;
|
||||
(*currentPortStatus)[i].contaminantDetectionStatus = ContaminantDetectionStatus::DISABLED;
|
||||
(*currentPortStatus)[i].supportsEnableContaminantPresenceDetection = true;
|
||||
(*currentPortStatus)[i].supportsEnableContaminantPresenceProtection = false;
|
||||
|
||||
@@ -157,23 +158,23 @@ Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus)
|
||||
}
|
||||
if (status == "1") {
|
||||
(*currentPortStatus)[i].contaminantDetectionStatus =
|
||||
ContaminantDetectionStatus::DETECTED;
|
||||
ContaminantDetectionStatus::DETECTED;
|
||||
(*currentPortStatus)[i].contaminantProtectionStatus =
|
||||
ContaminantProtectionStatus::FORCE_SINK;
|
||||
ContaminantProtectionStatus::FORCE_SINK;
|
||||
} else
|
||||
(*currentPortStatus)[i].contaminantDetectionStatus =
|
||||
ContaminantDetectionStatus::NOT_DETECTED;
|
||||
ContaminantDetectionStatus::NOT_DETECTED;
|
||||
}
|
||||
|
||||
ALOGI("ContaminantDetectionStatus[%d]:%hhd ContaminantProtectionStatus[%d]:%hhd",
|
||||
i, (*currentPortStatus)[i].contaminantDetectionStatus,
|
||||
i, (*currentPortStatus)[i].contaminantProtectionStatus);
|
||||
ALOGI("ContaminantDetectionStatus[%d]:%hhd ContaminantProtectionStatus[%d]:%hhd", i,
|
||||
(*currentPortStatus)[i].contaminantDetectionStatus, i,
|
||||
(*currentPortStatus)[i].contaminantProtectionStatus);
|
||||
}
|
||||
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
Status queryNonCompliantChargerStatus(std::vector<PortStatus> *currentPortStatus) {
|
||||
Status queryNonCompliantChargerStatus(std::vector<PortStatus>* currentPortStatus) {
|
||||
string reasons, path;
|
||||
|
||||
for (int i = 0; i < currentPortStatus->size(); i++) {
|
||||
@@ -182,7 +183,7 @@ Status queryNonCompliantChargerStatus(std::vector<PortStatus> *currentPortStatus
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
string appendRoleNodeHelper(const string &portName, PortRole::Tag tag) {
|
||||
string appendRoleNodeHelper(const string& portName, PortRole::Tag tag) {
|
||||
string node(kTypecPath + portName);
|
||||
|
||||
switch (tag) {
|
||||
@@ -204,20 +205,24 @@ string convertRoletoString(PortRole role) {
|
||||
else if (role.get<PortRole::powerRole>() == PortPowerRole::SINK)
|
||||
return "sink";
|
||||
} else if (role.getTag() == PortRole::dataRole) {
|
||||
if (role.get<PortRole::dataRole>() == PortDataRole::HOST)
|
||||
if (role.get<PortRole::dataRole>() == PortDataRole::HOST) {
|
||||
return "host";
|
||||
if (role.get<PortRole::dataRole>() == PortDataRole::DEVICE)
|
||||
}
|
||||
if (role.get<PortRole::dataRole>() == PortDataRole::DEVICE) {
|
||||
return "device";
|
||||
}
|
||||
} else if (role.getTag() == PortRole::mode) {
|
||||
if (role.get<PortRole::mode>() == PortMode::UFP)
|
||||
if (role.get<PortRole::mode>() == PortMode::UFP) {
|
||||
return "sink";
|
||||
if (role.get<PortRole::mode>() == PortMode::DFP)
|
||||
}
|
||||
if (role.get<PortRole::mode>() == PortMode::DFP) {
|
||||
return "source";
|
||||
}
|
||||
}
|
||||
return "none";
|
||||
}
|
||||
|
||||
void extractRole(string *roleName) {
|
||||
void extractRole(string* roleName) {
|
||||
std::size_t first, last;
|
||||
|
||||
first = roleName->find("[");
|
||||
@@ -228,17 +233,18 @@ void extractRole(string *roleName) {
|
||||
}
|
||||
}
|
||||
|
||||
void switchToDrp(const string &portName) {
|
||||
void switchToDrp(const string& portName) {
|
||||
string filename = appendRoleNodeHelper(string(portName.c_str()), PortRole::mode);
|
||||
FILE *fp;
|
||||
FILE* fp;
|
||||
|
||||
if (filename != "") {
|
||||
fp = fopen(filename.c_str(), "w");
|
||||
if (fp != NULL) {
|
||||
int ret = fputs("dual", fp);
|
||||
fclose(fp);
|
||||
if (ret == EOF)
|
||||
if (ret == EOF) {
|
||||
ALOGE("Fatal: Error while switching back to drp");
|
||||
}
|
||||
} else {
|
||||
ALOGE("Fatal: Cannot open file to switch back to drp");
|
||||
}
|
||||
@@ -247,10 +253,10 @@ void switchToDrp(const string &portName) {
|
||||
}
|
||||
}
|
||||
|
||||
bool switchMode(const string &portName, const PortRole &in_role, struct Usb *usb) {
|
||||
bool switchMode(const string& portName, const PortRole& in_role, struct Usb* usb) {
|
||||
string filename = appendRoleNodeHelper(string(portName.c_str()), in_role.getTag());
|
||||
string written;
|
||||
FILE *fp;
|
||||
FILE* fp;
|
||||
bool roleSwitch = false;
|
||||
|
||||
if (filename == "") {
|
||||
@@ -294,8 +300,9 @@ bool switchMode(const string &portName, const PortRole &in_role, struct Usb *usb
|
||||
pthread_mutex_unlock(&usb->mPartnerLock);
|
||||
}
|
||||
|
||||
if (!roleSwitch)
|
||||
if (!roleSwitch) {
|
||||
switchToDrp(string(portName.c_str()));
|
||||
}
|
||||
|
||||
return roleSwitch;
|
||||
}
|
||||
@@ -304,8 +311,7 @@ Usb::Usb()
|
||||
: mLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
mRoleSwitchLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
mPartnerLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
mPartnerUp(false)
|
||||
{
|
||||
mPartnerUp(false) {
|
||||
pthread_condattr_t attr;
|
||||
if (pthread_condattr_init(&attr)) {
|
||||
ALOGE("pthread_condattr_init failed: %s", strerror(errno));
|
||||
@@ -325,11 +331,11 @@ Usb::Usb()
|
||||
}
|
||||
}
|
||||
|
||||
ScopedAStatus Usb::switchRole(const string& in_portName,
|
||||
const PortRole& in_role, int64_t in_transactionId) {
|
||||
ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role,
|
||||
int64_t in_transactionId) {
|
||||
string filename = appendRoleNodeHelper(string(in_portName.c_str()), in_role.getTag());
|
||||
string written;
|
||||
FILE *fp;
|
||||
FILE* fp;
|
||||
bool roleSwitch = false;
|
||||
|
||||
if (filename == "") {
|
||||
@@ -367,10 +373,12 @@ ScopedAStatus Usb::switchRole(const string& in_portName,
|
||||
|
||||
pthread_mutex_lock(&mLock);
|
||||
if (mCallback != NULL) {
|
||||
ScopedAStatus ret = mCallback->notifyRoleSwitchStatus(
|
||||
in_portName, in_role, roleSwitch ? Status::SUCCESS : Status::ERROR, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
ScopedAStatus ret = mCallback->notifyRoleSwitchStatus(
|
||||
in_portName, in_role, roleSwitch ? Status::SUCCESS : Status::ERROR,
|
||||
in_transactionId);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("RoleSwitchStatus error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGE("Not notifying the userspace. Callback is not set");
|
||||
}
|
||||
@@ -381,15 +389,16 @@ ScopedAStatus Usb::switchRole(const string& in_portName,
|
||||
}
|
||||
|
||||
ScopedAStatus Usb::limitPowerTransfer(const string& in_portName, bool /*in_limit*/,
|
||||
int64_t in_transactionId) {
|
||||
int64_t in_transactionId) {
|
||||
std::vector<PortStatus> currentPortStatus;
|
||||
|
||||
pthread_mutex_lock(&mLock);
|
||||
if (mCallback != NULL && in_transactionId >= 0) {
|
||||
ScopedAStatus ret = mCallback->notifyLimitPowerTransferStatus(
|
||||
in_portName, false, Status::NOT_SUPPORTED, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("limitPowerTransfer error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGE("Not notifying the userspace. Callback is not set");
|
||||
}
|
||||
@@ -398,7 +407,7 @@ ScopedAStatus Usb::limitPowerTransfer(const string& in_portName, bool /*in_limit
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Status getAccessoryConnected(const string &portName, string *accessory) {
|
||||
Status getAccessoryConnected(const string& portName, string* accessory) {
|
||||
string filename = kTypecPath + portName + "-partner/accessory_mode";
|
||||
|
||||
if (!ReadFileToString(filename, accessory)) {
|
||||
@@ -410,7 +419,7 @@ Status getAccessoryConnected(const string &portName, string *accessory) {
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
Status getCurrentRoleHelper(const string &portName, bool connected, PortRole *currentRole) {
|
||||
Status getCurrentRoleHelper(const string& portName, bool connected, PortRole* currentRole) {
|
||||
string filename;
|
||||
string roleName;
|
||||
string accessory;
|
||||
@@ -430,8 +439,9 @@ Status getCurrentRoleHelper(const string &portName, bool connected, PortRole *cu
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
if (!connected)
|
||||
if (!connected) {
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
if (currentRole->getTag() == PortRole::mode) {
|
||||
if (getAccessoryConnected(portName, &accessory) != Status::SUCCESS) {
|
||||
@@ -478,18 +488,18 @@ Status getCurrentRoleHelper(const string &portName, bool connected, PortRole *cu
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
Status getTypeCPortNamesHelper(std::unordered_map<string, bool> *names) {
|
||||
DIR *dp;
|
||||
Status getTypeCPortNamesHelper(std::unordered_map<string, bool>* names) {
|
||||
DIR* dp;
|
||||
|
||||
dp = opendir(kTypecPath);
|
||||
if (dp != NULL) {
|
||||
struct dirent *ep;
|
||||
struct dirent* ep;
|
||||
|
||||
while ((ep = readdir(dp))) {
|
||||
if (ep->d_type == DT_LNK) {
|
||||
if (string::npos == string(ep->d_name).find("-partner")) {
|
||||
std::unordered_map<string, bool>::const_iterator portName =
|
||||
names->find(ep->d_name);
|
||||
names->find(ep->d_name);
|
||||
if (portName == names->end()) {
|
||||
names->insert({ep->d_name, false});
|
||||
}
|
||||
@@ -506,7 +516,7 @@ Status getTypeCPortNamesHelper(std::unordered_map<string, bool> *names) {
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
bool canSwitchRoleHelper(const string &portName) {
|
||||
bool canSwitchRoleHelper(const string& portName) {
|
||||
string filename = kTypecPath + portName + "-partner/supports_usb_power_delivery";
|
||||
string supportsPD;
|
||||
|
||||
@@ -520,7 +530,7 @@ bool canSwitchRoleHelper(const string &portName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Status getPortStatusHelper(std::vector<PortStatus> *currentPortStatus) {
|
||||
Status getPortStatusHelper(std::vector<PortStatus>* currentPortStatus) {
|
||||
std::unordered_map<string, bool> names;
|
||||
Status result = getTypeCPortNamesHelper(&names);
|
||||
int i = -1;
|
||||
@@ -534,7 +544,7 @@ Status getPortStatusHelper(std::vector<PortStatus> *currentPortStatus) {
|
||||
|
||||
PortRole currentRole;
|
||||
currentRole.set<PortRole::powerRole>(PortPowerRole::NONE);
|
||||
if (getCurrentRoleHelper(port.first, port.second, ¤tRole) == Status::SUCCESS){
|
||||
if (getCurrentRoleHelper(port.first, port.second, ¤tRole) == Status::SUCCESS) {
|
||||
(*currentPortStatus)[i].currentPowerRole = currentRole.get<PortRole::powerRole>();
|
||||
} else {
|
||||
ALOGE("Error while retrieving portNames");
|
||||
@@ -559,9 +569,9 @@ Status getPortStatusHelper(std::vector<PortStatus> *currentPortStatus) {
|
||||
|
||||
(*currentPortStatus)[i].canChangeMode = true;
|
||||
(*currentPortStatus)[i].canChangeDataRole =
|
||||
port.second ? canSwitchRoleHelper(port.first) : false;
|
||||
port.second ? canSwitchRoleHelper(port.first) : false;
|
||||
(*currentPortStatus)[i].canChangePowerRole =
|
||||
port.second ? canSwitchRoleHelper(port.first) : false;
|
||||
port.second ? canSwitchRoleHelper(port.first) : false;
|
||||
|
||||
(*currentPortStatus)[i].supportedModes.push_back(PortMode::DRP);
|
||||
|
||||
@@ -590,18 +600,18 @@ done:
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
void queryVersionHelper(android::hardware::usb::Usb *usb,
|
||||
std::vector<PortStatus> *currentPortStatus) {
|
||||
void queryVersionHelper(android::hardware::usb::Usb* usb,
|
||||
std::vector<PortStatus>* currentPortStatus) {
|
||||
Status status;
|
||||
pthread_mutex_lock(&usb->mLock);
|
||||
status = getPortStatusHelper(currentPortStatus);
|
||||
queryMoistureDetectionStatus(currentPortStatus);
|
||||
queryNonCompliantChargerStatus(currentPortStatus);
|
||||
if (usb->mCallback != NULL) {
|
||||
ScopedAStatus ret = usb->mCallback->notifyPortStatusChange(*currentPortStatus,
|
||||
status);
|
||||
if (!ret.isOk())
|
||||
ScopedAStatus ret = usb->mCallback->notifyPortStatusChange(*currentPortStatus, status);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("queryPortStatus error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGI("Notifying userspace skipped. Callback is NULL");
|
||||
}
|
||||
@@ -614,10 +624,11 @@ ScopedAStatus Usb::queryPortStatus(int64_t in_transactionId) {
|
||||
queryVersionHelper(this, ¤tPortStatus);
|
||||
pthread_mutex_lock(&mLock);
|
||||
if (mCallback != NULL) {
|
||||
ScopedAStatus ret = mCallback->notifyQueryPortStatus(
|
||||
"all", Status::SUCCESS, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
ScopedAStatus ret =
|
||||
mCallback->notifyQueryPortStatus("all", Status::SUCCESS, in_transactionId);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("notifyQueryPortStatus error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGE("Not notifying the userspace. Callback is not set");
|
||||
}
|
||||
@@ -627,16 +638,18 @@ ScopedAStatus Usb::queryPortStatus(int64_t in_transactionId) {
|
||||
}
|
||||
|
||||
ScopedAStatus Usb::enableContaminantPresenceDetection(const string& in_portName,
|
||||
bool /* in_enable */, int64_t in_transactionId) {
|
||||
bool /* in_enable */,
|
||||
int64_t in_transactionId) {
|
||||
std::vector<PortStatus> currentPortStatus;
|
||||
std::string disable = GetProperty(DISABLE_CONTAMINANT_DETECTION, "");
|
||||
|
||||
pthread_mutex_lock(&mLock);
|
||||
if (mCallback != NULL) {
|
||||
ScopedAStatus ret = mCallback->notifyContaminantEnabledStatus(
|
||||
in_portName, true, Status::SUCCESS, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
in_portName, true, Status::SUCCESS, in_transactionId);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("enableContaminantPresenceDetection error %s", ret.getDescription().c_str());
|
||||
}
|
||||
} else {
|
||||
ALOGE("Not notifying the userspace. Callback is not set");
|
||||
}
|
||||
@@ -646,22 +659,24 @@ ScopedAStatus Usb::enableContaminantPresenceDetection(const string& in_portName,
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
||||
struct data {
|
||||
int uevent_fd;
|
||||
::aidl::android::hardware::usb::Usb *usb;
|
||||
::aidl::android::hardware::usb::Usb* usb;
|
||||
};
|
||||
|
||||
static void uevent_event(uint32_t /*epevents*/, struct data *payload) {
|
||||
static void uevent_event(uint32_t /*epevents*/, struct data* payload) {
|
||||
char msg[UEVENT_MSG_LEN + 2];
|
||||
char *cp;
|
||||
char* cp;
|
||||
int n;
|
||||
|
||||
n = uevent_kernel_multicast_recv(payload->uevent_fd, msg, UEVENT_MSG_LEN);
|
||||
if (n <= 0)
|
||||
if (n <= 0) {
|
||||
return;
|
||||
if (n >= UEVENT_MSG_LEN) /* overflow -- discard */
|
||||
}
|
||||
if (n >= UEVENT_MSG_LEN) {
|
||||
// overflow -- discard
|
||||
return;
|
||||
}
|
||||
|
||||
msg[n] = '\0';
|
||||
msg[n + 1] = '\0';
|
||||
@@ -683,10 +698,10 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) {
|
||||
// Role switch is not in progress and port is in disconnected state
|
||||
if (!pthread_mutex_trylock(&payload->usb->mRoleSwitchLock)) {
|
||||
for (unsigned long i = 0; i < currentPortStatus.size(); i++) {
|
||||
DIR *dp =
|
||||
opendir(string(kTypecPath +
|
||||
string(currentPortStatus[i].portName.c_str()) +
|
||||
"-partner").c_str());
|
||||
DIR* dp = opendir(string(kTypecPath +
|
||||
string(currentPortStatus[i].portName.c_str()) +
|
||||
"-partner")
|
||||
.c_str());
|
||||
if (dp == NULL) {
|
||||
switchToDrp(currentPortStatus[i].portName);
|
||||
} else {
|
||||
@@ -702,7 +717,7 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) {
|
||||
}
|
||||
}
|
||||
|
||||
void *work(void *param) {
|
||||
void* work(void* param) {
|
||||
int epoll_fd, uevent_fd;
|
||||
struct epoll_event ev;
|
||||
int nevents = 0;
|
||||
@@ -716,12 +731,12 @@ void *work(void *param) {
|
||||
}
|
||||
|
||||
payload.uevent_fd = uevent_fd;
|
||||
payload.usb = (::aidl::android::hardware::usb::Usb *)param;
|
||||
payload.usb = (::aidl::android::hardware::usb::Usb*)param;
|
||||
|
||||
fcntl(uevent_fd, F_SETFL, O_NONBLOCK);
|
||||
|
||||
ev.events = EPOLLIN;
|
||||
ev.data.ptr = (void *)uevent_event;
|
||||
ev.data.ptr = (void*)uevent_event;
|
||||
|
||||
epoll_fd = epoll_create(UEVENT_MAX_EVENTS);
|
||||
if (epoll_fd == -1) {
|
||||
@@ -739,16 +754,18 @@ void *work(void *param) {
|
||||
|
||||
nevents = epoll_wait(epoll_fd, events, UEVENT_MAX_EVENTS, -1);
|
||||
if (nevents == -1) {
|
||||
if (errno == EINTR)
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
ALOGE("usb epoll_wait failed; errno=%d", errno);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int n = 0; n < nevents; ++n) {
|
||||
if (events[n].data.ptr)
|
||||
(*(void (*)(int, struct data *payload))events[n].data.ptr)(events[n].events,
|
||||
if (events[n].data.ptr) {
|
||||
(*(void (*)(int, struct data* payload))events[n].data.ptr)(events[n].events,
|
||||
&payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,8 +773,9 @@ void *work(void *param) {
|
||||
error:
|
||||
close(uevent_fd);
|
||||
|
||||
if (epoll_fd >= 0)
|
||||
if (epoll_fd >= 0) {
|
||||
close(epoll_fd);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -771,12 +789,9 @@ void sighandler(int sig) {
|
||||
signal(SIGUSR1, sighandler);
|
||||
}
|
||||
|
||||
ScopedAStatus Usb::setCallback(
|
||||
const shared_ptr<IUsbCallback>& in_callback) {
|
||||
|
||||
ScopedAStatus Usb::setCallback(const shared_ptr<IUsbCallback>& in_callback) {
|
||||
pthread_mutex_lock(&mLock);
|
||||
if ((mCallback == NULL && in_callback == NULL) ||
|
||||
(mCallback != NULL && in_callback != NULL)) {
|
||||
if ((mCallback == NULL && in_callback == NULL) || (mCallback != NULL && in_callback != NULL)) {
|
||||
mCallback = in_callback;
|
||||
pthread_mutex_unlock(&mLock);
|
||||
return ScopedAStatus::ok();
|
||||
@@ -786,7 +801,7 @@ ScopedAStatus Usb::setCallback(
|
||||
ALOGI("registering callback");
|
||||
|
||||
if (mCallback == NULL) {
|
||||
if (!pthread_kill(mPoll, SIGUSR1)) {
|
||||
if (!pthread_kill(mPoll, SIGUSR1)) {
|
||||
pthread_join(mPoll, NULL);
|
||||
ALOGI("pthread destroyed");
|
||||
}
|
||||
@@ -810,7 +825,7 @@ ScopedAStatus Usb::setCallback(
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // aidl
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <aidl/android/hardware/usb/BnUsb.h>
|
||||
#include <aidl/android/hardware/usb/BnUsbCallback.h>
|
||||
#include <android-base/file.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#define UEVENT_MSG_LEN 2048
|
||||
#define UEVENT_MAX_EVENTS 64
|
||||
#define UEVENT_MSG_LEN 2048
|
||||
#define UEVENT_MAX_EVENTS 64
|
||||
// The type-c stack waits for 4.5 - 5.5 secs before declaring a port non-pd.
|
||||
// The -partner directory would not be created until this is done.
|
||||
// Having a margin of ~3 secs for the directory and other related bookeeping
|
||||
@@ -40,9 +40,9 @@ namespace usb {
|
||||
|
||||
using ::aidl::android::hardware::usb::IUsbCallback;
|
||||
using ::aidl::android::hardware::usb::PortRole;
|
||||
using ::android::sp;
|
||||
using ::android::base::ReadFileToString;
|
||||
using ::android::base::WriteStringToFile;
|
||||
using ::android::sp;
|
||||
using ::ndk::ScopedAStatus;
|
||||
using ::std::shared_ptr;
|
||||
using ::std::string;
|
||||
@@ -50,20 +50,19 @@ using ::std::string;
|
||||
struct Usb : public BnUsb {
|
||||
Usb();
|
||||
|
||||
ScopedAStatus enableContaminantPresenceDetection(const std::string& in_portName,
|
||||
bool in_enable, int64_t in_transactionId) override;
|
||||
ScopedAStatus enableContaminantPresenceDetection(const std::string& in_portName, bool in_enable,
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus queryPortStatus(int64_t in_transactionId) override;
|
||||
ScopedAStatus setCallback(const shared_ptr<IUsbCallback>& in_callback) override;
|
||||
ScopedAStatus switchRole(const string& in_portName, const PortRole& in_role,
|
||||
int64_t in_transactionId) override;
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus enableUsbData(const string& in_portName, bool in_enable,
|
||||
int64_t in_transactionId) override;
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus enableUsbDataWhileDocked(const string& in_portName,
|
||||
int64_t in_transactionId) override;
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus limitPowerTransfer(const std::string& in_portName, bool in_limit,
|
||||
int64_t in_transactionId)override;
|
||||
ScopedAStatus resetUsbPort(const std::string& in_portName,
|
||||
int64_t in_transactionId)override;
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus resetUsbPort(const std::string& in_portName, int64_t in_transactionId) override;
|
||||
|
||||
shared_ptr<IUsbCallback> mCallback;
|
||||
// Protects mCallback variable
|
||||
@@ -76,11 +75,12 @@ struct Usb : public BnUsb {
|
||||
pthread_mutex_t mPartnerLock;
|
||||
// Variable to signal partner coming back online after type switch
|
||||
bool mPartnerUp;
|
||||
|
||||
private:
|
||||
pthread_t mPoll;
|
||||
};
|
||||
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // aidl
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (C) 2021 The Android Open Source Project
|
||||
// Copyright (C) 2024 The LineageOS Project
|
||||
// Copyright (C) 2024-2026 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.
|
||||
@@ -14,26 +14,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
soong_config_module_type {
|
||||
name: "gadget_name",
|
||||
module_type: "cc_defaults",
|
||||
config_namespace: "samsungUsbGadgetVars",
|
||||
value_variables: ["gadget_name"],
|
||||
properties: ["cppflags"],
|
||||
}
|
||||
|
||||
gadget_name {
|
||||
name: "gadget_name_defaults",
|
||||
soong_config_variables: {
|
||||
gadget_name: {
|
||||
cppflags: ["-DGADGET_NAME=\"%s\""],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.usb.gadget-service.samsung",
|
||||
defaults: ["gadget_name_defaults"],
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.usb.gadget-service.samsung.rc"],
|
||||
vintf_fragments: [
|
||||
@@ -44,10 +26,13 @@ cc_binary {
|
||||
"service_gadget.cpp",
|
||||
"UsbGadget.cpp",
|
||||
],
|
||||
cflags: [
|
||||
cppflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
],
|
||||
] + select(soong_config_variable("samsungUsbGadgetVars", "gadget_name"), {
|
||||
any @ flag_val: ["-DGADGET_NAME=\"" + flag_val + "\""],
|
||||
default: [],
|
||||
}),
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"liblog",
|
||||
|
||||
@@ -49,25 +49,25 @@ UsbGadget::UsbGadget() {
|
||||
}
|
||||
}
|
||||
|
||||
void currentFunctionsAppliedCallback(bool functionsApplied, void *payload) {
|
||||
UsbGadget *gadget = (UsbGadget *)payload;
|
||||
void currentFunctionsAppliedCallback(bool functionsApplied, void* payload) {
|
||||
UsbGadget* gadget = (UsbGadget*)payload;
|
||||
gadget->mCurrentUsbFunctionsApplied = functionsApplied;
|
||||
}
|
||||
|
||||
ScopedAStatus UsbGadget::getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t in_transactionId) {
|
||||
ScopedAStatus UsbGadget::getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t in_transactionId) {
|
||||
ScopedAStatus ret = callback->getCurrentUsbFunctionsCb(
|
||||
mCurrentUsbFunctions,
|
||||
mCurrentUsbFunctionsApplied ? Status::FUNCTIONS_APPLIED : Status::FUNCTIONS_NOT_APPLIED,
|
||||
in_transactionId);
|
||||
mCurrentUsbFunctions,
|
||||
mCurrentUsbFunctionsApplied ? Status::FUNCTIONS_APPLIED : Status::FUNCTIONS_NOT_APPLIED,
|
||||
in_transactionId);
|
||||
if (!ret.isOk())
|
||||
ALOGE("Call to getCurrentUsbFunctionsCb failed %s", ret.getDescription().c_str());
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus UsbGadget::getUsbSpeed(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t in_transactionId) {
|
||||
ScopedAStatus UsbGadget::getUsbSpeed(const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t in_transactionId) {
|
||||
std::string current_speed;
|
||||
if (ReadFileToString(SPEED_PATH, ¤t_speed)) {
|
||||
current_speed = Trim(current_speed);
|
||||
@@ -94,15 +94,16 @@ ScopedAStatus UsbGadget::getUsbSpeed(const shared_ptr<IUsbGadgetCallback> &callb
|
||||
if (callback) {
|
||||
ScopedAStatus ret = callback->getUsbSpeedCb(mUsbSpeed, in_transactionId);
|
||||
|
||||
if (!ret.isOk())
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("Call to getUsbSpeedCb failed %s", ret.getDescription().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Status UsbGadget::tearDownGadget() {
|
||||
if (Status(resetGadget()) != Status::SUCCESS){
|
||||
if (Status(resetGadget()) != Status::SUCCESS) {
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
@@ -123,8 +124,7 @@ static Status validateAndSetVidPid(int64_t functions) {
|
||||
vid = "0x04E8";
|
||||
pid = "0x6860";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::MTP:
|
||||
case GadgetFunction::ADB | GadgetFunction::MTP:
|
||||
vid = "0x04E8";
|
||||
pid = "0x6860";
|
||||
break;
|
||||
@@ -132,8 +132,7 @@ static Status validateAndSetVidPid(int64_t functions) {
|
||||
vid = "0x04E8";
|
||||
pid = "0x6863";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::RNDIS:
|
||||
case GadgetFunction::ADB | GadgetFunction::RNDIS:
|
||||
vid = "0x04E8";
|
||||
pid = "0x6864";
|
||||
break;
|
||||
@@ -141,8 +140,7 @@ static Status validateAndSetVidPid(int64_t functions) {
|
||||
vid = "0x04E8";
|
||||
pid = "0x6865";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::PTP:
|
||||
case GadgetFunction::ADB | GadgetFunction::PTP:
|
||||
vid = "0x04E8";
|
||||
pid = "0x6865";
|
||||
break;
|
||||
@@ -154,8 +152,7 @@ static Status validateAndSetVidPid(int64_t functions) {
|
||||
vid = "0x04E8";
|
||||
pid = "0x686C";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::MIDI:
|
||||
case GadgetFunction::ADB | GadgetFunction::MIDI:
|
||||
vid = "0x04E8";
|
||||
pid = "0x686C";
|
||||
break;
|
||||
@@ -163,8 +160,7 @@ static Status validateAndSetVidPid(int64_t functions) {
|
||||
vid = "0x18D1";
|
||||
pid = "0x2D00";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::ACCESSORY:
|
||||
case GadgetFunction::ADB | GadgetFunction::ACCESSORY:
|
||||
vid = "0x18d1";
|
||||
pid = "0x2d01";
|
||||
break;
|
||||
@@ -172,19 +168,15 @@ static Status validateAndSetVidPid(int64_t functions) {
|
||||
vid = "0x18D1";
|
||||
pid = "0x2D02";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::AUDIO_SOURCE:
|
||||
case GadgetFunction::ADB | GadgetFunction::AUDIO_SOURCE:
|
||||
vid = "0x18D1";
|
||||
pid = "0x2D03";
|
||||
break;
|
||||
case GadgetFunction::ACCESSORY |
|
||||
GadgetFunction::AUDIO_SOURCE:
|
||||
case GadgetFunction::ACCESSORY | GadgetFunction::AUDIO_SOURCE:
|
||||
vid = "0x18D1";
|
||||
pid = "0x2D04";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::ACCESSORY |
|
||||
GadgetFunction::AUDIO_SOURCE:
|
||||
case GadgetFunction::ADB | GadgetFunction::ACCESSORY | GadgetFunction::AUDIO_SOURCE:
|
||||
vid = "0x18D1";
|
||||
pid = "0x2D05";
|
||||
break;
|
||||
@@ -192,8 +184,7 @@ static Status validateAndSetVidPid(int64_t functions) {
|
||||
vid = "0x04E8";
|
||||
pid = "0x685D";
|
||||
break;
|
||||
case GadgetFunction::ADB |
|
||||
GadgetFunction::NCM:
|
||||
case GadgetFunction::ADB | GadgetFunction::NCM:
|
||||
vid = "0x04E8";
|
||||
pid = "0x685D";
|
||||
break;
|
||||
@@ -226,62 +217,68 @@ error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
ScopedAStatus UsbGadget::reset(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t in_transactionId) {
|
||||
ScopedAStatus UsbGadget::reset(const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t in_transactionId) {
|
||||
ALOGI("USB Gadget reset");
|
||||
|
||||
if (!WriteStringToFile("none", PULLUP_PATH)) {
|
||||
ALOGI("Gadget cannot be pulled down");
|
||||
if (callback)
|
||||
if (callback) {
|
||||
callback->resetCb(Status::ERROR, in_transactionId);
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
-1, "Gadget cannot be pulled down");
|
||||
}
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(-1,
|
||||
"Gadget cannot be pulled down");
|
||||
}
|
||||
|
||||
usleep(kDisconnectWaitUs);
|
||||
|
||||
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
|
||||
ALOGI("Gadget cannot be pulled up");
|
||||
if (callback)
|
||||
if (callback) {
|
||||
callback->resetCb(Status::ERROR, in_transactionId);
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
-1, "Gadget cannot be pulled up");
|
||||
}
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(-1, "Gadget cannot be pulled up");
|
||||
}
|
||||
if (callback)
|
||||
if (callback) {
|
||||
callback->resetCb(Status::SUCCESS, in_transactionId);
|
||||
}
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Status UsbGadget::setupFunctions(long functions,
|
||||
const shared_ptr<IUsbGadgetCallback> &callback, uint64_t timeout,
|
||||
int64_t in_transactionId) {
|
||||
Status UsbGadget::setupFunctions(long functions, const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
uint64_t timeout, int64_t in_transactionId) {
|
||||
bool ffsEnabled = false;
|
||||
int i = 0;
|
||||
|
||||
if (Status(addGenericAndroidFunctions(&monitorFfs, functions, &ffsEnabled, &i)) !=
|
||||
Status::SUCCESS)
|
||||
Status::SUCCESS) {
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
if ((functions & GadgetFunction::ADB) != 0) {
|
||||
ffsEnabled = true;
|
||||
if (Status(addAdb(&monitorFfs, &i)) != Status::SUCCESS)
|
||||
if (Status(addAdb(&monitorFfs, &i)) != Status::SUCCESS) {
|
||||
return Status::ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if ((functions & GadgetFunction::NCM) != 0) {
|
||||
ALOGI("setCurrentUsbFunctions ncm");
|
||||
if (linkFunction("ncm.gs9", i++))
|
||||
if (linkFunction("ncm.gs9", i++)) {
|
||||
return Status::ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// Pull up the gadget right away when there are no ffs functions.
|
||||
if (!ffsEnabled) {
|
||||
if (!WriteStringToFile(kGadgetName, PULLUP_PATH))
|
||||
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
|
||||
return Status::ERROR;
|
||||
}
|
||||
mCurrentUsbFunctionsApplied = true;
|
||||
if (callback)
|
||||
if (callback) {
|
||||
callback->setCurrentUsbFunctionsCb(functions, Status::SUCCESS, in_transactionId);
|
||||
}
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -291,13 +288,14 @@ Status UsbGadget::setupFunctions(long functions,
|
||||
// dies and restarts.
|
||||
monitorFfs.startMonitor();
|
||||
|
||||
if (kDebug)
|
||||
if (kDebug) {
|
||||
ALOGI("Mainthread in Cv");
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
bool pullup = monitorFfs.waitForPullUp(timeout);
|
||||
ScopedAStatus ret = callback->setCurrentUsbFunctionsCb(
|
||||
functions, pullup ? Status::SUCCESS : Status::ERROR, in_transactionId);
|
||||
functions, pullup ? Status::SUCCESS : Status::ERROR, in_transactionId);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("setCurrentUsbFunctionsCb error %s", ret.getDescription().c_str());
|
||||
return Status::ERROR;
|
||||
@@ -306,11 +304,9 @@ Status UsbGadget::setupFunctions(long functions,
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ScopedAStatus UsbGadget::setCurrentUsbFunctions(long functions,
|
||||
const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t timeout,
|
||||
int64_t in_transactionId) {
|
||||
const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t timeout, int64_t in_transactionId) {
|
||||
std::unique_lock<std::mutex> lk(mLockSetCurrentFunction);
|
||||
std::string current_usb_power_operation_mode, current_usb_type;
|
||||
std::string usb_limit_sink_enable;
|
||||
@@ -330,12 +326,13 @@ ScopedAStatus UsbGadget::setCurrentUsbFunctions(long functions,
|
||||
usleep(kDisconnectWaitUs);
|
||||
|
||||
if (functions == GadgetFunction::NONE) {
|
||||
if (callback == NULL)
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
-1, "callback == NULL");
|
||||
if (callback == NULL) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(-1, "callback == NULL");
|
||||
}
|
||||
ScopedAStatus ret = callback->setCurrentUsbFunctionsCb(functions, status, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("Error while calling setCurrentUsbFunctionsCb %s", ret.getDescription().c_str());
|
||||
}
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
-1, "Error while calling setCurrentUsbFunctionsCb");
|
||||
}
|
||||
@@ -356,17 +353,19 @@ ScopedAStatus UsbGadget::setCurrentUsbFunctions(long functions,
|
||||
|
||||
error:
|
||||
ALOGI("Usb Gadget setcurrent functions failed");
|
||||
if (callback == NULL)
|
||||
if (callback == NULL) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
-1, "Usb Gadget setcurrent functions failed");
|
||||
}
|
||||
ScopedAStatus ret = callback->setCurrentUsbFunctionsCb(functions, status, in_transactionId);
|
||||
if (!ret.isOk())
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("Error while calling setCurrentUsbFunctionsCb %s", ret.getDescription().c_str());
|
||||
}
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
-1, "Error while calling setCurrentUsbFunctionsCb");
|
||||
-1, "Error while calling setCurrentUsbFunctionsCb");
|
||||
}
|
||||
} // namespace gadget
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // aidl
|
||||
} // namespace aidl
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <aidl/android/hardware/usb/gadget/BnUsbGadget.h>
|
||||
#include <aidl/android/hardware/usb/gadget/BnUsbGadgetCallback.h>
|
||||
#include <aidl/android/hardware/usb/gadget/GadgetFunction.h>
|
||||
#include <aidl/android/hardware/usb/gadget/IUsbGadget.h>
|
||||
#include <aidl/android/hardware/usb/gadget/IUsbGadgetCallback.h>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <pixelusb/UsbGadgetAidlCommon.h>
|
||||
#include <sched.h>
|
||||
#include <sys/epoll.h>
|
||||
@@ -44,15 +44,15 @@ namespace usb {
|
||||
namespace gadget {
|
||||
|
||||
using ::aidl::android::hardware::usb::gadget::GadgetFunction;
|
||||
using ::aidl::android::hardware::usb::gadget::IUsbGadgetCallback;
|
||||
using ::aidl::android::hardware::usb::gadget::IUsbGadget;
|
||||
using ::aidl::android::hardware::usb::gadget::IUsbGadgetCallback;
|
||||
using ::aidl::android::hardware::usb::gadget::Status;
|
||||
using ::aidl::android::hardware::usb::gadget::UsbSpeed;
|
||||
using ::android::base::GetProperty;
|
||||
using ::android::base::SetProperty;
|
||||
using ::android::base::unique_fd;
|
||||
using ::android::base::ReadFileToString;
|
||||
using ::android::base::SetProperty;
|
||||
using ::android::base::Trim;
|
||||
using ::android::base::unique_fd;
|
||||
using ::android::base::WriteStringToFile;
|
||||
using ::android::hardware::google::pixel::usb::addAdb;
|
||||
using ::android::hardware::google::pixel::usb::addEpollFd;
|
||||
@@ -86,28 +86,28 @@ struct UsbGadget : public BnUsbGadget {
|
||||
UsbSpeed mUsbSpeed;
|
||||
|
||||
ScopedAStatus setCurrentUsbFunctions(long functions,
|
||||
const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t timeout, int64_t in_transactionId) override;
|
||||
const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t timeout, int64_t in_transactionId) override;
|
||||
|
||||
ScopedAStatus getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t in_transactionId) override;
|
||||
|
||||
ScopedAStatus reset(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus reset(const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t in_transactionId) override;
|
||||
|
||||
ScopedAStatus getUsbSpeed(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
int64_t in_transactionId) override;
|
||||
ScopedAStatus getUsbSpeed(const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
int64_t in_transactionId) override;
|
||||
|
||||
ScopedAStatus setVidPid(const char *vid,const char *pid);
|
||||
ScopedAStatus setVidPid(const char* vid, const char* pid);
|
||||
|
||||
private:
|
||||
Status tearDownGadget();
|
||||
Status setupFunctions(long functions, const shared_ptr<IUsbGadgetCallback> &callback,
|
||||
uint64_t timeout, int64_t in_transactionId);
|
||||
Status setupFunctions(long functions, const shared_ptr<IUsbGadgetCallback>& callback,
|
||||
uint64_t timeout, int64_t in_transactionId);
|
||||
};
|
||||
|
||||
} // namespace gadget
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // aidl
|
||||
} // namespace aidl
|
||||
|
||||
@@ -34,10 +34,11 @@ int main() {
|
||||
std::shared_ptr<UsbGadget> usbgadget = ndk::SharedRefBase::make<UsbGadget>();
|
||||
|
||||
const std::string instance = std::string() + UsbGadget::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(usbgadget->asBinder().get(), instance.c_str());
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(usbgadget->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ALOGV("AIDL USB Gadget HAL about to start");
|
||||
ABinderProcess_joinThreadPool();
|
||||
return -1; // Should never be reached
|
||||
return -1; // Should never be reached
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ int main() {
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return -1; // Should never be reached
|
||||
return -1; // Should never be reached
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <fcntl.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@@ -26,28 +26,23 @@ namespace vibrator {
|
||||
const std::string kVibratorPropPrefix = "ro.vendor.vibrator_hal.";
|
||||
const std::string kVibratorPropDuration = "_duration";
|
||||
|
||||
static std::map<Effect, int> CP_TRIGGER_EFFECTS {
|
||||
{ Effect::CLICK, 10 },
|
||||
{ Effect::DOUBLE_CLICK, 14 },
|
||||
{ Effect::HEAVY_CLICK, 23 },
|
||||
{ Effect::TEXTURE_TICK, 50 },
|
||||
{ Effect::TICK, 50 }
|
||||
};
|
||||
static std::map<Effect, int> CP_TRIGGER_EFFECTS{{Effect::CLICK, 10},
|
||||
{Effect::DOUBLE_CLICK, 14},
|
||||
{Effect::HEAVY_CLICK, 23},
|
||||
{Effect::TEXTURE_TICK, 50},
|
||||
{Effect::TICK, 50}};
|
||||
|
||||
static std::map<Effect, short> FF_EFFECT_IDS {
|
||||
{ Effect::CLICK, 1 },
|
||||
{ Effect::DOUBLE_CLICK, 5 },
|
||||
{ Effect::TICK, 41 },
|
||||
{ Effect::HEAVY_CLICK, 14 },
|
||||
{ Effect::TEXTURE_TICK, 41 }
|
||||
};
|
||||
static std::map<Effect, short> FF_EFFECT_IDS{{Effect::CLICK, 1},
|
||||
{Effect::DOUBLE_CLICK, 5},
|
||||
{Effect::TICK, 41},
|
||||
{Effect::HEAVY_CLICK, 14},
|
||||
{Effect::TEXTURE_TICK, 41}};
|
||||
|
||||
#ifdef VIBRATOR_SUPPORTS_DURATION_AMPLITUDE_CONTROL
|
||||
static std::map<EffectStrength, float> DURATION_AMPLITUDE = {
|
||||
{ EffectStrength::LIGHT, DURATION_AMPLITUDE_LIGHT },
|
||||
{ EffectStrength::MEDIUM, DURATION_AMPLITUDE_MEDIUM },
|
||||
{ EffectStrength::STRONG, DURATION_AMPLITUDE_STRONG }
|
||||
};
|
||||
{EffectStrength::LIGHT, DURATION_AMPLITUDE_LIGHT},
|
||||
{EffectStrength::MEDIUM, DURATION_AMPLITUDE_MEDIUM},
|
||||
{EffectStrength::STRONG, DURATION_AMPLITUDE_STRONG}};
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -84,7 +79,7 @@ static int getIntProperty(const std::string& key, int def) {
|
||||
Vibrator::Vibrator() {
|
||||
mIsTimedOutVibrator = nodeExists(VIBRATOR_TIMEOUT_PATH);
|
||||
if (!mIsTimedOutVibrator) {
|
||||
for (const auto &file : std::filesystem::directory_iterator("/dev/input")) {
|
||||
for (const auto& file : std::filesystem::directory_iterator("/dev/input")) {
|
||||
auto fd = open(file.path().c_str(), O_RDWR);
|
||||
if (fd != -1) {
|
||||
char name[32];
|
||||
@@ -92,6 +87,7 @@ Vibrator::Vibrator() {
|
||||
if (strcmp("sec_vibrator_inputff", name) == 0) {
|
||||
mVibratorFd = fd;
|
||||
mIsForceFeedbackVibrator = true;
|
||||
writeNode("/sys/class/sec_vib_inputff/control/use_sep_index", 1);
|
||||
break;
|
||||
}
|
||||
close(fd);
|
||||
@@ -105,17 +101,20 @@ Vibrator::Vibrator() {
|
||||
ndk::ScopedAStatus Vibrator::getCapabilities(int32_t* _aidl_return) {
|
||||
*_aidl_return = IVibrator::CAP_ON_CALLBACK | IVibrator::CAP_PERFORM_CALLBACK |
|
||||
IVibrator::CAP_EXTERNAL_CONTROL /*| IVibrator::CAP_COMPOSE_EFFECTS |
|
||||
IVibrator::CAP_ALWAYS_ON_CONTROL*/;
|
||||
IVibrator::CAP_ALWAYS_ON_CONTROL*/
|
||||
;
|
||||
|
||||
#ifdef VIBRATOR_SUPPORTS_DURATION_AMPLITUDE_CONTROL
|
||||
*_aidl_return |= IVibrator::CAP_AMPLITUDE_CONTROL | IVibrator::CAP_EXTERNAL_AMPLITUDE_CONTROL;
|
||||
#else
|
||||
if (mHasTimedOutIntensity)
|
||||
*_aidl_return |= IVibrator::CAP_AMPLITUDE_CONTROL | IVibrator::CAP_EXTERNAL_AMPLITUDE_CONTROL;
|
||||
*_aidl_return |=
|
||||
IVibrator::CAP_AMPLITUDE_CONTROL | IVibrator::CAP_EXTERNAL_AMPLITUDE_CONTROL;
|
||||
#endif
|
||||
|
||||
if (mIsForceFeedbackVibrator)
|
||||
if (mIsForceFeedbackVibrator) {
|
||||
*_aidl_return |= IVibrator::CAP_AMPLITUDE_CONTROL;
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
@@ -124,14 +123,17 @@ ndk::ScopedAStatus Vibrator::off() {
|
||||
return activate(0);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr<IVibratorCallback>& callback) {
|
||||
ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) {
|
||||
ndk::ScopedAStatus status;
|
||||
|
||||
if (mHasTimedOutEffect)
|
||||
writeNode(VIBRATOR_CP_TRIGGER_PATH, 0); // Clear all effects
|
||||
if (mHasTimedOutEffect) {
|
||||
writeNode(VIBRATOR_CP_TRIGGER_PATH, 0); // Clear all effects
|
||||
}
|
||||
|
||||
if (mIsForceFeedbackVibrator)
|
||||
uploadFFEffect(0, timeoutMs);
|
||||
if (mIsForceFeedbackVibrator) {
|
||||
uploadFFEffect({0}, timeoutMs);
|
||||
}
|
||||
|
||||
#ifdef VIBRATOR_SUPPORTS_DURATION_AMPLITUDE_CONTROL
|
||||
timeoutMs *= mDurationAmplitude;
|
||||
@@ -153,16 +155,20 @@ ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr<IVibrat
|
||||
return status;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, const std::shared_ptr<IVibratorCallback>& callback, int32_t* _aidl_return) {
|
||||
ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength,
|
||||
const std::shared_ptr<IVibratorCallback>& callback,
|
||||
int32_t* _aidl_return) {
|
||||
ndk::ScopedAStatus status;
|
||||
float amplitude = strengthToAmplitude(strength, &status);
|
||||
uint32_t ms = 1000;
|
||||
|
||||
if (!status.isOk())
|
||||
if (!status.isOk()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (mIsTimedOutVibrator)
|
||||
if (mIsTimedOutVibrator) {
|
||||
activate(0);
|
||||
}
|
||||
|
||||
setAmplitude(amplitude);
|
||||
|
||||
@@ -171,15 +177,17 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, con
|
||||
} else if (mIsForceFeedbackVibrator) {
|
||||
if (FF_EFFECT_IDS.find(effect) == FF_EFFECT_IDS.end())
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
uploadFFEffect(FF_EFFECT_IDS[effect], 0);
|
||||
uploadFFEffect({0, FF_EFFECT_IDS.at(effect)}, 0);
|
||||
} else {
|
||||
if (mHasTimedOutEffect)
|
||||
writeNode(VIBRATOR_CP_TRIGGER_PATH, 0); // Clear previous effect
|
||||
if (mHasTimedOutEffect) {
|
||||
writeNode(VIBRATOR_CP_TRIGGER_PATH, 0); // Clear previous effect
|
||||
}
|
||||
|
||||
ms = effectToMs(effect, &status);
|
||||
|
||||
if (!status.isOk())
|
||||
if (!status.isOk()) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VIBRATOR_SUPPORTS_DURATION_AMPLITUDE_CONTROL
|
||||
@@ -202,12 +210,12 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, con
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect>* _aidl_return) {
|
||||
*_aidl_return = { Effect::CLICK, Effect::TICK, Effect::TEXTURE_TICK };
|
||||
*_aidl_return = {Effect::CLICK, Effect::TICK, Effect::TEXTURE_TICK};
|
||||
|
||||
if (mHasTimedOutEffect) {
|
||||
for (const auto& effect : CP_TRIGGER_EFFECTS) {
|
||||
_aidl_return->push_back(effect.first);
|
||||
}
|
||||
for (const auto& effect : CP_TRIGGER_EFFECTS) {
|
||||
_aidl_return->push_back(effect.first);
|
||||
}
|
||||
}
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
@@ -235,10 +243,10 @@ ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) {
|
||||
}
|
||||
|
||||
if (mIsForceFeedbackVibrator) {
|
||||
struct input_event event {
|
||||
.type = EV_FF,
|
||||
.code = FF_GAIN,
|
||||
.value = static_cast<__s32>(intensity),
|
||||
struct input_event event{
|
||||
.type = EV_FF,
|
||||
.code = FF_GAIN,
|
||||
.value = static_cast<__s32>(intensity),
|
||||
};
|
||||
if (write(mVibratorFd, &event, sizeof(event)) == -1)
|
||||
return ndk::ScopedAStatus::fromExceptionCode(STATUS_UNKNOWN_ERROR);
|
||||
@@ -269,15 +277,18 @@ ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t* /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimitive>* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(
|
||||
std::vector<CompositePrimitive>* /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive /*primitive*/, int32_t* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive /*primitive*/,
|
||||
int32_t* /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& /*composite*/, const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& /*composite*/,
|
||||
const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
@@ -285,7 +296,8 @@ ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect>* /*
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/, EffectStrength /*strength*/) {
|
||||
ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/,
|
||||
EffectStrength /*strength*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
@@ -325,7 +337,8 @@ ndk::ScopedAStatus Vibrator::getSupportedBraking(std::vector<Braking>* /*_aidl_r
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle>& /*composite*/, const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle>& /*composite*/,
|
||||
const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
@@ -335,12 +348,11 @@ ndk::ScopedAStatus Vibrator::activate(uint32_t timeoutMs) {
|
||||
return writeNode(VIBRATOR_TIMEOUT_PATH, timeoutMs);
|
||||
}
|
||||
if (mIsForceFeedbackVibrator) {
|
||||
struct input_event event {
|
||||
.type = EV_FF,
|
||||
.code = 0,
|
||||
.value = timeoutMs != 0,
|
||||
struct input_event event{
|
||||
.type = EV_FF,
|
||||
.code = 0,
|
||||
.value = timeoutMs != 0,
|
||||
};
|
||||
writeNode("/sys/class/sec_vib_inputff/control/use_sep_index", 1);
|
||||
if (write(mVibratorFd, &event, sizeof(event)) == -1)
|
||||
return ndk::ScopedAStatus::fromExceptionCode(STATUS_UNKNOWN_ERROR);
|
||||
return ndk::ScopedAStatus::ok();
|
||||
@@ -348,8 +360,7 @@ ndk::ScopedAStatus Vibrator::activate(uint32_t timeoutMs) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::uploadFFEffect(short effectId, int timeoutMs) {
|
||||
int16_t data[2] = {0, effectId};
|
||||
ndk::ScopedAStatus Vibrator::uploadFFEffect(std::vector<int16_t> effectData, int timeoutMs) {
|
||||
int ret;
|
||||
|
||||
// Remove previously uploaded effect in case it exists
|
||||
@@ -359,32 +370,18 @@ ndk::ScopedAStatus Vibrator::uploadFFEffect(short effectId, int timeoutMs) {
|
||||
}
|
||||
|
||||
struct ff_effect effect = {
|
||||
.type = FF_PERIODIC,
|
||||
.id = -1,
|
||||
.direction = 0,
|
||||
.trigger = {
|
||||
.button = 0,
|
||||
.interval = 0,
|
||||
},
|
||||
.replay = {
|
||||
.length = static_cast<uint16_t>(timeoutMs),
|
||||
.delay = 0,
|
||||
},
|
||||
.u.periodic = {
|
||||
.waveform = FF_CUSTOM,
|
||||
.period = 0,
|
||||
.magnitude = 0,
|
||||
.offset = 0,
|
||||
.phase = 0,
|
||||
.envelope = {
|
||||
.attack_length = 0,
|
||||
.attack_level = 0,
|
||||
.fade_length = 0,
|
||||
.fade_level = 0,
|
||||
},
|
||||
.custom_len = 2,
|
||||
.custom_data = data,
|
||||
},
|
||||
.type = FF_PERIODIC,
|
||||
.id = -1,
|
||||
.replay =
|
||||
{
|
||||
.length = static_cast<uint16_t>(timeoutMs),
|
||||
},
|
||||
.u.periodic =
|
||||
{
|
||||
.waveform = FF_CUSTOM,
|
||||
.custom_len = static_cast<uint32_t>(effectData.size()),
|
||||
.custom_data = effectData.data(),
|
||||
},
|
||||
};
|
||||
|
||||
ret = ioctl(mVibratorFd, EVIOCSFF, &effect);
|
||||
@@ -439,7 +436,7 @@ float Vibrator::durationAmplitude(float amplitude) {
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
#define VIBRATOR_INTENSITY_PATH "/sys/class/timed_output/vibrator/intensity"
|
||||
#define VIBRATOR_CP_TRIGGER_PATH "/sys/class/timed_output/vibrator/cp_trigger_index"
|
||||
|
||||
using ::aidl::android::hardware::vibrator::IVibratorCallback;
|
||||
using ::aidl::android::hardware::vibrator::Braking;
|
||||
using ::aidl::android::hardware::vibrator::Effect;
|
||||
using ::aidl::android::hardware::vibrator::EffectStrength;
|
||||
using ::aidl::android::hardware::vibrator::CompositeEffect;
|
||||
using ::aidl::android::hardware::vibrator::CompositePrimitive;
|
||||
using ::aidl::android::hardware::vibrator::Effect;
|
||||
using ::aidl::android::hardware::vibrator::EffectStrength;
|
||||
using ::aidl::android::hardware::vibrator::IVibratorCallback;
|
||||
using ::aidl::android::hardware::vibrator::PrimitivePwle;
|
||||
|
||||
namespace aidl {
|
||||
@@ -40,20 +40,26 @@ namespace hardware {
|
||||
namespace vibrator {
|
||||
|
||||
class Vibrator : public BnVibrator {
|
||||
public:
|
||||
public:
|
||||
Vibrator();
|
||||
ndk::ScopedAStatus getCapabilities(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus off() override;
|
||||
ndk::ScopedAStatus on(int32_t timeoutMs, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus perform(Effect effect, EffectStrength strength, const std::shared_ptr<IVibratorCallback>& callback, int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus on(int32_t timeoutMs,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus perform(Effect effect, EffectStrength strength,
|
||||
const std::shared_ptr<IVibratorCallback>& callback,
|
||||
int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedEffects(std::vector<Effect>* _aidl_return) override;
|
||||
ndk::ScopedAStatus setAmplitude(float amplitude) override;
|
||||
ndk::ScopedAStatus setExternalControl(bool enabled) override;
|
||||
ndk::ScopedAStatus getCompositionDelayMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getCompositionSizeMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedPrimitives(std::vector<CompositePrimitive>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive, int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus compose(const std::vector<CompositeEffect>& composite, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus getSupportedPrimitives(
|
||||
std::vector<CompositePrimitive>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive,
|
||||
int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus compose(const std::vector<CompositeEffect>& composite,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus getSupportedAlwaysOnEffects(std::vector<Effect>* _aidl_return) override;
|
||||
ndk::ScopedAStatus alwaysOnEnable(int32_t id, Effect effect, EffectStrength strength) override;
|
||||
ndk::ScopedAStatus alwaysOnDisable(int32_t id) override;
|
||||
@@ -65,11 +71,12 @@ public:
|
||||
ndk::ScopedAStatus getPwlePrimitiveDurationMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPwleCompositionSizeMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedBraking(std::vector<Braking>* _aidl_return) override;
|
||||
ndk::ScopedAStatus composePwle(const std::vector<PrimitivePwle>& composite, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus composePwle(const std::vector<PrimitivePwle>& composite,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
ndk::ScopedAStatus activate(uint32_t ms);
|
||||
ndk::ScopedAStatus uploadFFEffect(short effectId, int timeoutMs);
|
||||
ndk::ScopedAStatus uploadFFEffect(std::vector<int16_t> effectData, int timeoutMs);
|
||||
uint32_t effectToMs(Effect effect, ndk::ScopedAStatus* status);
|
||||
static float strengthToAmplitude(EffectStrength strength, ndk::ScopedAStatus* status);
|
||||
|
||||
@@ -90,7 +97,7 @@ private:
|
||||
int mVibratorFd{-1};
|
||||
};
|
||||
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "Vibrator.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
using ::aidl::android::hardware::vibrator::Vibrator;
|
||||
|
||||
@@ -17,9 +17,10 @@ int main() {
|
||||
std::shared_ptr<Vibrator> vibrator = ndk::SharedRefBase::make<Vibrator>();
|
||||
|
||||
const std::string instance = std::string() + Vibrator::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(vibrator->asBinder().get(), instance.c_str());
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(vibrator->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
|
||||
14
dap/res/values-iw/strings.xml
Normal file
14
dap/res/values-iw/strings.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="dolby_enable_title">הפעלת Dolby Atmos</string>
|
||||
<string name="dolby_top_intro_summary">חווית אודיו מדהימה לניגון מדיה שזורמת מעליך ומסביבך</string>
|
||||
<string name="dolby_profile_auto">אוטומטי</string>
|
||||
<string name="dolby_profile_game">משחק</string>
|
||||
<string name="dolby_profile_game_1">משחק 1</string>
|
||||
<string name="dolby_profile_game_2">משחק 2</string>
|
||||
<string name="dolby_profile_movie">סרט</string>
|
||||
<string name="dolby_profile_music">מוזיקה</string>
|
||||
<string name="dolby_profile_off">אין פרופיל</string>
|
||||
<string name="dolby_profile_spacial_audio">שמע מרחבי</string>
|
||||
<string name="dolby_profile_voice">קול</string>
|
||||
</resources>
|
||||
12
dap/res/values-sc-rIT/strings.xml
Normal file
12
dap/res/values-sc-rIT/strings.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="dolby_profile_auto">Auto</string>
|
||||
<string name="dolby_profile_game">Giogu</string>
|
||||
<string name="dolby_profile_game_1">Giogu 1</string>
|
||||
<string name="dolby_profile_game_2">Giogu 2</string>
|
||||
<string name="dolby_profile_movie">Film</string>
|
||||
<string name="dolby_profile_music">Mùsica</string>
|
||||
<string name="dolby_profile_off">Nissunu profilu</string>
|
||||
<string name="dolby_profile_spacial_audio">Àudio ispatziale</string>
|
||||
<string name="dolby_profile_voice">Boghe</string>
|
||||
</resources>
|
||||
@@ -3,49 +3,58 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/dolby_title">
|
||||
|
||||
<com.android.settingslib.widget.TopIntroPreference
|
||||
android:key="dolby_top_intro"
|
||||
android:title="@string/dolby_top_intro_summary" />
|
||||
|
||||
<com.android.settingslib.widget.MainSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="dolby_enable"
|
||||
android:title="@string/dolby_enable_title" />
|
||||
|
||||
<com.android.settingslib.widget.TopIntroPreference
|
||||
android:key="dolby_top_intro"
|
||||
android:title="@string/dolby_top_intro_summary" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:defaultValue="true"
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_auto"
|
||||
android:title="@string/dolby_profile_auto" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_game"
|
||||
android:title="@string/dolby_profile_game" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_game_1"
|
||||
android:title="@string/dolby_profile_game_1" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_game_2"
|
||||
android:title="@string/dolby_profile_game_2" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_movie"
|
||||
android:title="@string/dolby_profile_movie" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_music"
|
||||
android:title="@string/dolby_profile_music" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_off"
|
||||
android:title="@string/dolby_profile_off" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_spacial_audio"
|
||||
android:title="@string/dolby_profile_spacial_audio" />
|
||||
|
||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||
android:dependency="dolby_enable"
|
||||
android:key="dolby_profile_voice"
|
||||
android:title="@string/dolby_profile_voice" />
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@ package org.lineageos.dap
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
import androidx.preference.PreferenceManager
|
||||
|
||||
import org.lineageos.dap.DolbyFragment.Companion.PREF_DOLBY_ENABLE
|
||||
import org.lineageos.dap.DolbyFragment.Companion.PREF_DOLBY_MODES
|
||||
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
package org.lineageos.dap
|
||||
|
||||
import android.os.Bundle
|
||||
|
||||
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity
|
||||
|
||||
class DolbyActivity : CollapsingToolbarBaseActivity() {
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
fragmentManager.beginTransaction().replace(
|
||||
com.android.settingslib.collapsingtoolbar.R.id.content_frame,
|
||||
DolbyFragment()
|
||||
).commit()
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(com.android.settingslib.collapsingtoolbar.R.id.content_frame, DolbyFragment())
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@ package org.lineageos.dap
|
||||
|
||||
import android.content.Context
|
||||
import android.media.audiofx.AudioEffect
|
||||
|
||||
import org.lineageos.dap.DolbyFragment.Companion.PREF_DOLBY_MODES
|
||||
|
||||
import java.util.UUID
|
||||
import org.lineageos.dap.DolbyFragment.Companion.PREF_DOLBY_MODES
|
||||
|
||||
object DolbyCore {
|
||||
private const val EFFECT_PARAM_PROFILE = 0
|
||||
@@ -39,9 +37,8 @@ object DolbyCore {
|
||||
const val PROFILE_GAME_2 = 7
|
||||
const val PROFILE_SPACIAL_AUDIO = 8
|
||||
|
||||
private val audioEffect = runCatching {
|
||||
AudioEffect(EFFECT_TYPE_DAP, AudioEffect.EFFECT_TYPE_NULL, 0, 0)
|
||||
}.getOrNull()
|
||||
private val audioEffect =
|
||||
runCatching { AudioEffect(EFFECT_TYPE_DAP, AudioEffect.EFFECT_TYPE_NULL, 0, 0) }.getOrNull()
|
||||
|
||||
fun getProfile(): Int {
|
||||
val out = intArrayOf(PROFILE_AUTO)
|
||||
@@ -53,9 +50,9 @@ object DolbyCore {
|
||||
val profile = getProfile()
|
||||
val resourceName = PREF_DOLBY_MODES.filter { it.value == profile }.keys.first()
|
||||
|
||||
return context.resources.getString(context.resources.getIdentifier(
|
||||
resourceName, "string", context.packageName
|
||||
))
|
||||
return context.resources.getString(
|
||||
context.resources.getIdentifier(resourceName, "string", context.packageName)
|
||||
)
|
||||
}
|
||||
|
||||
fun setProfile(profile: Int) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user