From e844d32cd5eeb9149ffb0c74805396b6acadf9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=80=E6=BC=93=E4=B8=A8Sevtinge?= Date: Wed, 1 Nov 2023 06:20:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20=E5=AD=98=E6=A1=A3?= =?UTF-8?q?=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sevtinge/cemiuiler/utils/BackupUtils.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/sevtinge/cemiuiler/utils/BackupUtils.java b/app/src/main/java/com/sevtinge/cemiuiler/utils/BackupUtils.java index 35ba08d2c..638f20301 100644 --- a/app/src/main/java/com/sevtinge/cemiuiler/utils/BackupUtils.java +++ b/app/src/main/java/com/sevtinge/cemiuiler/utils/BackupUtils.java @@ -54,7 +54,7 @@ public static void handleCreateDocument(Activity activity, @Nullable Uri data) t for (Map.Entry entry : PrefsUtils.mSharedPreferences.getAll().entrySet()) { jsonObject.put(entry.getKey(), entry.getValue()); } - bufferedWriter.write(KS2Utils.encrypted(jsonObject.toString(), "\u0040\u0037\u0037\u0034\u0039\u0031")); + bufferedWriter.write(jsonObject.toString()); bufferedWriter.close(); } @@ -62,9 +62,15 @@ public static void handleReadDocument(Activity activity, @Nullable Uri data) thr if (data == null) return; SharedPreferences.Editor edit = PrefsUtils.mSharedPreferences.edit(); InputStream inputStream = activity.getContentResolver().openInputStream(data); - String documentContent = inputStream2String(inputStream); - String decryptedContent = KS2Utils.decrypted(documentContent, "\u0040\u0037\u0037\u0034\u0039\u0031"); - JSONObject jsonObject = new JSONObject(decryptedContent); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder stringBuilder = new StringBuilder(); + String line = bufferedReader.readLine(); + while (line != null) { + stringBuilder.append(line); + line = bufferedReader.readLine(); + } + String read = stringBuilder.toString(); + JSONObject jsonObject = new JSONObject(read); Iterator keys = jsonObject.keys(); while (keys.hasNext()) { String key = keys.next(); @@ -79,15 +85,4 @@ public static void handleReadDocument(Activity activity, @Nullable Uri data) thr } edit.apply(); } - - private static String inputStream2String(InputStream inputStream) throws IOException { - StringBuilder stringBuilder = new StringBuilder(); - String line; - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); - while ((line = bufferedReader.readLine()) != null) { - stringBuilder.append(line); - } - bufferedReader.close(); - return stringBuilder.toString(); - } }