MCPcopy
hub / github.com/ionic-team/capacitor / updateAndroidManifest

Function updateAndroidManifest

cli/src/tasks/migrate.ts:599–624  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

597}
598
599async function updateAndroidManifest(filename: string) {
600 const txt = readFile(filename);
601 if (!txt) {
602 return;
603 }
604
605 if (txt.includes('|density') || txt.includes('density|')) {
606 return; // Probably already updated
607 }
608 // Since navigation was an optional change in Capacitor 7, attempting to add density and/or navigation
609 const replaced = txt
610 .replace(
611 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"',
612 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"',
613 )
614 .replace(
615 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"',
616 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"',
617 );
618
619 if (!replaced.includes('|density')) {
620 logger.error(`Unable to add 'density' to 'android:configChanges' in ${filename}. Try adding it manually`);
621 } else {
622 writeFileSync(filename, replaced, 'utf-8');
623 }
624}

Callers 1

migrateCommandFunction · 0.85

Calls 2

readFileFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected