From 6c5e604a571dc7f337c68568c4045246f107b6ca Mon Sep 17 00:00:00 2001 From: John David Taylor Date: Tue, 13 Oct 2020 22:07:34 -0400 Subject: [PATCH] Change the way we parse the binary protocol buffers to see if it fixes (#364) the crashes on some devices. --- app/build.gradle | 4 ++-- .../android/stardroid/layers/AbstractFileBasedLayer.java | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d8ca4a598..999093ada 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.google.android.stardroid" minSdkVersion 16 targetSdkVersion 30 - versionCode 1518 - versionName "1.9.6 - RC1" + versionCode 1519 + versionName "1.9.6 - RC2" buildConfigField 'String', 'GOOGLE_ANALYTICS_CODE', '""' } diff --git a/app/src/main/java/com/google/android/stardroid/layers/AbstractFileBasedLayer.java b/app/src/main/java/com/google/android/stardroid/layers/AbstractFileBasedLayer.java index b28eeac38..b4121ffbb 100644 --- a/app/src/main/java/com/google/android/stardroid/layers/AbstractFileBasedLayer.java +++ b/app/src/main/java/com/google/android/stardroid/layers/AbstractFileBasedLayer.java @@ -26,6 +26,7 @@ import com.google.android.stardroid.util.Blog; import com.google.android.stardroid.util.MiscUtil; import com.google.common.io.Closeables; +import com.google.protobuf.Parser; import java.io.IOException; import java.io.InputStream; @@ -77,10 +78,10 @@ private void readSourceFile(String sourceFilename) { InputStream in = null; try { in = assetManager.open(sourceFilename, AssetManager.ACCESS_BUFFER); - AstronomicalSourcesProto.Builder builder = AstronomicalSourcesProto.newBuilder(); - builder.mergeFrom(in); + Parser parser = AstronomicalSourcesProto.parser(); + AstronomicalSourcesProto sources = parser.parseFrom(in); - for (AstronomicalSourceProto proto : builder.build().getSourceList()) { + for (AstronomicalSourceProto proto : sources.getSourceList()) { fileSources.add(new ProtobufAstronomicalSource(proto, getResources())); } Log.d(TAG, "Found: " + fileSources.size() + " sources");