Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
f3fe2d12
Commit
f3fe2d12
authored
1 year ago
by
Treehugger Robot
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Non-functionally refactor createBluetoothRoute" into main
parents
50788fe6
81be8279
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/core/java/com/android/server/media/BluetoothDeviceRoutesManager.java
+45
-21
45 additions, 21 deletions
...om/android/server/media/BluetoothDeviceRoutesManager.java
with
45 additions
and
21 deletions
services/core/java/com/android/server/media/BluetoothDeviceRoutesManager.java
+
45
−
21
View file @
f3fe2d12
...
...
@@ -134,10 +134,8 @@ import java.util.stream.Collectors;
@Nullable
public
synchronized
String
getRouteIdForBluetoothAddress
(
@Nullable
String
address
)
{
BluetoothDevice
bluetoothDevice
=
mAddressToBondedDevice
.
get
(
address
);
// TODO: b/305199571 - Optimize the following statement to avoid creating the full
// MediaRoute2Info instance. We just need the id.
return
bluetoothDevice
!=
null
?
createBluetoothRout
e
(
bluetoothDevice
)
.
mRoute
.
getId
(
)
?
getRouteIdForType
(
bluetoothDevice
,
getDeviceTyp
e
(
bluetoothDevice
))
:
null
;
}
...
...
@@ -227,25 +225,10 @@ import java.util.stream.Collectors;
newBtRoute
.
mBtDevice
=
device
;
String
deviceName
=
getDeviceName
(
device
);
String
routeId
=
device
.
getAddress
();
int
type
=
MediaRoute2Info
.
TYPE_BLUETOOTH_A2DP
;
newBtRoute
.
mConnectedProfiles
=
new
SparseBooleanArray
();
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
A2DP
,
device
))
{
newBtRoute
.
mConnectedProfiles
.
put
(
BluetoothProfile
.
A2DP
,
true
);
}
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
HEARING_AID
,
device
))
{
newBtRoute
.
mConnectedProfiles
.
put
(
BluetoothProfile
.
HEARING_AID
,
true
);
routeId
=
HEARING_AID_ROUTE_ID_PREFIX
+
mBluetoothProfileMonitor
.
getGroupId
(
BluetoothProfile
.
HEARING_AID
,
device
);
type
=
MediaRoute2Info
.
TYPE_HEARING_AID
;
}
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
LE_AUDIO
,
device
))
{
newBtRoute
.
mConnectedProfiles
.
put
(
BluetoothProfile
.
LE_AUDIO
,
true
);
routeId
=
LE_AUDIO_ROUTE_ID_PREFIX
+
mBluetoothProfileMonitor
.
getGroupId
(
BluetoothProfile
.
LE_AUDIO
,
device
);
type
=
MediaRoute2Info
.
TYPE_BLE_HEADSET
;
}
int
type
=
getDeviceType
(
device
);
String
routeId
=
getRouteIdForType
(
device
,
type
);
newBtRoute
.
mConnectedProfiles
=
getConnectedProfiles
(
device
);
// Note that volume is only relevant for active bluetooth routes, and those are managed via
// AudioManager.
newBtRoute
.
mRoute
=
...
...
@@ -273,6 +256,47 @@ import java.util.stream.Collectors;
}
return
deviceName
;
}
private
SparseBooleanArray
getConnectedProfiles
(
@NonNull
BluetoothDevice
device
)
{
SparseBooleanArray
connectedProfiles
=
new
SparseBooleanArray
();
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
A2DP
,
device
))
{
connectedProfiles
.
put
(
BluetoothProfile
.
A2DP
,
true
);
}
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
HEARING_AID
,
device
))
{
connectedProfiles
.
put
(
BluetoothProfile
.
HEARING_AID
,
true
);
}
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
LE_AUDIO
,
device
))
{
connectedProfiles
.
put
(
BluetoothProfile
.
LE_AUDIO
,
true
);
}
return
connectedProfiles
;
}
private
int
getDeviceType
(
@NonNull
BluetoothDevice
device
)
{
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
LE_AUDIO
,
device
))
{
return
MediaRoute2Info
.
TYPE_BLE_HEADSET
;
}
if
(
mBluetoothProfileMonitor
.
isProfileSupported
(
BluetoothProfile
.
HEARING_AID
,
device
))
{
return
MediaRoute2Info
.
TYPE_HEARING_AID
;
}
return
MediaRoute2Info
.
TYPE_BLUETOOTH_A2DP
;
}
private
String
getRouteIdForType
(
@NonNull
BluetoothDevice
device
,
int
type
)
{
return
switch
(
type
)
{
case
(
MediaRoute2Info
.
TYPE_BLE_HEADSET
)
->
LE_AUDIO_ROUTE_ID_PREFIX
+
mBluetoothProfileMonitor
.
getGroupId
(
BluetoothProfile
.
LE_AUDIO
,
device
);
case
(
MediaRoute2Info
.
TYPE_HEARING_AID
)
->
HEARING_AID_ROUTE_ID_PREFIX
+
mBluetoothProfileMonitor
.
getGroupId
(
BluetoothProfile
.
HEARING_AID
,
device
);
// TYPE_BLUETOOTH_A2DP
default
->
device
.
getAddress
();
};
}
private
static
class
BluetoothRouteInfo
{
private
BluetoothDevice
mBtDevice
;
...
...
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