Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62cc96ac authored by SongFerngWang's avatar SongFerngWang
Browse files

UI add more log

Bug: 260535339
Bug: 275754566
Test: build pass
Change-Id: I15c26d5b13f93e5a425c16174d6fbc2780c4e0a6
parent 785cdf54
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
        implements Preference.OnPreferenceClickListener {

    private static final String TAG = "AvailableMediaBluetoothDeviceUpdater";
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
    private static final boolean DBG = Log.isLoggable(BluetoothDeviceUpdater.TAG, Log.DEBUG);

    private static final String PREF_KEY = "available_media_bt";

@@ -111,4 +111,15 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
    protected String getPreferenceKey() {
        return PREF_KEY;
    }

    @Override
    protected String getLogTag() {
        return TAG;
    }

    @Override
    protected void update(CachedBluetoothDevice cachedBluetoothDevice) {
        super.update(cachedBluetoothDevice);
        Log.d(TAG, "Map : " + mPreferenceMap);
    }
}
+13 −7
Original line number Diff line number Diff line
@@ -267,8 +267,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
            for (LocalBluetoothProfile profile : tmpResult) {
                if (mProfileDeviceMap.containsKey(profile.toString())) {
                    mProfileDeviceMap.get(profile.toString()).add(cachedItem);
                    Log.d(TAG, "getProfiles: " + profile.toString() + " add device "
                            + cachedItem.getDevice().getAnonymizedAddress());
                } else {
                    List<CachedBluetoothDevice> tmpCachedDeviceList =
                            new ArrayList<CachedBluetoothDevice>();
@@ -303,7 +301,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
            result.remove(mManager.getProfileManager().getA2dpProfile());
            result.remove(mManager.getProfileManager().getHeadsetProfile());
        }
        Log.d(TAG, "getProfiles:result:" + result);
        Log.d(TAG, "getProfiles:Map:" + mProfileDeviceMap);
        return result;
    }

@@ -336,7 +334,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll

        for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
            Log.d(TAG,
                    "User disable LE device: " + leAudioDevice.getDevice().getAnonymizedAddress());
                    "device:" + leAudioDevice.getDevice().getAnonymizedAddress()
                            + "disable LE profile");
            profile.setEnabled(leAudioDevice.getDevice(), false);
            if (vcp != null) {
                vcp.setEnabled(leAudioDevice.getDevice(), false);
@@ -374,7 +373,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
        LocalBluetoothProfile csip = mProfileManager.getCsipSetCoordinatorProfile();
        for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
            Log.d(TAG,
                    "User enable LE device: " + leAudioDevice.getDevice().getAnonymizedAddress());
                    "device:" + leAudioDevice.getDevice().getAnonymizedAddress()
                            + "enable LE profile");
            profile.setEnabled(leAudioDevice.getDevice(), true);
            if (vcp != null) {
                vcp.setEnabled(leAudioDevice.getDevice(), true);
@@ -390,9 +390,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
            Log.d(TAG, "Disable " + profile.toString() + " before user enables LE");
            for (CachedBluetoothDevice profileDevice : mProfileDeviceMap.get(profile.toString())) {
                if (profile.isEnabled(profileDevice.getDevice())) {
                    Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":"
                            + profile.toString() + " set disable");
                    profile.setEnabled(profileDevice.getDevice(), false);
                } else {
                    Log.d(TAG, "The " + profile.toString() + " profile is disabled. Do nothing.");
                    Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":"
                            + profile.toString() + " profile is disabled. Do nothing.");
                }
            }
        }
@@ -403,9 +406,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
            Log.d(TAG, "enable " + profile.toString() + "after user disables LE");
            for (CachedBluetoothDevice profileDevice : mProfileDeviceMap.get(profile.toString())) {
                if (!profile.isEnabled(profileDevice.getDevice())) {
                    Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":"
                            + profile.toString() + " set enable");
                    profile.setEnabled(profileDevice.getDevice(), true);
                } else {
                    Log.d(TAG, "The " + profile.toString() + " profile is enabled. Do nothing.");
                    Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":"
                            + profile.toString() + " profile is enabled. Do nothing.");
                }
            }
        }
+13 −9
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
    protected LocalBluetoothManager mLocalManager;
    protected int mMetricsCategory;

    private static final String TAG = "BluetoothDeviceUpdater";
    protected static final String TAG = "BluetoothDeviceUpdater";
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);

    @VisibleForTesting
@@ -88,7 +88,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
     */
    public void registerCallback() {
        if (mLocalManager == null) {
            Log.e(TAG, "registerCallback() Bluetooth is not supported on this device");
            Log.e(getLogTag(), "registerCallback() Bluetooth is not supported on this device");
            return;
        }
        mLocalManager.setForegroundActivity(mContext);
@@ -102,7 +102,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
     */
    public void unregisterCallback() {
        if (mLocalManager == null) {
            Log.e(TAG, "unregisterCallback() Bluetooth is not supported on this device");
            Log.e(getLogTag(), "unregisterCallback() Bluetooth is not supported on this device");
            return;
        }
        mLocalManager.setForegroundActivity(null);
@@ -115,7 +115,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
     */
    public void forceUpdate() {
        if (mLocalManager == null) {
            Log.e(TAG, "forceUpdate() Bluetooth is not supported on this device");
            Log.e(getLogTag(), "forceUpdate() Bluetooth is not supported on this device");
            return;
        }
        if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
@@ -131,7 +131,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,

    public void removeAllDevicesFromPreference() {
        if (mLocalManager == null) {
            Log.e(TAG, "removeAllDevicesFromPreference() BT is not supported on this device");
            Log.e(getLogTag(),
                    "removeAllDevicesFromPreference() BT is not supported on this device");
            return;
        }
        final Collection<CachedBluetoothDevice> cachedDevices =
@@ -172,7 +173,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
    public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
            int bluetoothProfile) {
        if (DBG) {
            Log.d(TAG, "onProfileConnectionStateChanged() device: " + cachedDevice.getName()
            Log.d(getLogTag(), "onProfileConnectionStateChanged() device: " + cachedDevice.getName()
                    + ", state: " + state + ", bluetoothProfile: " + bluetoothProfile);
        }
        update(cachedDevice);
@@ -181,7 +182,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
    @Override
    public void onAclConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
        if (DBG) {
            Log.d(TAG, "onAclConnectionStateChanged() device: " + cachedDevice.getName()
            Log.d(getLogTag(), "onAclConnectionStateChanged() device: " + cachedDevice.getName()
                    + ", state: " + state);
        }
        update(cachedDevice);
@@ -312,8 +313,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
        }
        final BluetoothDevice device = cachedDevice.getDevice();
        if (DBG) {
            Log.d(TAG, "isDeviceConnected() device name : " + cachedDevice.getName() +
                    ", is connected : " + device.isConnected() + " , is profile connected : "
            Log.d(getLogTag(), "isDeviceConnected() device name : " + cachedDevice.getName()
                    + ", is connected : " + device.isConnected() + " , is profile connected : "
                    + cachedDevice.isConnected());
        }
        return device.getBondState() == BluetoothDevice.BOND_BONDED && device.isConnected();
@@ -331,4 +332,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
    protected boolean isDeviceInCachedDevicesList(CachedBluetoothDevice cachedDevice){
        return mLocalManager.getCachedDeviceManager().getCachedDevicesCopy().contains(cachedDevice);
    }
    protected String getLogTag() {
        return TAG;
    }
}
+12 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice;
public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {

    private static final String TAG = "ConnBluetoothDeviceUpdater";
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
    private static final boolean DBG = Log.isLoggable(BluetoothDeviceUpdater.TAG, Log.DEBUG);

    private static final String PREF_KEY = "connected_bt";

@@ -118,4 +118,15 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
    protected String getPreferenceKey() {
        return PREF_KEY;
    }

    @Override
    protected String getLogTag() {
        return TAG;
    }

    @Override
    protected void update(CachedBluetoothDevice cachedBluetoothDevice) {
        super.update(cachedBluetoothDevice);
        Log.d(TAG, "Map : " + mPreferenceMap);
    }
}
+20 −5
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
    @VisibleForTesting
    LayoutPreference mLayoutPreference;
    private CachedBluetoothDevice mCachedDevice;
    private List<CachedBluetoothDevice> mLeAudioDevices;
    @VisibleForTesting
    Handler mHandler = new Handler(Looper.getMainLooper());
    @VisibleForTesting
@@ -128,7 +129,13 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
            return;
        }
        mIsRegisterCallback = true;
        if (mLeAudioDevices != null && !mLeAudioDevices.isEmpty()) {
            for (CachedBluetoothDevice item : mLeAudioDevices) {
                item.registerCallback(this);
            }
        } else {
            mCachedDevice.registerCallback(this);
        }
        refresh();
    }

@@ -137,7 +144,13 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
        if (!mIsRegisterCallback) {
            return;
        }
        if (mLeAudioDevices != null && !mLeAudioDevices.isEmpty()) {
            for (CachedBluetoothDevice item : mLeAudioDevices) {
                item.unregisterCallback(this);
            }
        } else {
            mCachedDevice.unregisterCallback(this);
        }
        mIsRegisterCallback = false;
    }

@@ -149,6 +162,8 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
            LocalBluetoothManager bluetoothManager) {
        mCachedDevice = cachedBluetoothDevice;
        mProfileManager = bluetoothManager.getProfileManager();
        mLeAudioDevices = getAllOfLeAudioDevices();

    }

    @VisibleForTesting
@@ -230,15 +245,15 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
                leAudioDevices.add(member);
            }
        }
        Log.d(TAG, "mLeAudioDevices is " + mLeAudioDevices);
        return leAudioDevices;
    }

    private void updateBatteryLayout() {
        // Init the battery layouts.
        hideAllOfBatteryLayouts();
        final List<CachedBluetoothDevice> leAudioDevices = getAllOfLeAudioDevices();
        LeAudioProfile leAudioProfile = mProfileManager.getLeAudioProfile();
        if (leAudioDevices == null || leAudioDevices.isEmpty()) {
        if (mLeAudioDevices == null || mLeAudioDevices.isEmpty()) {
            Log.e(TAG, "There is no LeAudioProfile.");
            return;
        }
@@ -252,7 +267,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
            return;
        }

        for (CachedBluetoothDevice cachedDevice : leAudioDevices) {
        for (CachedBluetoothDevice cachedDevice : mLeAudioDevices) {
            int deviceId = leAudioProfile.getAudioLocation(cachedDevice.getDevice());
            Log.d(TAG, "LeAudioDevices:" + cachedDevice.getDevice().getAnonymizedAddress()
                    + ", deviceId:" + deviceId);
Loading