Files
b811b90172 v2.0: Android and HarmonyOS ports, Korean, iPhone Duo, Xbox controller layout, separate game packages, Mac icon and pointer
- Android (#113, @yyan160; graphics engine and shader-bundle packer from @biglawine's HarmonyOS port): an
  Android app (dm/android) with a JNI host, a touch overlay on the shared touch state machine, Vulkan
  presentation and AAudio sound; an NVN-to-Vulkan replay engine (dm/gfx/vulkan) behind the same backend
  interface as Metal; the shared host now builds for Apple and Android, and the module rewriter has an
  Android target (DM_TARGET=android; Apple output unchanged). Measured by the authors at a median 60 fps on
  a Redmi K50 Ultra.
- Android install with your own game files: the release APK (dm/android/tools/shell_apk.sh) contains no game
  content; dm/tools/d2rm_android.py makes an import pack (rewritten program, Vulkan shader bundles, touch overlay,
  data tables) that the App imports from Download/S2X/D2R Mobile/android with a progress screen. The shader export
  step (dm/gfx/tools/dmsh_vk.py) makes the 6,927 game shader bundles byte-for-byte identical to the tested set.
- Android rewriter fix (#113, @yyan160): rewrite blocks no longer stash registers below sp (Android has no red
  zone); equiv.py checks Android outputs, structck.py recognizes the Android block shapes. Apple output unchanged.
- Android touch controls drawn as on iOS (sockets, silver skill silhouettes, joystick), no map key in game state,
  no virtual pad buttons over panels; dm/android/tools/art_compare.sh compares the two drawings pixel by pixel.
- HarmonyOS (#114, @biglawine): a HarmonyOS NEXT app (dm/harmony, ArkTS shell + N-API library) on the same shared host
  and Vulkan engine as Android; shared changes are behind __OHOS__ or opt-in switches (adaptive present tier, fence waits
  woken on completion, OHAudio, HiTrace markers, a byte-identical BC fast path).
- HarmonyOS install with your own game files (@biglawine, 0.19.4 / code122): the release HAP is unsigned and contains
  no game content; players re-sign it with their own debug certificate and import a pack made with
  dm/tools/d2rm_android.py --target ohos. The registering stand-ins read the tables only when dm_derived_reload() is
  called (on __OHOS__); first import creates the target folders; outside a game a map toggle request is dropped
  before the AutoMap exists. Run by the author on a Mate 90 Pro Max: re-sign, install, import, in game, save and exit.
- Vulkan: NaN-ignoring min / max / clamp as on Maxwell (#113, @yyan160), fixing one-frame black tiles on the OnePlus 13.
- Xbox controllers (from #110, @rrroy5640): recognized automatically and given the PC / Xbox layout (bottom
  confirms, right goes back) with the game's Xbox button icons; other controllers are unchanged. The Mac-only
  keyboard prompt switch became a three-way prompt style (Switch / keyboard / Xbox) on every platform.
- Separate base and update packages (#106, @PowerBeef): setup.sh and extract_game.sh take both packages and
  read the title keys from their tickets.
- Mac App (#108, #109, @PowerBeef): the project's icon by default; the pointer hides after resting 3 s.
- run.sh install no longer goes through the test-device battery gate (#107, @PowerBeef).
- Chinese wording (#101, @zzz6519003): 「旧接口版」 and 「默认构建」 throughout.
- Dynamic 3D resolution (from #113): a run of dropped frames counts only its first 3 frames unless it lasts
  1 s, so one-off stalls no longer lower the resolution.
- In-game Korean (#118, @soulsakura): a 한국어 column for all our UI text, a fifth option in the language row (each
  checkbox now sits before its name), Korean touch wording and map name plates, Korean voice when the game files
  carry it; a Korean system language picks Korean on first install.
- iPhone Duo: in full screen the output size follows the window when the phone is unfolded or folded, up to the
  size the game started with; needs Xcode 27.1 for the inner screen to be filled. Test switches DM_TEST_FOLD and
  DM_TEST_SCREEN simulate the two screens with the iOS package on a Mac.
- README: Android and HarmonyOS sections, device table and credits in all three languages; dependency list for Android.

Every change was ported into the internal tree with its authors credited. For the shared files, the code
changes match the pull requests' after stripping comments. Host / graphics / iOS unit tests, the full
acceptance gate and the Mac smoke test passed; the rewriter's rule sets were rebuilt and passed the
equivalence regression; an iOS build of this code was played on an iPhone; the Android APK with an import pack
made from our own game files was played on a vivo X200 Ultra.

Exported from main 8055e5212.

Co-authored-by: Yuechuan Yang <22333122+yyan160@users.noreply.github.com>
Co-authored-by: biglawine <26263820+biglawine@users.noreply.github.com>
Co-authored-by: rrroy <hly5640@gmail.com>
Co-authored-by: Patrice Déry <109446870+PowerBeef@users.noreply.github.com>
Co-authored-by: Sam Snowman(赵正中) <zhengzhongzhao@gmail.com>
Co-authored-by: soulsakura <74704744+soulsakura@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 09:21:08 +08:00
..

Hero desktop widgets / vivo atomic-component candidate

The Android shell provides two read-only RemoteViews widgets: the latest saved hero (2×2), and up to three most recently played heroes (4×2). Both open the app when tapped and have a separate refresh action. Empty and unreadable-save states are localized. No game executable, game art, experience table, or player save is included.

This is implementation for platform evaluation. It has not received vivo platform permission, component review, or store approval. Installing an APK or setting vivo_widget=true does not demonstrate inclusion in the vivo atomic-component catalog or one-tap pinning support.

Data and limitations

SaveSummaryReader reads only context.getFilesDir()/save/<directory>/<directory>.d2s, the committed DM_SAVE path set in jni_android.c. It rejects a root named save.work, symbolic-link entries, oversized/truncated files, invalid checksums, malformed UTF-8, unknown classes, and unsupported versions. No save is created, modified, imported, or deleted by widget code. File reads run off the broadcast thread.

The field layout follows the existing Harmony SaveSummary.ts: class at 0x18, level at 0x1b, unsigned last-played time at 0x20, UTF-8 name at 0x12b, and LSB-first gf stat fields. Versions 0x61 (the Harmony reader's documented format) and 0x69 (also evidenced by dm/verify/savecmp.py) are accepted. Other versions require independently verified layout support. The checksum and declared length must match; the bitstream must terminate with ordered known IDs and a level matching the header. If no unambiguous valid stat block is found, experience/gold remain unavailable while valid header fields can still be shown. Gold is carried plus bank gold only when both fields were read.

Experience percentages and progress bars are intentionally absent: no generated experience table is connected. Raw experience is displayed when verified. The original Harmony reader's embedded experience table was not copied. There are no extracted class portraits, last-played date labels, or gameplay actions in this first implementation. The wide layout uses three columns rather than assuming Harmony's dimension naming maps to Android.

Application integration

These receivers are registered under the manifest's application. Do not add an application process or load the native game library for widget updates.

<receiver android:name=".widget.HeroWidget2x2Provider"
    android:exported="false" android:label="@string/dmAndroidWidgetName2x2">
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_2x2_info" />
    <meta-data android:name="vivo_widget" android:value="true" />
    <meta-data android:name="vivoWidgetVersion" android:value="1" />
    <meta-data android:name="vivo.widget.description" android:resource="@string/dmAndroidWidgetDescription" />
</receiver>
<receiver android:name=".widget.HeroWidget4x2Provider"
    android:exported="false" android:label="@string/dmAndroidWidgetName4x2">
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_4x2_info" />
    <meta-data android:name="vivo_widget" android:value="true" />
    <meta-data android:name="vivoWidgetVersion" android:value="1" />
    <meta-data android:name="vivo.widget.description" android:resource="@string/dmAndroidWidgetDescription" />
</receiver>

The Activity calls this from onStop after backgrounding:

com.xiaoboluo.d2r.widget.HeroWidgetProvider.requestUpdate(this);

This sends explicit updates only to installed widget instances and never starts the game. The widget's refresh button also reads the current committed saves. There is no native save-commit callback yet; avoid describing backgrounding as proof that a save succeeded. The periodic fallback is 12 hours, matching vivo's minimum; no frequent timer or file watcher runs. No extra Gradle dependency, network permission, email, account operation, or vendor SDK was introduced.

The shared dm/i18n/ui_text.tsv keys below are integrated. The existing generator includes dmAndroid* and lowercases keys into R.string IDs.

Key 中文 English
dmAndroidWidgetTitle 英雄 Heroes
dmAndroidWidgetRefresh 刷新 Refresh
dmAndroidWidgetName2x2 最近英雄 Latest Hero
dmAndroidWidgetName4x2 英雄列表 Hero List
dmAndroidWidgetDescription 查看已保存的英雄进度 View saved hero progress
dmAndroidWidgetEmpty 还没有英雄 No heroes yet
dmAndroidWidgetEmptyHint 点开游戏创建英雄 Open the game to create a hero
dmAndroidWidgetError 无法读取存档摘要 Save summary unavailable
dmAndroidWidgetErrorHint 成功保存后请刷新 Refresh after a successful save
dmAndroidWidgetStats %1$d级 · %2$s Lv %1$d · %2$s
dmAndroidWidgetExp 经验 %1$s Exp %1$s
dmAndroidWidgetGold 金币 %1$s Gold %1$s
dmAndroidWidgetExpUnknown 经验暂不可读 Experience unavailable
dmAndroidWidgetGoldUnknown 金币暂不可读 Gold unavailable
dmAndroidWidgetFooter %1$d位英雄 %1$d heroes
dmAndroidWidgetPartial %1$d位英雄 · 部分存档不可读 %1$d heroes · some saves unreadable
dmAndroidWidgetClassAmazon 亚马逊 Amazon
dmAndroidWidgetClassSorceress 法师 Sorceress
dmAndroidWidgetClassNecromancer 死灵法师 Necromancer
dmAndroidWidgetClassPaladin 圣骑士 Paladin
dmAndroidWidgetClassBarbarian 野蛮人 Barbarian
dmAndroidWidgetClassDruid 德鲁伊 Druid
dmAndroidWidgetClassAssassin 刺客 Assassin
dmAndroidWidgetClassWarlock 术士 Warlock

Validation

From the repository root, run with a JDK (no Android/native build needed):

javac -d <temporary-output> dm/android/app/src/main/java/com/xiaoboluo/d2r/widget/SaveSummaryReader.java dm/android/tests/SaveSummaryReaderTest.java
java -cp <temporary-output> com.xiaoboluo.d2r.widget.SaveSummaryReaderTest

The test generates synthetic bytes and its own temporary directory, then removes only that directory. It covers supported/unknown versions, checksum/length validation, unsigned fields, UTF-8, malformed stats, sort order, partial failures, working-directory rejection, and no mutation of input or save bytes. It does not establish compatibility with a real player's save, launcher rendering, platform acceptance, or refresh delivery. APK compilation and lint passed on 2026-10-16; vivo registered both providers. Launcher rendering, refresh and real-save compatibility remain unverified.

Official sources and external requirements

  • vivo technical adaptation: AppWidget receiver metadata, 2×2/4×2 dimensions, minimum 12-hour periodic refresh, resizeMode=none, no component scrolling, fresh RemoteViews per update, background-thread I/O.
  • vivo onboarding: the app must already be in the vivo store; the developer must apply for component-management access and submit the APK for review. No application was sent by this implementation.
  • vivo review rules: separate review and design requirements apply.
  • Android AppWidget documentation: standard provider/RemoteViews behavior is separate from vendor approval.

The vivo pages are JavaScript shells; their official public content endpoint /webapi/doc/info?id=<id> was read to verify these requirements. Availability in a particular OriginOS build remains untested. No one-tap pinning/catalog navigation code is included because it would require capability and approval checks.