Skip to content

Commit

Permalink
Fixed google bug 154855417
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Jun 1, 2020
1 parent 04a0d83 commit 3a6b229
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.odk.collect.android.preferences.AutoSendPreferenceMigrator;
import org.odk.collect.android.preferences.FormMetadataMigrator;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.MetaSharedPreferencesProvider;
import org.odk.collect.android.preferences.PrefMigrator;
import org.odk.collect.android.storage.StoragePathProvider;
import org.odk.collect.android.tasks.sms.SmsNotificationReceiver;
Expand All @@ -67,6 +68,7 @@
import static org.odk.collect.android.logic.PropertyManager.PROPMGR_USERNAME;
import static org.odk.collect.android.logic.PropertyManager.SCHEME_USERNAME;
import static org.odk.collect.android.preferences.GeneralKeys.KEY_APP_LANGUAGE;
import static org.odk.collect.android.preferences.GeneralKeys.KEY_GOOGLE_BUG_154855417_FIXED;
import static org.odk.collect.android.preferences.GeneralKeys.KEY_USERNAME;
import static org.odk.collect.android.tasks.sms.SmsNotificationReceiver.SMS_NOTIFICATION_ACTION;
import static org.odk.collect.android.tasks.sms.SmsSender.SMS_SEND_ACTION;
Expand All @@ -91,6 +93,9 @@ public class Collect extends Application {
@Inject
public CollectJobCreator collectJobCreator;

@Inject
MetaSharedPreferencesProvider metaSharedPreferencesProvider;

public static Collect getInstance() {
return singleton;
}
Expand Down Expand Up @@ -150,6 +155,7 @@ public void onCreate() {
singleton = this;

setupDagger();
fixGoogleBug154855417();

NotificationUtils.createNotificationChannel(singleton);

Expand Down Expand Up @@ -307,4 +313,24 @@ public static String getFormIdentifierHash(String formId, String formVersion) {
String formIdentifier = new FormsDao().getFormTitleForFormIdAndFormVersion(formId, formVersion) + " " + formId;
return FileUtils.getMd5Hash(new ByteArrayInputStream(formIdentifier.getBytes()));
}

// https://issuetracker.google.com/issues/154855417
private void fixGoogleBug154855417() {
try {
boolean hasFixedGoogleBug154855417 = metaSharedPreferencesProvider
.getMetaSharedPreferences()
.getBoolean(KEY_GOOGLE_BUG_154855417_FIXED, false);
if (!hasFixedGoogleBug154855417) {
File corruptedZoomTables = new File(getFilesDir(), "ZoomTables.data");
corruptedZoomTables.delete();
metaSharedPreferencesProvider
.getMetaSharedPreferences()
.edit()
.putBoolean(KEY_GOOGLE_BUG_154855417_FIXED, true)
.apply();
}
} catch (Exception ignored) {
// ignored
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,9 @@ public QRCodeGenerator providesQRCodeGenerator() {
public VersionInformation providesVersionInformation() {
return new VersionInformation(() -> BuildConfig.VERSION_NAME);
}

@Provides
MetaSharedPreferencesProvider providesMetaSharedPreferencesProvider(Context context) {
return new MetaSharedPreferencesProvider(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public final class GeneralKeys {
public static final String KEY_FIRST_RUN = "firstRun";
public static final String KEY_SCOPED_STORAGE_USED = "scoped_storage_used";
public static final String KEY_MAPBOX_INITIALIZED = "mapbox_initialized";
public static final String KEY_GOOGLE_BUG_154855417_FIXED = "google_bug_154855417_fixed";

/** Whether any existing username and email values have been migrated to form metadata */
static final String KEY_METADATA_MIGRATED = "metadata_migrated";
Expand Down

0 comments on commit 3a6b229

Please sign in to comment.