[Physical Keyboard Setting] Add log and null check

update getParcelable api usage, add null check and logging.

Bug: 317416208
Test: Verified on device
Change-Id: I125a6c9cdb5c86be7582ad5102257efb1fa6a1a4
This commit is contained in:
shaoweishen
2024-01-08 08:33:01 +00:00
committed by Shaowei Shen
parent 2a1051cbab
commit ff74d9db0b
2 changed files with 13 additions and 4 deletions

View File

@@ -105,8 +105,13 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
public void onActivityCreated(final Bundle icicle) {
super.onActivityCreated(icicle);
Bundle arguments = getArguments();
if (arguments == null) {
Log.e(TAG, "Arguments should not be null");
return;
}
mInputDeviceIdentifier =
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
InputDeviceIdentifier.class);
if (mInputDeviceIdentifier == null) {
Log.e(TAG, "The inputDeviceIdentifier should not be null");
return;
@@ -128,6 +133,7 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
InputDevice inputDevice =
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
if (inputDevice == null) {
Log.e(TAG, "Unable to start: input device is null");
getActivity().finish();
return;
}