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

Commit 3afd5f20 authored by Josh Hou's avatar Josh Hou
Browse files

NPE protection

ComponentName#unflattenFromString is a @Nullable API, so take the NPE protection to avoid the crashes

Bug: 304184859
Test: Run CTS
      atest LocaleManagerTests
      atest CtsLocaleManagerHostTestCases

      Run unit test
      atest LocaleManagerServiceTest

Change-Id: Idf981304b9eaf31bc7ed39dde86ed6801fcbb7e0
parent f7f16510
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -486,9 +486,12 @@ public class LocaleManagerService extends SystemService {
                Settings.Secure.DEFAULT_INPUT_METHOD,
                userId);
        if (!TextUtils.isEmpty(currentInputMethod)) {
            String inputMethodPkgName = ComponentName
                    .unflattenFromString(currentInputMethod)
                    .getPackageName();
            ComponentName componentName = ComponentName.unflattenFromString(currentInputMethod);
            if (componentName == null) {
                Slog.d(TAG, "inValid input method");
                return false;
            }
            String inputMethodPkgName = componentName.getPackageName();
            int inputMethodUid = getPackageUid(inputMethodPkgName, userId);
            return inputMethodUid >= 0 && UserHandle.isSameApp(Binder.getCallingUid(),
                    inputMethodUid);