Fix preferences under Related category can not launch its own page in bluetooth device details page

Root Cause: KeyboardSettingsPreferenceController override
handlePreferenceTreeClick() without checking the preference key, it will lead to handle all preferences' click action.

Solution: Check the preference is the expected preference key

Bug: 264017256
Test: make RunSettingsRoboTests ROBOTEST_FILTER=KeyboardSettingsPreferenceControllerTest
Change-Id: Idcdadc323df5b758b4b21329227e2bb721b1c394
This commit is contained in:
jasonwshsu
2022-12-30 19:35:15 +08:00
committed by Jason Hsu
parent 181119f0b5
commit 829a671265
2 changed files with 94 additions and 0 deletions

View File

@@ -50,6 +50,10 @@ public class KeyboardSettingsPreferenceController extends BasePreferenceControll
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (!getPreferenceKey().equals(preference.getKey())) {
return false;
}
final Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
intent.setClass(mContext, PhysicalKeyboardActivity.class);
intent.putExtra(PhysicalKeyboardFragment.EXTRA_BT_ADDRESS, mCachedDevice.getAddress());