diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/gallery/ChangeBackupServer.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/gallery/ChangeBackupServer.java
index 90c0214a34..9946a98628 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/gallery/ChangeBackupServer.java
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/gallery/ChangeBackupServer.java
@@ -1,34 +1,87 @@
/*
- * This file is part of HyperCeiler.
+ * This file is part of HyperCeiler.
- * HyperCeiler is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License.
+ * HyperCeiler is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
- * Copyright (C) 2023-2024 HyperCeiler Contributions
-*/
+ * Copyright (C) 2023-2024 HyperCeiler Contributions
+ */
package com.sevtinge.hyperceiler.module.hook.gallery;
import com.sevtinge.hyperceiler.module.base.BaseHook;
+import de.robv.android.xposed.XC_MethodHook;
+import de.robv.android.xposed.XC_MethodReplacement;
+
public class ChangeBackupServer extends BaseHook {
@Override
public void init() throws NoSuchMethodException {
- boolean getBackupServer = mPrefsMap.getStringAsInt("gallery_backup_server", 0) == 2;
- findAndHookMethod("com.miui.gallery.transfer.GoogleSyncHelper", "isCloudServiceOffLine", new MethodHook(){
- @Override
- protected void before(MethodHookParam param) throws Throwable {
- param.setResult(getBackupServer);
+ boolean isXiaomi = mPrefsMap.getStringAsInt("gallery_backup_server", 0) == 1;
+ boolean isGoogle = mPrefsMap.getStringAsInt("gallery_backup_server", 0) == 2;
+ boolean isOneDrive = mPrefsMap.getStringAsInt("gallery_backup_server", 0) == 3;
+ if (isOneDrive) {
+ findAndHookMethod("com.miui.gallery.ui.GallerySettingsFragment", "initGlobalBackupPreference", new MethodHook() {
+ XC_MethodHook.Unhook isInternationalHook;
+
+ @Override
+ protected void before(MethodHookParam param) throws Throwable {
+ isInternationalHook = findAndHookMethodUseUnhook("com.miui.gallery.util.BaseBuildUtil", lpparam.classLoader, "isInternational", XC_MethodReplacement.returnConstant(true));
+ }
+
+ @Override
+ protected void after(MethodHookParam param) throws Throwable {
+ if (isInternationalHook != null) isInternationalHook.unhook();
+ isInternationalHook = null;
+ }
+ });
+ findAndHookMethod("com.miui.gallery.util.PhotoModelTypeUtil", "isSupportOneDrive", new MethodHook() {
+ @Override
+ protected void before(MethodHookParam param) throws Throwable {
+ param.setResult(true);
+ }
+ });
+ } else {
+ if (isXiaomi) {
+ findAndHookMethod("com.miui.gallery.ui.GallerySettingsFragment", "initGlobalBackupPreference", new MethodHook() {
+ XC_MethodHook.Unhook isInternationalHook;
+
+ @Override
+ protected void before(MethodHookParam param) throws Throwable {
+ isInternationalHook = findAndHookMethodUseUnhook("com.miui.gallery.util.BaseBuildUtil", lpparam.classLoader, "isInternational", XC_MethodReplacement.returnConstant(false));
+ }
+
+ @Override
+ protected void after(MethodHookParam param) throws Throwable {
+ if (isInternationalHook != null) isInternationalHook.unhook();
+ isInternationalHook = null;
+ }
+ });
+ }
+ try {
+ findAndHookMethod("com.miui.gallery.transfer.GoogleSyncHelper", "isCloudServiceOffLine", new MethodHook() {
+ @Override
+ protected void before(MethodHookParam param) throws Throwable {
+ param.setResult(isGoogle);
+ }
+ });
+ } catch (Throwable t) {
+ findAndHookMethod("com.miui.gallery.util.BuildUtil", "isGlobal", new MethodHook() {
+ @Override
+ protected void before(MethodHookParam param) throws Throwable {
+ param.setResult(isGoogle);
+ }
+ });
}
- });
+ }
}
}
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 98e10f969d..b522486d4e 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -1053,6 +1053,7 @@
备份服务提供商
小米云服务
Google
+ Google 与 OneDrive
MIUI 安全组件
系统安全组件
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 638aff8495..63ed254eb0 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -968,12 +968,14 @@
- @string/array_default
- @string/gallery_backup_server_xiaomi
- @string/gallery_backup_server_google
+ - @string/gallery_backup_server_onedrive
- 0
- 1
- 2
+ - 3
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e9a0c73e6e..e567ab4b64 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1030,6 +1030,7 @@
Backup server
Xiaomi Cloud Service
Google
+ Google & OneDrive
MIUI security components
System Security Components