[tauri] KeepHerSafeApps: App words for Keep her safe, and Android's own save screen through a narrow bridge
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { apkProblems, manifestProblems, patchManifest, RULE_FILES, RULE_SECTIONS, ruleProblems } from '../src/android-privacy.js';
|
||||
import { PACKAGE, SRC_TAURI, tauri } from './tauri.js';
|
||||
|
||||
@@ -22,6 +22,10 @@ const MANIFEST = join(MAIN, 'AndroidManifest.xml');
|
||||
const RES_FROM = join(PACKAGE, 'android', 'res', 'xml');
|
||||
const RES_TO = join(MAIN, 'res', 'xml');
|
||||
const OUTPUTS = join(SRC_TAURI, 'gen', 'android', 'app', 'build', 'outputs', 'apk');
|
||||
// Rosea's own MainActivity: the save bridge (keep-her-safe-apps.md A2, A5).
|
||||
const IDENTIFIER = (JSON.parse(readFileSync(join(SRC_TAURI, 'tauri.conf.json'), 'utf8')) as { identifier: string }).identifier;
|
||||
const ACTIVITY_FROM = join(PACKAGE, 'android', 'java', 'MainActivity.kt');
|
||||
const ACTIVITY_TO = join(MAIN, 'java', ...IDENTIFIER.split('.'), 'MainActivity.kt');
|
||||
|
||||
function fail(problems: readonly string[]): never {
|
||||
for (const p of problems) console.error(`android: ${p}`);
|
||||
@@ -36,6 +40,10 @@ function problems(): string[] {
|
||||
if (!existsSync(at)) found.push(`res/xml/${f} is missing`);
|
||||
else if (readFileSync(at, 'utf8') !== readFileSync(join(RES_FROM, f), 'utf8')) found.push(`res/xml/${f} differs from android/res/xml/${f}`);
|
||||
}
|
||||
if (!existsSync(ACTIVITY_TO)) found.push(`no MainActivity.kt at ${ACTIVITY_TO}`);
|
||||
else if (readFileSync(ACTIVITY_TO, 'utf8') !== readFileSync(ACTIVITY_FROM, 'utf8')) {
|
||||
found.push("MainActivity.kt is not Rosea's (android/java/MainActivity.kt): no save bridge");
|
||||
}
|
||||
// The launcher icon is Rosea's, not the Tauri logo `init` put there (scripts/icons.ts).
|
||||
const ours = join(SRC_TAURI, 'icons', 'android', 'mipmap-mdpi', 'ic_launcher.png');
|
||||
const there = join(MAIN, 'res', 'mipmap-mdpi', 'ic_launcher.png');
|
||||
@@ -55,12 +63,14 @@ function apply(): void {
|
||||
const after = patchManifest(before);
|
||||
mkdirSync(RES_TO, { recursive: true });
|
||||
for (const f of RULE_FILES) copyFileSync(join(RES_FROM, f), join(RES_TO, f));
|
||||
if (!existsSync(dirname(ACTIVITY_TO))) fail([`no generated activity folder ${dirname(ACTIVITY_TO)}; the identifier changed?`]);
|
||||
copyFileSync(ACTIVITY_FROM, ACTIVITY_TO);
|
||||
if (after !== before) writeFileSync(MANIFEST, after);
|
||||
const left = problems();
|
||||
if (left.length > 0) fail(left);
|
||||
console.log(
|
||||
`android: privacy ${after === before ? 'already in place' : 'applied'} ` +
|
||||
'(no INTERNET, no backup or transfer, WebView metrics and Safe Browsing off)'
|
||||
"(no INTERNET, no backup or transfer, WebView metrics and Safe Browsing off; Rosea's MainActivity)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user