Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
device_xiaomi_onclite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid-Devices
device_xiaomi_onclite
Commits
2b6a2884
Commit
2b6a2884
authored
2 years ago
by
0xCAFEBABE
Committed by
Dhina17
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
onclite: vibrator: Add support for basic vibration
Change-Id: Iac191110fee04ed3463c66370ee51922c219866a
parent
d89ac90d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
vibrator/Android.bp
+1
-0
1 addition, 0 deletions
vibrator/Android.bp
vibrator/Vibrator.cpp
+16
-4
16 additions, 4 deletions
vibrator/Vibrator.cpp
vibrator/Vibrator.h
+1
-1
1 addition, 1 deletion
vibrator/Vibrator.h
with
18 additions
and
5 deletions
vibrator/Android.bp
+
1
−
0
View file @
2b6a2884
...
...
@@ -22,6 +22,7 @@ cc_binary {
srcs: ["service.cpp", "Vibrator.cpp"],
cflags: ["-Wall", "-Werror"],
shared_libs: [
"libbase",
"libhidlbase",
"liblog",
"libutils",
...
...
This diff is collapsed.
Click to expand it.
vibrator/Vibrator.cpp
+
16
−
4
View file @
2b6a2884
...
...
@@ -16,6 +16,7 @@
#define LOG_TAG "VibratorService"
#include
<android-base/file.h>
#include
<log/log.h>
#include
"Vibrator.h"
...
...
@@ -26,6 +27,11 @@ namespace vibrator {
namespace
V1_3
{
namespace
implementation
{
static
const
std
::
string
kLedVibDeviceDir
=
"/sys/class/leds/vibrator/"
;
static
const
std
::
string
kLedVibDeviceActivateFile
=
kLedVibDeviceDir
+
"activate"
;
static
const
std
::
string
kLedVibDeviceDurationFile
=
kLedVibDeviceDir
+
"duration"
;
static
const
std
::
string
kLedVibDeviceStateFile
=
kLedVibDeviceDir
+
"state"
;
static
constexpr
uint32_t
MS_PER_S
=
1000
;
static
constexpr
uint32_t
NS_PER_MS
=
1000000
;
...
...
@@ -142,11 +148,17 @@ Return<void> Vibrator::perform(T effect, EffectStrength strength, perform_cb _hi
return
perform
(
static_cast
<
Effect
>
(
effect
),
strength
,
_hidl_cb
);
}
Status
Vibrator
::
enable
(
bool
enabled
)
{
Status
Vibrator
::
enable
(
bool
enabled
,
uint32_t
ms
)
{
if
(
mExternalControl
)
{
ALOGW
(
"Enabling/disabling while the vibrator is externally controlled is unsupported!"
);
return
Status
::
UNSUPPORTED_OPERATION
;
}
else
{
if
(
!
android
::
base
::
WriteStringToFile
(
enabled
?
"1"
:
"0"
,
kLedVibDeviceStateFile
)
||
!
android
::
base
::
WriteStringToFile
(
std
::
to_string
(
ms
),
kLedVibDeviceDurationFile
)
||
!
android
::
base
::
WriteStringToFile
(
enabled
?
"1"
:
"0"
,
kLedVibDeviceActivateFile
))
{
ALOGE
(
"Failed to enable vibration!"
);
return
Status
::
UNKNOWN_ERROR
;
}
ALOGI
(
"Enabled: %s -> %s
\n
"
,
mEnabled
?
"true"
:
"false"
,
enabled
?
"true"
:
"false"
);
mEnabled
=
enabled
;
return
Status
::
OK
;
...
...
@@ -158,7 +170,7 @@ Status Vibrator::activate(uint32_t ms) {
Status
status
=
Status
::
OK
;
if
(
ms
>
0
)
{
status
=
enable
(
true
);
status
=
enable
(
true
,
ms
);
if
(
status
!=
Status
::
OK
)
{
return
status
;
}
...
...
@@ -176,7 +188,7 @@ Status Vibrator::activate(uint32_t ms) {
if
((
status
!=
Status
::
OK
)
||
!
ms
)
{
Status
_status
;
_status
=
enable
(
false
);
_status
=
enable
(
false
,
0
);
if
(
status
==
Status
::
OK
)
{
status
=
_status
;
...
...
@@ -195,7 +207,7 @@ void Vibrator::timeout() {
}
if
(
ts
.
it_value
.
tv_sec
==
0
&&
ts
.
it_value
.
tv_nsec
==
0
)
{
enable
(
false
);
enable
(
false
,
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
vibrator/Vibrator.h
+
1
−
1
View file @
2b6a2884
...
...
@@ -57,7 +57,7 @@ class Vibrator : public IVibrator {
Return
<
void
>
perform
(
Effect
effect
,
EffectStrength
strength
,
perform_cb
_hidl_cb
);
template
<
typename
T
>
Return
<
void
>
perform
(
T
effect
,
EffectStrength
strength
,
perform_cb
_hidl_cb
);
Status
enable
(
bool
enabled
);
Status
enable
(
bool
enabled
,
uint32_t
ms
);
Status
activate
(
uint32_t
ms
);
void
timeout
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment