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

Commit e19085a0 authored by Ahaan Ugale's avatar Ahaan Ugale
Browse files

Fix UiTranslationStateCallback crash due to null locales.

The locales aren't available on a RESUMED event; now they're stored on a
STARTED event. The crash happens because the default Callback impl
converts the Locale to a string to support a deprecated method.

Fix: 186392998
Test: manual - install test apk which triggers the crash. no crash with
 this change.
Change-Id: Iaceca8d29f4c2b0d692c8f6780b0ab963e4e2243
parent 19a0cc75
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -315,6 +315,8 @@ public final class UiTranslationManager {
    private static class UiTranslationStateRemoteCallback extends IRemoteCallback.Stub {
        private final Executor mExecutor;
        private final UiTranslationStateCallback mCallback;
        private ULocale mSourceLocale;
        private ULocale mTargetLocale;

        UiTranslationStateRemoteCallback(Executor executor,
                UiTranslationStateCallback callback) {
@@ -331,10 +333,12 @@ public final class UiTranslationManager {
            int state = bundle.getInt(EXTRA_STATE);
            switch (state) {
                case STATE_UI_TRANSLATION_STARTED:
                    mSourceLocale = (ULocale) bundle.getSerializable(EXTRA_SOURCE_LOCALE);
                    mTargetLocale = (ULocale) bundle.getSerializable(EXTRA_TARGET_LOCALE);
                    mCallback.onStarted(mSourceLocale, mTargetLocale);
                    break;
                case STATE_UI_TRANSLATION_RESUMED:
                    mCallback.onStarted(
                            (ULocale) bundle.getSerializable(EXTRA_SOURCE_LOCALE),
                            (ULocale) bundle.getSerializable(EXTRA_TARGET_LOCALE));
                    mCallback.onStarted(mSourceLocale, mTargetLocale);
                    break;
                case STATE_UI_TRANSLATION_PAUSED:
                    mCallback.onPaused();