diff --git a/app/src/main/assets/sys/systemres/abc/AbilityConstant.abc b/app/src/main/assets/sys/systemres/abc/AbilityConstant.abc new file mode 100644 index 0000000..fff5894 Binary files /dev/null and b/app/src/main/assets/sys/systemres/abc/AbilityConstant.abc differ diff --git a/app/src/main/assets/sys/systemres/abc/UIAbility.abc b/app/src/main/assets/sys/systemres/abc/UIAbility.abc new file mode 100644 index 0000000..3d804a5 Binary files /dev/null and b/app/src/main/assets/sys/systemres/abc/UIAbility.abc differ diff --git a/app/src/main/assets/sys/systemres/abc/common.abc b/app/src/main/assets/sys/systemres/abc/common.abc new file mode 100644 index 0000000..8fa7a99 Binary files /dev/null and b/app/src/main/assets/sys/systemres/abc/common.abc differ diff --git a/app/src/main/assets/sys/systemres/abc/netErrorList.abc b/app/src/main/assets/sys/systemres/abc/netErrorList.abc new file mode 100644 index 0000000..14acdd5 Binary files /dev/null and b/app/src/main/assets/sys/systemres/abc/netErrorList.abc differ diff --git a/app/src/main/assets/sys/systemres/abc/wantAgent.abc b/app/src/main/assets/sys/systemres/abc/wantAgent.abc new file mode 100644 index 0000000..445b5ec Binary files /dev/null and b/app/src/main/assets/sys/systemres/abc/wantAgent.abc differ diff --git a/scripts/compile_stubs.py b/scripts/compile_stubs.py new file mode 100644 index 0000000..aea07e0 --- /dev/null +++ b/scripts/compile_stubs.py @@ -0,0 +1,57 @@ +import subprocess +import os +import glob +import sys + +def find_es2abc(): + # 1. Check system path + for path in os.environ.get("PATH", "").split(os.pathsep): + exe = os.path.join(path, "es2abc.exe") + if os.path.exists(exe): + return exe + + # 2. Check standard DevEco Studio installation path + dev_eco_studio_root = r"C:\Program Files\Huawei\DevEco Studio" + if os.path.exists(dev_eco_studio_root): + pattern = os.path.join(dev_eco_studio_root, "**", "es2abc.exe") + matches = glob.glob(pattern, recursive=True) + if matches: + return matches[0] + + return None + +def main(): + es2abc = find_es2abc() + if not es2abc: + print("ERROR: es2abc.exe could not be found. Please make sure DevEco Studio is installed or add it to PATH.") + sys.exit(1) + + print(f"Found es2abc: {es2abc}") + + script_dir = os.path.dirname(os.path.abspath(__file__)) + src_dir = os.path.join(script_dir, "stubs") + dest_dir = os.path.join(script_dir, "..", "app", "src", "main", "assets", "sys", "systemres", "abc") + dest_dir = os.path.abspath(dest_dir) + + os.makedirs(dest_dir, exist_ok=True) + + js_files = glob.glob(os.path.join(src_dir, "*.js")) + if not js_files: + print(f"No .js files found in {src_dir}") + return + + for js_file in js_files: + basename = os.path.basename(js_file) + name, _ = os.path.splitext(basename) + abc_file = os.path.join(dest_dir, f"{name}.abc") + + print(f"Compiling {basename} -> {name}.abc...") + cmd = [es2abc, js_file, "--module", "--output", abc_file] + try: + subprocess.run(cmd, check=True) + print(f" Successfully compiled {name}.abc") + except Exception as e: + print(f" ERROR compiling {name}.abc: {e}") + +if __name__ == "__main__": + main() diff --git a/scripts/stubs/AbilityConstant.js b/scripts/stubs/AbilityConstant.js new file mode 100644 index 0000000..60109d5 --- /dev/null +++ b/scripts/stubs/AbilityConstant.js @@ -0,0 +1,14 @@ +const LaunchReason = { + UNKNOWN: 0, + START_ABILITY: 1, + CALL: 2, +}; +const LastExitReason = { + UNKNOWN: 0, + NORMAL: 1, + EXCEPTION: 2, +}; +export default { + LaunchReason: LaunchReason, + LastExitReason: LastExitReason, +}; diff --git a/scripts/stubs/UIAbility.js b/scripts/stubs/UIAbility.js new file mode 100644 index 0000000..e64eb19 --- /dev/null +++ b/scripts/stubs/UIAbility.js @@ -0,0 +1,16 @@ +class UIAbility { + constructor() { + this.context = null; + this.launchWant = null; + } + onCreate(want, launchParam) {} + onDestroy() {} + onWindowStageCreate(windowStage) {} + onWindowStageDestroy() {} + onForeground() {} + onBackground() {} + onNewWant(want, launchParam) {} + onConfigurationUpdate(newConfig) {} + onMemoryLevel(level) {} +} +export default UIAbility; diff --git a/scripts/stubs/common.js b/scripts/stubs/common.js new file mode 100644 index 0000000..dd5e1aa --- /dev/null +++ b/scripts/stubs/common.js @@ -0,0 +1,6 @@ +export default { + UIAbilityContext: {}, + AbilityStageContext: {}, + ApplicationContext: {}, + Context: {}, +}; diff --git a/scripts/stubs/netErrorList.js b/scripts/stubs/netErrorList.js new file mode 100644 index 0000000..97def41 --- /dev/null +++ b/scripts/stubs/netErrorList.js @@ -0,0 +1,19 @@ +export default { + NET_OK: 0, + ERR_IO_PENDING: -1, + ERR_FAILED: -2, + ERR_ABORTED: -3, + ERR_TIMED_OUT: -7, + ERR_CERT_DATE_INVALID: -201, + ERR_CERT_AUTHORITY_INVALID: -202, + ERR_NAME_NOT_RESOLVED: -105, + ERR_CONNECTION_REFUSED: -102, + ERR_CONNECTION_RESET: -101, + ERR_CONNECTION_ABORTED: -103, + ERR_CONNECTION_FAILED: -104, + ERR_INTERNET_DISCONNECTED: -106, + ERR_SSL_PROTOCOL_ERROR: -107, + ERR_INVALID_URL: -300, + ERR_DISALLOWED_URL_SCHEME: -301, + ERR_UNKNOWN_URL_SCHEME: -302, +}; diff --git a/scripts/stubs/wantAgent.js b/scripts/stubs/wantAgent.js new file mode 100644 index 0000000..5d8e942 --- /dev/null +++ b/scripts/stubs/wantAgent.js @@ -0,0 +1,7 @@ +export default { + getWantAgent: function(info, callback) { + if (callback) callback(null, {}); + return Promise.resolve({}); + }, + triggerWantAgent: function() {}, +};