Merge "[Bluetooth] Convert BluetoothController logs to log buffer so we'll always have them." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
390a963bd2
@@ -16,6 +16,20 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_CONNECTED;
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_CONNECTING;
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_DISCONNECTED;
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_DISCONNECTING;
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_OFF;
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_ON;
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF;
|
||||||
|
import static android.bluetooth.BluetoothAdapter.STATE_TURNING_ON;
|
||||||
|
|
||||||
|
import android.annotation.IntDef;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BluetoothCallback provides a callback interface for the settings
|
* BluetoothCallback provides a callback interface for the settings
|
||||||
@@ -33,7 +47,7 @@ public interface BluetoothCallback {
|
|||||||
* {@link android.bluetooth.BluetoothAdapter#STATE_ON},
|
* {@link android.bluetooth.BluetoothAdapter#STATE_ON},
|
||||||
* {@link android.bluetooth.BluetoothAdapter#STATE_TURNING_OFF}.
|
* {@link android.bluetooth.BluetoothAdapter#STATE_TURNING_OFF}.
|
||||||
*/
|
*/
|
||||||
default void onBluetoothStateChanged(int bluetoothState) {}
|
default void onBluetoothStateChanged(@AdapterState int bluetoothState) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It will be called when the local Bluetooth adapter has started
|
* It will be called when the local Bluetooth adapter has started
|
||||||
@@ -89,7 +103,9 @@ public interface BluetoothCallback {
|
|||||||
* {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTED},
|
* {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTED},
|
||||||
* {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTING}.
|
* {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTING}.
|
||||||
*/
|
*/
|
||||||
default void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {}
|
default void onConnectionStateChanged(
|
||||||
|
@Nullable CachedBluetoothDevice cachedDevice,
|
||||||
|
@ConnectionState int state) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It will be called when device been set as active for {@code bluetoothProfile}
|
* It will be called when device been set as active for {@code bluetoothProfile}
|
||||||
@@ -124,8 +140,10 @@ public interface BluetoothCallback {
|
|||||||
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING}.
|
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING}.
|
||||||
* @param bluetoothProfile the BluetoothProfile id.
|
* @param bluetoothProfile the BluetoothProfile id.
|
||||||
*/
|
*/
|
||||||
default void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice,
|
default void onProfileConnectionStateChanged(
|
||||||
int state, int bluetoothProfile) {
|
CachedBluetoothDevice cachedDevice,
|
||||||
|
@ConnectionState int state,
|
||||||
|
int bluetoothProfile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,4 +158,22 @@ public interface BluetoothCallback {
|
|||||||
*/
|
*/
|
||||||
default void onAclConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
|
default void onAclConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@IntDef(prefix = { "STATE_" }, value = {
|
||||||
|
STATE_DISCONNECTED,
|
||||||
|
STATE_CONNECTING,
|
||||||
|
STATE_CONNECTED,
|
||||||
|
STATE_DISCONNECTING,
|
||||||
|
})
|
||||||
|
@interface ConnectionState {}
|
||||||
|
|
||||||
|
@IntDef(prefix = { "STATE_" }, value = {
|
||||||
|
STATE_OFF,
|
||||||
|
STATE_TURNING_ON,
|
||||||
|
STATE_ON,
|
||||||
|
STATE_TURNING_OFF,
|
||||||
|
})
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@interface AdapterState {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.systemui.bluetooth
|
||||||
|
|
||||||
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
|
import com.android.systemui.log.LogBuffer
|
||||||
|
import com.android.systemui.log.LogLevel
|
||||||
|
import com.android.systemui.log.dagger.BluetoothLog
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
/** Helper class for logging bluetooth events. */
|
||||||
|
@SysUISingleton
|
||||||
|
class BluetoothLogger @Inject constructor(@BluetoothLog private val logBuffer: LogBuffer) {
|
||||||
|
fun logActiveDeviceChanged(address: String, profileId: Int) =
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = address
|
||||||
|
int1 = profileId
|
||||||
|
},
|
||||||
|
{ "ActiveDeviceChanged. address=$str1 profileId=$int1" }
|
||||||
|
)
|
||||||
|
|
||||||
|
fun logDeviceConnectionStateChanged(address: String?, state: String) =
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = address
|
||||||
|
str2 = state
|
||||||
|
},
|
||||||
|
{ "DeviceConnectionStateChanged. address=$str1 state=$str2" }
|
||||||
|
)
|
||||||
|
|
||||||
|
fun logAclConnectionStateChanged(address: String, state: String) =
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = address
|
||||||
|
str2 = state
|
||||||
|
},
|
||||||
|
{ "AclConnectionStateChanged. address=$str1 state=$str2" }
|
||||||
|
)
|
||||||
|
|
||||||
|
fun logProfileConnectionStateChanged(address: String, state: String, profileId: Int) =
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = address
|
||||||
|
str2 = state
|
||||||
|
int1 = profileId
|
||||||
|
},
|
||||||
|
{ "ProfileConnectionStateChanged. address=$str1 state=$str2 profileId=$int1" }
|
||||||
|
)
|
||||||
|
|
||||||
|
fun logStateChange(state: String) =
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{ str1 = state },
|
||||||
|
{ "BluetoothStateChanged. state=$str1" }
|
||||||
|
)
|
||||||
|
|
||||||
|
fun logBondStateChange(address: String, state: Int) =
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = address
|
||||||
|
int1 = state
|
||||||
|
},
|
||||||
|
{ "DeviceBondStateChanged. address=$str1 state=$int1" }
|
||||||
|
)
|
||||||
|
|
||||||
|
fun logDeviceAdded(address: String) =
|
||||||
|
logBuffer.log(TAG, LogLevel.DEBUG, { str1 = address }, { "DeviceAdded. address=$str1" })
|
||||||
|
|
||||||
|
fun logDeviceDeleted(address: String) =
|
||||||
|
logBuffer.log(TAG, LogLevel.DEBUG, { str1 = address }, { "DeviceDeleted. address=$str1" })
|
||||||
|
|
||||||
|
fun logDeviceAttributesChanged() =
|
||||||
|
logBuffer.log(TAG, LogLevel.DEBUG, {}, { "DeviceAttributesChanged." })
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val TAG = "BluetoothLog"
|
||||||
@@ -601,7 +601,7 @@ public class KeyboardUI extends CoreStartable implements InputManager.OnTabletMo
|
|||||||
|
|
||||||
private final class BluetoothCallbackHandler implements BluetoothCallback {
|
private final class BluetoothCallbackHandler implements BluetoothCallback {
|
||||||
@Override
|
@Override
|
||||||
public void onBluetoothStateChanged(int bluetoothState) {
|
public void onBluetoothStateChanged(@BluetoothCallback.AdapterState int bluetoothState) {
|
||||||
mHandler.obtainMessage(MSG_ON_BLUETOOTH_STATE_CHANGED,
|
mHandler.obtainMessage(MSG_ON_BLUETOOTH_STATE_CHANGED,
|
||||||
bluetoothState, 0).sendToTarget();
|
bluetoothState, 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.systemui.log.dagger
|
||||||
|
|
||||||
|
import javax.inject.Qualifier
|
||||||
|
|
||||||
|
/** A [com.android.systemui.log.LogBuffer] for bluetooth. */
|
||||||
|
@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class BluetoothLog
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
package com.android.systemui.log.dagger
|
package com.android.systemui.log.dagger
|
||||||
|
|
||||||
|
import javax.inject.Qualifier
|
||||||
|
|
||||||
/** A [com.android.systemui.log.LogBuffer] for KeyguardUpdateMonitor. */
|
/** A [com.android.systemui.log.LogBuffer] for KeyguardUpdateMonitor. */
|
||||||
|
@Qualifier
|
||||||
|
@MustBeDocumented
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
annotation class KeyguardUpdateMonitorLog
|
annotation class KeyguardUpdateMonitorLog
|
||||||
|
|||||||
@@ -305,4 +305,14 @@ public class LogModule {
|
|||||||
public static LogBuffer provideKeyguardUpdateMonitorLogBuffer(LogBufferFactory factory) {
|
public static LogBuffer provideKeyguardUpdateMonitorLogBuffer(LogBufferFactory factory) {
|
||||||
return factory.create("KeyguardUpdateMonitorLog", 200);
|
return factory.create("KeyguardUpdateMonitorLog", 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a {@link LogBuffer} for bluetooth-related logs.
|
||||||
|
*/
|
||||||
|
@Provides
|
||||||
|
@SysUISingleton
|
||||||
|
@BluetoothLog
|
||||||
|
public static LogBuffer providerBluetoothLogBuffer(LogBufferFactory factory) {
|
||||||
|
return factory.create("BluetoothLog", 50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import android.os.Looper;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
@@ -37,6 +36,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
|||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
|
import com.android.systemui.bluetooth.BluetoothLogger;
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.dagger.qualifiers.Background;
|
import com.android.systemui.dagger.qualifiers.Background;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
@@ -57,9 +57,9 @@ import javax.inject.Inject;
|
|||||||
public class BluetoothControllerImpl implements BluetoothController, BluetoothCallback,
|
public class BluetoothControllerImpl implements BluetoothController, BluetoothCallback,
|
||||||
CachedBluetoothDevice.Callback, LocalBluetoothProfileManager.ServiceListener {
|
CachedBluetoothDevice.Callback, LocalBluetoothProfileManager.ServiceListener {
|
||||||
private static final String TAG = "BluetoothController";
|
private static final String TAG = "BluetoothController";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
|
||||||
|
|
||||||
private final DumpManager mDumpManager;
|
private final DumpManager mDumpManager;
|
||||||
|
private final BluetoothLogger mLogger;
|
||||||
private final LocalBluetoothManager mLocalBluetoothManager;
|
private final LocalBluetoothManager mLocalBluetoothManager;
|
||||||
private final UserManager mUserManager;
|
private final UserManager mUserManager;
|
||||||
private final int mCurrentUser;
|
private final int mCurrentUser;
|
||||||
@@ -70,6 +70,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
private final List<CachedBluetoothDevice> mConnectedDevices = new ArrayList<>();
|
private final List<CachedBluetoothDevice> mConnectedDevices = new ArrayList<>();
|
||||||
|
|
||||||
private boolean mEnabled;
|
private boolean mEnabled;
|
||||||
|
@ConnectionState
|
||||||
private int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED;
|
private int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED;
|
||||||
private boolean mAudioProfileOnly;
|
private boolean mAudioProfileOnly;
|
||||||
private boolean mIsActive;
|
private boolean mIsActive;
|
||||||
@@ -83,10 +84,12 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
public BluetoothControllerImpl(
|
public BluetoothControllerImpl(
|
||||||
Context context,
|
Context context,
|
||||||
DumpManager dumpManager,
|
DumpManager dumpManager,
|
||||||
|
BluetoothLogger logger,
|
||||||
@Background Looper bgLooper,
|
@Background Looper bgLooper,
|
||||||
@Main Looper mainLooper,
|
@Main Looper mainLooper,
|
||||||
@Nullable LocalBluetoothManager localBluetoothManager) {
|
@Nullable LocalBluetoothManager localBluetoothManager) {
|
||||||
mDumpManager = dumpManager;
|
mDumpManager = dumpManager;
|
||||||
|
mLogger = logger;
|
||||||
mLocalBluetoothManager = localBluetoothManager;
|
mLocalBluetoothManager = localBluetoothManager;
|
||||||
mBgHandler = new Handler(bgLooper);
|
mBgHandler = new Handler(bgLooper);
|
||||||
mHandler = new H(mainLooper);
|
mHandler = new H(mainLooper);
|
||||||
@@ -116,7 +119,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pw.print(" mEnabled="); pw.println(mEnabled);
|
pw.print(" mEnabled="); pw.println(mEnabled);
|
||||||
pw.print(" mConnectionState="); pw.println(stateToString(mConnectionState));
|
pw.print(" mConnectionState="); pw.println(connectionStateToString(mConnectionState));
|
||||||
pw.print(" mAudioProfileOnly="); pw.println(mAudioProfileOnly);
|
pw.print(" mAudioProfileOnly="); pw.println(mAudioProfileOnly);
|
||||||
pw.print(" mIsActive="); pw.println(mIsActive);
|
pw.print(" mIsActive="); pw.println(mIsActive);
|
||||||
pw.print(" mConnectedDevices="); pw.println(getConnectedDevices());
|
pw.print(" mConnectedDevices="); pw.println(getConnectedDevices());
|
||||||
@@ -127,7 +130,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String stateToString(int state) {
|
private static String connectionStateToString(@ConnectionState int state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BluetoothAdapter.STATE_CONNECTED:
|
case BluetoothAdapter.STATE_CONNECTED:
|
||||||
return "CONNECTED";
|
return "CONNECTED";
|
||||||
@@ -320,8 +323,8 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBluetoothStateChanged(int bluetoothState) {
|
public void onBluetoothStateChanged(@AdapterState int bluetoothState) {
|
||||||
if (DEBUG) Log.d(TAG, "BluetoothStateChanged=" + stateToString(bluetoothState));
|
mLogger.logStateChange(BluetoothAdapter.nameForState(bluetoothState));
|
||||||
mEnabled = bluetoothState == BluetoothAdapter.STATE_ON
|
mEnabled = bluetoothState == BluetoothAdapter.STATE_ON
|
||||||
|| bluetoothState == BluetoothAdapter.STATE_TURNING_ON;
|
|| bluetoothState == BluetoothAdapter.STATE_TURNING_ON;
|
||||||
mState = bluetoothState;
|
mState = bluetoothState;
|
||||||
@@ -331,7 +334,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeviceAdded(CachedBluetoothDevice cachedDevice) {
|
public void onDeviceAdded(CachedBluetoothDevice cachedDevice) {
|
||||||
if (DEBUG) Log.d(TAG, "DeviceAdded=" + cachedDevice.getAddress());
|
mLogger.logDeviceAdded(cachedDevice.getAddress());
|
||||||
cachedDevice.registerCallback(this);
|
cachedDevice.registerCallback(this);
|
||||||
updateConnected();
|
updateConnected();
|
||||||
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
||||||
@@ -339,7 +342,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) {
|
public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) {
|
||||||
if (DEBUG) Log.d(TAG, "DeviceDeleted=" + cachedDevice.getAddress());
|
mLogger.logDeviceDeleted(cachedDevice.getAddress());
|
||||||
mCachedState.remove(cachedDevice);
|
mCachedState.remove(cachedDevice);
|
||||||
updateConnected();
|
updateConnected();
|
||||||
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
||||||
@@ -347,7 +350,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
|
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
|
||||||
if (DEBUG) Log.d(TAG, "DeviceBondStateChanged=" + cachedDevice.getAddress());
|
mLogger.logBondStateChange(cachedDevice.getAddress(), bondState);
|
||||||
mCachedState.remove(cachedDevice);
|
mCachedState.remove(cachedDevice);
|
||||||
updateConnected();
|
updateConnected();
|
||||||
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
||||||
@@ -355,29 +358,29 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeviceAttributesChanged() {
|
public void onDeviceAttributesChanged() {
|
||||||
if (DEBUG) Log.d(TAG, "DeviceAttributesChanged");
|
mLogger.logDeviceAttributesChanged();
|
||||||
updateConnected();
|
updateConnected();
|
||||||
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
|
public void onConnectionStateChanged(
|
||||||
if (DEBUG) {
|
@Nullable CachedBluetoothDevice cachedDevice,
|
||||||
Log.d(TAG, "ConnectionStateChanged=" + cachedDevice.getAddress() + " "
|
@ConnectionState int state) {
|
||||||
+ stateToString(state));
|
String address = cachedDevice == null ? null : cachedDevice.getAddress();
|
||||||
}
|
mLogger.logDeviceConnectionStateChanged(address, connectionStateToString(state));
|
||||||
mCachedState.remove(cachedDevice);
|
mCachedState.remove(cachedDevice);
|
||||||
updateConnected();
|
updateConnected();
|
||||||
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice,
|
public void onProfileConnectionStateChanged(
|
||||||
int state, int bluetoothProfile) {
|
CachedBluetoothDevice cachedDevice,
|
||||||
if (DEBUG) {
|
@ConnectionState int state,
|
||||||
Log.d(TAG, "ProfileConnectionStateChanged=" + cachedDevice.getAddress() + " "
|
int bluetoothProfile) {
|
||||||
+ stateToString(state) + " profileId=" + bluetoothProfile);
|
mLogger.logProfileConnectionStateChanged(
|
||||||
}
|
cachedDevice.getAddress(), connectionStateToString(state), bluetoothProfile);
|
||||||
mCachedState.remove(cachedDevice);
|
mCachedState.remove(cachedDevice);
|
||||||
updateConnected();
|
updateConnected();
|
||||||
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
||||||
@@ -385,20 +388,15 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) {
|
public void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) {
|
||||||
if (DEBUG) {
|
mLogger.logActiveDeviceChanged(activeDevice.getAddress(), bluetoothProfile);
|
||||||
Log.d(TAG, "ActiveDeviceChanged=" + activeDevice.getAddress()
|
|
||||||
+ " profileId=" + bluetoothProfile);
|
|
||||||
}
|
|
||||||
updateActive();
|
updateActive();
|
||||||
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAclConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
|
public void onAclConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
|
||||||
if (DEBUG) {
|
mLogger.logAclConnectionStateChanged(
|
||||||
Log.d(TAG, "ACLConnectionStateChanged=" + cachedDevice.getAddress() + " "
|
cachedDevice.getAddress(), connectionStateToString(state));
|
||||||
+ stateToString(state));
|
|
||||||
}
|
|
||||||
mCachedState.remove(cachedDevice);
|
mCachedState.remove(cachedDevice);
|
||||||
updateConnected();
|
updateConnected();
|
||||||
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
|||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.bluetooth.BluetoothLogger;
|
||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -81,6 +82,7 @@ public class BluetoothControllerImplTest extends SysuiTestCase {
|
|||||||
|
|
||||||
mBluetoothControllerImpl = new BluetoothControllerImpl(mContext,
|
mBluetoothControllerImpl = new BluetoothControllerImpl(mContext,
|
||||||
mMockDumpManager,
|
mMockDumpManager,
|
||||||
|
mock(BluetoothLogger.class),
|
||||||
mTestableLooper.getLooper(),
|
mTestableLooper.getLooper(),
|
||||||
mTestableLooper.getLooper(),
|
mTestableLooper.getLooper(),
|
||||||
mMockBluetoothManager);
|
mMockBluetoothManager);
|
||||||
|
|||||||
Reference in New Issue
Block a user