70 Commits
vic ... bka

Author SHA1 Message Date
Bruno Martins
ce1bf5c27f aidl: camera: Partially return to soong_config_module_type usage
Some checks failed
action.yml / aidl: camera: Partially return to soong_config_module_type usage (push) Failing after 0s
This partially reverts commit 00809a1, that broke too many devices
that weren't ready yet.

Change-Id: I4d234e79a99da15542b81e1741290336e9f08d0b
2026-01-19 07:49:39 +00:00
LuK1337
44c057f60b pre-commit: Enable clang-format
Change-Id: I7a22a5fe9ee7176604fed0825f96417c53adb1ff
2026-01-18 15:59:00 +00:00
Bruno Martins
474ebe1722 sensors: Run through clang-format
Change-Id: I64ff0a321a1e95eaac78e8caefbf43a125fd5c84
2026-01-18 15:59:00 +00:00
Bruno Martins
c7abe693bd ril: Run through clang-format
Change-Id: I7964e1770a1b603242f336de037f0d5f095dff1a
2026-01-18 15:59:00 +00:00
Bruno Martins
ef4647e636 rebalance_interrupts: Run through clang-format
Change-Id: I76495309d747349077fef7980864fc794807723a
2026-01-18 15:59:00 +00:00
Bruno Martins
4b128b05b3 hidl: Run through clang-format
Change-Id: Ia848230ceb454b858d535481b34f193e06e765c6
2026-01-18 15:59:00 +00:00
Bruno Martins
6157fb0df0 aidl: Run through clang-format
Change-Id: I46a43e533cda2988a8f4cd547b644bccb5979431
2026-01-18 15:59:00 +00:00
Bruno Martins
d87a8f30a4 aidl: vibrator: Add some brackets
Change-Id: I4b804fb88bd098a1adcf42357a56acf286102e6c
2026-01-18 15:59:00 +00:00
Bruno Martins
211e5f0b1a aidl: usb: Add some brackets
Change-Id: I2498700fd38037974e8a27b7c5c77baf29cd0909
2026-01-18 15:59:00 +00:00
Bruno Martins
f76655d7bc aidl: memtrack: Add some brackets
Change-Id: Id950738a6871d6b6822b7b6bcfb641ab9c141dcf
2026-01-18 15:59:00 +00:00
Bruno Martins
0073e77169 aidl: camera: Remove deprecated module
Change-Id: I74151184a0c0b1d4bab442a84f330095a618763c
2026-01-18 15:59:00 +00:00
Bruno Martins
661a74dc6a hidl: camera: Remove deprecated custom device impl and provider
All Samsung targets out there are using AIDL custom device impl/provider.
There's no need to continue maintaining HIDL ones any longer.

Change-Id: I6dc832b04f2795e30052df6f37448c126fdad692
2026-01-18 15:59:00 +00:00
Bruno Martins
7063bcad23 aidl: usb: gadget: Migrate to select()
Change-Id: Id4696b9aa6af0243c43ca5f71d5d71e1ee0ee963
2026-01-18 15:59:00 +00:00
Bruno Martins
00809a12b0 aidl: camera: Migrate to select()
Change-Id: Id29a05301cc720fcbc9b28c98f3c98e2d67df166
2026-01-18 15:58:56 +00:00
Bruno Martins
9d8b250ce5 samsung: Remove loki_tool
It looks like this was only used by an ancient device... back in the
good'ol CM days.

Change-Id: Ib9aef0a72c32674ca2189e368752c90aa916c530
2026-01-18 14:00:38 +00:00
Bruno Martins
8aba80de2b samsung: Delete dtbhtoold
All the devices that used this tool are quite dead. Anyway, if proven
to be really needed, the tool should be placed in a dedicated Exynos
repository.

Change-Id: I2aefdeca818ed92d65e4cf50f83a0af42d3d2f2d
2026-01-18 14:00:38 +00:00
Bruno Martins
33f74940ad AdvancedDisplay: Blend into color preference category
Depends-on: I56b161c98eb7f669703f46d73f56e081ebf18558
Change-Id: I10a216b0d202f78cc42791ef45b4d49cf5767382
2026-01-02 01:19:30 +00:00
LineageOS Infra
b2f5a8db8d Automatic translation import
Change-Id: I9df6976f19746c9725ec39ec9970628cd1dcb789
2026-01-01 17:23:55 +00:00
borbelyvince
df0812cd0b aidl: vibrator: Use std::vector for effect data and clean up unnecessary field initializers
Change-Id: Ic20202204e2f3c4af03a9a298c645145aef0ce35
2026-01-01 16:40:34 +00:00
borbelyvince
4881519b23 aidl: vibrator: Write use_sep_index value in constructor
It only has to be initialized once, and no subsequent changes are needed.

Change-Id: I9c3290bdcff3964546efb9017ad12866d5903af8
2026-01-01 16:40:34 +00:00
Bruno Martins
96cec7c200 aidl: fingerprint: Add missing include
Spotted after clang-format formatting changes:

  hardware/samsung/aidl/fingerprint/LockoutTracker.h:26:5: error: unknown type name 'int64_t'
     26 |     int64_t getLockoutTimeLeft();
        |     ^
  hardware/samsung/aidl/fingerprint/LockoutTracker.h:29:5: error: unknown type name 'int32_t'
     29 |     int32_t mFailedCount = 0;
        |     ^
  hardware/samsung/aidl/fingerprint/LockoutTracker.h:30:5: error: unknown type name 'int64_t'
     30 |     int64_t mLockoutTimedStart;
        |     ^

Change-Id: I2cc02e0bdda9e3302aac8bffc5c6022caee96b34
2026-01-01 16:32:57 +00:00
Bruno Martins
1c29fd2599 aidl: fingerprint: Run through clang-format
Change-Id: I866e2c5621cf009a64658bd2f2b20087286c6f4d
2026-01-01 16:32:52 +00:00
Bruno Martins
2326b7c10b aidl: fingerprint: Add some brackets
Change-Id: I361c408cf50857ab53d32d5e67050dc940d96ef3
2026-01-01 16:32:48 +00:00
Luka Panio
1ff326fde4 aidl: fingerprint: Allow more than one fingerprint location
* Needed for foldable devices which have different locations
  on inner and outer screens

Change-Id: Iebdab30de5542bad43d4fc786a528e5306e26daa
2026-01-01 16:32:39 +00:00
Bruno Martins
078d67d671 Run pre-commit run --all
Change-Id: Ib794c4ef4425c3f372f8c92caa8da5c7b0957987
2026-01-01 15:44:34 +00:00
LuK1337
d29b39b66a Introduce pre-commit & GitHub Actions for it
Change-Id: I4604d13e5ccf74ec4c7088a40a9f7f915f9b1293
2026-01-01 15:44:02 +00:00
Bruno Martins
b0416d32bc ril: Run dos2unix
Change-Id: Ibbad45e91278ffcf2290c37deca117de4163c04f
2026-01-01 15:43:57 +00:00
Bruno Martins
1b4d8a2b03 fingerprint: Set defaults if no Z-order is set
Change-Id: If905bf143de7bd9232c83daa664d77067bec2aa6
2025-12-08 15:46:28 +00:00
Kai Jones
354ca305ca fingerprint: Configurable UDFPS dim layer Z-order
Introduce a build-time configuration for UDFPS dim layer Z-order.
Define `fod_dim_layer_zorder` via Soong, dynamically set using:

  $(call soong_config_set,samsungUdfpsVars,dim_layer_zorder,0x20000001u)

Change-Id: Ie1d5e78894e191150be235eb48e400ea1feab9b2
2025-12-08 15:46:18 +00:00
Bruno Martins
923942619f fingerprint: FOD -> UDFPS
Change-Id: I0b6be82483d8fc6bb74a529c2962d1e4b40cf04a
2025-12-08 15:46:03 +00:00
Anay Wadhera
33ccfec6cf doze: Drop minSdkVersion
Change-Id: Idbbe6713999ca8b942b2bf91cc899118e22a062b
2025-12-02 15:26:59 +00:00
LineageOS Infra
9cc8f56671 Automatic translation import
Change-Id: Ie3b52befcad81669a498f51598ca79e8ca20b260
2025-12-01 14:53:11 +00:00
e1ebb45e3c AdvancedDisplay: Move to PreferenceFragmentCompat
PreferenceFragment was deprecated in API level 28.

https://developer.android.com/jetpack/androidx/releases/preference#1.1.0

Change-Id: I3ae5a8b9a3be3317f097564368559802b9322558
Signed-off-by: AnierinB <anierin@evolution-x.org>
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-11-27 22:05:07 +00:00
Bruno Martins
c65e8a6f0f dap: Place top intro above main switch
To go along with the rest of Settings UI.

Change-Id: I04ec5319131cf557079480cc3cab590a16497e18
2025-11-27 21:58:31 +00:00
ExtremeXT
699a741aa9 dap: Gray out profiles when DAP is disabled
Change-Id: Ia1dc3cf4b8a6c16ed41fb79dd04f2d53c94e2103
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-11-27 21:58:21 +00:00
Bruno Martins
403a57cc0d dap: Use new method to listen for preference changes
Usage of addOnSwitchChangeListener(OnCheckedChangeListener) is
deprecated. The Javadoc explicitly says:

  Use setOnPreferenceChangeListener(OnPreferenceChangeListener) instead.

Change-Id: I591c52ee8e79ad075ba74f45c656344e7e3abbca
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-11-27 21:10:41 +00:00
08cfc0cbc2 dap: Move to PreferenceFragmentCompat
PreferenceFragment was deprecated in API level 28.

https://developer.android.com/jetpack/androidx/releases/preference#1.1.0

Change-Id: I4f933bab13382550c820ade4e759dd645aad37c4
Signed-off-by: AnierinB <anierin@evolution-x.org>
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-11-27 20:51:10 +00:00
Bruno Martins
e1873e9df4 doze: Use new method to listen for preference changes
Usage of addOnSwitchChangeListener(OnCheckedChangeListener) is
deprecated. The Javadoc explicitly says:

  Use setOnPreferenceChangeListener(OnPreferenceChangeListener) instead.

Change-Id: I71e0e3f86ff339a312cac1e09106f6d5d15b7e43
2025-11-27 20:46:31 +00:00
Michael Bestas
0c4a57235f doze: Convert to SwitchPreferenceCompat
Change-Id: Ic1cbaba37d499da1855af9c3930f2df426e2d3af
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-11-27 20:35:41 +00:00
0426336593 doze: Move to PreferenceFragmentCompat
PreferenceFragment was deprecated in API level 28.

https://developer.android.com/jetpack/androidx/releases/preference#1.1.0

Change-Id: Ie8a4b04bd588afbbbc5882349ddbc05f988f80bf
Signed-off-by: AnierinB <anierin@evolution-x.org>
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-11-27 20:05:38 +00:00
Michael Bestas
04da539900 Revert "samsung: hidl: add vibrator HAL for SEC Haptic Engine"
This reverts commit a4922f4f1c.

Reason for revert: HIDL vibrator is dead in BP3A and nobody uses this.

Change-Id: I53bb04b8efe42be67ff922a0be83f7cd4a92bd46
2025-11-20 23:52:50 +02:00
Tim Zimmermann
9f2dfb966f aidl: health: Uprev to V4
* No change in implementation is needed since it is pulled in from libhealth_aidl_impl_user

Change-Id: I1ab76e0311aaf69d493ef303ad6f0081e6e38c8e
2025-11-02 09:41:53 +01:00
ata-kaner
121dddc138 aidl: codec2: Add missing seccomp architectures
Fixes following error on non-ARM targets.

error: hardware/samsung/aidl/codec2/Android.bp:62:1: module "android.software.media.c2-default-seccomp_policy" variant "android_x86": src: missing prebuilt source file

Change-Id: I6dcc59329618853d75f55750b1a21b405f0c175a
2025-10-20 05:36:03 +03:00
LineageOS Infra
d72d21d4ca Automatic translation import
Change-Id: I72dc070a527fa0e03bdc2472322afc9ca5777091
2025-09-24 20:06:36 +00:00
Bruno Martins
73dc774852 samsung: Normalize vars namespaces
Change-Id: Iaef6bef86e572192c524dbb27cad58235523751c
2025-09-20 12:47:38 +00:00
Tim Zimmermann
888b1252e0 Revert "aidl: health: Allow disabling charger suspend"
This reverts commit 1940e53398.

Reason for revert: The original issue this was created for should
be fixed in the kernel. If we really want this disableable in the future
it should be done through a sysprop anyways.

Change-Id: I88d85e45bbd86c9e4d963c99c874ae23275ad5bc
2025-09-09 17:13:38 +02:00
Tim Zimmermann
4dd00a62d7 Revert "aidl: usb: gadget: Link mass_storage.0 when MTP or ADB is enabled"
This reverts commit de83d093e6.

Reason for revert: Rather hacky workaround for a 3rd party app.

Change-Id: I68763fa4365bfc86c1f612218d0b494f52864a13
2025-09-09 17:12:04 +02:00
Tim Zimmermann
f8f8b96472 Revert "aidl: usb: gadget: Don't bail out on mass_storage link fail"
This reverts commit 2af299f594.

Change-Id: I61af933fbccb61ef381ff8617db455ef90418874
2025-09-09 17:12:02 +02:00
ExtremeXT
2af299f594 aidl: usb: gadget: Don't bail out on mass_storage link fail
* This feature requires a change in the kernel config and another one in the USB init:
* e1e4a193d4
* bdd598c4d0

* This is not a vital feature, so there is no reason to bail out and completely kill USB when it fails.

Change-Id: I7e5a391d100ef77b9904384119e53629dc69260b
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-09-06 14:07:46 +03:00
Cyber Knight
de83d093e6 aidl: usb: gadget: Link mass_storage.0 when MTP or ADB is enabled
- This fixes DriveDroid functionality when coupled together with [1].

[1]: 0e435675d7

Test: Open DriveDroid, host an image, change usb configuration to File Transfer and try to boot an OS on PC by plugging in the phone.
Change-Id: I7956e14fb8239d273e687b61ed4154a0695460ce
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
[Flopster101: Also enable for ADB, it's more convenient since MTP isn't on by default.]
Signed-off-by: Flopster101 <nahuelgomez329@gmail.com>
Signed-off-by: Majaahh <maja.blaszczak@proton.me>
2025-09-06 09:41:20 +00:00
Tim Zimmermann
efaf58c10a secril_config_svc: Set ro.telephony.default_network property
Change-Id: I0345d103df56c8b8a1d91828edea2af7ceee7194
2025-09-05 15:26:09 +02:00
Tim Zimmermann
098923d64e secril_config_svc: Handle properties in a treble-compliant way
* This is also more similar to what the stock service does

Change-Id: Ic1e7e1f2fdd6d32bd0d89ed1a0c31f7ad69a0c84
2025-09-05 15:24:08 +02:00
Atakan
edf680575b secril_config_svc: Check called args before trying to set properties
Change-Id: I8b94d69915e643e8ca74857e90fcc2df68715f90
2025-09-05 00:18:32 +00:00
ExtremeXT
876585001b secril_config_svc: Set ro.vendor.radio.default_network properly
Devices supporting different network bands (LTE, 5G, etc) have different
values for this prop, hence hardcoding it in vendor.prop is not the best
solution.

Let secril_config_svc set this dynamically based on persist.radio.def_network
from telephony.prop.

Co-authored-by: Flopster101 <nahuelgomez329@gmail.com>
Change-Id: I8ee568224bfae74cb65c1f0440bd26bdce58814f
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-09-04 21:45:00 +00:00
Atakan
c111b52360 secril_config_svc: Set ro.telephony.sim_slots.count property
Devices from different regions may have different slot numbers, so hard-coding the number through overlays is not a good approach.

Let secril_config_svc handle this dynamically, just like how Samsung did on Android 16.

Change-Id: Ib832f6004bccb528a22ac4e6fe9fffa279892f1f
2025-09-02 22:22:36 +03:00
Atakan
5074e1b915 secril_config_svc: Use SetProperty() for fallback props
Change-Id: Ie4c4a46364962d81c82aaed909f55cf7bec25a2c
2025-09-02 22:12:59 +03:00
Bruno Martins
608872573b livedisplay: Migrate to AIDL
Change-Id: I4a67910fdc09a3350c5ee7215d5ac9b69c977af0
2025-09-02 13:16:38 +00:00
Atakan
d4c580a5bc livedisplay: Refactor for modern Qualcomm devices
We're now supporting various Qualcomm chipsets.

- Commonize DisplayColorCalibration for both Exynos and Qualcomm.
- Decommonize ReadingEnhancement for Exynos only (doesn't work on Qualcomm).
- Cleanup legacy code and paths.

Change-Id: Id2068e5ee421a546ed1f17f3fd2deb3ed0a26f8e
Co-Authored-By: Simon1511 <me@simon1511.de>
2025-09-02 13:16:38 +00:00
Majaahh
1940e53398 aidl: health: Allow disabling charger suspend
[Flopster101: Having it enabled on Exynos 1280 (s5e8825) devices would cause
the device to kernel panic shortly after the screen turned off in offline
charging, and I could not diagnose this at the kernel level.

[   38.159432] [0:      watchdogd:  496] Watchdog: secdbg_wdd_ping_handler RTC 2025-07-05 10:37:31 UTC
[   39.913841] [1:  kworker/u16:1:    9] [SHUB]      debug_work_func( 135) :  (2025/07/05 10:37:33) FW(0):0, Sensor state: 0x0, 0x0, En: 0x0, 0x0, Reset cnt: -1[0 : C 0(0, 0), N 0, 0, 0, D 0], Cal result : [M:N, P:N]
[   41.961728]I[1:      swapper/1:    0] Suspend/Resume hang between PM_SUSPEND_PREPARE and DEV_SUSPEND_PREPARE
[   41.961744]I[1:      swapper/1:    0] curr jiffies(4294902784) pm_prepare_jiffies (4294896320) expires jiffies(4294902570)
[   41.961804]I[1:      swapper/1:    0] Suspend/Resume hang detected
[   41.961820]I[1:      swapper/1:    0] Kernel panic - not syncing: SSLD:S2R timeout,time = 16110981 usec|action(freeze_processes, 0)[android.hardwar, 508]
[   41.961854]I[1:      swapper/1:    0] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G         C        5.10.238-android12-9 #3
[   41.961863]I[1:      swapper/1:    0] Hardware name: Samsung A25X SWA OPEN based on S5E8825 (DT)
[   41.961874] [6:    kworker/6:4:  359] deferred_work_fn: [sicd] deferred done]

Change-Id: Ibe27c52be81aa1ddde13aeda7a28f892ef4a855e
Co-authored-by: Flopster101 <nahuelgomez329@gmail.com>
Signed-off-by: Majaahh <maja.blaszczak@proton.me>
2025-09-01 15:10:37 +00:00
Bruno Martins
cd805062ff touch: Properly check if gestures are supported
Checking if the TSP command node exists is not enough to declare that
feature is supported, so check if the command is listed as available.

Change-Id: Id7884e62358db966cfd8b85fbca95bc13de03f80
2025-08-31 15:18:51 +00:00
Atakan
ca6f97fb2d vintf: Add MDFPP Gatekeeper entry
Change-Id: I05043484bd860d3daf48bcf53ac59622d494702b
2025-08-30 23:20:50 +00:00
Atakan
9627fa4826 hidl: keymaster: Update init script
Samsung has updated the keymaster init script in Android 11.

Change-Id: I696e8ae55243857c12faf0ef7e3d42fbd284ff93
2025-08-30 23:20:16 +00:00
ExtremeXT
e132bfadd8 touch: Add Single Tap gesture support
Co-authored-by: Simon1511 <simon2002.schoenmackers@gmail.com>
Change-Id: I0400802734471bffcf90d9711dbb7771fc7c8c86
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-08-28 20:02:58 +00:00
ExtremeXT
f4dd7d73f4 touch: Rename TOUCHSCREEN_GESTURE_NODE
To be more explicit as to what it is, in preparation for follow-up
change that adds a single tap gesture to the interface.

Change-Id: I5387e60fe24a0b6edd6b691ae403f734e281dca6
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-08-28 20:02:16 +00:00
Atakan
cb586c51f4 aidl: codec2: Modify for Samsung
Change-Id: I9d314651afd78761355e6667b69fb74199caaaaa
2025-08-28 19:31:04 +00:00
Atakan
db3ce29c77 aidl: Import AOSP C2 example service
From: frameworks/av/media/codec2/hal/services @ android-15.0.0_r32

Change-Id: I49fb09063bacd7571c04bd0e287227c2452e2bbd
2025-08-28 19:30:26 +00:00
ExtremeXT
a72f98f12b touch: Also support set_scan_rate TSP CMD
This adds support for set_scan_rate SEC TSP command, which is used by devices like the S20-S22 Series (non-FE).

Keeps backward compatibility for devices with a melfas touchscreen like the S20 FE (r8s/r8q), using set_game_mode TSP command.

Change-Id: I643832df015220874d728b1ef54533c07e59f885
Signed-off-by: ExtremeXT <extremextdev@gmail.com>
2025-08-28 19:29:48 +00:00
Bruno Martins
9ab477d63c touch: Add HighTouchPollingRate support
Change-Id: I40d1d909aec8bd9430fada68ce8ceec234c0ec88
2025-08-28 19:28:55 +00:00
Bruno Martins
25f925f7a9 hidl: Disable LiveDisplay HIDL
Will be migrated at a later stage. Just to unbreak things.

Change-Id: I0759ed5355c49c27718f4f1485b59ffd7ee7fdd3
2025-08-19 09:53:13 +00:00
Nolen Johnson
38094acf43 hidl: Kill fastcharge
Change-Id: I22a8ac6ec2721f86e4508f072bf728d4b216ed2a
2025-08-17 15:39:41 +01:00
214 changed files with 3935 additions and 7430 deletions

View File

@@ -1 +0,0 @@
../../build/soong/scripts/system-clang-format

13
.clang-format Normal file
View 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
View 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
View 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
View 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]

View File

@@ -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" />

View File

@@ -1,5 +1,3 @@
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep class ** extends android.support.v14.preference.PreferenceFragment

View File

@@ -2,4 +2,3 @@
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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();
}

View File

@@ -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 */

View File

@@ -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"],
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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",

View File

@@ -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

View File

@@ -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:

View File

@@ -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",

View File

@@ -224,7 +224,7 @@ bool CameraProvider::initialize() {
}
std::vector<int> extraIDs = {
#ifdef EXTRA_IDS
EXTRA_IDS
EXTRA_IDS
#endif
};
for (int i : extraIDs) {

View File

@@ -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
View 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"],
}

View 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

View 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>

View File

@@ -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>

View 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>

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
View 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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View File

@@ -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.";

View File

@@ -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>

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View 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

View File

@@ -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,
}

View 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

View File

@@ -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

View 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

View 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

View 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

View File

@@ -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

View File

@@ -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

View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View 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;
}

View 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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -19,5 +19,5 @@ int main() {
CHECK(status == STATUS_OK);
ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // Unreachable
return EXIT_FAILURE; // Unreachable
}

View File

@@ -5,4 +5,3 @@
<fqname>IMemtrack/default</fqname>
</hal>
</manifest>

View File

@@ -11,6 +11,7 @@ cc_binary {
proprietary: true,
srcs: [
"GloveMode.cpp",
"HighTouchPollingRate.cpp",
"KeyDisabler.cpp",
"StylusMode.cpp",
"TouchscreenGesture.cpp",

View 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

View 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

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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"

View File

@@ -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";

View File

@@ -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

View File

@@ -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, &currentRole) == Status::SUCCESS){
if (getCurrentRoleHelper(port.first, port.second, &currentRole) == 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, &currentPortStatus);
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

View File

@@ -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

View File

@@ -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",

View File

@@ -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, &current_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

View File

@@ -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

View File

@@ -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
}

View File

@@ -31,5 +31,5 @@ int main() {
CHECK(status == STATUS_OK);
ABinderProcess_joinThreadPool();
return -1; // Should never be reached
return -1; // Should never be reached
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View 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>

View 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>

View File

@@ -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" />

View File

@@ -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

View File

@@ -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()
}
}

View File

@@ -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