Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Bluetooth
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
platform_packages_modules_Bluetooth
Commits
976361c4
Commit
976361c4
authored
2 years ago
by
Hui Peng
Committed by
Android (Google) Code Review
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add regression test for b/254774758" into tm-dev
parents
a3141b5d
be2a1570
No related branches found
Branches containing commit
No related tags found
Loading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
system/gd/Android.bp
+1
-0
1 addition, 0 deletions
system/gd/Android.bp
system/gd/btaa/Android.bp
+7
-0
7 additions, 0 deletions
system/gd/btaa/Android.bp
system/gd/btaa/linux_generic/attribution_processor_tests.cc
+85
-0
85 additions, 0 deletions
system/gd/btaa/linux_generic/attribution_processor_tests.cc
with
93 additions
and
0 deletions
system/gd/Android.bp
+
1
−
0
View file @
976361c4
...
...
@@ -373,6 +373,7 @@ cc_test {
":BluetoothShimTestSources",
":BluetoothSecurityUnitTestSources",
":BluetoothStorageUnitTestSources",
":BluetoothBtaaSources_linux_generic_tests",
],
generated_headers: [
"BluetoothGeneratedBundlerSchema_h_bfbs",
...
...
This diff is collapsed.
Click to expand it.
system/gd/btaa/Android.bp
+
7
−
0
View file @
976361c4
...
...
@@ -30,3 +30,10 @@ filegroup {
"linux_generic/wakelock_processor.cc",
],
}
filegroup {
name: "BluetoothBtaaSources_linux_generic_tests",
srcs: [
"linux_generic/attribution_processor_tests.cc",
],
}
This diff is collapsed.
Click to expand it.
system/gd/btaa/linux_generic/attribution_processor_tests.cc
0 → 100644
+
85
−
0
View file @
976361c4
/*
* Copyright 2022 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
<base/strings/stringprintf.h>
#include
<gtest/gtest.h>
#include
<unistd.h>
#include
<chrono>
#include
<functional>
#include
<memory>
#include
<vector>
#include
"btaa/activity_attribution.h"
#include
"btaa/attribution_processor.h"
using
bluetooth
::
hci
::
Address
;
using
namespace
bluetooth
::
activity_attribution
;
using
namespace
std
::
chrono
;
// mock for std::chrono::system_clock::now
static
AttributionProcessor
::
ClockType
now_ret_val
;
static
AttributionProcessor
::
ClockType
fake_now
()
{
return
now_ret_val
;
}
class
AttributionProcessorTest
:
public
::
testing
::
Test
{
protected:
void
SetUp
()
override
{
pAttProc
=
std
::
make_unique
<
AttributionProcessor
>
(
fake_now
);
}
void
TearDown
()
override
{
pAttProc
.
reset
();
}
std
::
unique_ptr
<
AttributionProcessor
>
pAttProc
;
};
static
void
fake_now_set_current
()
{
now_ret_val
=
system_clock
::
now
();
}
static
void
fake_now_advance_1000sec
()
{
now_ret_val
+=
seconds
(
1000s
);
}
TEST_F
(
AttributionProcessorTest
,
UAFInOnWakelockReleasedRegressionTest
)
{
std
::
vector
<
BtaaHciPacket
>
btaaPackets
;
Address
addr
;
fake_now_set_current
();
// setup the condition 1 for triggering erase operation
// add 220 entries in app_activity_aggregator_
// and btaa_aggregator_
for
(
int
i
=
0
;
i
<
220
;
i
++
)
{
std
::
string
addrStr
=
base
::
StringPrintf
(
"21:43:65:87:a9:%02x"
,
i
+
10
);
ASSERT_TRUE
(
Address
::
FromString
(
addrStr
,
addr
));
BtaaHciPacket
packet
(
Activity
::
ACL
,
addr
,
30
*
i
);
btaaPackets
.
push_back
(
packet
);
pAttProc
->
NotifyActivityAttributionInfo
(
i
+
1000
,
"com.test.app"
+
std
::
to_string
(
i
),
addrStr
);
}
pAttProc
->
OnBtaaPackets
(
btaaPackets
);
pAttProc
->
OnWakelockReleased
(
100
);
// setup the condition 2 for triggering erase operation
// make elapsed_time_sec > 900s
fake_now_advance_1000sec
();
pAttProc
->
OnBtaaPackets
(
btaaPackets
);
pAttProc
->
OnWakelockReleased
(
100
);
}
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