Skip to content

Commit d739383

Browse files
committed
BackupAndRestore: actual restore path on Android 10+
1 parent 9874a7c commit d739383

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/BackupSettingsPresenter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private void appendLocalBackupRestoreOptions(List<OptionItem> options) {
176176
BackupAndRestoreManager backupManager = new BackupAndRestoreManager(getContext());
177177

178178
String backupPath = backupManager.getBackupRootPath();
179+
String restorePath = backupManager.getRestoreRootPath();
179180

180181
options.add(UiOptionItem.from(
181182
backupPath == null ? getContext().getString(R.string.app_backup) :
@@ -190,7 +191,7 @@ private void appendLocalBackupRestoreOptions(List<OptionItem> options) {
190191

191192
options.add(UiOptionItem.from(
192193
backupPath == null ? getContext().getString(R.string.app_restore) :
193-
String.format("%s:\n%s", getContext().getString(R.string.app_restore), backupPath),
194+
String.format("%s:\n%s", getContext().getString(R.string.app_restore), restorePath),
194195
option -> {
195196
backupManager.getBackupNames(names -> showLocalRestoreDialog(backupManager, names));
196197
}));

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/misc/BackupAndRestoreManager.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,26 +276,18 @@ public void onPermissions(int requestCode, String[] permissions, int[] grantResu
276276
}
277277
}
278278

279-
public String getBackupPath() {
280-
File currentBackup = getBackup();
281-
282-
return currentBackup != null ? currentBackup.toString() : null;
283-
}
284-
285279
public String getBackupRootPath() {
286280
// NOTE: Android 11+ only backup through the file manager (no shared dir)
287281
if (hasAccessOnlyToAppFolders() && VERSION.SDK_INT > 29) {
288282
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath()
289283
+ "/" + BackupAndRestoreHelper.BACKUP_FOLDER_NAME;
290284
}
291285

292-
return String.format("%s/data", getExternalStorageDirectory());
286+
return getRestoreRootPath();
293287
}
294288

295-
public String getBackupPathCheck() {
296-
File currentBackup = getBackupCheck();
297-
298-
return currentBackup != null ? currentBackup.toString() : null;
289+
public String getRestoreRootPath() {
290+
return String.format("%s/data", getExternalStorageDirectory());
299291
}
300292

301293
public void getBackupNames(OnBackupNames callback) {

0 commit comments

Comments
 (0)