Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] Migrate installation identifier to non-backed-up storage #11005

Merged
merged 10 commits into from
Nov 20, 2020
Merged
Next Next commit
[expoview] Add support for scoped noBackupDir to ScopedContext
sjchmiela committed Nov 19, 2020
commit 4a47ad895d43da1039c8f01e5887f9ae6739b5dc
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ public class ScopedContext extends ContextWrapper {

private String mScope;
private File mFilesDir;
private File mNoBackupDir;
private File mCacheDir;
private ScopedApplicationContext mScopedApplicationContext;

@@ -63,6 +64,7 @@ public ScopedContext(final Context context, final String scope) {
File scopedFilesDir = new File(getBaseContext().getFilesDir() + "/ExperienceData/" + scope);
mFilesDir = scopedFilesDir;
mCacheDir = new File(getBaseContext().getCacheDir() + "/ExperienceData/" + scope);
mNoBackupDir = new File(getBaseContext().getNoBackupFilesDir() + "/ExperienceData/" + scope);

if (Constants.isStandaloneApp()) {
File scopedFilesMigrationMarker = new File(scopedFilesDir, ".expo-migration");
@@ -71,6 +73,7 @@ public ScopedContext(final Context context, final String scope) {
}
mFilesDir = getBaseContext().getFilesDir();
mCacheDir = getBaseContext().getCacheDir();
mNoBackupDir = getBaseContext().getNoBackupFilesDir();
}
}

@@ -169,6 +172,16 @@ public File getCacheDir() {
return mCacheDir;
}

@Override
public File getNoBackupFilesDir() {
// We only need to create the directory if someone
// asks for it - that's why .mkdirs() is not
// in the constructor.
//noinspection ResultOfMethodCallIgnored
mNoBackupDir.mkdirs();
return mNoBackupDir;
}

@Override
public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory) {
return getBaseContext().openOrCreateDatabase(mScope + name, mode, factory);