Merge "Fix UiTranslationStateCallback crash due to null locales." into sc-dev am: 2c6a3b5cd0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14419522

Change-Id: Ib46dd5b6bf58e15ade2a1382507dafcb208cb8ba
This commit is contained in:
Joanne Chung
2021-05-04 13:45:52 +00:00
committed by Automerger Merge Worker

View File

@@ -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();