mirror of
https://github.com/status-im/status-react.git
synced 2025-01-10 19:16:59 +00:00
Use no backup android & ios
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
4c545cb70d
commit
b0dc2dd4f5
@ -114,6 +114,10 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNoBackupDirectory() {
|
||||||
|
return this.getReactApplicationContext().getNoBackupFilesDir().getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
public void handleSignal(String jsonEvent) {
|
public void handleSignal(String jsonEvent) {
|
||||||
Log.d(TAG, "Signal event: " + jsonEvent);
|
Log.d(TAG, "Signal event: " + jsonEvent);
|
||||||
WritableMap params = Arguments.createMap();
|
WritableMap params = Arguments.createMap();
|
||||||
@ -201,7 +205,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
|
|
||||||
Activity currentActivity = getCurrentActivity();
|
Activity currentActivity = getCurrentActivity();
|
||||||
|
|
||||||
final String absRootDirPath = currentActivity.getApplicationInfo().dataDir;
|
final String absRootDirPath = this.getNoBackupDirectory();
|
||||||
final String dataFolder = this.getTestnetDataDir(absRootDirPath);
|
final String dataFolder = this.getTestnetDataDir(absRootDirPath);
|
||||||
Log.d(TAG, "Starting Geth node in folder: " + dataFolder);
|
Log.d(TAG, "Starting Geth node in folder: " + dataFolder);
|
||||||
|
|
||||||
@ -312,16 +316,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOldExternalDir() {
|
|
||||||
File extStore = Environment.getExternalStorageDirectory();
|
|
||||||
return extStore.exists() ? pathCombine(extStore.getAbsolutePath(), "ethereum/testnet") : getNewInternalDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getNewInternalDir() {
|
|
||||||
Activity currentActivity = getCurrentActivity();
|
|
||||||
return pathCombine(currentActivity.getApplicationInfo().dataDir, "ethereum/testnet");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteDirectory(File folder) {
|
private void deleteDirectory(File folder) {
|
||||||
File[] files = folder.listFiles();
|
File[] files = folder.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
@ -365,40 +359,14 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
|
||||||
public void shouldMoveToInternalStorage(Callback callback) {
|
|
||||||
String oldDir = getOldExternalDir();
|
|
||||||
String newDir = getNewInternalDir();
|
|
||||||
|
|
||||||
File oldDirFile = new File(oldDir);
|
|
||||||
File newDirFile = new File(newDir);
|
|
||||||
|
|
||||||
callback.invoke(oldDirFile.exists() && !newDirFile.exists());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ReactMethod
|
|
||||||
public void moveToInternalStorage(Callback callback) {
|
|
||||||
String oldDir = getOldExternalDir();
|
|
||||||
String newDir = getNewInternalDir();
|
|
||||||
|
|
||||||
try {
|
|
||||||
File oldDirFile = new File(oldDir);
|
|
||||||
copyDirectory(oldDirFile, new File(newDir));
|
|
||||||
deleteDirectory(oldDirFile);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.d(TAG, "Moving error: " + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
callback.invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
private void initKeystore() {
|
private void initKeystore() {
|
||||||
Log.d(TAG, "initKeystore");
|
Log.d(TAG, "initKeystore");
|
||||||
|
|
||||||
Activity currentActivity = getCurrentActivity();
|
Activity currentActivity = getCurrentActivity();
|
||||||
|
|
||||||
final String keydir = pathCombine(currentActivity.getApplicationInfo().dataDir, "/keystore");
|
final String keydir = pathCombine(this.getNoBackupDirectory(), "/keystore");
|
||||||
|
|
||||||
if (!checkAvailability()) {
|
if (!checkAvailability()) {
|
||||||
Log.e(TAG, "[initKeystore] Activity doesn't exist, cannot init keystore");
|
Log.e(TAG, "[initKeystore] Activity doesn't exist, cannot init keystore");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -419,7 +387,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
private void openAccounts(final Callback callback) {
|
private void openAccounts(final Callback callback) {
|
||||||
Activity currentActivity = getCurrentActivity();
|
Activity currentActivity = getCurrentActivity();
|
||||||
|
|
||||||
final String rootDir = currentActivity.getApplicationInfo().dataDir;
|
final String rootDir = this.getNoBackupDirectory();
|
||||||
Log.d(TAG, "openAccounts");
|
Log.d(TAG, "openAccounts");
|
||||||
if (!checkAvailability()) {
|
if (!checkAvailability()) {
|
||||||
Log.e(TAG, "[openAccounts] Activity doesn't exist, cannot call openAccounts");
|
Log.e(TAG, "[openAccounts] Activity doesn't exist, cannot call openAccounts");
|
||||||
@ -448,7 +416,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
|
|
||||||
Activity currentActivity = getCurrentActivity();
|
Activity currentActivity = getCurrentActivity();
|
||||||
|
|
||||||
final String absRootDirPath = currentActivity.getApplicationInfo().dataDir;
|
final String absRootDirPath = this.getNoBackupDirectory();
|
||||||
final String newKeystoreDir = pathCombine(absRootDirPath, "keystore");
|
final String newKeystoreDir = pathCombine(absRootDirPath, "keystore");
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
Runnable r = new Runnable() {
|
||||||
|
@ -116,7 +116,7 @@ RCT_EXPORT_METHOD(initKeystore) {
|
|||||||
#endif
|
#endif
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSURL *rootUrl =[[fileManager
|
NSURL *rootUrl =[[fileManager
|
||||||
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
||||||
lastObject];
|
lastObject];
|
||||||
|
|
||||||
NSURL *keystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
NSURL *keystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
||||||
@ -166,7 +166,7 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson
|
|||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
NSURL *rootUrl =[[fileManager
|
NSURL *rootUrl =[[fileManager
|
||||||
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
||||||
lastObject];
|
lastObject];
|
||||||
|
|
||||||
NSURL *zipFile = [rootUrl URLByAppendingPathComponent:@"logs.zip"];
|
NSURL *zipFile = [rootUrl URLByAppendingPathComponent:@"logs.zip"];
|
||||||
@ -326,7 +326,7 @@ RCT_EXPORT_METHOD(multiAccountDeriveAddresses:(NSString *)json
|
|||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
NSURL *rootUrl =[[fileManager
|
NSURL *rootUrl =[[fileManager
|
||||||
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
||||||
lastObject];
|
lastObject];
|
||||||
NSURL *absTestnetFolderName = [rootUrl URLByAppendingPathComponent:@"ethereum/testnet"];
|
NSURL *absTestnetFolderName = [rootUrl URLByAppendingPathComponent:@"ethereum/testnet"];
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ RCT_EXPORT_METHOD(openAccounts:(RCTResponseSenderBlock)callback) {
|
|||||||
#endif
|
#endif
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSURL *rootUrl =[[fileManager
|
NSURL *rootUrl =[[fileManager
|
||||||
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
||||||
lastObject];
|
lastObject];
|
||||||
|
|
||||||
NSString *result = StatusgoOpenAccounts(rootUrl.path);
|
NSString *result = StatusgoOpenAccounts(rootUrl.path);
|
||||||
@ -460,7 +460,7 @@ RCT_EXPORT_METHOD(verify:(NSString *)address
|
|||||||
#endif
|
#endif
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSURL *rootUrl =[[fileManager
|
NSURL *rootUrl =[[fileManager
|
||||||
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
||||||
lastObject];
|
lastObject];
|
||||||
NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user