fix bug 184901520.
getParcelableArray may return Parcelable[] which cannot be casted to TranslationCapability[] BUG=184901520 Test: Manually Change-Id: Ic49c2b7454e61b470dd766294a58e3dc7b3720b0
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user