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

Commit d952496f authored by synch's avatar synch
Browse files

fix bug 184901520.

getParcelableArray may return Parcelable[] which cannot be casted to
TranslationCapability[]

BUG=184901520
Test: Manually

Change-Id: Ic49c2b7454e61b470dd766294a58e3dc7b3720b0
parent b6a26615
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.PendingIntent;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SynchronousResultReceiver;
import android.util.ArrayMap;
@@ -200,8 +201,14 @@ public final class TranslationManager {
            if (result.resultCode != STATUS_SYNC_CALL_SUCCESS) {
                return Collections.emptySet();
            }
            return new ArraySet<>(
                    (TranslationCapability[]) result.bundle.getParcelableArray(EXTRA_CAPABILITIES));
            Parcelable[] parcelables = result.bundle.getParcelableArray(EXTRA_CAPABILITIES);
            ArraySet<TranslationCapability> capabilities = new ArraySet();
            for (Parcelable obj : parcelables) {
                if (obj instanceof TranslationCapability) {
                    capabilities.add((TranslationCapability) obj);
                }
            }
            return capabilities;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        } catch (TimeoutException e) {