1 #This file is part of The Open GApps script of @mfonville.
3 # The Open GApps scripts are free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # These scripts are distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
14 echo "# begin addon properties
18 ro.addon.platform=$PLATFORM
19 ro.addon.open_type=$VARIANT
20 ro.addon.open_version=$DATE
21 # end addon properties" > "$build/$1"
22 EXTRACTFILES
="$EXTRACTFILES $1"
27 if [ "$API" -le "21" ] && [ "$GAPPSREMOVEVARIANT" = "super" ]; then
28 get_supported_variants
"stock" # On 5.0 and lower the largest package is stock instead of super for the "regular" package-type
30 get_supported_variants
"$GAPPSREMOVEVARIANT" # Retrieve the largest package of the package-type branch
32 get_gapps_list
"$supported_variants"
33 for gapp
in $gapps_list; do
34 get_package_info
"$gapp"
35 if [ -n "$packagetarget" ]; then
36 gapps_remove
="/system/$packagetarget$REMOVALSUFFIX
39 for lib
in $packagelibs; do
41 getpathsystemlib
"$lib"
42 for libpath
in $systemlibpath; do
43 gapps_remove
="/system/$libpath
47 for file in $packagefiles; do
48 gapps_remove
="/system/$file
51 for extraline
in $packagegappsremove; do
52 gapps_remove
="/system/$extraline
56 printf "%s" "$gapps_remove" |
sort -u > "$build/$1" # make unique for the VRmode entries
57 EXTRACTFILES
="$EXTRACTFILES $1"
62 #This file is part of The Open GApps script of @mfonville.
64 # The Open GApps scripts are free software: you can redistribute it and/or modify
65 # it under the terms of the GNU General Public License as published by
66 # the Free Software Foundation, either version 3 of the License, or
67 # (at your option) any later version, w/Open GApps installable zip exception.
69 # These scripts are distributed in the hope that it will be useful,
70 # but WITHOUT ANY WARRANTY; without even the implied warranty of
71 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72 # GNU General Public License for more details.
74 # This Open GApps installer-runtime is because of the Open GApps installable
75 # zip exception de-facto LGPLv3 licensed.
78 export OUTFD="/proc/self/fd/$2"
81 *86*) export BINARCH="x86";; # e.g. Zenfone is i686
82 *ar*) export BINARCH="arm";; # i.e. armv7l and aarch64
84 bb="$TMP/'"$2"'-$BINARCH"
88 unzip -o "$OPENGAZIP" "$f" -d "$TMP";
95 for i in $($bb --list); do
96 if ! ln -sf "$bb" "$l/$i" && ! $bb ln -sf "$bb" "$l/$i" && ! $bb ln -f "$bb" "$l/$i" ; then
97 # create script wrapper if symlinking and hardlinking failed because of restrictive selinux policy
98 if ! echo "#!$bb" > "$l/$i" || ! chmod +x "$l/$i" ; then
99 echo "ui_print ERROR 10: Failed to set-up Open GApps'"'"' pre-bundled '"$2"'" > "$OUTFD"
100 echo "ui_print" > "$OUTFD"
101 echo "ui_print Please use TWRP as recovery instead" > "$OUTFD"
102 echo "ui_print" > "$OUTFD"
107 PATH="$l:$PATH" $bb ash "$TMP/'"$3"'" "$@"
110 echo "ui_print ERROR 64: Wrong architecture to set-up Open GApps'"'"' pre-bundled '"$2"'" > "$OUTFD"
111 echo "ui_print" > "$OUTFD"
117 EXTRACTFILES
="$EXTRACTFILES $1"
119 #This file is part of The Open GApps script of @mfonville.
121 # The Open GApps scripts are free software: you can redistribute it and/or modify
122 # it under the terms of the GNU General Public License as published by
123 # the Free Software Foundation, either version 3 of the License, or
124 # (at your option) any later version, w/Open GApps installable zip exception.
126 # These scripts are distributed in the hope that it will be useful,
127 # but WITHOUT ANY WARRANTY; without even the implied warranty of
128 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
129 # GNU General Public License for more details.
131 # This Open GApps installer-runtime is because of the Open GApps installable
132 # zip exception de-facto LGPLv3 licensed.
134 # This script of the Open GApps Installer is contains work from the PA GApps of @TKruzze and @osm0sis,
135 # PA GApps source is used with permission, under the license that it may be re-used to continue GApps packages.
137 # Last Updated: '"$DATE"'
138 # _____________________________________________________________________________________________________________________
139 # Define Current Package Variables
140 # List of GApps packages that can be installed with this installer
141 pkg_names="'"$SUPPORTEDVARIANTS"'";
143 # Installer Name (32 chars Total, excluding "")
144 installer_name="Open GApps '"$VARIANT"' '"$PLATFORM"' - ";
146 req_android_arch="'"$ARCH"'";
147 req_android_sdk="'"$API"'";
148 req_android_version="'"$PLATFORM"'";
151 faceLock_lib_filename="'"$FACELOCKLIB"'";
152 atvremote_lib_filename="libatv_uinputbridge.so"
153 WebView_lib_filename="libwebviewchromium.so";
155 # Buffer of extra system space to require for GApps install (9216=9MB)
156 # This will allow for some ROM size expansion when GApps are restored
157 buffer_size_kb=9216; small_buffer_size=2048;
159 # List of GApps files that should NOT be automatically removed as they are also included in (many) ROMs
160 removal_bypass_list="'"$REMOVALBYPASS"'
163 # Define exit codes (returned upon exit due to an error)
164 E_ROMVER=20; # Wrong ROM version
165 E_NOBUILDPROP=25; #No build.prop or equivalent
166 E_RECCOMPR=30; # Recovery without transparent compression
167 E_NOSPACE=70; # Insufficient Space Available in System Partition
168 E_NONOPEN=40; # NON Open GApps Currently Installed
169 E_ARCH=64; # Wrong Architecture Detected
170 #_________________________________________________________________________________________________________________
171 # GApps List (Applications user can Select/Deselect)
212 # _____________________________________________________________________________________________________________________
213 # Default Stock/AOSP Removal List (Stock GApps Only)
214 default_stock_remove_list="
217 # _____________________________________________________________________________________________________________________
218 # Optional Stock/AOSP/ROM Removal List
219 optional_aosp_remove_list="
269 visualizationwallpapers
272 # _____________________________________________________________________________________________________________________
273 # Stock/AOSP/ROM File Removal Lists
275 vendor/bundled-app/Boxer'"$REMOVALSUFFIX"'"
278 app/Browser'"$REMOVALSUFFIX"'
279 app/Browser2'"$REMOVALSUFFIX"'
280 app/BrowserIntl'"$REMOVALSUFFIX"'
281 app/BrowserProviderProxy'"$REMOVALSUFFIX"'
282 app/Chromium'"$REMOVALSUFFIX"'
283 app/Fluxion'"$REMOVALSUFFIX"'
284 app/Gello'"$REMOVALSUFFIX"'
285 app/PA_Browser'"$REMOVALSUFFIX"'
286 app/YuBrowser'"$REMOVALSUFFIX"'
287 priv-app/BLUOpera'"$REMOVALSUFFIX"'
288 priv-app/BLUOperaPreinstall'"$REMOVALSUFFIX"'
289 priv-app/Browser'"$REMOVALSUFFIX"'
290 priv-app/BrowserIntl'"$REMOVALSUFFIX"'"
293 app/BasicDreams'"$REMOVALSUFFIX"'"
295 # Must be used when GoogleCalculator is installed
296 calculatorstock_list="
297 app/Calculator'"$REMOVALSUFFIX"'
298 app/ExactCalculator'"$REMOVALSUFFIX"'
299 app/FineOSCalculator'"$REMOVALSUFFIX"'"
301 # Must be used when GoogleCalendar is installed
303 app/Calendar'"$REMOVALSUFFIX"'
304 priv-app/Calendar'"$REMOVALSUFFIX"'
305 app/FineOSCalendar'"$REMOVALSUFFIX"'"
307 # Must be used when GoogleCamera is installed
309 app/Camera'"$REMOVALSUFFIX"'
310 app/Camera2'"$REMOVALSUFFIX"'
311 priv-app/Camera'"$REMOVALSUFFIX"'
312 priv-app/Camera2'"$REMOVALSUFFIX"'
313 app/MotCamera'"$REMOVALSUFFIX"'
314 app/MtkCamera'"$REMOVALSUFFIX"'
315 app/MTKCamera'"$REMOVALSUFFIX"'
316 priv-app/MotCamera'"$REMOVALSUFFIX"'
317 priv-app/MiuiCamera'"$REMOVALSUFFIX"'
318 priv-app/MtkCamera'"$REMOVALSUFFIX"'
319 priv-app/MTKCamera'"$REMOVALSUFFIX"'
320 app/Snap'"$REMOVALSUFFIX"'
321 priv-app/Snap'"$REMOVALSUFFIX"'
322 app/SnapdragonCamera'"$REMOVALSUFFIX"'
323 priv-app/SnapdragonCamera'"$REMOVALSUFFIX"'
324 app/FineOSCamera'"$REMOVALSUFFIX"'"
327 app/DeskClock'"$REMOVALSUFFIX"'
328 app/DeskClock2'"$REMOVALSUFFIX"'
329 app/FineOSDeskClock'"$REMOVALSUFFIX"'"
332 priv-app/CMAccount'"$REMOVALSUFFIX"'"
335 priv-app/AudioFX'"$REMOVALSUFFIX"'"
338 priv-app/CMBugReport'"$REMOVALSUFFIX"'"
341 app/CMFileManager'"$REMOVALSUFFIX"'"
344 app/Apollo'"$REMOVALSUFFIX"'
345 app/Eleven'"$REMOVALSUFFIX"'
346 app/Music'"$REMOVALSUFFIX"'"
349 priv-app/Screencast'"$REMOVALSUFFIX"'"
352 app/CyanogenSetupWizard'"$REMOVALSUFFIX"'
353 priv-app/CyanogenSetupWizard'"$REMOVALSUFFIX"'"
356 priv-app/CMUpdater'"$REMOVALSUFFIX"'"
359 app/CMWallpapers'"$REMOVALSUFFIX"'"
361 cmweatherprovider_list="
362 priv-app/WeatherProvider'"$REMOVALSUFFIX"'"
364 # Must be used when Google Contacts is installed
366 priv-app/Contacts'"$REMOVALSUFFIX"'
367 priv-app/FineOSContacts'"$REMOVALSUFFIX"'"
370 app/DashClock'"$REMOVALSUFFIX"'"
372 # Must be used when Google Dialer is installed
374 priv-app/Dialer'"$REMOVALSUFFIX"'
375 priv-app/FineOSDialer'"$REMOVALSUFFIX"'"
378 app/Email'"$REMOVALSUFFIX"'
379 app/PrebuiltEmailGoogle'"$REMOVALSUFFIX"'
380 priv-app/Email'"$REMOVALSUFFIX"'"
383 app/Exchange2'"$REMOVALSUFFIX"'
384 priv-app/Exchange2'"$REMOVALSUFFIX"'"
386 extservicesstock_list="
387 priv-app/ExtServices'"$REMOVALSUFFIX"'"
389 extssharedstock_list="
390 app/ExtShared'"$REMOVALSUFFIX"'"
393 app/FM'"$REMOVALSUFFIX"'
394 app/FM2'"$REMOVALSUFFIX"'
395 app/FMRecord'"$REMOVALSUFFIX"'
396 priv-app/FMRadio'"$REMOVALSUFFIX"'
397 priv-app/MiuiRadio'"$REMOVALSUFFIX"'"
400 app/Galaxy4'"$REMOVALSUFFIX"'"
403 app/Gallery'"$REMOVALSUFFIX"'
404 priv-app/Gallery'"$REMOVALSUFFIX"'
405 app/Gallery2'"$REMOVALSUFFIX"'
406 priv-app/Gallery2'"$REMOVALSUFFIX"'
407 app/MotGallery'"$REMOVALSUFFIX"'
408 priv-app/MotGallery'"$REMOVALSUFFIX"'
409 app/MediaShortcuts'"$REMOVALSUFFIX"'
410 priv-app/MediaShortcuts'"$REMOVALSUFFIX"'
411 priv-app/MiuiGallery'"$REMOVALSUFFIX"'
412 priv-app/FineOSGallery'"$REMOVALSUFFIX"'"
415 app/HexoLibre'"$REMOVALSUFFIX"'"
418 app/HoloSpiralWallpaper'"$REMOVALSUFFIX"'"
420 # Must be used when GoogleKeyboard is installed
422 app/LatinIME'"$REMOVALSUFFIX"'
423 app/MzInput'"$REMOVALSUFFIX"'
424 priv-app/BLUTouchPal'"$REMOVALSUFFIX"'
425 priv-app/BLUTouchPalPortuguesebrPack'"$REMOVALSUFFIX"'
426 priv-app/BLUTouchPalSpanishLatinPack'"$REMOVALSUFFIX"'
427 priv-app/MzInput'"$REMOVALSUFFIX"'"
430 app/CMHome'"$REMOVALSUFFIX"'
431 app/CustomLauncher3'"$REMOVALSUFFIX"'
432 app/EasyLauncher'"$REMOVALSUFFIX"'
433 app/Fluctuation'"$REMOVALSUFFIX"'
434 app/FlymeLauncher'"$REMOVALSUFFIX"'
435 app/FlymeLauncherIntl'"$REMOVALSUFFIX"'
436 app/Launcher2'"$REMOVALSUFFIX"'
437 app/Launcher3'"$REMOVALSUFFIX"'
438 app/LiquidLauncher'"$REMOVALSUFFIX"'
439 app/Paclauncher'"$REMOVALSUFFIX"'
440 app/SlimLauncher'"$REMOVALSUFFIX"'
441 app/Trebuchet'"$REMOVALSUFFIX"'
442 app/FineOSHome'"$REMOVALSUFFIX"'
443 priv-app/CMHome'"$REMOVALSUFFIX"'
444 priv-app/CustomLauncher3'"$REMOVALSUFFIX"'
445 priv-app/EasyLauncher'"$REMOVALSUFFIX"'
446 priv-app/Fluctuation'"$REMOVALSUFFIX"'
447 priv-app/FlymeLauncher'"$REMOVALSUFFIX"'
448 priv-app/FlymeLauncherIntl'"$REMOVALSUFFIX"'
449 priv-app/Launcher2'"$REMOVALSUFFIX"'
450 priv-app/Launcher3'"$REMOVALSUFFIX"'
451 priv-app/LiquidLauncher'"$REMOVALSUFFIX"'
452 priv-app/MiuiHome'"$REMOVALSUFFIX"'
453 priv-app/Paclauncher'"$REMOVALSUFFIX"'
454 priv-app/SlimLauncher'"$REMOVALSUFFIX"'
455 priv-app/Trebuchet'"$REMOVALSUFFIX"'
456 priv-app/Nox'"$REMOVALSUFFIX"'"
459 app/Br0Zip'"$REMOVALSUFFIX"'"
461 livewallpapers_list="
462 app/LiveWallpapers'"$REMOVALSUFFIX"'"
465 app/LockClock'"$REMOVALSUFFIX"'"
468 priv-app/Recorder'"$REMOVALSUFFIX"'"
471 app/LineageSetupWizard'"$REMOVALSUFFIX"'
472 priv-app/LineageSetupWizard'"$REMOVALSUFFIX"'"
475 app/messaging'"$REMOVALSUFFIX"'
476 priv-app/Mms'"$REMOVALSUFFIX"'
477 priv-app/FineOSMms'"$REMOVALSUFFIX"'"
480 app/FileManager'"$REMOVALSUFFIX"'"
483 app/MzMPay'"$REMOVALSUFFIX"'
484 app/MzPay'"$REMOVALSUFFIX"'"
487 app/MzSetupWizard'"$REMOVALSUFFIX"'"
490 app/MzUpdate'"$REMOVALSUFFIX"'
491 app/SystemUpdate'"$REMOVALSUFFIX"'
492 app/SystemUpdateAssistant'"$REMOVALSUFFIX"'"
495 app/Weather'"$REMOVALSUFFIX"'"
498 app/NoiseField'"$REMOVALSUFFIX"'"
501 priv-app/OmniSwitch'"$REMOVALSUFFIX"'"
503 # Must be used when Google PackageInstaller is installed; non-capitalized spelling on Lenovo K3 Note
504 packageinstallerstock_list="
505 app/PackageInstaller'"$REMOVALSUFFIX"'
506 priv-app/PackageInstaller'"$REMOVALSUFFIX"'
507 priv-app/packageinstaller'"$REMOVALSUFFIX"'"
510 app/PhaseBeam'"$REMOVALSUFFIX"'"
513 app/PhotoPhase'"$REMOVALSUFFIX"'"
516 app/PhotoTable'"$REMOVALSUFFIX"'"
519 app/PicoTts'"$REMOVALSUFFIX"'
520 priv-app/PicoTts'"$REMOVALSUFFIX"'
525 printservicestock_list="
526 app/PrintRecommendationService'"$REMOVALSUFFIX"'"
529 app/Provision'"$REMOVALSUFFIX"'
530 priv-app/Provision'"$REMOVALSUFFIX"'"
533 app/Stk'"$REMOVALSUFFIX"'"
536 app/SoundRecorder'"$REMOVALSUFFIX"'"
538 storagemanagerstock_list="
539 priv-app/StorageManager'"$REMOVALSUFFIX"'"
542 app/VideoEditor'"$REMOVALSUFFIX"'"
545 app/Layers'"$REMOVALSUFFIX"'"
548 priv-app/Tag'"$REMOVALSUFFIX"'"
551 app/Terminal'"$REMOVALSUFFIX"'"
554 priv-app/CustomizeCenter'"$REMOVALSUFFIX"'
555 priv-app/ThemeChooser'"$REMOVALSUFFIX"'
556 priv-app/ThemesProvider'"$REMOVALSUFFIX"'"
558 visualizationwallpapers_list="
559 app/VisualizationWallpapers'"$REMOVALSUFFIX"'"
562 app/webview'"$REMOVALSUFFIX"'
563 app/WebView'"$REMOVALSUFFIX"'
564 '"$webviewstocklibs"'"
567 app/WhisperPush'"$REMOVALSUFFIX"'"
568 # _____________________________________________________________________________________________________________________
569 # Permanently Removed Folders
570 # Pieces that may be left over from AIO ROMs that can/will interfere with these GApps
572 /system/app/BooksStub'"$REMOVALSUFFIX"'
573 /system/app/CalendarGoogle'"$REMOVALSUFFIX"'
574 /system/app/CloudPrint'"$REMOVALSUFFIX"'
575 /system/app/DeskClockGoogle'"$REMOVALSUFFIX"'
576 /system/app/EditorsDocsStub'"$REMOVALSUFFIX"'
577 /system/app/EditorsSheetsStub'"$REMOVALSUFFIX"'
578 /system/app/EditorsSlidesStub'"$REMOVALSUFFIX"'
579 /system/app/Gmail'"$REMOVALSUFFIX"'
580 /system/app/Gmail2'"$REMOVALSUFFIX"'
581 /system/app/GoogleCalendar'"$REMOVALSUFFIX"'
582 /system/app/GoogleCloudPrint'"$REMOVALSUFFIX"'
583 /system/app/GoogleHangouts'"$REMOVALSUFFIX"'
584 /system/app/GoogleKeep'"$REMOVALSUFFIX"'
585 /system/app/GoogleLatinIme'"$REMOVALSUFFIX"'
586 /system/app/GooglePlus'"$REMOVALSUFFIX"'
587 /system/app/Keep'"$REMOVALSUFFIX"'
588 /system/app/NewsstandStub'"$REMOVALSUFFIX"'
589 /system/app/NewsWeather'"$REMOVALSUFFIX"'
590 /system/app/PartnerBookmarksProvider'"$REMOVALSUFFIX"'
591 /system/app/PrebuiltBugleStub'"$REMOVALSUFFIX"'
592 /system/app/PrebuiltKeepStub'"$REMOVALSUFFIX"'
593 /system/app/QuickSearchBox'"$REMOVALSUFFIX"'
594 /system/app/Vending'"$REMOVALSUFFIX"'
595 /system/priv-app/GmsCore'"$REMOVALSUFFIX"'
596 /system/priv-app/GoogleNow'"$REMOVALSUFFIX"'
597 /system/priv-app/GoogleSearch'"$REMOVALSUFFIX"'
598 /system/priv-app/GoogleHangouts'"$REMOVALSUFFIX"'
599 /system/priv-app/OneTimeInitializer'"$REMOVALSUFFIX"'
600 /system/priv-app/QuickSearchBox'"$REMOVALSUFFIX"'
601 /system/priv-app/Vending'"$REMOVALSUFFIX"'
602 /system/priv-app/Velvet_update'"$REMOVALSUFFIX"'
603 /system/priv-app/GmsCore_update'"$REMOVALSUFFIX"'
606 # Apps from app that need to be installed in priv-app
608 /system/app/CanvasPackageInstaller'"$REMOVALSUFFIX"'
609 /system/app/ConfigUpdater'"$REMOVALSUFFIX"'
610 /system/app/GoogleBackupTransport'"$REMOVALSUFFIX"'
611 /system/app/GoogleFeedback'"$REMOVALSUFFIX"'
612 /system/app/GoogleLoginService'"$REMOVALSUFFIX"'
613 /system/app/GoogleOneTimeInitializer'"$REMOVALSUFFIX"'
614 /system/app/GooglePartnerSetup'"$REMOVALSUFFIX"'
615 /system/app/GoogleServicesFramework'"$REMOVALSUFFIX"'
616 /system/app/OneTimeInitializer'"$REMOVALSUFFIX"'
617 /system/app/Phonesky'"$REMOVALSUFFIX"'
618 /system/app/PrebuiltGmsCore'"$REMOVALSUFFIX"'
619 /system/app/SetupWizard'"$REMOVALSUFFIX"'
620 /system/app/Velvet'"$REMOVALSUFFIX"'
623 # Stock/AOSP Keyboard lib (and symlink) that are always removed since they are always replaced
628 # Remove from priv-app since it was moved to app and vice-versa or other path changes
630 /system/app/CalculatorGoogle
631 /system/priv-app/GoogleHome'"$REMOVALSUFFIX"'
632 /system/priv-app/Hangouts'"$REMOVALSUFFIX"'
633 /system/priv-app/PrebuiltExchange3Google'"$REMOVALSUFFIX"'
634 /system/priv-app/talkback'"$REMOVALSUFFIX"'
635 /system/priv-app/Wallet'"$REMOVALSUFFIX"'
638 # Old addon.d backup scripts as we will be replacing with updated version during install
641 /system/addon.d/70-gapps.sh
643 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
645 remove_list="${other_list}${privapp_list}${reqd_list}${obsolete_list}${oldscript_list}";
646 # _____________________________________________________________________________________________________________________
647 # Installer Error Messages
648 arch_compat_msg="INSTALLATION FAILURE: This Open GApps package cannot be installed on this\ndevice's architecture. Please download the correct version for your device.\n";
649 camera_sys_msg="WARNING: Google Camera has/will not be installed as requested. Google Camera\ncan only be installed during a Clean Install or as an update to an existing\nGApps Installation.\n";
650 camera_compat_msg="WARNING: Google Camera has/will not be installed as requested. Google Camera\nis NOT compatible with your device if installed on the system partition. Try\ninstalling from the Play Store instead.\n";
651 cmcompatibility_msg="WARNING: PackageInstallerGoogle is not installed. Cyanogenmod is NOT\ncompatible with some Google Applications and Open GApps\n will skip their installation.\n";
652 dialergoogle_msg="WARNING: Google Dialer has/will not be installed as requested. Dialer Framework\nmust be added to the GApps installation if you want to install the\nGoogle Dialer.\n";
653 faceunlock_msg="NOTE: FaceUnlock can only be installed on devices with a front facing camera.\n";
654 googlenow_msg="WARNING: Google Now Launcher has/will not be installed as requested. Google Search\nmust be added to the GApps installation if you want to install the\nGoogle Now Launcher.\n";
655 pixellauncher_msg="WARNING: Pixel Launcher has/will not be installed as requested. Wallpapers and\nGoogle Search must be added to the GApps installation if you want to install\nthe Pixel Launcher.\n";
656 projectfi_msg="WARNING: Project Fi has/will not be installed as requested. GCS must be\nadded to the GApps installation if you want to install the Project Fi app.\n";
657 nobuildprop="INSTALLATION FAILURE: The installed ROM has no build.prop or equivalent\n";
658 nokeyboard_msg="NOTE: The Stock/AOSP keyboard was NOT removed as requested to ensure your device\nwas not accidentally left with no keyboard installed. If this was intentional,\nyou can add 'Override' to your gapps-config to override this protection.\n";
659 nolauncher_msg="NOTE: The Stock/AOSP Launcher was NOT removed as requested to ensure your device\nwas not accidentally left with no Launcher. If this was your intention, you can\nadd 'Override' to your gapps-config to override this protection.\n";
660 nomms_msg="NOTE: The Stock/AOSP MMS app was NOT removed as requested to ensure your device\nwas not accidentally left with no way to receive text messages. If this WAS\nintentional, add 'Override' to your gapps-config to override this protection.\n";
661 nowebview_msg="NOTE: The Stock/AOSP WebView was NOT removed as requested to ensure your device\nwas not accidentally left with no WebViewProvider installed. If this was intentional,\nyou can add 'Override' to your gapps-config to override this protection.\n";
662 non_open_gapps_msg="INSTALLATION FAILURE: Open GApps can only be installed on top of an existing\nOpen GApps installation. Since you are currently using another GApps package, you\nwill need to wipe (format) your system partition before installing Open GApps.\n";
663 fornexus_open_gapps_msg="NOTE: The installer detected that you already have Stock ROM GApps installed.\nThe installer will now continue, but please be aware that there could be problems.\n";
664 recovery_compression_msg="INSTALLATION FAILURE: Your ROM uses transparent compression, but your recovery\ndoes not support this feature, resulting in corrupt files.\nPlease update your recovery before flashing ANY package to prevent corruption.\n";
665 rom_android_version_msg="INSTALLATION FAILURE: This GApps package can only be installed on a $req_android_version.x ROM.\n";
666 simulation_msg="TEST INSTALL: This was only a simulated install. NO CHANGES WERE MADE TO YOUR\nDEVICE. To complete the installation remove 'Test' from your gapps-config.\n";
667 stubwebview_msg="NOTE: Stub WebView was installed instead of Google WebView because your device\nhas already Chrome installed as WebViewProvider. If you still want Google WebView,\nyou can add 'Override' to your gapps-config to override this redundancy protection.\n";
668 system_space_msg="INSTALLATION FAILURE: Your device does not have sufficient space available in\nthe system partition to install this GApps package as currently configured.\nYou will need to switch to a smaller GApps package or use gapps-config to\nreduce the installed size.\n";
669 user_multiplefound_msg="NOTE: All User Application Removals included in gapps-config were unable to be\nprocessed as requested because multiple versions of the app were found on your\ndevice. See the log portion below for the name(s) of the application(s).\n";
670 user_notfound_msg="NOTE: All User Application Removals included in gapps-config were unable to be\nremoved as requested because the files were not found on your device. See the\nlog portion below for the name(s) of the application(s).\n";
671 vrservice_compat_msg="WARNING: Google VR Services has/will not be installed as requested.\nGoogle VR Services is NOT compatible with your device.\n";
672 del_conflict_msg="!!! WARNING !!! - Duplicate files were found between your ROM and this GApps\npackage. This is likely due to your ROM's dev including Google proprietary\nfiles in the ROM. The duplicate files are shown in the log portion below.\n";
674 nogooglecontacts_removal_msg="NOTE: The Stock/AOSP Contacts is not available on your\nROM (anymore), the Google equivalent will not be removed."
675 nogoogledialer_removal_msg="NOTE: The Stock/AOSP Dialer is not available on your\nROM (anymore), the Google equivalent will not be removed."
676 nogooglekeyboard_removal_msg="NOTE: The Stock/AOSP Keyboard is not available on your\nROM (anymore), the Google equivalent will not be removed."
677 nogooglepackageinstaller_removal_msg="NOTE: The Stock/AOSP Package Installer is not\navailable on your ROM (anymore), the Google equivalent will not be removed."
678 nogoogletag_removal_msg="NOTE: The Stock/AOSP NFC Tag is not available on your\nROM (anymore), the Google equivalent will not be removed."
679 nogooglewebview_removal_msg="NOTE: The Stock/AOSP WebView is not available on your\nROM (anymore), not all Google WebViewProviders will be removed."
681 # _____________________________________________________________________________________________________________________
683 zip_folder="$(dirname "$OPENGAZIP")";
684 g_prop=/system/etc/g.prop
685 PROPFILES="$g_prop /system/default.prop /system/build.prop /data/local.prop /default.prop /build.prop"
686 bkup_tail=$TMP/bkup_tail.sh;
687 gapps_removal_list=$TMP/gapps-remove.txt;
689 calc_log=$TMP/calc.log;
690 conflicts_log=$TMP/conflicts.log;
691 rec_cache_log=/cache/recovery/log;
692 rec_tmp_log=$TMP/recovery.log;
693 user_remove_notfound_log=$TMP/user_remove_notfound.log;
694 user_remove_multiplefound_log=$TMP/user_remove_multiplefound.log;
696 log_close="# End Open GApps Install Log\n";
698 reclaimed_gapps_space_kb=0;
699 reclaimed_removal_space_kb=0;
700 reclaimed_aosp_space_kb=0;
701 total_install_size_kb=0;
702 # _____________________________________________________________________________________________________________________
706 ui_print "- NO changes were made to your device";
708 ui_print "Installer will now exit...";
710 ui_print "Error Code: $1";
716 chcon -h u:object_r:system_file:s0 "$1";
720 if [ -f "$1" ] && ("$TMP/unzip-$BINARCH" -ql "$1" | grep -q "META-INF/MANIFEST.MF"); then # strict, only files
721 "$TMP/unzip-$BINARCH" -p "$1" "META-INF/MANIFEST.MF" | grep -q "$2"
728 complete_gapps_list() {
742 if [ -f /data/system/packages.xml ] && [ "$forceclean" != "true" ]; then
749 "$TMP/unzip-$BINARCH" -l "$OPENGAZIP" "$1" | grep -q "$1"
754 tarpath="$TMP/$1.tar" # NB no suffix specified here
755 if "$TMP/unzip-$BINARCH" -o "$OPENGAZIP" "$1.tar*" -d "$TMP"; then # wildcard for suffix
756 app_name="$(basename "$1")"
757 which_dpi "$app_name"
758 echo "Found $1 DPI path: $dpiapkpath"
759 folder_extract "$tarpath" "$dpiapkpath" "$app_name/common"
761 echo "Failed to extract $1.tar* from $OPENGAZIP"
767 if [ "$skipvendorlibs" = "true" ]; then
768 umount /system/vendor # unmount tmpfs
770 if ( ! grep -qiE '^ *nodebug *($|#)+' "$g_conf" ); then
771 if [ "$g_conf" ]; then # copy gapps-config files to debug logs folder
772 cp -f "$g_conf_orig" "$TMP/logs/gapps-config_original.txt"
773 cp -f "$g_conf" "$TMP/logs/gapps-config_processed.txt"
775 ls -alZR /system > "$TMP/logs/System_Files_After.txt"
776 df -k > "$TMP/logs/Device_Space_After.txt"
777 cp -f "$log_folder/open_gapps_log.txt" "$TMP/logs"
778 for f in $PROPFILES; do
779 cp -f "$f" "$TMP/logs"
781 cp -f "/system/addon.d/70-gapps.sh" "$TMP/logs"
782 cp -f "$gapps_removal_list" "$TMP/logs/gapps-remove_revised.txt"
783 cp -f "$rec_cache_log" "$TMP/logs/Recovery_cache.log"
784 cp -f "$rec_tmp_log" "$TMP/logs/Recovery_tmp.log"
785 logcat -d -f "$TMP/logs/logcat"
787 tar -cz -f "$log_folder/open_gapps_debug_logs.tar.gz" logs/*
790 find $TMP/* -maxdepth 0 ! -path "$rec_tmp_log" -exec rm -rf {} +
792 ui_print "- Unmounting $mounts"
803 if [ -e "$archive.xz" ]; then
805 if [ "$f" != "unknown" ]; then
806 "$TMP/xzdec-$BINARCH" "$archive.xz" | "$TMP/tar-$BINARCH" -x -C "$TMP" -f - "$f" && install_extracted "$f"
810 elif [ -e "$archive.lz" ]; then
812 if [ "$f" != "unknown" ]; then
813 "$TMP/tar-$BINARCH" -xf "$archive.lz" -C "$TMP" "$f" && install_extracted "$f"
817 elif [ -e "$archive" ]; then
819 if [ "$f" != "unknown" ]; then
820 "$TMP/tar-$BINARCH" -xf "$archive" -C "$TMP" "$f" && install_extracted "$f"
828 if [ -z "$2" ]; then # no arch given
833 if exists_in_zip "$1-$apparch.*"; then # add the . to make sure it is not a substring being matched
836 get_fallback_arch "$apparch"
837 if [ "$apparch" != "$fallback_arch" ]; then
838 get_apparch "$1" "$fallback_arch"
841 apparch="" # No arch-specific package
849 if get_apparch "$1"; then
850 apparchives="$1-$apparch"
852 if exists_in_zip "$1-common.*"; then
853 apparchives="$1-common $apparchives"
855 if exists_in_zip "$1-lib-$arch.*"; then
856 apparchives="$1-lib-$arch $apparchives"
858 if [ -n "$fbarch" ] && exists_in_zip "$1-lib-$fbarch.*"; then
859 apparchives="$1-lib-$fbarch $apparchives"
864 app_name="$(basename "$1")"
865 which_dpi "$app_name"
866 app_density="$(basename "$dpiapkpath")"
868 true*) odexsize="|odex";;
871 appsize="$(cat $TMP/app_sizes.txt | grep -E "$app_name.*[[:blank:]]($app_density|common$odexsize)[[:blank:]]" | awk 'BEGIN { app_size=0; } { folder_size=$3; app_size=app_size+folder_size; } END { printf app_size; }')"
876 arm) fallback_arch="all";;
877 arm64) fallback_arch="arm";;
878 x86) fallback_arch="arm";; #by using libhoudini
879 x86_64) fallback_arch="x86";; #e.g. chain: x86_64->x86->arm->all
880 *) fallback_arch="$1";; #return original arch if no fallback available
885 grep -m1 "^$2=" "$1" | cut -d= -f2
889 #check known .prop files using get_file_prop
890 for f in $PROPFILES; do
892 prop="$(get_file_prop "$f" "$1")"
893 if [ -n "$prop" ]; then
894 break #if an entry has been found, break out of the loop
898 #if prop is still empty; try to use recovery's built-in getprop method; otherwise output current result
899 if [ -z "$prop" ]; then
900 getprop "$1" | cut -c1-
906 install_extracted() {
907 file_list="$(find "$TMP/$1/" -mindepth 1 -type f | cut -d/ -f5-)"
908 dir_list="$(find "$TMP/$1/" -mindepth 1 -type d | cut -d/ -f5-)"
909 for file in $file_list; do
910 install -D "$TMP/$1/${file}" "/system/${file}"
911 ch_con "/system/${file}"
912 set_perm 0 0 644 "/system/${file}";
914 for dir in $dir_list; do
915 ch_con "/system/${dir}"
916 set_perm 0 0 755 "/system/${dir}";
920 installedapkpaths="$(find "$TMP/$1/" -name "*.apk" -type f | cut -d/ -f5-)"
921 for installedapkpath in $installedapkpaths; do # TODO fix spaces-handling
922 if ! checkmanifest "/system/$installedapkpath" "classes.dex"; then
923 ui_print "- pre-ODEX-ing $gapp_name";
924 log "pre-ODEX-ing" "$gapp_name";
925 odexapk "/system/$installedapkpath"
930 bkup_list=$'\n'"${file_list}${bkup_list}"
935 printf "%31s | %s\n" "$1" "$2" >> $g_log;
939 printf "%7s | %26s | + %7d | %7d\n" "$1" "$2" "$3" "$4">> $calc_log;
943 printf "%7s | %26s | - %7d | %7d\n" "$1" "$2" "$3" "$4">> $calc_log;
946 obsolete_gapps_list() {
953 if [ -f "$1" ]; then # strict, only files
954 apkdir="$(dirname "$1")"
955 apkname="$(basename "$1" ".apk")" # Take note not to use -s, it is not supported in busybox
956 install -d "$TMP/classesdex"
957 "$TMP/unzip-$BINARCH" -q -o "$1" "classes*.dex" -d "$TMP/classesdex/" # extract to temporary location first, to avoid potential disk space shortage
958 eval '$TMP/zip-$BINARCH -d "$1" "classes*.dex"'
959 cp "$TMP/classesdex/"* "$apkdir"
960 rm -rf "$TMP/classesdex/"
961 dexfiles="$(find "$apkdir" -name "classes*.dex")"
962 if [ -n "$dexfiles" ]; then
963 dex="LD_LIBRARY_PATH='/system/lib:/system/lib64' /system/bin/dex2oat"
964 for d in $dexfiles; do
965 dex="$dex --dex-file=\"$d\""
966 bkup_list=$'\n'"${d#\/system\/}${bkup_list}" # Backup the dex for re-generating oat in the future
968 dex="install -d \"$apkdir/oat/$req_android_arch\" && $dex --instruction-set=\"$req_android_arch\" --oat-file=\"$apkdir/oat/$req_android_arch/$apkname.odex\""
970 # Add the dex2oat command to addon.d for re-running during a restore
971 sed -i "\:# Re-pre-ODEX APKs (from GApps Installer):a \ $dex" $bkup_tail
978 install_note=$(echo "${install_note}" | sort -r | sed '/^$/d'); # sort Installation Notes & remove empty lines
979 echo ------------------------------------------------------------------ >> $g_log;
980 echo -e "$log_close" >> $g_log;
982 # Add Installation Notes to log to help user better understand conflicts/errors
983 for note in $install_note; do
984 eval "error_msg=\$${note}";
985 echo -e "$error_msg" >> $g_log;
988 # Add User App Removals NotFound Log if it exists
989 if [ -r $user_remove_notfound_log ]; then
990 echo -e "$user_notfound_msg" >> $g_log;
991 echo "# Begin User App Removals NOT Found (from gapps-config)" >> $g_log;
992 cat $user_remove_notfound_log >> $g_log;
993 rm -f $user_remove_notfound_log;
994 echo -e "# End User App Removals NOT Found (from gapps-config)\n" >> $g_log;
996 # Add User App Removals MultipleFound Log if it exists
997 if [ -r $user_remove_multiplefound_log ]; then
998 echo -e "$user_multiplefound_msg" >> $g_log;
999 echo "# Begin User App Removals MULTIPLE Found (from gapps-config)" >> $g_log;
1000 cat $user_remove_multiplefound_log >> $g_log;
1001 rm -f $user_remove_multiplefound_log;
1002 echo -e "# End User App Removals MULTIPLE Found (from gapps-config)\n" >> $g_log;
1005 # Add Duplicate Files Log if it exists
1006 if [ -r $conflicts_log ]; then
1007 echo -e "$del_conflict_msg" >> $g_log;
1008 echo "# Begin GApps <> ROM Duplicate File List" >> $g_log;
1009 cat $conflicts_log >> $g_log;
1010 rm -f $conflicts_log;
1011 echo -e "# End GApps <> ROM Duplicate File List\n" >> $g_log;
1014 # Add Installation Calculations to the log if they were performed
1015 if [ -r $calc_log ]; then
1016 echo "# Begin GApps Size Calculations" >> $g_log;
1017 cat $calc_log >> $g_log;
1019 echo -e "\n# End GApps Size Calculations" >> $g_log;
1022 # Add list of Raw User Application Removals back to end of processed gapps-config for display in gapps log
1023 if [ -n "$user_remove_list" ]; then
1024 for user_remove_app_raw in $user_remove_list; do
1025 echo "(${user_remove_app_raw})" >> "$g_conf";
1030 # Add gapps-config information to the log
1031 echo -e "\n# Begin User's gapps-config" >> $g_log;
1032 if [ "$g_conf" ]; then
1033 cat "$g_conf" >> $g_log;
1035 echo -n " *** NOT USED ***" >> $g_log;
1037 echo -e "\n# End User's gapps-config" >> $g_log;
1039 # Copy logs to proper folder (Same as gapps-config or same as Zip)
1040 ui_print "- Copying Log to $log_folder";
1042 cp -f $g_log "$log_folder/open_gapps_log.txt";
1052 set_progress() { echo "set_progress $1" > "$OUTFD"; }
1055 if ( grep -q "codePath=\"/system/app/$1" /data/system/packages.xml ); then
1062 echo "ui_print $1" > "$OUTFD";
1063 echo "ui_print" > "$OUTFD";
1067 # Calculate available densities
1069 app_densities="$(cat $TMP/app_densities.txt | grep -E "$1/([0-9-]+|nodpi)/" | sed -r 's#.*/([0-9-]+|nodpi)/.*#\1#' | sort)";
1070 dpiapkpath="unknown"
1071 # Check if in the package there is a version for our density, or a universal one.
1072 for densities in $app_densities; do
1073 case "$densities" in
1074 *"$density"*) dpiapkpath="$1/$densities"; break;;
1075 *nodpi*) dpiapkpath="$1/nodpi"; break;;
1078 # Check if density is unknown or set to nopdi and there is not a universal package and select the package with higher density.
1079 if { [ "$density" = "unknown" ] || [ "$density" = "nopdi" ]; } && [ "$dpiapkpath" = "unknown" ] && [ -n "$app_densities" ]; then
1080 app_densities="$(echo "$app_densities" | sort -r)"
1081 for densities in $app_densities; do
1082 dpiapkpath="$1/$densities";
1086 # If there is no package for our density nor a universal one, we will look for the one with closer, but higher density.
1087 if [ "$dpiapkpath" = "unknown" ] && [ -n "$app_densities" ]; then
1088 app_densities="$(echo "$app_densities" | sort)"
1089 for densities in $app_densities; do
1090 all_densities="$(echo "$densities" | sed 's/-/ /g' | tr ' ' '\n' | sort | tr '\n' ' ')";
1091 for d in $all_densities; do
1092 if [ "$d" -ge "$density" ]; then
1093 dpiapkpath="$1/$densities";
1099 # If there is no package for our density nor a universal one or one for higher density, we will use the one with closer, but lower density.
1100 if [ "$dpiapkpath" = "unknown" ] && [ -n "$app_densities" ]; then
1101 app_densities="$(echo "$app_densities" | sort -r)"
1102 for densities in $app_densities; do
1103 all_densities="$(echo "$densities" | sed 's/-/ /g' | tr ' ' '\n' | sort -r | tr '\n' ' ')";
1104 for d in $all_densities; do
1105 if [ "$d" -le "$density" ]; then
1106 dpiapkpath="$1/$densities";
1113 # _____________________________________________________________________________________________________________________
1114 # Gather Pre-Install Info
1115 # Are we on an Android device is or is a really stupid person running this script on their computer?
1116 if [ -e "/etc/lsb-release" ] || [ -n "$OSTYPE" ]; then
1117 echo "Don't run this on your computer! You need to flash the Open GApps zip on an Android Recovery!"
1120 # Get GApps Version and GApps Type from g.prop extracted at top of script
1121 gapps_version=$(get_file_prop "$TMP/g.prop" "ro.addon.open_version")
1122 gapps_type=$(get_file_prop "$TMP/g.prop" "ro.addon.open_type")
1123 # _____________________________________________________________________________________________________________________
1124 # Begin GApps Installation
1126 ui_print '##############################';
1127 ui_print ' _____ _____ ___ ____ ';
1128 ui_print ' / _ \ | __ \ / _ \ | _ \ ';
1129 ui_print '| / \ || |__) | |_| || | \ \';
1130 ui_print '| | | || ___/| __/ | | | |';
1131 ui_print '| \ / || | \ |__ | | | |';
1132 ui_print ' \_/ \_/ |_| \___| |_| |_|';
1133 ui_print ' ___ _ ___ ___ ___ ';
1134 ui_print ' / __| /_\ | _ \ _ \/ __|';
1135 ui_print ' | (_ |/ _ \| _/ _/\__ \';
1136 ui_print ' \___/_/ \_\_| |_| |___/';
1137 ui_print '##############################';
1139 ui_print "$installer_name$gapps_version";
1142 for p in "/cache" "/data" "/persist" "/system" "/vendor"; do
1143 if [ -d "$p" ] && grep -q "$p" "/etc/fstab" && ! mountpoint -q "$p"; then
1147 ui_print "- Mounting $mounts";
1150 for m in $mounts; do
1153 grep -q "/system.*\sro[\s,]" /proc/mounts && mount -o remount,rw /system # remount /system, sometimes necessary if mounted read-only
1155 # _____________________________________________________________________________________________________________________
1156 # Gather Device & GApps Package Information
1157 if [ -z "$(get_prop "ro.build.id")" ]; then
1158 ui_print "*** No ro.build.id ***"
1160 ui_print "Your ROM has no valid build.prop or equivalent"
1162 ui_print "******* GApps Installation failed *******"
1164 install_note="${install_note}nobuildprop"$'\n'
1165 abort "$E_NOBUILDPROP"
1168 testcomprfile="$(find /system -maxdepth 1 -type f | head -n 1)" #often this should return the build.prop, but it can be any file for this test
1169 # Check if $testcomprfile if it is exists is not compressed and thus unprocessable
1170 if [ -e "$testcomprfile" ] && [ "$(head -c 4 "$testcomprfile")" = "zzzz" ]; then
1171 ui_print "*** Recovery does not support transparent compression ***"
1173 ui_print "Your ROM uses transparent compression, but your recovery"
1174 ui_print "does not support this feature, resulting in corrupt files."
1176 ui_print "BEFORE INSTALLING ANYTHING ANYMORE YOU SHOULD UPDATE YOUR"
1177 ui_print "RECOVERY AS SOON AS POSSIBLE, TO PREVENT FILE CORRUPTION."
1179 ui_print "******* GApps Installation failed *******"
1181 install_note="${install_note}recovery_compression_msg"$'\n'
1185 # Get device name any which way we can
1186 for field in ro.product.device ro.build.product ro.product.name; do
1187 device_name="$(get_prop "$field")"
1188 if [ "${#device_name}" -ge "2" ]; then
1191 device_name="Bad ROM/Recovery"
1194 # Locate gapps-config (if used)
1195 for i in "$TMP/aroma/.gapps-config"\
1196 "$zip_folder/.gapps-config-$device_name"\
1197 "$zip_folder/gapps-config-$device_name.txt"\
1198 "/sdcard/Open-GApps/.gapps-config-$device_name"\
1199 "/sdcard/Open-GApps/gapps-config-$device_name.txt"\
1200 "$zip_folder/.gapps-config"\
1201 "$zip_folder/gapps-config.txt"\
1202 "/sdcard/Open-GApps/.gapps-config"\
1203 "/sdcard/Open-GApps/gapps-config.txt"\
1204 "$zip_folder/.gapps-config-$device_name.txt"\
1205 "/sdcard/Open-GApps/.gapps-config-$device_name.txt"\
1206 "$zip_folder/.gapps-config.txt"\
1207 "/sdcard/Open-GApps/.gapps-config.txt"\
1208 "/persist/.gapps-config-$device_name"\
1209 "/persist/gapps-config-$device_name.txt"\
1210 "/persist/.gapps-config"\
1211 "/persist/gapps-config.txt"\
1212 "/persist/.gapps-config-$device_name.txt"\
1213 "/persist/.gapps-config.txt"\
1214 "/tmp/install/gapps-config.txt"\
1215 "/tmp/install/.gapps-config-$device_name.txt"\
1216 "/tmp/install/.gapps-config.txt"; do
1217 if [ -r "$i" ]; then
1223 # We log in the same directory as the gapps-config file, unless it is aroma
1224 if [ -n "$g_conf" ] && [ "$g_conf" != "$TMP/aroma/.gapps-config" ]; then
1225 log_folder="$(dirname "$g_conf")";
1227 log_folder="$zip_folder";
1230 if [ "$g_conf" ]; then
1231 config_file="$g_conf";
1232 g_conf_orig="$g_conf";
1233 g_conf="$TMP/proc_gconf";
1235 sed -r -e 's/\r//g' -e 's|#.*||g' -e 's/^[ \t ]*//g' -e 's/[ \t ]*$//g' -e '/^$/d' "$g_conf_orig" > "$g_conf"; # UNIX line-endings, strip comments+emptylines+spaces+tabs
1237 # include mentioned as a *whole word* (surrounded by space/tabs or start/end or directly followed by a comment) and is itself NOT a comment (should not be possible because of sed above)
1238 if ( grep -qiE '^([^#]*[[:blank:]]+)?include($|#|[[:blank:]])' "$g_conf" ); then
1239 config_type="include"
1241 config_type="exclude"
1243 sed -i -r -e 's/\<(in|ex)clude\>//gI' "$g_conf" # drop in/exclude from the config
1245 user_remove_list=$(awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' "$g_conf"); # Get users list of apk's to remove from gapps-config
1246 sed -i -e s/'([^)]*)'/''/g -e '/^$/d' "$g_conf"; # Remove all instances of user app removals (stuff between parentheses) and empty lines we might have created
1248 config_file="Not Used";
1249 g_conf="$TMP/proc_gconf";
1253 # Unless this is a NoDebug install - create folder and take 'Before' snapshots
1254 if ( ! grep -qiE '^nodebug$' "$g_conf" ); then
1255 install -d $TMP/logs;
1256 ls -alZR /system > $TMP/logs/System_Files_Before.txt;
1257 df -k > $TMP/logs/Device_Space_Before.txt;
1260 # Get ROM Android version
1261 ui_print "- Gathering device & ROM information"
1264 # Get ROM SDK version
1265 rom_build_sdk="$(get_prop "ro.build.version.sdk")"
1268 if echo "$(get_prop "ro.build.characteristics")" | grep -qi "tablet"; then
1270 elif echo "$(get_prop "ro.build.characteristics")" | grep -qi "tv"; then
1272 core_gapps_list="$tvcore_gapps_list" # use the TV core apps instead of the regular core apps
1277 echo "# Begin Open GApps Install Log" > $g_log;
1278 echo ------------------------------------------------------------------ >> $g_log;
1280 # Check to make certain user has proper version ROM Installed
1281 if [ ! "$rom_build_sdk" = "$req_android_sdk" ]; then
1282 ui_print "*** Incompatible Android ROM detected ***";
1284 ui_print "This GApps pkg is for Android $req_android_version.x ONLY";
1285 ui_print "Please download the correct version for"
1286 ui_print "your ROM: $(get_prop "ro.build.version.release") (SDK $rom_build_sdk)"
1288 ui_print "******* GApps Installation failed *******";
1290 install_note="${install_note}rom_android_version_msg"$'\n'; # make note that ROM Version is not compatible with these GApps
1294 # Check to make certain that user device matches the architecture
1295 device_architecture="$(get_prop "ro.product.cpu.abilist")"
1296 # If the recommended field is empty, fall back to the deprecated one
1297 if [ -z "$device_architecture" ]; then
1298 device_architecture="$(get_prop "ro.product.cpu.abi")"
1301 case "$device_architecture" in
1302 *x86_64*) arch="x86_64"; libfolder="lib64";;
1303 *x86*) arch="x86"; libfolder="lib";;
1304 *arm64*) arch="arm64"; libfolder="lib64";;
1305 *armeabi*) arch="arm"; libfolder="lib";;
1310 echo "for targetarch in $ARCH abort; do" >> "$build/$1" # we add abort as latest entry to detect if there is no match
1311 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
1312 if [ "$arch" = "$targetarch" ]; then
1313 if [ "$libfolder" = "lib64" ]; then #on 64bit we also need to install 32 bit libs from the fbarch
1314 get_fallback_arch "$arch"
1315 fbarch="$fallback_arch"
1320 elif [ "abort" = "$targetarch" ]; then
1321 ui_print "***** Incompatible Device Detected *****"
1323 ui_print "This Open GApps package cannot be"
1324 ui_print "installed on this device's architecture."
1325 ui_print "Please download the correct version for"
1326 ui_print "your device: $arch"
1328 ui_print "******* GApps Installation failed *******"
1330 install_note="${install_note}arch_compat_msg"$'\n' # make note that Open GApps are not compatible with architecture
1335 # Determine Recovery Type and Version
1336 for rec_log in $rec_tmp_log $rec_cache_log; do
1337 recovery=$(grep -m 2 -E " Recovery v|Starting TWRP|Welcome to|PhilZ|Starting recovery \(" $rec_log);
1339 *Welcome*) recovery="$(grep -m 1 "Welcome to" $rec_log | awk '{ print substr($0, index($0,$3)) }')$(grep -m 1 "^ext.version" $rec_log | cut -d\" -f2)"; break;;
1340 *Recovery*) recovery=$(grep -m 1 "Recovery v" $rec_log); recovery=${recovery/Recovery v/Recovery }; break;;
1341 *PhilZ*) recovery=$(grep -m 2 -E "PhilZ|ClockworkMod" $rec_log); recovery="${recovery/ClockworkMod v/(ClockworkMod })"; break;;
1342 *Starting\ recovery\ \(*) recovery=$(grep -m 1 "ro.cm.version=" $rec_log| sed -e 's/.*ro.cm.version=/CM Recovery /gI'); break;;
1343 Starting*) recovery=$(echo "$recovery" | awk -F"Starting " '{ print $2 }' | awk -F" on " '{ print $1 }'); break;;
1348 device_model="$(get_prop "ro.product.model")"
1350 # Get display density
1351 density="$(get_prop "ro.sf.lcd_density")"
1353 # Check for DPI Override in gapps-config
1354 if ( grep -qiE '^forcedpi(120|160|213|240|260|280|300|320|340|360|400|420|480|560|640|nodpi)$' "$g_conf" ); then # user wants to override the DPI selection
1355 density=$( grep -iEo '^forcedpi(120|160|213|240|260|280|300|320|340|360|400|420|480|560|640|nodpi)$' "$g_conf" | tr '[:upper:]' '[:lower:]' )
1356 density=${density#forcedpi}
1359 # Set density to unknown if it's still empty
1360 test -z "$density" && density="unknown"
1362 # Check for Camera API v2 availability
1363 cameraapi="$(get_prop "camera2.portability.force_api")"
1364 camerahal="$(get_prop "persist.camera.HAL3.enabled")"
1365 if ( grep -qiE '^forcenewcamera$' "$g_conf" ); then # takes precedence over any detection
1366 newcamera_compat="true[forcenewcamera]"
1368 if [ -n "$cameraapi" ]; then # we check first for the existence of this key, it takes precedence if set to any value
1369 if [ "$cameraapi" -ge "2" ]; then
1370 newcamera_compat="true[force_api]"
1372 newcamera_compat="false[force_api]"
1374 elif [ -n "$camerahal" ] && [ "$camerahal" -ge "1" ]; then
1375 newcamera_compat="true"
1377 # If not explictly defined, check whitelist
1378 case $device_name in
1379 ryu|angler|bullhead|shamu|volantis*|flounder*|hammerhead*|sprout*) newcamera_compat="true[whitelist]";;
1380 *) newcamera_compat="false";;
1385 cmcompatibilityhacks="false" # test for CM/Lineage since they do weird AOSP-breaking changes to their code, breaking some GApps
1386 case "$(get_prop "ro.build.flavor")" in
1387 cm_*|lineage_*) cmcompatibilityhacks="true"; if [ "$rom_build_sdk" -ge "24" ]; then aosp_remove_list="${aosp_remove_list}cmsetupwizard"$'\n';fi;; # CMSetupWizard is broken in LineageOS 14+ and can be safely removed on CM14+ as well
1390 # Check for Clean Override in gapps-config
1391 if ( grep -qiE '^forceclean$' "$g_conf" ); then
1397 # Check for Pre-Odex support or NoPreODEX Override in gapps-config
1398 if [ "$rom_build_sdk" -lt "23" ]; then
1399 preodex="false [Only 6.0+]"
1400 elif [ "$(get_prop "persist.sys.dalvik.vm.lib.2")" != "libart.so" ] && [ "$(get_prop "persist.sys.dalvik.vm.lib.2")" != "libart" ]; then
1401 preodex="false [No ART]"
1402 elif ! command -v "$TMP/zip-$BINARCH" >/dev/null 2>&1; then
1403 preodex="false [No Info-Zip]"
1404 elif ! command -v "dex2oat" >/dev/null 2>&1; then
1405 preodex="false [No dex2oat]"
1406 elif ( grep -qiE '^nopreodex$' "$g_conf" ); then
1407 preodex="false [nopreodex]"
1408 elif ( grep -qiE '^preodex$' "$g_conf" ); then
1409 preodex="true [preodex]"
1411 preodex="false" #temporarily changed to false by default until we sort the issues out
1414 # Check for skipswypelibs in gapps-config
1415 if ( grep -qiE '^skipswypelibs$' $g_conf ); then
1416 skipswypelibs="true"
1418 skipswypelibs="false"
1421 # Check for substituteswypelibs in gapps-config
1422 if ( grep -qiE '^substituteswypelibs$' $g_conf ); then
1423 substituteswypelibs="true"
1425 substituteswypelibs="false"
1428 # Check for skipvendorlibs in gapps-config
1429 if ( grep -qiE '^skipvendorlibs$' $g_conf ); then
1430 skipvendorlibs="true"
1431 mount -t tmpfs tmpfs /system/vendor # by mounting a tmpfs on this location, we hide the existing files from any operations
1433 skipvendorlibs="false"
1436 # Remove any files from gapps-remove.txt that should not be processed for automatic removal
1437 for bypass_file in $removal_bypass_list; do
1438 sed -i "\:${bypass_file}:d" $gapps_removal_list
1441 # Is this a 'Clean' or 'Dirty' install
1442 if ( clean_inst ); then
1443 install_type="Clean[Data Wiped]"
1444 cameragoogle_inst=Clean
1446 install_type="Dirty[Data NOT Wiped]"
1448 # Was Google Camera previously installed (in /system)
1449 if ( sys_app GoogleCamera ); then
1450 cameragoogle_inst=true
1452 cameragoogle_inst=false
1456 # Is device FaceUnlock compatible
1457 if ( ! grep -qE "Victory|herring|sun4i" /proc/cpuinfo ); then
1458 for xml in /system/etc/permissions/android.hardware.camera.front.xml /system/etc/permissions/android.hardware.camera.xml; do
1459 if ( awk -vRS='-->' '{ gsub(/<!--.*/,"")}1' $xml | grep -q "feature name=\"android.hardware.camera.front" ); then
1460 faceunlock_compat=true
1463 faceunlock_compat=false
1466 faceunlock_compat=false
1469 # Is device VRMode compatible
1470 for xml in $(grep -rl 'name="android.software.vr.mode"' /system/etc/); do
1471 if ( awk -vRS='-->' '{ gsub(/<!--.*/,"")}1' $xml | grep -q 'name="android.software.vr.mode"' /system/etc/ ); then
1478 # Check device name for devices that are incompatible with Google Camera
1479 case $device_name in
1481 cameracompatibilityhack
"$build/$1" #in kitkat we don't have google camera compatibility with some phones
1482 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
1483 *) cameragoogle_compat=true;;
1486 # Check if Google Pixel
1487 case $device_name in
1488 marlin|sailfish) googlepixel_compat="true";;
1489 *) googlepixel_compat="false";;
1492 log "ROM Android version" "$(get_prop "ro.build.version.release")"
1493 log "ROM Build ID" "$(get_prop "ro.build.display.id")"
1494 log "ROM Version increment" "$(get_prop "ro.build.version.incremental")"
1495 log "ROM SDK version" "$rom_build_sdk"
1496 log "ROM/Recovery modversion" "$(get_prop "ro.modversion")"
1497 log "Device Recovery" "$recovery"
1498 log "Device Name" "$device_name"
1499 log "Device Model" "$device_model"
1500 log "Device Type" "$device_type"
1501 log "Device CPU" "$device_architecture"
1502 log "Installer Platform" "$BINARCH"
1503 log "ROM Platform" "$arch"
1504 log "Display Density Used" "$density"
1505 log "Install Type" "$install_type"
1506 log "Smart ART Pre-ODEX" "$preodex"
1507 log "Google Camera already installed" "$cameragoogle_inst"
1508 log "FaceUnlock Compatible" "$faceunlock_compat"
1509 log "VRMode Compatible" "$vrmode_compat"
1510 log "Google Camera Compatible" "$cameragoogle_compat"
1511 log "New Camera API Compatible" "$newcamera_compat"
1512 log "Google Pixel Features" "$googlepixel_compat"
1514 # Determine if a GApps package is installed and
1515 # the version, type, and whether it's an Open GApps package
1516 if [ -e "/system/priv-app/GoogleServicesFramework/GoogleServicesFramework.apk" ] || [ -e "/system/priv-app/GoogleServicesFramework.apk" ]; then
1517 openversion="$(get_prop "ro.addon.open_version")"
1518 if [ -n "$openversion" ]; then
1519 log "Current GApps Version" "$openversion"
1520 opentype="$(get_prop "ro.addon.open_type")"
1521 if [ -z "$opentype" ]; then
1524 log "Current Open GApps Package" "$opentype"
1525 elif [ -e "/system/etc/g.prop" ]; then
1526 log "Current GApps Version" "NON Open GApps Package Currently Installed (FAILURE)"
1527 ui_print "* Incompatible GApps Currently Installed *"
1529 ui_print "This Open GApps package can ONLY be installed"
1530 ui_print "on top of an existing installation of Open GApps"
1531 ui_print "or a clean AOSP/CyanogenMod ROM installation,"
1532 ui_print "or a Stock ROM that conforms to Nexus standards."
1533 ui_print "You must wipe (format) your system partition"
1534 ui_print "and flash your ROM BEFORE installing Open GApps."
1536 ui_print "******* GApps Installation failed *******"
1538 install_note="${install_note}non_open_gapps_msg"$'\n'
1541 log "Current GApps Version" "Stock ROM GApps Currently Installed (NOTICE)"
1542 ui_print "* Stock ROM GApps Currently Installed *"
1544 ui_print "The installer detected that Stock ROM GApps are"
1545 ui_print "already installed. If you are flashing over a"
1546 ui_print "Nexus-compatible ROM there is no problem, but if"
1547 ui_print "you are flashing over a custom ROM, you may want"
1548 ui_print "to contact the developer to request the removal of"
1549 ui_print "the included GApps. The installation will now"
1550 ui_print "continue, but please be aware that any problems"
1551 ui_print "that may occur depend on your ROM."
1553 install_note="${install_note}fornexus_open_gapps_msg"$'\n'
1556 # User does NOT have a GApps package installed on their device
1557 log "Current GApps Version" "No GApps Installed"
1559 # Did this 6.0+ system already boot and generated runtime permissions
1560 if [ -e /data/system/users/0/runtime-permissions.xml ]; then
1561 # Check if permissions were granted to Google Setupwizard, this permissions should always be set in the file if GApps were installed before
1562 if ! grep -q "com.google.android.setupwizard" /data/system/users/*/runtime-permissions.xml; then
1563 # Purge the runtime permissions to prevent issues if flashing GApps for the first time on a dirty install
1564 rm -f /data/system/users/*/runtime-permissions.xml
1565 log "Runtime Permissions" "Reset"
1569 # Use the opportunity of No GApps installed to check for potential ROM conflicts when deleting existing GApps files
1570 while read gapps_file; do
1571 if [ -e "$gapps_file" ] && [ "$gapps_file" != "/system/lib/$WebView_lib_filename" ] && [ "$gapps_file" != "/system/lib64/$WebView_lib_filename" ]; then
1572 echo "$gapps_file" >> $conflicts_log
1574 done < $gapps_removal_list
1576 # _____________________________________________________________________________________________________________________
1577 # Prepare the list of GApps being installed and AOSP/Stock apps being removed
1578 # Build list of available GApps that can be installed (and check for a user package preset)
1579 for pkg in $pkg_names; do
1580 eval "addto=\$${pkg}_gapps_list"; # Look for method to combine this with line below
1581 all_gapps_list=${all_gapps_list}${addto}; # Look for method to combine this with line above
1582 if ( grep -qiE "^${pkg}gapps\$" "$g_conf" ); then # user has selected a 'preset' install
1584 sed -i "/ro.addon.open_type/c\ro.addon.open_type=$pkg" "$TMP/g.prop"; # modify g.prop to new package type
1589 # Prepare list of User specified GApps that will be installed
1590 if [ "$g_conf" ]; then
1591 if [ "$config_type" = "include" ]; then # User is indicating the apps they WANT installed
1592 for gapp_name in $all_gapps_list; do
1593 if ( grep -qiE "^$gapp_name\$" "$g_conf" ); then
1594 gapps_list="$gapps_list$gapp_name"$'\n';
1597 else # User is indicating the apps they DO NOT WANT installed
1598 for gapp_name in $all_gapps_list; do
1599 if ( ! grep -qiE "^$gapp_name\$" "$g_conf" ); then
1600 gapps_list="$gapps_list$gapp_name"$'\n';
1604 else # User is not using a gapps-config and we're doing the 'full monty'
1605 config_type="[Default]";
1606 gapps_list=$all_gapps_list;
1609 # Configure default removal of Stock/AOSP apps - if we're installing Stock GApps or larger
1610 if [ "$gapps_type" = "super" ] || [ "$gapps_type" = "stock" ] || [ "$gapps_type" = "aroma" ]; then
1611 for default_name in $default_stock_remove_list; do
1612 eval "remove_${default_name}=true[default]";
1615 # Do not perform any default removals - but make them optional
1616 for default_name in $default_stock_remove_list; do
1617 eval "remove_${default_name}=false[default]";
1621 # Prepare list of AOSP/ROM files that will be deleted using gapps-config
1622 # We will look for +Browser, +CameraStock, +Email, +Gallery, +Launcher, +MMS, +PicoTTS and more to prevent their removal
1624 if [ "$g_conf" ]; then
1625 for default_name in $default_stock_remove_list; do
1626 if ( grep -qiE "^\+$default_name\$" "$g_conf" ); then
1627 eval "remove_${default_name}=false[gapps-config]";
1628 elif [ "$gapps_type" = "super" ] || [ "$gapps_type" = "stock" ] || [ "$gapps_type" = "aroma" ]; then
1629 aosp_remove_list="$aosp_remove_list$default_name"$'\n';
1630 if ( grep -qiE "^$default_name\$" "$g_conf" ); then
1631 eval "remove_${default_name}=true[gapps-config]";
1634 if ( grep -qiE "^$default_name\$" "$g_conf" ); then
1635 eval "remove_${default_name}=true[gapps-config]";
1636 aosp_remove_list="$aosp_remove_list$default_name"$'\n';
1640 # Check gapps-config for other optional AOSP/ROM files that will be deleted
1641 for opt_name in $optional_aosp_remove_list; do
1642 if ( grep -qiE "^$opt_name\$" "$g_conf" ); then
1643 aosp_remove_list="$aosp_remove_list$opt_name"$'\n';
1647 if [ "$gapps_type" = "super" ] || [ "$gapps_type" = "stock" ] || [ "$gapps_type" = "aroma" ]; then
1648 aosp_remove_list=$default_stock_remove_list;
1652 # Provision folder always has to be removed (it conflicts with SetupWizard)
1653 aosp_remove_list="${aosp_remove_list}provision"$'\n';
1654 # Remove AOSP Android Shared Services in favour of our Google versions of it
1655 aosp_remove_list="${aosp_remove_list}extsharedstock"$'\n'"extservicesstock"$'\n';
1658 hotwordadditionhack
"$build/$1" # HotwordEnrollment to support OK Google device-wide (requires compatible hardware)
1659 webviewcheckhack
"$build/$1" # WebViewProvider rules differ Pre-Nougat and Nougat+
1660 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
1661 # Cyanogenmod breaks Google's PackageInstaller don't install it on CM
1662 if ( contains "$gapps_list" "packageinstallergoogle" ) && [ $cmcompatibilityhacks = "true" ]; then
1663 gapps_list=${gapps_list/packageinstallergoogle};
1664 install_note="${install_note}cmcompatibility_msg"$'\n'; # make note that CM compatibility hacks are applied
1667 # Verify device is FaceUnlock compatible BEFORE we allow it in $gapps_list
1668 if ( contains "$gapps_list" "faceunlock" ) && [ $faceunlock_compat = "false" ]; then
1669 gapps_list=${gapps_list/faceunlock};
1670 install_note="${install_note}faceunlock_msg"$'\n'; # make note that FaceUnlock will NOT be installed as user requested
1673 # Add Google Pixel config if this is a Pixel device (and remove if it is not)
1674 if ( ! contains "$gapps_list" "googlepixelconfig" ) && [ $googlepixel_compat = "true" ]; then
1675 gapps_list="${gapps_list}googlepixelconfig"$'\n'
1677 if ( contains "$gapps_list" "googlepixelconfig" ) && [ $googlepixel_compat = "false" ]; then
1678 gapps_list=${gapps_list/googlepixelconfig};
1681 # If we're NOT installing chrome make certain 'browser' is NOT in $aosp_remove_list UNLESS 'browser' is in $g_conf
1682 if ( ! contains "$gapps_list" "chrome" ) && ( ! grep -qiE '^browser$' "$g_conf" ); then
1683 aosp_remove_list=${aosp_remove_list/browser};
1684 remove_browser="false[NO_Chrome]";
1687 # If we're NOT installing gmail make certain 'email' is NOT in $aosp_remove_list UNLESS 'email' is in $g_conf
1688 if ( ! contains "$gapps_list" "gmail" ) && ( ! grep -qiE '^email$' "$g_conf" ); then
1689 aosp_remove_list=${aosp_remove_list/email};
1690 remove_email="false[NO_Gmail]";
1693 # If we're NOT installing photos make certain 'gallery' is NOT in $aosp_remove_list UNLESS 'gallery' is in $g_conf
1694 if ( ! contains "$gapps_list" "photos" ) && ( ! grep -qiE '^gallery$' "$g_conf" ); then
1695 aosp_remove_list=${aosp_remove_list/gallery};
1696 remove_gallery="false[NO_Photos]";
1699 # If $device_type is not a 'phone' make certain we're not installing messenger
1700 if ( contains "$gapps_list" "messenger" ) && [ $device_type != "phone" ]; then
1701 gapps_list=${gapps_list/messenger}; # we'll prevent messenger from being installed since this isn't a phone
1704 # If $device_type is not a 'phone' make certain we're not installing dialerframework (implies no dialergoogle)
1705 if ( contains "$gapps_list" "dialerframework" ) && [ $device_type != "phone" ]; then
1706 gapps_list=${gapps_list/dialerframework}; # we'll prevent dialerframework from being installed since this isn't a phone
1709 # If we're NOT installing dialerframework then we MUST REMOVE dialergoogle from $gapps_list (if it's currently there)
1710 if ( ! contains "$gapps_list" "dialerframework" ) && ( contains "$gapps_list" "dialergoogle" ); then
1711 gapps_list=${gapps_list/dialergoogle};
1712 install_note="${install_note}dialergoogle_msg"$'\n'; # make note that Google Dialer will NOT be installed as user requested
1715 # If we're NOT installing hangouts or messenger make certain 'mms' is NOT in $aosp_remove_list UNLESS 'mms' is in $g_conf
1716 if ( ! contains "$gapps_list" "hangouts" ) && ( ! contains "$gapps_list" "messenger" ) && ( ! grep -qiE '^mms$' "$g_conf" ); then
1717 aosp_remove_list=${aosp_remove_list/mms};
1718 remove_mms="false[NO_Hangouts]";
1721 # If we're NOT installing hangouts or messenger and mms is in $aosp_remove_list then user must override removal protection
1722 if ( ! contains "$gapps_list" "hangouts" ) && ( ! contains "$gapps_list" "messenger" ) && ( contains "$aosp_remove_list" "mms" ) && ( ! grep -qiE '^override$' "$g_conf" ); then
1723 aosp_remove_list=${aosp_remove_list/mms}; # we'll prevent mms from being removed so user isn't left with no way to receive text messages
1724 remove_mms="false[NO_Override]";
1725 install_note="${install_note}nomms_msg"$'\n'; # make note that MMS can't be removed unless user Overrides
1728 # If we're NOT installing googletts make certain 'picotts' is NOT in $aosp_remove_list UNLESS 'picotts' is in $g_conf
1729 if ( ! contains "$gapps_list" "googletts" ) && ( ! grep -qiE '^picotts$' "$g_conf" ); then
1730 aosp_remove_list=${aosp_remove_list/picotts};
1731 remove_picotts="false[NO_GoogleTTS]";
1734 # If we're NOT installing wallpapers then we MUST REMOVE pixellauncher from $gapps_list (if it's currently there)
1735 if ( ! contains "$gapps_list" "wallpapers" ) && ( contains "$gapps_list" "pixellauncher" ); then
1736 gapps_list=${gapps_list/pixellauncher};
1737 install_note="${install_note}pixellauncher_msg"$'\n'; # make note that Google Now Launcher will NOT be installed as user requested
1740 # If we're NOT installing search then we MUST REMOVE pixellauncher from $gapps_list (if it's currently there)
1741 if ( ! contains "$gapps_list" "search" ) && ( contains "$gapps_list" "pixellauncher" ); then
1742 gapps_list=${gapps_list/pixellauncher};
1743 install_note="${install_note}pixellauncher_msg"$'\n'; # make note that Pixel Launcher will NOT be installed as user requested
1746 # If we're NOT installing search then we MUST REMOVE googlenow from $gapps_list (if it's currently there)
1747 if ( ! contains "$gapps_list" "search" ) && ( contains "$gapps_list" "googlenow" ); then
1748 gapps_list=${gapps_list/googlenow};
1749 install_note="${install_note}googlenow_msg"$'\n'; # make note that Google Now Launcher will NOT be installed as user requested
1752 # If we're NOT installing search then we MUST REMOVE pixellauncher from $gapps_list (if it's currently there)
1753 if ( ! contains "$gapps_list" "search" ) && ( contains "$gapps_list" "pixellauncher" ); then
1754 gapps_list=${gapps_list/pixellauncher};
1755 install_note="${install_note}pixellauncher_msg"$'\n'; # make note that Pixel Launcher will NOT be installed as user requested
1758 # If we're NOT installing googlenow or pixellauncher make certain 'launcher' is NOT in $aosp_remove_list UNLESS 'launcher' is in $g_conf
1759 if ( ! contains "$gapps_list" "googlenow" ) && ( ! contains "$gapps_list" "pixellauncher" ) && ( ! grep -qiE '^launcher$' "$g_conf" ); then
1760 aosp_remove_list=${aosp_remove_list/launcher};
1761 remove_launcher="false[NO_GoogleNow/PixelLauncher]";
1764 # If we're NOT installing googlenow or pixellauncher and launcher is in $aosp_remove_list then user must override removal protection
1765 if ( ! contains "$gapps_list" "googlenow" ) && ( ! contains "$gapps_list" "pixellauncher" ) && ( contains "$aosp_remove_list" "launcher" ) && ( ! grep -qiE '^override$' "$g_conf" ); then
1766 aosp_remove_list=${aosp_remove_list/launcher}; # we'll prevent launcher from being removed so user isn't left with no Launcher
1767 remove_launcher="false[NO_Override]";
1768 install_note="${install_note}nolauncher_msg"$'\n'; # make note that Launcher can't be removed unless user Overrides
1771 # If we're installing calendargoogle we must ADD calendarstock to $aosp_remove_list (if it's not already there)
1772 if ( contains "$gapps_list" "calendargoogle" ) && ( ! contains "$aosp_remove_list" "calendarstock" ); then
1773 aosp_remove_list="${aosp_remove_list}calendarstock"$'\n';
1776 # If we're installing calendargoogle we must NOT install calsync
1777 if ( contains "$gapps_list" "calendargoogle" ); then
1778 gapps_list=${gapps_list/calsync};
1781 # If we're installing keyboardgoogle we must ADD keyboardstock to $aosp_remove_list (if it's not already there)
1782 if ( contains "$gapps_list" "keyboardgoogle" ) && ( ! contains "$aosp_remove_list" "keyboardstock" ); then
1783 aosp_remove_list="${aosp_remove_list}keyboardstock"$'\n';
1786 # If we're NOT installing keyboardgoogle and keyboardstock is in $aosp_remove_list then user must override removal protection
1787 if ( ! contains "$gapps_list" "keyboardgoogle" ) && ( contains "$aosp_remove_list" "keyboardstock" ) && ( ! grep -qi "override" "$g_conf" ); then
1788 aosp_remove_list=${aosp_remove_list/keyboardstock}; # we'll prevent keyboardstock from being removed so user isn't left with no keyboard
1789 install_note="${install_note}nokeyboard_msg"$'\n'; # make note that Stock Keyboard can't be removed unless user Overrides
1792 # Verify device is Google Camera compatible BEFORE we allow it in $gapps_list
1793 if ( contains "$gapps_list" "cameragoogle" ) && [ $cameragoogle_compat = "false" ]; then
1794 gapps_list=${gapps_list/cameragoogle}; # we must DISALLOW cameragoogle from being installed
1795 install_note="${install_note}camera_compat_msg"$'\n'; # make note that Google Camera will NOT be installed as user requested
1798 # If user wants to install cameragoogle then it MUST be a Clean Install OR cameragoogle was previously installed in system partition
1799 if ( contains "$gapps_list" "cameragoogle" ) && ( ! clean_inst ) && [ $cameragoogle_inst = "false" ]; then
1800 gapps_list=${gapps_list/cameragoogle}; # we must DISALLOW cameragoogle from being installed
1801 aosp_remove_list=${aosp_remove_list/camerastock}; # and we'll prevent camerastock from being removed so user isn't left with no camera
1802 install_note="${install_note}camera_sys_msg"$'\n'; # make note that Google Camera will NOT be installed as user requested
1805 # If we're NOT installing cameragoogle make certain 'camerastock' is NOT in $aosp_remove_list UNLESS 'camerastock' is in $g_conf
1806 if ( ! contains "$gapps_list" "cameragoogle" ) && ( ! grep -qiE '^camerastock$' "$g_conf" ); then
1807 aosp_remove_list=${aosp_remove_list/camerastock};
1808 remove_camerastock="false[NO_CameraGoogle]";
1811 # Verify device is VRMode compatible, BEFORE we allow vrservice in $gapps_list
1812 if ( contains "$gapps_list" "vrservice" ) && [ "$vrmode_compat" = "true" ]; then
1813 gapps_list=${gapps_list/vrservice}; # we must DISALLOW vrservice from being installed
1814 install_note="${install_note}vrservice_compat_msg"$'\n'; # make note that VRService will NOT be installed as user requested
1817 # If we're installing clockgoogle we must ADD clockstock to $aosp_remove_list (if it's not already there)
1818 if ( contains "$gapps_list" "clockgoogle" ) && ( ! contains "$aosp_remove_list" "clockstock" ); then
1819 aosp_remove_list="${aosp_remove_list}clockstock"$'\n';
1822 # If we're installing exchangegoogle we must ADD exchangestock to $aosp_remove_list (if it's not already there)
1823 if ( contains "$gapps_list" "exchangegoogle" ) && ( ! contains "$aosp_remove_list" "exchangestock" ); then
1824 aosp_remove_list="${aosp_remove_list}exchangestock"$'\n';
1827 # If we're installing printservicegoogle we must ADD printservicestock to $aosp_remove_list (if it's not already there)
1828 if ( contains "$gapps_list" "printservicegoogle" ) && ( ! contains "$aosp_remove_list" "printservicestock" ); then
1829 aosp_remove_list="${aosp_remove_list}printservicestock"$'\n';
1832 # If we're installing storagemanagergoogle we must ADD storagemanagerstock to $aosp_remove_list (if it's not already there)
1833 if ( contains "$gapps_list" "storagemanagergoogle" ) && ( ! contains "$aosp_remove_list" "storagemanagerstock" ); then
1834 aosp_remove_list="${aosp_remove_list}storagemanagerstock"$'\n';
1837 # If we're installing taggoogle we must ADD tagstock to $aosp_remove_list (if it's not already there)
1838 if ( contains "$gapps_list" "taggoogle" ) && ( ! contains "$aosp_remove_list" "tagstock" ); then
1839 aosp_remove_list="${aosp_remove_list}tagstock"$'\n';
1842 # If we're installing calculatorgoogle we MUST ADD calculatorstock to $aosp_remove_list (if it's not already there)
1843 if ( contains "$gapps_list" "calculatorgoogle" ) && ( ! contains "$aosp_remove_list" "calculatorstock" ); then
1844 aosp_remove_list="${aosp_remove_list}calculatorstock"$'\n';
1847 # If we're installing contactsgoogle we MUST ADD contactsstock to $aosp_remove_list (if it's not already there)
1848 if ( contains "$gapps_list" "contactsgoogle" ) && ( ! contains "$aosp_remove_list" "contactsstock" ); then
1849 aosp_remove_list="${aosp_remove_list}contactsstock"$'\n';
1852 # If we're installing dialergoogle we MUST ADD dialerstock to $aosp_remove_list (if it's not already there)
1853 if ( contains "$gapps_list" "dialergoogle" ) && ( ! contains "$aosp_remove_list" "dialerstock" ); then
1854 aosp_remove_list="${aosp_remove_list}dialerstock"$'\n';
1857 # If we're installing packageinstallergoogle we MUST ADD packageinstallerstock to $aosp_remove_list (if it's not already there)
1858 if ( contains "$gapps_list" "packageinstallergoogle" ) && ( ! contains "$aosp_remove_list" "packageinstallerstock" ); then
1859 aosp_remove_list="${aosp_remove_list}packageinstallerstock"$'\n';
1862 # If we're NOT installing gcs then we MUST REMOVE projectfi from $gapps_list (if it's currently there)
1863 if ( ! contains "$gapps_list" "gcs" ) && ( contains "$gapps_list" "projectfi" ); then
1864 gapps_list=${gapps_list/projectfi};
1865 install_note="${install_note}projectfi_msg"$'\n'; # make note that Project Fi will NOT be installed as user requested
1868 # Some ROMs bundle Google Apps or the user might have installed a Google replacement app during an earlier install
1869 # Some of these apps are crucial to a functioning system and should NOT be removed if no AOSP/Stock equivalent is available
1870 # Unless override keyword is used, make sure they are not removed
1871 # NOTICE: Only for Google Keyboard we need to take KitKat support into account, others are only Lollipop+
1872 ignoregooglecontacts="true"
1873 for f in $contactsstock_list; do
1874 if [ -e "/system/$f" ]; then
1875 ignoregooglecontacts="false"
1876 break; #at least 1 aosp stock file is present
1879 if [ "$ignoregooglecontacts" = "true" ]; then
1880 if ( ! contains "$gapps_list" "contactsgoogle" ) && ( ! grep -qiE '^override$' "$g_conf" ); then
1881 sed -i "\:/system/priv-app/GoogleContacts:d" $gapps_removal_list;
1882 ignoregooglecontacts="true[NoRemove]"
1883 install_note="${install_note}nogooglecontacts_removal"$'\n'; # make note that Google Contacts will not be removed
1885 ignoregooglecontacts="false[ContactsGoogle]"
1889 ignoregoogledialer="true"
1890 for f in $dialerstock_list; do
1891 if [ -e "/system/$f" ]; then
1892 ignoregoogledialer="false"
1893 break; #at least 1 aosp stock file is present
1896 if [ "$ignoregoogledialer" = "true" ]; then
1897 if ( ! contains "$gapps_list" "dialergoogle" ) && ( ! grep -qiE '^override$' "$g_conf" ); then
1898 sed -i "\:/system/priv-app/GoogleDialer:d" $gapps_removal_list;
1899 ignoregoogledialer="true[NoRemove]"
1900 install_note="${install_note}nogoogledialer_removal"$'\n'; # make note that Google Dialer will not be removed
1902 ignoregoogledialer="false[DialerGoogle]"
1906 ignoregooglekeyboard="true"
1907 for f in $keyboardstock_list; do
1908 if [ -e "/system/$f" ]; then
1909 ignoregooglekeyboard="false"
1910 break; #at least 1 aosp stock file is present
1913 if [ "$ignoregooglekeyboard" = "true" ]; then
1914 if ( ! contains "$gapps_list" "keyboardgoogle" ) && ( ! grep -qiE '^override$' "$g_conf" ); then
1916 keyboardgooglenotremovehack
"$build/$1"
1917 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
1918 ignoregooglekeyboard="true[NoRemove]"
1919 install_note="${install_note}nogooglekeyboard_removal"$'\n'; # make note that Google Keyboard will not be removed
1921 ignoregooglekeyboard="false[KeyboardGoogle]"
1925 ignoregooglepackageinstaller="true"
1926 for f in $packageinstallerstock_list; do
1927 if [ -e "/system/$f" ]; then
1928 ignoregooglepackageinstaller="false"
1929 break; #at least 1 aosp stock file is present
1932 if [ "$ignoregooglepackageinstaller" = "true" ]; then
1933 if ( ! contains "$gapps_list" "packageinstallergoogle" ) && ( ! grep -qiE '^override$' "$g_conf" ); then
1934 sed -i "\:/system/priv-app/GooglePackageInstaller:d" $gapps_removal_list;
1935 ignoregooglepackageinstaller="true[NoRemove]"
1936 install_note="${install_note}nogooglepackageinstaller_removal"$'\n'; # make note that Google Package Installer will not be removed
1938 ignoregooglepackageinstaller="false[PackageInstallerGoogle]"
1942 ignoregoogletag="true"
1943 for f in $tagstock_list; do
1944 if [ -e "/system/$f" ]; then
1945 ignoregoogletag="false"
1946 break; #at least 1 aosp stock file is present
1949 if [ "$ignoregoogletag" = "true" ]; then
1950 if ( ! contains "$gapps_list" "taggoogle" ) && ( ! grep -qiE '^override$' "$g_conf" ); then
1951 sed -i "\:/system/priv-app/TagGoogle:d" $gapps_removal_list;
1952 ignoregoogletag="true[NoRemove]"
1953 install_note="${install_note}nogoogletag_removal"$'\n'; # make note that Google Tag will not be removed
1955 ignoregoogletag="false[TagGoogle]"
1959 ignoregooglewebview="true"
1960 for f in $webviewstock_list; do
1961 if [ -e "/system/$f" ]; then
1962 ignoregooglewebview="false"
1963 break; #at least 1 aosp stock file is present
1967 webviewignorehack
"$build/$1" # in Nougat Chrome and WebViewStub can also be used as WebViewProvider
1968 camerav3compatibilityhack
"$build/$1" # in Marshmallow we need to use the legacy camera that uses the older api
1969 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
1971 # Process User Application Removals for calculations and subsequent removal
1972 if [ -n "$user_remove_list" ]; then
1973 for remove_apk in $user_remove_list; do
1974 testapk=$( echo "$remove_apk" | tr '[:upper:]' '[:lower:]' );
1975 # Add apk extension if user didn't include it
1978 * ) testapk="${testapk}.apk" ;;
1980 # Create user_remove_folder_list if this is a system/ROM application
1981 for folder in /system/app /system/priv-app; do # Check all subfolders in /system/app /system/priv-app for the apk
1982 file_count=0; # Reset Counter
1983 file_count=$(find $folder -iname "$testapk" | wc -l);
1987 universalremoverhack
"$build/$1" #on kitkat the paths for the universalremover are different
1988 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
1990 *) echo "$remove_apk" >> $user_remove_multiplefound_log; # Add app to user_remove_multiplefound_log since we found more than 1 instance
1994 if [ "$file_count" -eq 0 ]; then
1995 echo "$remove_apk" >> $user_remove_notfound_log;
1996 fi; # Add 'not found' app to user_remove_notfound_log
2000 # Removing old Chrome libraries
2001 obsolete_libs_list="";
2002 for f in $(find /system/lib /system/lib64 -name 'libchrome.*.so' 2>/dev/null); do
2003 obsolete_libs_list="${obsolete_libs_list}$f"$'\n';
2006 # Read in gapps removal list from file and append old Chrome libs
2007 full_removal_list="$(cat $gapps_removal_list)"$'\n'"${obsolete_libs_list}";
2009 # Read in old user removal list from addon.d to allow for persistence
2010 addond_remove_folder_list=$(sed -e "1,/# Remove 'user requested' apps (from gapps-config)/d" -e '/;;/,$d' -e 's/ rm -rf //' /system/addon.d/70-gapps.sh)
2012 # Clean up and sort our lists for space calculations and installation
2014 gapps_list=$(echo "${gapps_list}" | sort | sed '/^$/d'); # sort GApps list & remove empty lines
2015 aosp_remove_list=$(echo "${aosp_remove_list}" | sort | sed '/^$/d'); # sort AOSP Remove list & remove empty lines
2016 full_removal_list=$(echo "${full_removal_list}" | sed '/^$/d'); # Remove empty lines from FINAL GApps Removal list
2017 remove_list=$(echo "${remove_list}" | sed '/^$/d'); # Remove empty lines from remove_list
2018 user_remove_folder_list=$(echo "${user_remove_folder_list}" | sed '/^$/d'); # Remove empty lines from User Application Removal list
2020 log "Installing GApps Zipfile" "$OPENGAZIP"
2021 log "Installing GApps Version" "$gapps_version";
2022 log "Installing GApps Type" "$gapps_type";
2023 log "Config Type" "$config_type";
2024 log "Using gapps-config" "$config_file";
2025 log "Remove Stock/AOSP Browser" "$remove_browser";
2026 log "Remove Stock/AOSP Camera" "$remove_camerastock";
2027 log "Remove Stock/AOSP Email" "$remove_email";
2028 log "Remove Stock/AOSP Gallery" "$remove_gallery";
2029 log "Remove Stock/AOSP Launcher" "$remove_launcher";
2030 log "Remove Stock/AOSP MMS App" "$remove_mms";
2031 log "Remove Stock/AOSP Pico TTS" "$remove_picotts";
2032 log "Ignore Google Contacts" "$ignoregooglecontacts";
2033 log "Ignore Google Dialer" "$ignoregoogledialer";
2034 log "Ignore Google Keyboard" "$ignoregooglekeyboard";
2035 log "Ignore Google Package Installer" "$ignoregooglepackageinstaller";
2036 log "Ignore Google NFC Tag" "$ignoregoogletag";
2037 log "Ignore Google WebView" "$ignoregooglewebview";
2038 # _____________________________________________________________________________________________________________________
2039 # Perform space calculations
2040 ui_print "- Performing system space calculations";
2043 # Perform calculations of core applications
2045 for gapp_name in $core_gapps_list; do
2046 get_apparchives "Core/$gapp_name"
2047 for archive in $apparchives; do
2049 setupwizarddefault) if [ "$device_type" != "tablet" ]; then get_appsize "$archive"; fi;;
2050 setupwizardtablet) if [ "$device_type" = "tablet" ]; then get_appsize "$archive"; fi;;
2051 *) get_appsize "$archive";;
2053 core_size=$((core_size + appsize))
2057 # Add swypelibs size to core, if it will be installed
2058 if ( ! contains "$gapps_list" "keyboardgoogle" ) || [ "$skipswypelibs" = "false" ]; then
2059 get_appsize "Optional/swypelibs-lib-$arch" # Keep it simple, swypelibs is only lib-$arch
2060 core_size=$((core_size + keybd_lib_size)) # Add Keyboard Lib size to core, if it exists
2063 # Read and save system partition size details
2064 df=$(df -k /system | tail -n 1);
2066 /dev/block/*) df=$(echo "$df" | awk '{ print substr($0, index($0,$2)) }');;
2068 total_system_size_kb=$(echo "$df" | awk '{ print $1 }');
2069 used_system_size_kb=$(echo "$df" | awk '{ print $2 }');
2070 free_system_size_kb=$(echo "$df" | awk '{ print $3 }');
2071 log "Total System Size (KB)" "$total_system_size_kb";
2072 log "Used System Space (KB)" "$used_system_size_kb";
2073 log "Current Free Space (KB)" "$free_system_size_kb";
2075 # Perform storage space calculations of existing GApps that will be deleted/replaced
2076 reclaimed_gapps_space_kb=$(du -ck $(complete_gapps_list) | tail -n 1 | awk '{ print $1 }');
2078 # Perform storage space calculations of other Removals that need to be deleted (Obsolete and Conflicting Apps)
2080 reclaimed_removal_space_kb=$(du -ck $(obsolete_gapps_list) | tail -n 1 | awk '{ print $1 }');
2082 # Add information to calc.log that will later be added to open_gapps.log to assist user with app removals
2083 post_install_size_kb=$((free_system_size_kb + reclaimed_gapps_space_kb)); # Add opening calculations
2084 echo ------------------------------------------------------------------ > $calc_log;
2085 printf "%7s | %26s | %7s | %7s\n" "TYPE " "DESCRIPTION " "SIZE" " TOTAL" >> $calc_log;
2086 printf "%7s | %26s | %7d | %7d\n" "" "Current Free Space" "$free_system_size_kb" "$free_system_size_kb" >> $calc_log;
2087 printf "%7s | %26s | + %7d | %7d\n" "Remove" "Existing GApps" "$reclaimed_gapps_space_kb" $post_install_size_kb >> $calc_log;
2088 post_install_size_kb=$((post_install_size_kb + reclaimed_removal_space_kb)); # Add reclaimed_removal_space_kb
2089 printf "%7s | %26s | + %7d | %7d\n" "Remove" "Obsolete Files" "$reclaimed_removal_space_kb" $post_install_size_kb >> $calc_log;
2091 # Perform calculations of AOSP/ROM files that will be deleted
2093 for aosp_name in $aosp_remove_list; do
2094 eval "list_name=\$${aosp_name}_list";
2095 aosp_size_kb=0; # Reset counter
2096 for file_name in $list_name; do
2097 if [ -e "/system/$file_name" ]; then
2098 file_size_kb=$(du -ck "/system/$file_name" | tail -n 1 | awk '{ print $1 }');
2099 aosp_size_kb=$((file_size_kb + aosp_size_kb));
2100 post_install_size_kb=$((post_install_size_kb + file_size_kb));
2103 log_add "Remove" "$aosp_name" $aosp_size_kb $post_install_size_kb;
2106 # Perform calculations of User App Removals that will be deleted
2107 for remove_folder in $user_remove_folder_list; do
2108 if [ -e "$remove_folder" ]; then
2109 folder_size_kb=$(du -ck "$remove_folder" | tail -n 1 | awk '{ print $1 }');
2110 post_install_size_kb=$((post_install_size_kb + folder_size_kb));
2111 log_add "Remove" "$(basename "$remove_folder")*" "$folder_size_kb" $post_install_size_kb;
2115 # Perform calculations of GApps files that will be installed
2117 post_install_size_kb=$((post_install_size_kb - core_size)) # Add Core GApps
2118 log_sub "Install" "Core" $core_size $post_install_size_kb
2120 for gapp_name in $gapps_list; do
2122 photos) if [ "$vrmode_compat" = "true" ] && [ "$arch" = "arm64" ] && [ "$rom_build_sdk" -ge "24" ]; then gapp_name="photosvrmode"; fi;; # for now only available on Nougat arm64
2123 movies) if [ "$vrmode_compat" = "true" ] && ( [ "$arch" = "arm" ] || [ "$arch" = "arm64" ] ) && [ "$rom_build_sdk" -ge "24" ]; then gapp_name="moviesvrmode"; fi;; # for now only available on Nougat arm & arm64
2126 get_apparchives "GApps/$gapp_name"
2128 for archive in $apparchives; do
2129 get_appsize "$archive"
2130 total_appsize=$((total_appsize + $appsize))
2133 echo "$DATASIZESCODE" >> "$build/$1"
2134 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
2135 post_install_size_kb=$((post_install_size_kb - total_appsize))
2136 log_sub "Install" "$gapp_name" "$total_appsize" "$post_install_size_kb"
2139 # Perform calculations of required Buffer Size
2141 if ( grep -qiE '^smallbuffer$' "$g_conf" ); then
2142 buffer_size_kb=$small_buffer_size
2145 post_install_size_kb=$((post_install_size_kb - buffer_size_kb));
2146 log_sub "" "Buffer Space" "$buffer_size_kb" $post_install_size_kb;
2147 echo ------------------------------------------------------------------ >> $calc_log;
2149 if [ "$post_install_size_kb" -ge 0 ]; then
2150 printf "%47s | %7d\n" " Post Install Free Space" $post_install_size_kb >> $calc_log;
2151 log "Post Install Free Space (KB)" "$post_install_size_kb << See Calculations Below";
2153 additional_size_kb=$((post_install_size_kb * -1));
2154 printf "%47s | %7d\n" "Additional Space Required" $additional_size_kb >> $calc_log;
2155 log "Additional Space Required (KB)" "$additional_size_kb << See Calculations Below";
2158 # Finish up Calculation Log
2159 echo ------------------------------------------------------------------ >> $calc_log;
2160 if [ -n "$user_remove_folder_list" ]; then
2161 echo " * User Requested Removal" >> $calc_log;
2164 # Check whether there's enough free space to complete this installation
2165 if [ "$post_install_size_kb" -lt 0 ]; then
2166 # We don't have enough system space to install everything user requested
2167 ui_print "Insufficient storage space available in";
2168 ui_print "System partition. You may want to use a";
2169 ui_print "smaller Open GApps package or consider";
2170 ui_print "removing some apps using gapps-config.";
2171 ui_print "See:'$log_folder/open_gapps_log.txt'";
2172 ui_print "for complete details and information.";
2174 install_note="${install_note}system_space_msg"$'\n'; # make note that there is insufficient space in system to install
2178 # Check to see if this is the 'real thing' or only a test
2179 if ( grep -qiE '^test$' "$g_conf" ); then # user has selected a 'test' install ONLY
2180 ui_print "- Exiting Simulated Install";
2182 install_note="${install_note}simulation_msg"$'\n'; # make note that this is only a test installation
2186 # _____________________________________________________________________________________________________________________
2188 # Remove ALL Existing GApps files
2190 ui_print "- Removing existing/obsolete Apps";
2192 rm -rf $(complete_gapps_list);
2194 # Remove Obsolete and Conflicting Apps
2195 rm -rf $(obsolete_gapps_list);
2197 # Remove Stock/AOSP Apps and add Removals to addon.d script
2198 aosp_remove_list=$(echo "${aosp_remove_list}" | sort -r); # reverse sort list for more readable output
2199 for aosp_name in $aosp_remove_list; do
2200 eval "list_name=\$${aosp_name}_list";
2201 list_name=$(echo "${list_name}" | sort -r); # reverse sort list for more readable output
2202 for file_name in $list_name; do
2203 rm -rf "/system/$file_name";
2204 sed -i "\:# Remove Stock/AOSP apps (from GApps Installer):a \ rm -rf /system/$file_name" $bkup_tail;
2208 # Add saved addon.d User App Removals to make them persistent through repeat dirty GApps installs though the app may have already been removed
2209 user_remove_folder_list=$(echo -e "${user_remove_folder_list}\n${addond_remove_folder_list}" | sort -u | sed '/^$/d') # remove duplicates and empty lines
2211 # Perform User App Removals and add Removals to addon.d script
2212 user_remove_folder_list=$(echo "${user_remove_folder_list}" | sort -r); # reverse sort list for more readable output
2213 for user_app in $user_remove_folder_list; do
2215 sed -i "\:# Remove 'user requested' apps (from gapps-config):a \ rm -rf $user_app" $bkup_tail;
2218 # Remove any empty folders we may have created during the removal process
2219 for i in /system/app /system/priv-app /system/vendor/pittpatt /system/usr/srec /system/etc/preferred-apps; do
2220 find "$i" -type d | xargs -r rmdir -p --ignore-fail-on-non-empty;
2222 # _____________________________________________________________________________________________________________________
2224 ui_print "- Installing core GApps";
2226 for gapp_name in $core_gapps_list; do
2227 get_apparchives "Core/$gapp_name"
2228 for archive in $apparchives; do
2230 setupwizarddefault) if [ "$device_type" != "tablet" ]; then extract_app "$archive"; fi;;
2231 setupwizardtablet) if [ "$device_type" = "tablet" ]; then extract_app "$archive"; fi;;
2232 *) extract_app "$archive";;
2240 echo "$KEYBDINSTALLCODE" >> "$build/$1"
2241 echo "$DATAINSTALLCODE" >> "$build/$1"
2242 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
2243 # Progress Bar increment calculations for GApps Install process
2245 gapps_count=$(echo "${gapps_list}" | wc -w); # Count number of GApps left to be installed
2246 if [ "$gapps_count" -lt 1 ]; then gapps_count=1; fi; # Prevent division by zero
2247 incr_amt=$(( 5000 / gapps_count )); # Determine increment factor of progress bar during GApps installation
2248 prog_bar=3000; # Set Progress Bar start point (0.3000) for below
2250 # Install the rest of GApps still in $gapps_list
2251 for gapp_name in $gapps_list; do
2253 photos) if [ "$vrmode_compat" = "true" ] && [ "$arch" = "arm64" ] && [ "$rom_build_sdk" -ge "24" ]; then gapp_name="photosvrmode"; fi;; # for now only available on Nougat arm64
2254 movies) if [ "$vrmode_compat" = "true" ] && ( [ "$arch" = "arm" ] || [ "$arch" = "arm64" ] ) && [ "$rom_build_sdk" -ge "24" ]; then gapp_name="moviesvrmode"; fi;; # for now only available on Nougat arm & arm64
2257 ui_print "- Installing $gapp_name"
2258 get_apparchives "GApps/$gapp_name"
2259 for archive in $apparchives; do
2260 extract_app "$archive" # Installing User Selected GApps
2262 prog_bar=$((prog_bar + incr_amt))
2263 set_progress 0.$prog_bar
2267 ui_print "- Miscellaneous tasks";
2270 # Use Gms (Google Play services) for feedback/bug reporting (instead of org.cyanogenmod.bugreport or others)
2271 sed -i "s/ro.error.receiver.system.apps=.*/ro.error.receiver.system.apps=com.google.android.gms/g" /system/build.prop
2272 sed -i "\:# Apply build.prop changes (from GApps Installer):a \ sed -i \"s/ro.error.receiver.system.apps=.*/ro.error.receiver.system.apps=com.google.android.gms/g\" /system/build.prop" $bkup_tail
2274 # Enable Google Assistant
2275 if ( grep -qiE '^googleassistant$' "$g_conf" ); then #TODO this is not enabled by default atm; because Assistant still has various regressions compared to Google Now
2276 if ! grep -q "ro.opa.eligible_device=" /system/build.prop; then
2277 echo "ro.opa.eligible_device=true" >> /system/build.prop
2279 sed -i "\:# Apply build.prop changes (from GApps Installer):a \ if ! grep -q \"ro.opa.eligible_device=\" /system/build.prop; then echo \"ro.opa.eligible_device=true\" >> /system/build.prop; fi" $bkup_tail
2282 # Create FaceLock lib symlink if installed
2283 if ( contains "$gapps_list" "faceunlock" ); then
2284 install -d "/system/app/FaceLock/lib/$arch"
2285 ln -sfn "/system/$libfolder/$faceLock_lib_filename" "/system/app/FaceLock/lib/$arch/$faceLock_lib_filename"
2286 # Add same code to backup script to insure symlinks are recreated on addon.d restore
2287 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ ln -sfn \"/system/$libfolder/$faceLock_lib_filename\" \"/system/app/FaceLock/lib/$arch/$faceLock_lib_filename\"" $bkup_tail
2288 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ install -d \"/system/app/FaceLock/lib/$arch\"" $bkup_tail
2292 if [ "$API" -lt "24" ]; then # Only 5.1 and 6.0
2293 echo '# Create TVRemote lib symlink if installed
2294 if ( contains "$gapps_list" "tvremote" ); then
2295 install -d "/system/app/AtvRemoteService/lib/$arch"
2296 ln -sfn "/system/$libfolder/$atvremote_lib_filename" "/system/app/AtvRemoteService/lib/$arch/$atvremote_lib_filename"
2297 # Add same code to backup script to insure symlinks are recreated on addon.d restore
2298 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ ln -sfn \"/system/$libfolder/$atvremote_lib_filename\" \"/system/app/AtvRemoteService/lib/$arch/$atvremote_lib_filename\"" $bkup_tail
2299 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ install -d \"/system/app/AtvRemoteService/lib/$arch\"" $bkup_tail
2304 if [ "$API" -lt "23" ]; then
2305 echo '# Create WebView lib symlink if WebView was installed
2306 if ( contains "$gapps_list" "webviewgoogle" ); then
2307 install -d "/system/app/WebViewGoogle/lib/$arch"
2308 ln -sfn "/system/$libfolder/$WebView_lib_filename" "/system/app/WebViewGoogle/lib/$arch/$WebView_lib_filename"
2309 # Add same code to backup script to insure symlinks are recreated on addon.d restore
2310 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ ln -sfn \"/system/$libfolder/$WebView_lib_filename\" \"/system/app/WebViewGoogle/lib/$arch/$WebView_lib_filename\"" $bkup_tail
2311 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ install -d \"/system/app/WebViewGoogle/lib/$arch\"" $bkup_tail
2312 if [ -n "$fbarch" ]; then # on 64bit we also need to add 32 bit libs
2313 install -d "/system/app/WebViewGoogle/lib/$fbarch"
2314 ln -sfn "/system/lib/$WebView_lib_filename" "/system/app/WebViewGoogle/lib/$fbarch/$WebView_lib_filename"
2315 # Add same code to backup script to insure symlinks are recreated on addon.d restore
2316 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ ln -sfn \"/system/lib/$WebView_lib_filename\" \"/system/app/WebViewGoogle/lib/$fbarch/$WebView_lib_filename\"" $bkup_tail
2317 sed -i "\:# Recreate required symlinks (from GApps Installer):a \ install -d \"/system/app/WebViewGoogle/lib/$fbarch\"" $bkup_tail
2322 tee -a "$build/$1" > /dev
/null
<<'EOFILE'
2324 # Copy g.prop over to /system/etc
2325 cp -f "$TMP/g.prop" "$g_prop"
2326 # _____________________________________________________________________________________________________________________
2327 # Build and Install Addon.d Backup Script
2328 # Add 'other' Removals to addon.d script
2330 other_list=$(echo "${other_list}" | sort -r); # reverse sort list for more readable output
2331 for other_name in $other_list; do
2332 sed -i "\:# Remove 'other' apps (per installer.data):a \ rm -rf $other_name" $bkup_tail;
2335 # Add 'priv-app' Removals to addon.d script
2336 privapp_list=$(echo "${privapp_list}" | sort -r); # reverse sort list for more readable output
2337 for privapp_name in $privapp_list; do
2338 sed -i "\:# Remove 'priv-app' apps from 'app' (per installer.data):a \ rm -rf $privapp_name" $bkup_tail;
2341 # Add 'required' Removals to addon.d script
2342 reqd_list=$(echo "${reqd_list}" | sort -r); # reverse sort list for more readable output
2343 for reqdapp_name in $reqd_list; do
2344 sed -i "\:# Remove 'required' apps (per installer.data):a \ rm -rf $reqdapp_name" $bkup_tail;
2347 # Create final addon.d script in system
2348 bkup_header="#!/sbin/sh\n# \n# /system/addon.d/70-gapps.sh\n#\n. /tmp/backuptool.functions\n\nlist_files() {\ncat <<EOF"
2349 bkup_list="$bkup_list"$'\n'"etc/g.prop"; # add g.prop to backup list
2350 bkup_list=$(echo "${bkup_list}" | sort -u| sed '/^$/d'); # sort list & remove duplicates and empty lines
2351 install -d /system/addon.d;
2352 echo -e "$bkup_header" > /system/addon.d/70-gapps.sh;
2353 echo -e "$bkup_list" >> /system/addon.d/70-gapps.sh;
2354 cat $bkup_tail >> /system/addon.d/70-gapps.sh;
2355 # _____________________________________________________________________________________________________________________
2359 find /system/vendor/pittpatt -type d -exec chown 0:2000 '{}' \; # Change pittpatt folders to root:shell per Google Factory Settings
2361 set_perm 0 0 755 "/system/addon.d/70-gapps.sh"
2362 ch_con "/system/addon.d/70-gapps.sh"
2364 set_perm 0 0 644 "$g_prop"
2370 ui_print "- Installation complete!"
2373 if ( contains "$gapps_list" "dialergoogle" ); then
2374 ui_print "You installed Google Dialer."
2375 ui_print "Please set it as default Phone"
2376 ui_print "application to prevent calls"
2377 ui_print "from rebooting your device."
2378 ui_print "See https://goo.gl/LTIJ0o"
2380 # set Google Dialer as default; based on the work of osm0sis @ xda-developers
2381 setver="122" # lowest version in MM, tagged at 6.0.0
2382 setsec="/data/system/users/0/settings_secure.xml"
2383 if [ -f "$setsec" ]; then
2384 if grep -q 'dialer_default_application' "$setsec"; then
2385 if ! grep -q 'dialer_default_application" value="com.google.android.dialer' "$setsec"; then
2386 curentry="$(grep -o 'dialer_default_application" value=.*$' "$setsec")"
2387 newentry='dialer_default_application" value="com.google.android.dialer" package="android" />\r'
2388 sed -i "s;${curentry};${newentry};" "$setsec"
2392 for i in $(grep -o 'id=.*$' "$setsec" | cut -d '"' -f 2); do
2393 test "$i" -gt "$max" && max="$i"
2395 entry='<setting id="'"$((max + 1))"'" name="dialer_default_application" value="com.google.android.dialer" package="android" />\r'
2396 sed -i "/<settings version=\"/a\ \ ${entry}" "$setsec"
2399 if [ ! -d "/data/system/users/0" ]; then
2400 install -d "/data/system/users/0"
2401 chown -R 1000:1000 "/data/system"
2402 chmod -R 775 "/data/system"
2403 chmod 700 "/data/system/users/0"
2405 { echo -e "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r";
2406 echo -e '<settings version="'$setver'">\r';
2407 echo -e ' <setting id="1" name="dialer_default_application" value="com.google.android.dialer" package="android" />\r';
2408 echo -e '</settings>'; } > "$setsec"
2410 chown 1000:1000 "$setsec"