@androperator/emulator-macos-tweaks 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/bin/androperator-emulator-tweaks.js +1 -1
- package/package.json +1 -1
- package/src/core.js +26 -5
- package/src/png.js +12 -5
package/README.md
CHANGED
|
@@ -18,10 +18,10 @@ This is an independent CLI. It does not depend on ADBuddy or change emulator lau
|
|
|
18
18
|
|
|
19
19
|
- macOS 14 or newer and Node.js 22 or newer.
|
|
20
20
|
- Write access to your Android SDK and backup location; do not run with sudo.
|
|
21
|
-
- Android Emulator **37.
|
|
21
|
+
- Android Emulator **37.x, Apple Silicon GUI binary**, with a compatible icon and executable layout.
|
|
22
22
|
- Executable SHA-256: `eaa97a970b81f81640db73ed79e19ee173323653a0a1203217e1199d078011f3`.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
The reference build is 37.1.11, build 15917651. Other 37.x builds are checked by executable structure and embedded icon contents rather than an exact version or whole-file hash. Intel builds and other major versions remain unsupported.
|
|
25
25
|
|
|
26
26
|
Patching replaces Google's signature with a **local ad-hoc signature**, preserving the original entitlements and hardened runtime. The modified emulator is no longer Google-signed or notarized. No developer certificate or private key is used. Gatekeeper may treat the patched emulator differently. The CLI does not disable Gatekeeper or change system security settings.
|
|
27
27
|
|
|
@@ -120,7 +120,7 @@ node scripts/verify-names.mjs
|
|
|
120
120
|
|
|
121
121
|
Tests use synthetic executables and fake process integrations. They require neither an Android SDK nor a device. macOS CI runs on Node.js 22 and 24. Real signing and boot checks supplement these tests for the supported build.
|
|
122
122
|
|
|
123
|
-
To add support for a build, use an untouched, signature-verified vendor executable. Record its revision, build ID, architecture, full SHA-256, and each original PNG hash and allocation length in `src/profiles.json`. The patcher discovers images by content rather than fixed offsets. Provide replacement PNGs that fit those allocations exactly, with valid chunks and checksums. Verify signing, boot, Dock appearance, and exact restore on that build before adding it to the support table.
|
|
123
|
+
To add support for a build, use an untouched, signature-verified vendor executable. Record its revision, build ID, architecture, full SHA-256, and each original PNG hash and allocation length in `src/profiles.json`. The patcher discovers images by content rather than fixed offsets. Provide replacement PNGs that fit those allocations exactly, with valid chunks and checksums. Verify signing, boot, Dock appearance, and exact restore on that build before adding it to the support table. New layouts require a new verified profile; compatible 37.x builds do not require a separate whole-executable hash.
|
|
124
124
|
|
|
125
125
|
The editable `assets/Emulator.icon` source uses a vector phone/Android symbol, white background, and Apple's native icon renderer. The bundled 32, 128 and 256 pixel PNGs were compiled with Xcode's asset compiler and palette-compressed to fit the emulator's allocations. Xcode is not required by CLI users. Native helper source is in `native/`; `node scripts/build-runtime.mjs` rebuilds the packaged arm64 helper and all five icons and writes their content manifest. `npm run build:launcher` rebuilds the AVD dispatcher and its manifest. Rebuild and run native verification after changing those sources; review the regenerated manifest and runtime files together.
|
|
126
126
|
|
|
@@ -135,3 +135,15 @@ Android is a trademark of Google LLC. This project is not affiliated with or end
|
|
|
135
135
|
Written by clankers. Engineered by [@chrismlacy](https://x.com/chrismlacy).
|
|
136
136
|
|
|
137
137
|
Copyright (C) 2026 Action Launcher Pty Ltd
|
|
138
|
+
|
|
139
|
+
### Compatibility across SDK updates
|
|
140
|
+
|
|
141
|
+
Apple Silicon Android Emulator 37.x builds are accepted when their arm64 Mach-O
|
|
142
|
+
structure and embedded icon allocations match the bundled patch profile. The
|
|
143
|
+
reference build is 37.1.11; an exact revision or whole-executable hash match is
|
|
144
|
+
not required for other 37.x builds. Icon contents, dimensions, checksums, unique
|
|
145
|
+
allocations and load-command padding are checked before patching. Intel builds,
|
|
146
|
+
other major versions and incompatible layouts remain unsupported. Status JSON
|
|
147
|
+
includes `supportedVersions` and `compatibilityReason` for diagnosis. Compatible
|
|
148
|
+
does not mean every build has been tested live. Exact original backups and
|
|
149
|
+
SDK-update protection remain in effect.
|
|
@@ -34,7 +34,7 @@ try {
|
|
|
34
34
|
throw new Error("apply requires --accept-adhoc-signing. Applying this patch replaces Google's signature with a local ad-hoc signature while preserving its entitlements and hardened runtime. No developer certificate or private key is used. Gatekeeper may treat the patched emulator differently. Restore reinstates the original executable and Google's signature. No files changed.\nRun: androperator-emulator-tweaks apply --accept-adhoc-signing");
|
|
35
35
|
}
|
|
36
36
|
const result = await ({ status: inspect, apply, restore }[command])({ sdk: values.sdk, backupDir: values['backup-dir'], icons: values.icons, names: values.names });
|
|
37
|
-
const output = { command, names: result.names, namingHealthy: result.namingHealthy, icons: result.icons, runtimeHealthy: result.runtimeHealthy, sdk: result.sdk, revision: result.revision, state: result.state, changed: result.changed ?? false, executable: result.target, sha256: result.targetHash, backup: result.backup ?? result.receipt?.directory ?? null };
|
|
37
|
+
const output = { compatibilityReason: result.compatibilityReason, supportedVersions: result.supportedVersions, command, names: result.names, namingHealthy: result.namingHealthy, icons: result.icons, runtimeHealthy: result.runtimeHealthy, sdk: result.sdk, revision: result.revision, state: result.state, changed: result.changed ?? false, executable: result.target, sha256: result.targetHash, backup: result.backup ?? result.receipt?.directory ?? null };
|
|
38
38
|
// Refresh the reported hash after a successful mutation.
|
|
39
39
|
if (result.changed) output.sha256 = (await inspect({ sdk: values.sdk, backupDir: values['backup-dir'] })).targetHash;
|
|
40
40
|
console.log(values.json ? JSON.stringify(output, null, 2) : `${result.state}${result.names === 'avd' ? ` (AVD names${result.namingHealthy === false ? ', naming runtime missing or corrupt; restore remains available' : ''})` : ''}${result.icons ? ` (${result.icons} icons${result.runtimeHealthy === false ? ', runtime missing or corrupt; restore remains available' : ''})` : ''}: Android Emulator ${result.revision}\n${result.target}${output.backup ? `\nBackup: ${output.backup}` : ''}${result.changed ? '\nRestart emulators to see the change.' : ''}`);
|
package/package.json
CHANGED
package/src/core.js
CHANGED
|
@@ -3,7 +3,7 @@ import { resolve, join, dirname } from 'node:path';
|
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { sha256, patchImages } from './png.js';
|
|
6
|
+
import { sha256, patchImages, locateIcons } from './png.js';
|
|
7
7
|
import { macOS } from './platform.js';
|
|
8
8
|
import { addIconHelper } from './macho.js';
|
|
9
9
|
import { readRuntime, copyRuntime, verifyRuntime, runtimeHash } from './runtime.js';
|
|
@@ -12,6 +12,24 @@ const packageRoot = fileURLToPath(new URL('../', import.meta.url));
|
|
|
12
12
|
const bundledProfiles = JSON.parse(await readFile(new URL('./profiles.json', import.meta.url)));
|
|
13
13
|
const hashFile = async file => sha256(await readFile(file));
|
|
14
14
|
|
|
15
|
+
async function resolveProfile(bytes, revision, profiles, binary) {
|
|
16
|
+
const hash = sha256(bytes);
|
|
17
|
+
const exact = profiles.find(item => item.revision === revision && item.sha256 === hash && item.binary === binary);
|
|
18
|
+
if (exact) return { profile: exact, compatibilityReason: null };
|
|
19
|
+
const candidates = profiles.filter(item => item.revision.split('.')[0] === revision?.split('.')[0] && item.binary === binary);
|
|
20
|
+
if (!candidates.length) return { profile: null, compatibilityReason: `Requires an Apple Silicon emulator in a supported major version (${[...new Set(profiles.map(item => item.revision.split('.')[0] + '.x'))].join(', ')}).` };
|
|
21
|
+
let compatibilityReason;
|
|
22
|
+
for (const template of candidates) {
|
|
23
|
+
try {
|
|
24
|
+
addIconHelper(bytes, '/compatibility-check/helper.dylib');
|
|
25
|
+
const profile = { ...template, revision, build: 'structurally compatible', sha256: hash };
|
|
26
|
+
locateIcons(bytes, profile);
|
|
27
|
+
return { profile, compatibilityReason: null };
|
|
28
|
+
} catch (error) { compatibilityReason = error.message; }
|
|
29
|
+
}
|
|
30
|
+
return { profile: null, compatibilityReason };
|
|
31
|
+
}
|
|
32
|
+
|
|
15
33
|
async function atomicJSON(file, value) {
|
|
16
34
|
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
17
35
|
const handle = await open(temporary, 'wx', 0o600);
|
|
@@ -75,7 +93,10 @@ export async function inspect({ sdk: explicit, backupDir, profiles = bundledProf
|
|
|
75
93
|
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
76
94
|
const configHash = await configurationHash(target);
|
|
77
95
|
const receipt = receipts.find(record => record.schema === 3 && record.configHash === configHash && [record.patchedHash, record.originalHash].includes(targetHash)) ?? receipts.find(record => record.patchedHash === targetHash) ?? receipts.find(record => record.originalHash === targetHash);
|
|
78
|
-
const
|
|
96
|
+
const originalSource = receipt?.patchedHash === targetHash ? join(receipt.directory, 'original') : target;
|
|
97
|
+
const originalBytes = await readFile(originalSource);
|
|
98
|
+
if (receipt?.patchedHash === targetHash && sha256(originalBytes) !== receipt.originalHash) throw new Error('Original backup is corrupt');
|
|
99
|
+
const { profile, compatibilityReason } = await resolveProfile(originalBytes, revision, profiles, target.slice(sdk.length + '/emulator/'.length));
|
|
79
100
|
const state = receipt?.patchedHash === targetHash ? 'patched' : profile ? 'original' : 'unsupported';
|
|
80
101
|
let runtimeHealthy = null;
|
|
81
102
|
if (receipt?.runtime && state === 'patched') {
|
|
@@ -89,7 +110,7 @@ export async function inspect({ sdk: explicit, backupDir, profiles = bundledProf
|
|
|
89
110
|
try { await verifyNaming(receipt); namingHealthy = configHash === receipt.configHash; }
|
|
90
111
|
catch { namingHealthy = false; }
|
|
91
112
|
}
|
|
92
|
-
return { configHash, names, namingHealthy, icons, runtimeHealthy, sdk, revision, target, targetHash, storage, folder, targetId, state, receipt, profile, adapter, mode: info.mode & 0o777, receipts };
|
|
113
|
+
return { compatibilityReason, supportedVersions: [...new Set(profiles.map(item => item.revision.split('.')[0] + '.x'))], configHash, names, namingHealthy, icons, runtimeHealthy, sdk, revision, target, targetHash, storage, folder, targetId, state, receipt, profile, adapter, mode: info.mode & 0o777, receipts };
|
|
93
114
|
}
|
|
94
115
|
|
|
95
116
|
async function withLock(context, operation) {
|
|
@@ -129,8 +150,8 @@ export async function apply(options = {}) {
|
|
|
129
150
|
const context = await inspect(options);
|
|
130
151
|
const runtimeDirectory = options.runtimeDir ?? join(packageRoot, 'assets/runtime');
|
|
131
152
|
const originalHash = context.state === 'patched' ? context.receipt.originalHash : context.targetHash;
|
|
132
|
-
const profile =
|
|
133
|
-
if (!profile) throw new Error(`Unsupported emulator ${context.revision ?? 'version'} (${context.targetHash}). No files changed.
|
|
153
|
+
const profile = context.profile;
|
|
154
|
+
if (!profile) throw new Error(`Unsupported emulator ${context.revision ?? 'version'} (${context.targetHash}). No files changed. ${context.compatibilityReason}`);
|
|
134
155
|
const bundle = icons === 'auto' ? await readRuntime(runtimeDirectory, context.adapter) : null;
|
|
135
156
|
const naming = names === 'avd' ? await readNamingBundle(options.packageRoot ?? packageRoot, context.adapter, options.nodePath) : null;
|
|
136
157
|
const namesHash = naming ? sha256(Buffer.from(JSON.stringify([naming.hash, icons, bundle?.hash ?? null]))) : null;
|
package/src/png.js
CHANGED
|
@@ -36,13 +36,10 @@ export function pngLength(bytes, offset = 0, expectedSize) {
|
|
|
36
36
|
throw new Error('Missing PNG end');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function
|
|
39
|
+
export function locateIcons(original, profile) {
|
|
40
40
|
if (sha256(original) !== profile.sha256) throw new Error('Unsupported executable hash; no files changed');
|
|
41
|
-
const patched = Buffer.from(original);
|
|
42
41
|
const slots = [];
|
|
43
42
|
for (const slot of profile.slots) {
|
|
44
|
-
const replacement = replacements.get(slot.size);
|
|
45
|
-
if (!replacement || replacement.length !== slot.length || sha256(replacement) !== slot.replacementSha256 || pngLength(replacement, 0, slot.size) !== slot.length) throw new Error('Replacement artwork failed validation');
|
|
46
43
|
const matches = [];
|
|
47
44
|
for (let offset = original.indexOf(signature); offset !== -1; offset = original.indexOf(signature, offset + 8)) {
|
|
48
45
|
if (sha256(original.subarray(offset, offset + slot.length)) === slot.sha256) {
|
|
@@ -53,8 +50,18 @@ export function patchImages(original, profile, replacements) {
|
|
|
53
50
|
if (matches.length !== 1) throw new Error(`Expected exactly one ${slot.size}px icon; found ${matches.length}`);
|
|
54
51
|
const offset = matches[0];
|
|
55
52
|
if (slots.some(other => offset < other.offset + other.length && other.offset < offset + slot.length)) throw new Error('Overlapping icon allocations');
|
|
56
|
-
replacement.copy(patched, offset);
|
|
57
53
|
slots.push({ offset, length: slot.length, size: slot.size });
|
|
58
54
|
}
|
|
55
|
+
return slots;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function patchImages(original, profile, replacements) {
|
|
59
|
+
const slots = locateIcons(original, profile);
|
|
60
|
+
const patched = Buffer.from(original);
|
|
61
|
+
for (const slot of profile.slots) {
|
|
62
|
+
const replacement = replacements.get(slot.size);
|
|
63
|
+
if (!replacement || replacement.length !== slot.length || sha256(replacement) !== slot.replacementSha256 || pngLength(replacement, 0, slot.size) !== slot.length) throw new Error('Replacement artwork failed validation');
|
|
64
|
+
replacement.copy(patched, slots.find(found => found.size === slot.size).offset);
|
|
65
|
+
}
|
|
59
66
|
return { patched, slots };
|
|
60
67
|
}
|