codeplay-common 4.11.25 → 4.11.27
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.
|
@@ -482,6 +482,10 @@ async function addOptionalCameraFeatures() {
|
|
|
482
482
|
if (!fs.existsSync(manifestPath)) return;
|
|
483
483
|
|
|
484
484
|
let manifest = fs.readFileSync(manifestPath, 'utf8');
|
|
485
|
+
const permissionManifest = manifest.replace(/<!--[\s\S]*?-->/g, '');
|
|
486
|
+
const hasCameraPermission = /<uses-permission(?:-sdk-23)?\b[^>]*\bandroid:name\s*=\s*(["'])android\.permission\.CAMERA\1(?=[\s/>])/.test(permissionManifest);
|
|
487
|
+
if (!hasCameraPermission) return;
|
|
488
|
+
|
|
485
489
|
const features = ['android.hardware.camera', 'android.hardware.camera.autofocus', 'android.hardware.camera.flash'];
|
|
486
490
|
const featureName = tag => /\bandroid:name\s*=\s*(["'])(.*?)\1/.exec(tag)?.[2];
|
|
487
491
|
const featureTags = /<!--[\s\S]*?-->|<uses-feature\b[^>]*>/g;
|
|
@@ -74,7 +74,8 @@ function syncAndroidAdmobPolicy(projectRoot, storeId, platform = 'android') {
|
|
|
74
74
|
let next = original;
|
|
75
75
|
const ensureMeta = (name, value) => {
|
|
76
76
|
const escapedName = name.replace(/\./g, '\\.');
|
|
77
|
-
|
|
77
|
+
// Stop at a self-closing tag before considering a later closing tag.
|
|
78
|
+
const existing = new RegExp(`<meta-data\\b(?=[^>]*\\bandroid:name\\s*=\\s*(['"])${escapedName}\\1)[^>]*?(?:/\\s*>|>[\\s\\S]*?</meta-data\\s*>)`);
|
|
78
79
|
const tag = `<meta-data android:name="${name}" android:value="${value}" />`;
|
|
79
80
|
next = existing.test(next) ? next.replace(existing, tag)
|
|
80
81
|
: next.replace(/<application\b[^>]*>/, match => `${match}${newline} ${tag}`);
|
|
@@ -91,7 +92,7 @@ function syncAndroidAdmobPolicy(projectRoot, storeId, platform = 'android') {
|
|
|
91
92
|
return changed;
|
|
92
93
|
}
|
|
93
94
|
update(path.join(projectRoot, 'android/app/src/main/AndroidManifest.xml'), original =>
|
|
94
|
-
original.replace(/^[ \t]*<(meta-data|activity|service|provider|receiver|uses-library)\b(?=[^>]*\bandroid:name\s*=\s*(['"])(?:com\.google\.android\.gms\.ads\.|com\.google\.ads\.|com\.google\.android\.ump\.)[^'"]*\2)[^>]
|
|
95
|
+
original.replace(/^[ \t]*<(meta-data|activity|service|provider|receiver|uses-library)\b(?=[^>]*\bandroid:name\s*=\s*(['"])(?:com\.google\.android\.gms\.ads\.|com\.google\.ads\.|com\.google\.android\.ump\.)[^'"]*\2)[^>]*?(?:\/\s*>|>[\s\S]*?<\/\1\s*>)[ \t]*(?:\r?\n)?/gm, ''));
|
|
95
96
|
update(path.join(projectRoot, 'android/app/src/main/assets/capacitor.config.json'), original => {
|
|
96
97
|
const generated = JSON.parse(original);
|
|
97
98
|
removeAdmobPluginConfig(generated);
|
package/package.json
CHANGED
|
@@ -4,6 +4,21 @@ const fs = require('node:fs');
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const { syncAndroidAdmobPolicy, withNativeAdProvider, admobConfigPlugin } = require('../files/buildCodeplay/ruads.cjs');
|
|
6
6
|
|
|
7
|
+
// Capacitor's paired FileProvider metadata previously let a self-closing AdMob
|
|
8
|
+
// entry consume the app components up to a later closing tag.
|
|
9
|
+
const appComponents = ` <activity android:name=".MainActivity" android:exported="true">
|
|
10
|
+
<intent-filter>
|
|
11
|
+
<action android:name="android.intent.action.MAIN" />
|
|
12
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
|
13
|
+
</intent-filter>
|
|
14
|
+
</activity>
|
|
15
|
+
<provider android:name="androidx.core.content.FileProvider"
|
|
16
|
+
android:authorities="\${applicationId}.fileprovider" android:exported="false"
|
|
17
|
+
android:grantUriPermissions="true">
|
|
18
|
+
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
|
|
19
|
+
android:resource="@xml/file_paths"></meta-data>
|
|
20
|
+
</provider>`;
|
|
21
|
+
|
|
7
22
|
function fixture(enabled = true) {
|
|
8
23
|
const temp = path.resolve(__dirname, '../agent-temp');
|
|
9
24
|
fs.mkdirSync(temp, { recursive: true });
|
|
@@ -22,6 +37,7 @@ function fixture(enabled = true) {
|
|
|
22
37
|
<provider android:name="com.google.android.gms.ads.MobileAdsInitProvider" />
|
|
23
38
|
<activity android:name="com.my.target.ads.MyTargetActivity" />
|
|
24
39
|
<meta-data android:name="firebase_analytics_collection_enabled" android:value="true" />
|
|
40
|
+
${appComponents}
|
|
25
41
|
</application>
|
|
26
42
|
</manifest>
|
|
27
43
|
`;
|
|
@@ -40,6 +56,34 @@ function fixture(enabled = true) {
|
|
|
40
56
|
return { root, write, manifest, read: name => fs.readFileSync(path.join(root, name), 'utf8') };
|
|
41
57
|
}
|
|
42
58
|
|
|
59
|
+
for (const pairedMetadata of [false, true]) {
|
|
60
|
+
for (const storeId of [1, 10]) {
|
|
61
|
+
test(`store ${storeId}: preserve launcher and FileProvider with ${pairedMetadata ? 'paired' : 'self-closing'} ad entries`, () => {
|
|
62
|
+
const f = fixture();
|
|
63
|
+
const manifestPath = 'android/app/src/main/AndroidManifest.xml';
|
|
64
|
+
const manifest = pairedMetadata ? f.manifest
|
|
65
|
+
.replace('android:name="com.google.android.gms.ads.APPLICATION_ID" />',
|
|
66
|
+
'android:name="com.google.android.gms.ads.APPLICATION_ID"></meta-data>')
|
|
67
|
+
.replace('<provider android:name="com.google.android.gms.ads.MobileAdsInitProvider" />',
|
|
68
|
+
'<provider android:name="com.google.android.gms.ads.MobileAdsInitProvider"></provider>') : f.manifest
|
|
69
|
+
.replace("android:value='true'></meta-data>", "android:value='true' />")
|
|
70
|
+
.replace('<activity android:name="com.google.android.gms.ads.AdActivity"><intent-filter /></activity>',
|
|
71
|
+
'<activity android:name="com.google.android.gms.ads.AdActivity" />');
|
|
72
|
+
f.write(manifestPath, manifest);
|
|
73
|
+
for (const targetStore of [storeId, storeId === 1 ? 10 : 1, storeId]) {
|
|
74
|
+
syncAndroidAdmobPolicy(f.root, targetStore);
|
|
75
|
+
const updated = f.read(manifestPath);
|
|
76
|
+
assert.ok(updated.includes(appComponents), 'App components must remain byte-for-byte identical');
|
|
77
|
+
assert.match(updated, /firebase_analytics_collection_enabled/);
|
|
78
|
+
assert.match(updated, /MyTargetActivity/);
|
|
79
|
+
assert.equal(updated.includes('com.google.android.gms.ads.APPLICATION_ID'), targetStore === 1);
|
|
80
|
+
assert.equal(syncAndroidAdmobPolicy(f.root, targetStore), false);
|
|
81
|
+
assert.equal(f.read(manifestPath), updated);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
43
87
|
for (const storeId of [4, 10]) {
|
|
44
88
|
test(`store ${storeId}: clean synced config, stale manifest and SDKs; repeat safely`, () => {
|
|
45
89
|
const f = fixture();
|