Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aed8f8eb authored by Doug Zongker's avatar Doug Zongker
Browse files

remove Settings.Gservices

Move the last few keys to secure settings, and delete the Gservices
table.

Change-Id: Ie3ba45aa8c1f220824aa027c547cb82884452eb5
parent 60545527
Loading
Loading
Loading
Loading
+72 −900

File changed.

Preview size limit exceeded, changes collapsed.

+11 −8
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
    // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
    // is properly propagated through your change.  Not doing so will result in a loss of user
    // settings.
    private static final int DATABASE_VERSION = 44;
    private static final int DATABASE_VERSION = 45;

    private Context mContext;

@@ -100,13 +100,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {

        createSecureTable(db);

        db.execSQL("CREATE TABLE gservices (" +
                   "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
                   "name TEXT UNIQUE ON CONFLICT REPLACE," +
                   "value TEXT" +
                   ");");
        db.execSQL("CREATE INDEX gservicesIndex1 ON gservices (name);");

        db.execSQL("CREATE TABLE bluetooth_devices (" +
                    "_id INTEGER PRIMARY KEY," +
                    "name TEXT," +
@@ -557,6 +550,16 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            upgradeVersion = 44;
        }

        if (upgradeVersion == 44) {
            /*
             * Gservices was moved into vendor/google.
             */
            db.execSQL("DROP TABLE IF EXISTS gservices");
            db.execSQL("DROP INDEX IF EXISTS gservicesIndex1");
            upgradeVersion = 45;
        }
            
        
        if (upgradeVersion != currentVersion) {
            Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion
                    + ", must wipe the settings provider");
+6 −17
Original line number Diff line number Diff line
@@ -75,8 +75,7 @@ public class SettingsProvider extends ContentProvider {
                throw new UnsupportedOperationException("WHERE clause not supported: " + url);
            } else {
                this.table = url.getPathSegments().get(0);
                if ("gservices".equals(this.table) || "system".equals(this.table)
                        || "secure".equals(this.table)) {
                if ("system".equals(this.table) || "secure".equals(this.table)) {
                    this.where = Settings.NameValueTable.NAME + "=?";
                    this.args = new String[] { url.getPathSegments().get(1) };
                } else {
@@ -110,8 +109,7 @@ public class SettingsProvider extends ContentProvider {
            throw new IllegalArgumentException("Invalid URI: " + tableUri);
        }
        String table = tableUri.getPathSegments().get(0);
        if ("gservices".equals(table) || "system".equals(table)
                || "secure".equals(table)) {
        if ("system".equals(table) || "secure".equals(table)) {
            String name = values.getAsString(Settings.NameValueTable.NAME);
            return Uri.withAppendedPath(tableUri, name);
        } else {
@@ -175,15 +173,6 @@ public class SettingsProvider extends ContentProvider {
            throw new SecurityException(
                    String.format("Permission denial: writing to secure settings requires %1$s",
                                  android.Manifest.permission.WRITE_SECURE_SETTINGS));

        // TODO: Move gservices into its own provider so we don't need this nonsense.
        } else if ("gservices".equals(args.table) &&
            getContext().checkCallingOrSelfPermission(
                    android.Manifest.permission.WRITE_GSERVICES) !=
                PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException(
                    String.format("Permission denial: writing to gservices settings requires %1$s",
                            android.Manifest.permission.WRITE_GSERVICES));
        }
    }