Skip to content

云服务: 国际版 ROM 下为中国区账号解除相册云同步封锁 - #1667

Open
jason5545 wants to merge 1 commit into
ReChronoRain:mainfrom
jason5545:feat/restore-gallery-sync
Open

云服务: 国际版 ROM 下为中国区账号解除相册云同步封锁#1667
jason5545 wants to merge 1 commit into
ReChronoRain:mainfrom
jason5545:feat/restore-gallery-sync

Conversation

@jason5545

Copy link
Copy Markdown

问题

国际版(IS_INTERNATIONAL_BUILD=true)ROM 上,CloudService 在每次应用云端配置时都会无条件执行相册同步终止逻辑(ServiceTerminatedHelper):

  • ContentResolver.setIsSyncable(gallery, 0)
  • ContentResolver.setSyncAutomatically(gallery, false)

这是为海外账号相册云同步下线(2023-05-31 截止)而设计的。但中国区账号的相册云服务仍然有效,在国际版 ROM(如 xiaomi.eu)上登录中国区账号时,配合相册选择小米云备份,设置里能看到开关,却永远卡在「正在请求」——因为同步框架里的 syncable 被反复置 0,请求从未真正发出。

方案

新增 RestoreGallerySync(作用于 com.miui.cloudservice),在以下两个条件同时满足时自动生效,无需额外开关:

  1. 用户已在相册将备份服务器选为小米云(gallery_backup_server == 1
  2. 小米账号注册区域为 CN(读取 acc_user_region,非 CN 账号完全保持原行为)

生效后:

  • 拦截 CloudService 对相册 authority 的 setIsSyncable(0) / setSyncAutomatically(false) 写入
  • CloudService 启动时主动修复状态(syncable=1、自动同步开启、请求一次同步)

测试

  • 设备:myron,xiaomi.eu(基于 OS3.0.308.0.WPMCNXM),中国区账号
  • 修复前:dumpsys contentcom.miui.gallery.cloud.provider syncable=0,历史同步次数 0
  • 修复后:syncable=1,同步多次 USER SUCCESS,云端 3800+ 条数据完整拉回,缩略图与原图正常下载
  • 其他同步项(联系人/短信/便签/录音等)不受影响

兼容性说明

  • 仅 hook ContentResolver.setIsSyncable/setSyncAutomatically 两个 AOSP 稳定 API,不涉及混淆类名,对 CloudService 版本变化稳健
  • 账号区域检查带缓存,读取失败默认不干预

…onal builds

On international builds, CloudService unconditionally runs the gallery
sync termination helper (setIsSyncable(gallery, 0) +
setSyncAutomatically(gallery, false)) whenever cloud config applies,
leaving accounts whose region still supports Gallery cloud sync stuck
at "requesting" forever.

When the user selects Mi Cloud as the gallery backup server
(gallery_backup_server == 1) and the Xiaomi account region is CN,
intercept those two writes for the gallery authority and repair the
sync state (syncable=1, auto-sync on, request sync) on CloudService
start. Non-CN accounts keep the stock behavior.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 26 complexity

Metric Results
Complexity 26

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant