More (frustrating) adventures in computing!...
I also submitted a script to Open GApps today to fix the GApps issue with Google Dialer causing reboots when it's not set as default (edit: final commit now live), ...
In addition to my above fix to Open GApps, I also tried to tackle the GApps issue where CMSetupWizard being removed on a clean install (useful because it allows Google's SetupWizard to grant default permissions, which naturally helps the GApps permissions issues present in Marshmallow and above) breaks the Quick Settings pull-down, not allowing it to expand from the Notifications layout.
@MastahF and I have documented it on the Open GApps wiki, but basically, I found the true issue was CM made a change to have the pull-down rely only on the "cm_setup_wizard_completed" setting from their wizard, (similar to Google's "device_provisioned" setting), and found setting it manually (with `su -c 'settings --cm put secure cm_setup_wizard_completed 1'`) instantly resolved the issue of the broken pull-down. The annoying part of this is of course that it means CMSetupWizard isn't even necessary to provision Quick Settings, since it gets set up perfectly well without it, and suggests this limitation to be artificial and arbitrary, so their code change should just be reverted.
Sorry if I sound a little bitter, but I spent a day trying to reverse engineer their cmsettings.db with sqlite3 to see if we could force the setting in from recovery like we did with setting Dialer as default in Google's settings_secure.xml, only to find there was no way to acceptably build it from scratch (hung boot) due to some differences in the way the CMSettings APK creates SQlite B-tree cell arrays versus doing it from the sqlite3 command-line, despite no PRAGMA differences or content differences. Using a prebuilt hacked/modified (stripped of all settings but cm_setup_wizard_completed) cmsettings.db would boot, but either a) not get provisioned with all the other settings it normally would from first-boot because the CMSettings APK isn't built to handle that if the cmsettings.db file exists or the db "user_version" was set >2, or b) overwrite our inserted settings as part of "upgrading" the db from a version <4.
Here is my script of failed attempts, for those interested, or in case it's helpful in the future. As shown it'll attempt to create the db; commented out is the hacked db replacement attempt.
cmsetup_fix.sh:
Code:
#!/sbin/sh
# osm0sis @ xda-developers
# WIP
mount /system 2> /dev/null
sqlite3="/system/xbin/sqlite3"
#cmsettings="/tmp/cmsettings.db"
cmdb() {
cat <<EOF
PRAGMA foreign_keys=OFF;
PRAGMA page_size=4096;
PRAGMA user_version=4;
BEGIN TRANSACTION;
CREATE TABLE android_metadata (locale TEXT);
INSERT INTO "android_metadata" VALUES('en_US');
CREATE TABLE system (_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT UNIQUE ON CONFLICT REPLACE,value TEXT);
CREATE TABLE secure (_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT UNIQUE ON CONFLICT REPLACE,value TEXT);
CREATE TABLE global (_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT UNIQUE ON CONFLICT REPLACE,value TEXT);
CREATE INDEX systemIndex1 ON system (name);
CREATE INDEX secureIndex1 ON secure (name);
CREATE INDEX globalIndex1 ON global (name);
INSERT INTO "secure" VALUES(1,'cm_setup_wizard_completed','1');
DELETE FROM sqlite_sequence;
INSERT INTO "sqlite_sequence" VALUES('system',0);
INSERT INTO "sqlite_sequence" VALUES('secure',1);
INSERT INTO "sqlite_sequence" VALUES('global',0);
COMMIT;
EOF
}
if [ ! -d "/data/data/org.cyanogenmod.cmsettings/databases" ]; then
install -d "/data/data/org.cyanogenmod.cmsettings/databases"
#cp "$cmsettings" "/data/data/org.cyanogenmod.cmsettings/databases/cmsettings.db"
$sqlite3 -batch "/data/data/org.cyanogenmod.cmsettings/databases/cmsettings.db" "$(cmdb)"
chown 1000:1000 "/data/data"
chown -R 1000:1000 "/data/data/org.cyanogenmod.cmsettings"
chmod 771 "/data/data" "/data/data/org.cyanogenmod.cmsettings/databases"
chmod 751 "/data/data/org.cyanogenmod.cmsettings"
chmod 660 "/data/data/org.cyanogenmod.cmsettings/databases/cmsettings.db"
fi
Anyway, TL;DR: I've added a new package, UPDATE-CMSetup.Fix.For.GApps.Installer-signed.zip, to the OP to automatically fix the Quick Settings pull-down issue for people wanting to use CM ROMs with GApps and allow them to continue to not pointlessly/detrimentally leave CMSetupWizard installed. It requires a SuperSU installation (for su.d support), so flash it after the SuperSU zip and your GApps. It will install the su.d script which follows, and if the fix has already been applied the script executes and does nothing, so, if you're a CM user, pretty much flash-and-forget as part of your clean ROM+GApps+SuperSU flash ritual.
000cmsetupfix:
Code:
#!/system/bin/sh
# chmod -R 755 /system/su.d /su/su.d
#
# Fix CM Quick Settings + GApps w/o CMSetupWizard
# osm0sis @ xda-developers
# run in an asynchronous subshell to not impede the boot with su.d
{
# ensure the cm settings database exists before attempting changes
until [ -f /data/data/org.cyanogenmod.cmsettings/databases/cmsettings.db ]; do
sleep 1;
done;
# wait until boot is complete to ensure any boot-time database setup is complete
until [ "$(getprop sys.boot_completed)" == 1 ]; do
sleep 1;
done;
# wait until general device setup is completed
until [ "$(settings get global device_provisioned)" == 1 ]; do
sleep 1;
done;
# set flag to restore quick settings functionality if it is not already
if [ "$(settings --cm get secure cm_setup_wizard_completed)" != 1 ]; then
settings --cm put secure cm_setup_wizard_completed 1;
fi;
}&
Lastly, on a brighter note - woot! My busybox fix when building for Android API 21 is in the v1.25.0 code drop from yesterday, but the version is currently labeled "unstable" so we'll have to wait a little while longer (probably 1.25.1 stable) for new builds. :good:
I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please do hit the donate link from my profile. Thanks for your support!
Edit: Added the CMSetup Fix blurb to the Installers section of the OP.
Last edited: