Skip to content

Commit 706e936

Browse files
deadlyjackAjit KumarbajrangCoder
authored
fix(admob): harden consent, banners, and variant builds (#2553)
* fix(admob): harden consent, banners, and variant builds - integrate UMP consent handling and reactive privacy choices - serialize adaptive banner visibility across pages and keyboard changes - make free and paid Cordova variant configuration idempotent - commit and validate a deterministic self-contained AdMob bundle - remove vulnerable legacy toolchains and update affected lockfiles - replace the legacy soft-input workaround with adjustResize - add tests, lockfile checks, bundle freshness, and security auditing to CI * fix(admob): harden banner suppression and variant builds - make banner suppression reason-aware across Pro and rewarded passes - centralize reward state refresh, expiry scheduling, and failure handling - remove stale Cordova consent and persisted AdMob variant metadata - add ES2020-compatible access and Java 21 Android native CI coverage - enforce transient plugin setup and clean tracked build state - remove the obsolete large-screen quicktools tutorial * fix: dev * chore: remove CI workflow changes --------- Co-authored-by: Ajit Kumar <dellevenjack@gmail> Co-authored-by: Raunak Raj <71929976+bajrangCoder@users.noreply.github.com>
1 parent 30877ec commit 706e936

75 files changed

Lines changed: 8647 additions & 11936 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.sh text eol=lf
2+
config.xml text eol=lf

bun.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.xml

Lines changed: 93 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,93 @@
1-
<?xml version='1.0' encoding='utf-8'?>
2-
<widget id="com.foxdebug.acode" android-versionCode="1003" version="1.12.7"
3-
xmlns="http://www.w3.org/ns/widgets"
4-
xmlns:android="http://schemas.android.com/apk/res/android"
5-
xmlns:cdv="http://cordova.apache.org/ns/1.0">
6-
<name>Acode</name>
7-
<description>
8-
Light weight code editor and web IDE for android.
9-
</description>
10-
<author email="ajit@foxdebug.com" href="https://foxdebug.com">
11-
Foxdebug
12-
</author>
13-
<content src="index.html" />
14-
<access launch-external="yes" origin="*" />
15-
<allow-navigation href="https://*/*" />
16-
<allow-navigation href="http://*/*" />
17-
<allow-intent href="http://*/*" />
18-
<allow-intent href="https://*/*" />
19-
<allow-intent href="tel:*" />
20-
<allow-intent href="sms:*" />
21-
<allow-intent href="mailto:*" />
22-
<allow-intent href="geo:*" />
23-
24-
<platform name="android">
25-
<allow-intent href="market:*" />
26-
<preference name="fullscreen" value="false" />
27-
<preference name="SplashScreen" value="none" />
28-
<preference name="ShowTitle" value="true" />
29-
<preference name="DisallowOverscroll" value="true" />
30-
<preference name="BackgroundColor" value="0xFF313131" />
31-
<preference name="AndroidWindowSplashScreenBackground" value="@color/ic_splash_background" />
32-
<preference name="AndroidWindowSplashScreenAnimatedIcon"
33-
value="res/android/drawable/ic_launcher_foreground.xml" />
34-
<preference name="AndroidPostSplashScreenTheme" value="@style/Theme.App.Activity" />
35-
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
36-
<preference name="AndroidLaunchMode" value="singleTask" />
37-
<preference name="prerendered-icon" value="false" />
38-
<preference name="androidxEnabled" value="true" />
39-
<preference name="GradlePluginKotlinEnabled" value="true" />
40-
<preference name="android-targetSdkVersion" value="36" />
41-
<preference name="android-minSdkVersion" value="26" />
42-
43-
44-
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
45-
target="/manifest/application">
46-
<application
47-
android:networkSecurityConfig="@xml/network_security_config"
48-
android:hardwareAccelerated="true"
49-
android:largeHeap="true"
50-
android:requestLegacyExternalStorage="true"
51-
android:usesCleartextTraffic="true"
52-
android:enableOnBackInvokedCallback="false" />
53-
</edit-config>
54-
55-
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
56-
target="/manifest/application/activity[@android:name='MainActivity']">
57-
<activity android:resizeableActivity="true" />
58-
</edit-config>
59-
60-
<config-file parent="./application/activity" target="AndroidManifest.xml">
61-
<intent-filter>
62-
<action android:name="android.intent.action.VIEW" />
63-
<action android:name="android.intent.action.EDIT" />
64-
<category android:name="android.intent.category.DEFAULT" />
65-
<category android:name="android.intent.category.LAUNCHER" />
66-
<data android:scheme="file" android:mimeType="*/*" />
67-
<data android:scheme="content" android:mimeType="*/*" />
68-
</intent-filter>
69-
<!-- Allow app to open using url from browser -->
70-
<intent-filter android:autoVerify="true">
71-
<action android:name="android.intent.action.VIEW" />
72-
<category android:name="android.intent.category.DEFAULT" />
73-
<category android:name="android.intent.category.BROWSABLE" />
74-
<data android:scheme="acode" />
75-
</intent-filter>
76-
</config-file>
77-
78-
<config-file target="AndroidManifest.xml" parent="/manifest">
79-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
80-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
81-
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
82-
<uses-permission android:name="android.permission.VIBRATE" />
83-
</config-file>
84-
85-
<hook type="before_prepare" src="hooks/restore-cordova-resources.js" />
86-
<hook type="before_prepare" src="hooks/modify-java-files.js" />
87-
<hook type="after_prepare" src="hooks/post-process.js" />
88-
</platform>
89-
<preference name="AndroidBlacklistSecureSocketProtocols" value="SSLv3,TLSv1" />
90-
</widget>
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<widget id="com.foxdebug.acode" android-versionCode="1003" version="1.12.7"
3+
xmlns="http://www.w3.org/ns/widgets"
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
xmlns:cdv="http://cordova.apache.org/ns/1.0">
6+
<name>Acode</name>
7+
<description>
8+
Light weight code editor and web IDE for android.
9+
</description>
10+
<author email="ajit@foxdebug.com" href="https://foxdebug.com">
11+
Foxdebug
12+
</author>
13+
<content src="index.html" />
14+
<access launch-external="yes" origin="*" />
15+
<allow-navigation href="https://*/*" />
16+
<allow-navigation href="http://*/*" />
17+
<allow-intent href="http://*/*" />
18+
<allow-intent href="https://*/*" />
19+
<allow-intent href="tel:*" />
20+
<allow-intent href="sms:*" />
21+
<allow-intent href="mailto:*" />
22+
<allow-intent href="geo:*" />
23+
24+
<platform name="android">
25+
<allow-intent href="market:*" />
26+
<preference name="GradlePluginKotlinVersion" value="2.3.0" />
27+
<preference name="fullscreen" value="false" />
28+
<preference name="SplashScreen" value="none" />
29+
<preference name="ShowTitle" value="true" />
30+
<preference name="DisallowOverscroll" value="true" />
31+
<preference name="BackgroundColor" value="0xFF313131" />
32+
<preference name="AndroidWindowSplashScreenBackground" value="@color/ic_splash_background" />
33+
<preference name="AndroidWindowSplashScreenAnimatedIcon"
34+
value="res/android/drawable/ic_launcher_foreground.xml" />
35+
<preference name="AndroidPostSplashScreenTheme" value="@style/Theme.App.Activity" />
36+
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
37+
<preference name="AndroidLaunchMode" value="singleTask" />
38+
<preference name="prerendered-icon" value="false" />
39+
<preference name="androidxEnabled" value="true" />
40+
<preference name="GradlePluginKotlinEnabled" value="true" />
41+
<preference name="android-targetSdkVersion" value="36" />
42+
<preference name="android-minSdkVersion" value="26" />
43+
44+
45+
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
46+
target="/manifest/application">
47+
<application
48+
android:networkSecurityConfig="@xml/network_security_config"
49+
android:hardwareAccelerated="true"
50+
android:largeHeap="true"
51+
android:requestLegacyExternalStorage="true"
52+
android:usesCleartextTraffic="true"
53+
android:enableOnBackInvokedCallback="false" />
54+
</edit-config>
55+
56+
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
57+
target="/manifest/application/activity[@android:name='MainActivity']">
58+
<activity
59+
android:resizeableActivity="true"
60+
android:windowSoftInputMode="adjustResize" />
61+
</edit-config>
62+
63+
<config-file parent="./application/activity" target="AndroidManifest.xml">
64+
<intent-filter>
65+
<action android:name="android.intent.action.VIEW" />
66+
<action android:name="android.intent.action.EDIT" />
67+
<category android:name="android.intent.category.DEFAULT" />
68+
<category android:name="android.intent.category.LAUNCHER" />
69+
<data android:scheme="file" android:mimeType="*/*" />
70+
<data android:scheme="content" android:mimeType="*/*" />
71+
</intent-filter>
72+
<!-- Allow app to open using url from browser -->
73+
<intent-filter android:autoVerify="true">
74+
<action android:name="android.intent.action.VIEW" />
75+
<category android:name="android.intent.category.DEFAULT" />
76+
<category android:name="android.intent.category.BROWSABLE" />
77+
<data android:scheme="acode" />
78+
</intent-filter>
79+
</config-file>
80+
81+
<config-file target="AndroidManifest.xml" parent="/manifest">
82+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
83+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
84+
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
85+
<uses-permission android:name="android.permission.VIBRATE" />
86+
</config-file>
87+
88+
<hook type="before_prepare" src="hooks/restore-cordova-resources.js" />
89+
<hook type="before_prepare" src="hooks/modify-java-files.js" />
90+
<hook type="after_prepare" src="hooks/post-process.js" />
91+
</platform>
92+
<preference name="AndroidBlacklistSecureSocketProtocols" value="SSLv3,TLSv1" />
93+
</widget>

hooks/post-process.js

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ fs.copyFileSync(gradleFilePath, androidGradleFilePath);
2727
copyDirRecursively(localResPath, resPath);
2828
enableLegacyJni();
2929
enableStaticContext();
30+
removeLegacyKeyboardWorkaround();
3031
patchTargetSdkVersion();
31-
enableKeyboardWorkaround();
3232

3333
function getPackageName() {
3434
const configPath = path.resolve(__dirname, '../config.xml');
@@ -210,8 +210,8 @@ function enableStaticContext() {
210210
}
211211
}
212212

213-
function enableKeyboardWorkaround() {
214-
try{
213+
function removeLegacyKeyboardWorkaround() {
214+
try {
215215
const prefix = execSync('npm prefix').toString().trim();
216216
const packageName = getPackageName();
217217
const mainActivityPath = path.join(
@@ -222,51 +222,30 @@ function enableKeyboardWorkaround() {
222222
);
223223

224224
if (!fs.existsSync(mainActivityPath)) {
225-
console.warn('[Cordova Hook] ⚠️ MainActivity.java not found at', mainActivityPath);
226225
return;
227226
}
228227

229-
let content = fs.readFileSync(mainActivityPath, 'utf-8');
230-
231-
// Skip if already patched
232-
if (content.includes('SoftInputAssist')) {
233-
console.log('[Cordova Hook] ✅ Keyboard workaround already enabled, skipping');
234-
return;
235-
}
236-
237-
// Add import
238-
if (!content.includes('import com.foxdebug.system.SoftInputAssist;')) {
239-
content = content.replace(
240-
/import java.lang.ref.WeakReference;|import org\.apache\.cordova\.\*;/,
241-
match =>
242-
match + '\nimport com.foxdebug.system.SoftInputAssist;'
228+
const content = fs.readFileSync(mainActivityPath, 'utf-8');
229+
const updatedContent = content
230+
.replace(/\r?\nimport com\.foxdebug\.system\.SoftInputAssist;/, '')
231+
.replace(/\r?\n\s*private SoftInputAssist softInputAssist;\r?\n/, '\n')
232+
.replace(
233+
/\r?\n\s*softInputAssist = new SoftInputAssist\(this\);/,
234+
''
243235
);
244-
}
245236

246-
// Declare field
247-
if (!content.includes('private SoftInputAssist softInputAssist;')) {
248-
content = content.replace(
249-
/public class MainActivity extends CordovaActivity\s*\{/,
250-
match =>
251-
match +
252-
`\n\n private SoftInputAssist softInputAssist;\n`
253-
);
237+
if (updatedContent !== content) {
238+
fs.writeFileSync(mainActivityPath, updatedContent, 'utf-8');
239+
console.log('[Cordova Hook] ✅ Removed legacy keyboard workaround');
254240
}
255-
256-
// Initialize in onCreate
257-
content = content.replace(
258-
/loadUrl\(launchUrl\);/,
259-
`loadUrl(launchUrl);\n\n softInputAssist = new SoftInputAssist(this);`
260-
);
261-
262-
fs.writeFileSync(mainActivityPath, content, 'utf-8');
263-
console.log('[Cordova Hook] ✅ Enabled keyboard workaround');
264241
} catch (err) {
265-
console.error('[Cordova Hook] ❌ Failed to enable keyboard workaround:', err.message);
242+
console.error(
243+
'[Cordova Hook] ❌ Failed to remove legacy keyboard workaround:',
244+
err.message
245+
);
266246
}
267247
}
268248

269-
270249
/**
271250
* Copy directory recursively
272251
* @param {string} src Source directory

0 commit comments

Comments
 (0)