fix(android): generate missing a11y service resources in plugin
Plugin referenced @string/accessibility_service_summary + @xml/accessibility_service_config in AndroidManifest but never created the underlying resource files. EAS Cloud prebuild --clean exposed this — local dev worked because resources were sometimes already there from previous builds. - withStringsXml: adds accessibility_service_summary string (DE) - withDangerousMod: writes res/xml/accessibility_service_config.xml at prebuild - Config flags match native service (TYPE_WINDOW_CONTENT_CHANGED + STATE_CHANGED, canRetrieveWindowContent for URL-bar reading) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5eebda4b6b
commit
eccc04b1e3
@ -27,8 +27,12 @@
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
withAndroidManifest,
|
withAndroidManifest,
|
||||||
|
withStringsXml,
|
||||||
|
withDangerousMod,
|
||||||
AndroidConfig,
|
AndroidConfig,
|
||||||
} = require('@expo/config-plugins');
|
} = require('@expo/config-plugins');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const VPN_SERVICE_CLASS =
|
const VPN_SERVICE_CLASS =
|
||||||
'expo.modules.rebreakprotection.vpn.RebreakVpnService';
|
'expo.modules.rebreakprotection.vpn.RebreakVpnService';
|
||||||
@ -113,15 +117,69 @@ function ensureAccessibilityService(manifest) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── 4) String resource für a11y-service-summary ────────────────────────────
|
||||||
|
|
||||||
|
const A11Y_SUMMARY_TEXT =
|
||||||
|
'ReBreak schützt vor Glücksspiel-Seiten in Browsern. Liest URLs in der Adressleiste, um Casino-Domains zu erkennen und zu blocken.';
|
||||||
|
|
||||||
|
function withA11yStringResource(config) {
|
||||||
|
return withStringsXml(config, (cfg) => {
|
||||||
|
cfg.modResults = AndroidConfig.Strings.setStringItem(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
$: { name: 'accessibility_service_summary', translatable: 'false' },
|
||||||
|
_: A11Y_SUMMARY_TEXT,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cfg.modResults,
|
||||||
|
);
|
||||||
|
return cfg;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── 5) XML-config für AccessibilityService ─────────────────────────────────
|
||||||
|
|
||||||
|
const A11Y_CONFIG_XML = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:accessibilityEventTypes="typeWindowContentChanged|typeWindowStateChanged"
|
||||||
|
android:accessibilityFeedbackType="feedbackGeneric"
|
||||||
|
android:accessibilityFlags="flagDefault|flagReportViewIds"
|
||||||
|
android:canRetrieveWindowContent="true"
|
||||||
|
android:notificationTimeout="100"
|
||||||
|
android:description="@string/accessibility_service_summary" />
|
||||||
|
`;
|
||||||
|
|
||||||
|
function withA11yConfigXml(config) {
|
||||||
|
return withDangerousMod(config, [
|
||||||
|
'android',
|
||||||
|
async (cfg) => {
|
||||||
|
const xmlDir = path.join(
|
||||||
|
cfg.modRequest.platformProjectRoot,
|
||||||
|
'app/src/main/res/xml',
|
||||||
|
);
|
||||||
|
fs.mkdirSync(xmlDir, { recursive: true });
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(xmlDir, 'accessibility_service_config.xml'),
|
||||||
|
A11Y_CONFIG_XML,
|
||||||
|
'utf8',
|
||||||
|
);
|
||||||
|
return cfg;
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// ─── Composition ────────────────────────────────────────────────────────────
|
// ─── Composition ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function withRebreakProtectionAndroid(config) {
|
function withRebreakProtectionAndroid(config) {
|
||||||
return withAndroidManifest(config, (cfg) => {
|
config = withAndroidManifest(config, (cfg) => {
|
||||||
ensureToolsNamespace(cfg.modResults);
|
ensureToolsNamespace(cfg.modResults);
|
||||||
ensureVpnService(cfg.modResults);
|
ensureVpnService(cfg.modResults);
|
||||||
ensureAccessibilityService(cfg.modResults);
|
ensureAccessibilityService(cfg.modResults);
|
||||||
return cfg;
|
return cfg;
|
||||||
});
|
});
|
||||||
|
config = withA11yStringResource(config);
|
||||||
|
config = withA11yConfigXml(config);
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = withRebreakProtectionAndroid;
|
module.exports = withRebreakProtectionAndroid;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user