Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
device_xiaomi_sm8350-common
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_sm8350-common
Commits
7c06a601
Commit
7c06a601
authored
3 years ago
by
Cosmin Tanislav
Browse files
Options
Downloads
Patches
Plain Diff
sm8350-common: import 2.X sensors hal proxy
parent
dad2cbe2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sensors/Android.bp
+2
-0
2 additions, 0 deletions
sensors/Android.bp
sensors/HalProxy.cpp
+754
-0
754 additions, 0 deletions
sensors/HalProxy.cpp
sensors/HalProxyCallback.cpp
+84
-0
84 additions, 0 deletions
sensors/HalProxyCallback.cpp
with
840 additions
and
0 deletions
sensors/Android.bp
+
2
−
0
View file @
7c06a601
...
...
@@ -22,6 +22,8 @@ cc_binary {
relative_install_path: "hw",
srcs: [
"service.cpp",
"HalProxy.cpp",
"HalProxyCallback.cpp",
],
init_rc: ["android.hardware.sensors@2.1-service-multihal.rc"],
vintf_fragments: ["android.hardware.sensors@2.1-multihal.xml"],
...
...
This diff is collapsed.
Click to expand it.
sensors/HalProxy.cpp
0 → 100644
+
754
−
0
View file @
7c06a601
This diff is collapsed.
Click to expand it.
sensors/HalProxyCallback.cpp
0 → 100644
+
84
−
0
View file @
7c06a601
/*
* 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.
*/
#include
"HalProxyCallback.h"
#include
<cinttypes>
namespace
android
{
namespace
hardware
{
namespace
sensors
{
namespace
V2_0
{
namespace
implementation
{
static
constexpr
int32_t
kBitsAfterSubHalIndex
=
24
;
/**
* Set the subhal index as first byte of sensor handle and return this modified version.
*
* @param sensorHandle The sensor handle to modify.
* @param subHalIndex The index in the hal proxy of the sub hal this sensor belongs to.
*
* @return The modified sensor handle.
*/
int32_t
setSubHalIndex
(
int32_t
sensorHandle
,
size_t
subHalIndex
)
{
return
sensorHandle
|
(
static_cast
<
int32_t
>
(
subHalIndex
)
<<
kBitsAfterSubHalIndex
);
}
void
HalProxyCallbackBase
::
postEvents
(
const
std
::
vector
<
V2_1
::
Event
>&
events
,
ScopedWakelock
wakelock
)
{
if
(
events
.
empty
()
||
!
mCallback
->
areThreadsRunning
())
return
;
size_t
numWakeupEvents
;
std
::
vector
<
V2_1
::
Event
>
processedEvents
=
processEvents
(
events
,
&
numWakeupEvents
);
if
(
numWakeupEvents
>
0
)
{
ALOG_ASSERT
(
wakelock
.
isLocked
(),
"Wakeup events posted while wakelock unlocked for subhal"
" w/ index %"
PRId32
"."
,
mSubHalIndex
);
}
else
{
ALOG_ASSERT
(
!
wakelock
.
isLocked
(),
"No Wakeup events posted but wakelock locked for subhal"
" w/ index %"
PRId32
"."
,
mSubHalIndex
);
}
mCallback
->
postEventsToMessageQueue
(
processedEvents
,
numWakeupEvents
,
std
::
move
(
wakelock
));
}
ScopedWakelock
HalProxyCallbackBase
::
createScopedWakelock
(
bool
lock
)
{
ScopedWakelock
wakelock
(
mRefCounter
,
lock
);
return
wakelock
;
}
std
::
vector
<
V2_1
::
Event
>
HalProxyCallbackBase
::
processEvents
(
const
std
::
vector
<
V2_1
::
Event
>&
events
,
size_t
*
numWakeupEvents
)
const
{
*
numWakeupEvents
=
0
;
std
::
vector
<
V2_1
::
Event
>
eventsOut
;
for
(
V2_1
::
Event
event
:
events
)
{
event
.
sensorHandle
=
setSubHalIndex
(
event
.
sensorHandle
,
mSubHalIndex
);
eventsOut
.
push_back
(
event
);
const
V2_1
::
SensorInfo
&
sensor
=
mCallback
->
getSensorInfo
(
event
.
sensorHandle
);
if
((
sensor
.
flags
&
V1_0
::
SensorFlagBits
::
WAKE_UP
)
!=
0
)
{
(
*
numWakeupEvents
)
++
;
}
}
return
eventsOut
;
}
}
// namespace implementation
}
// namespace V2_0
}
// namespace sensors
}
// namespace hardware
}
// namespace android
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