Fix corss-link hearing device settings

Root Cause: There are two device details entries in Connected devices and Hearing devices page which can both go to the same page, it will have the endless loop problem.

Solution: Only show hearing device settings comes from Connected devices page.

Bug: 320709814
Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothDeviceDetailsFragmentTest
Change-Id: I26941d0d16ab3bb0df0cb2c481c25c6c41340261
This commit is contained in:
jasonwshsu
2024-01-23 22:30:35 +08:00
parent a3e5036311
commit 917682603c
3 changed files with 59 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.hardware.input.InputManager;
import android.net.Uri;
@@ -53,6 +54,7 @@ import com.android.settings.slices.SlicePreferenceController;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.ArrayList;
@@ -324,8 +326,11 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
lifecycle));
controllers.add(new BluetoothDetailsPairOtherController(context, this, mCachedDevice,
lifecycle));
controllers.add(new BluetoothDetailsHearingDeviceControlsController(context, this,
mCachedDevice, lifecycle));
// Don't need to show hearing device again when launched from the same page.
if (!isLaunchFromHearingDevicePage()) {
controllers.add(new BluetoothDetailsHearingDeviceControlsController(context, this,
mCachedDevice, lifecycle));
}
controllers.add(new BluetoothDetailsDataSyncController(context, this,
mCachedDevice, lifecycle));
}
@@ -345,6 +350,16 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
return width;
}
private boolean isLaunchFromHearingDevicePage() {
final Intent intent = getIntent();
if (intent == null) {
return false;
}
return intent.getIntExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY,
SettingsEnums.PAGE_UNKNOWN) == SettingsEnums.ACCESSIBILITY_HEARING_AID_SETTINGS;
}
@VisibleForTesting
void setTitleForInputDevice() {
if (StylusDevicesController.isDeviceStylus(mInputDevice, mCachedDevice)) {