Loading android/app/src/com/android/bluetooth/btservice/storage/MetadataDatabase.java +93 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ import java.util.List; /** * MetadataDatabase is a Room database stores Bluetooth persistence data */ @Database(entities = {Metadata.class}, version = 102) @Database(entities = {Metadata.class}, version = 103) public abstract class MetadataDatabase extends RoomDatabase { /** * The database file name Loading @@ -51,6 +51,7 @@ public abstract class MetadataDatabase extends RoomDatabase { MetadataDatabase.class, DATABASE_NAME) .addMigrations(MIGRATION_100_101) .addMigrations(MIGRATION_101_102) .addMigrations(MIGRATION_102_103) .build(); } Loading Loading @@ -172,4 +173,95 @@ public abstract class MetadataDatabase extends RoomDatabase { database.execSQL("ALTER TABLE `metadata_tmp` RENAME TO `metadata`"); } }; @VisibleForTesting static final Migration MIGRATION_102_103 = new Migration(102, 103) { @Override public void migrate(SupportSQLiteDatabase database) { database.execSQL("CREATE TABLE IF NOT EXISTS `metadata_tmp` (" + "`address` TEXT NOT NULL, `migrated` INTEGER NOT NULL, " + "`a2dpSupportsOptionalCodecs` INTEGER NOT NULL, " + "`a2dpOptionalCodecsEnabled` INTEGER NOT NULL, " + "`a2dp_connection_policy` INTEGER, `a2dp_sink_connection_policy` INTEGER, " + "`hfp_connection_policy` INTEGER, `hfp_client_connection_policy` INTEGER, " + "`hid_host_connection_policy` INTEGER, `pan_connection_policy` INTEGER, " + "`pbap_connection_policy` INTEGER, `pbap_client_connection_policy` INTEGER, " + "`map_connection_policy` INTEGER, `sap_connection_policy` INTEGER, " + "`hearing_aid_connection_policy` INTEGER, " + "`map_client_connection_policy` INTEGER, `manufacturer_name` BLOB, " + "`model_name` BLOB, `software_version` BLOB, `hardware_version` BLOB, " + "`companion_app` BLOB, `main_icon` BLOB, `is_untethered_headset` BLOB, " + "`untethered_left_icon` BLOB, `untethered_right_icon` BLOB, " + "`untethered_case_icon` BLOB, `untethered_left_battery` BLOB, " + "`untethered_right_battery` BLOB, `untethered_case_battery` BLOB, " + "`untethered_left_charging` BLOB, `untethered_right_charging` BLOB, " + "`untethered_case_charging` BLOB, `enhanced_settings_ui_uri` BLOB, " + "PRIMARY KEY(`address`))"); database.execSQL("INSERT INTO metadata_tmp (" + "address, migrated, a2dpSupportsOptionalCodecs, a2dpOptionalCodecsEnabled, " + "a2dp_connection_policy, a2dp_sink_connection_policy, hfp_connection_policy," + "hfp_client_connection_policy, hid_host_connection_policy," + "pan_connection_policy, pbap_connection_policy," + "pbap_client_connection_policy, map_connection_policy, sap_connection_policy," + "hearing_aid_connection_policy, map_client_connection_policy, " + "manufacturer_name, model_name, software_version, hardware_version, " + "companion_app, main_icon, is_untethered_headset, untethered_left_icon, " + "untethered_right_icon, untethered_case_icon, untethered_left_battery, " + "untethered_right_battery, untethered_case_battery, " + "untethered_left_charging, untethered_right_charging, " + "untethered_case_charging, enhanced_settings_ui_uri) " + "SELECT " + "address, migrated, a2dpSupportsOptionalCodecs, a2dpOptionalCodecsEnabled, " + "a2dp_priority, a2dp_sink_priority, hfp_priority, hfp_client_priority, " + "hid_host_priority, pan_priority, pbap_priority, pbap_client_priority, " + "map_priority, sap_priority, hearing_aid_priority, map_client_priority, " + "CAST (manufacturer_name AS BLOB), " + "CAST (model_name AS BLOB), " + "CAST (software_version AS BLOB), " + "CAST (hardware_version AS BLOB), " + "CAST (companion_app AS BLOB), " + "CAST (main_icon AS BLOB), " + "CAST (is_untethered_headset AS BLOB), " + "CAST (untethered_left_icon AS BLOB), " + "CAST (untethered_right_icon AS BLOB), " + "CAST (untethered_case_icon AS BLOB), " + "CAST (untethered_left_battery AS BLOB), " + "CAST (untethered_right_battery AS BLOB), " + "CAST (untethered_case_battery AS BLOB), " + "CAST (untethered_left_charging AS BLOB), " + "CAST (untethered_right_charging AS BLOB), " + "CAST (untethered_case_charging AS BLOB), " + "CAST (enhanced_settings_ui_uri AS BLOB)" + "FROM metadata"); database.execSQL("UPDATE metadata_tmp SET a2dp_connection_policy = 100 " + "WHERE a2dp_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET a2dp_sink_connection_policy = 100 " + "WHERE a2dp_sink_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hfp_connection_policy = 100 " + "WHERE hfp_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hfp_client_connection_policy = 100 " + "WHERE hfp_client_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hid_host_connection_policy = 100 " + "WHERE hid_host_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET pan_connection_policy = 100 " + "WHERE pan_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET pbap_connection_policy = 100 " + "WHERE pbap_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET pbap_client_connection_policy = 100 " + "WHERE pbap_client_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET map_connection_policy = 100 " + "WHERE map_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET sap_connection_policy = 100 " + "WHERE sap_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hearing_aid_connection_policy = 100 " + "WHERE hearing_aid_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET map_client_connection_policy = 100 " + "WHERE map_client_connection_policy = 1000"); database.execSQL("DROP TABLE `metadata`"); database.execSQL("ALTER TABLE `metadata_tmp` RENAME TO `metadata`"); } }; } Loading
android/app/src/com/android/bluetooth/btservice/storage/MetadataDatabase.java +93 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ import java.util.List; /** * MetadataDatabase is a Room database stores Bluetooth persistence data */ @Database(entities = {Metadata.class}, version = 102) @Database(entities = {Metadata.class}, version = 103) public abstract class MetadataDatabase extends RoomDatabase { /** * The database file name Loading @@ -51,6 +51,7 @@ public abstract class MetadataDatabase extends RoomDatabase { MetadataDatabase.class, DATABASE_NAME) .addMigrations(MIGRATION_100_101) .addMigrations(MIGRATION_101_102) .addMigrations(MIGRATION_102_103) .build(); } Loading Loading @@ -172,4 +173,95 @@ public abstract class MetadataDatabase extends RoomDatabase { database.execSQL("ALTER TABLE `metadata_tmp` RENAME TO `metadata`"); } }; @VisibleForTesting static final Migration MIGRATION_102_103 = new Migration(102, 103) { @Override public void migrate(SupportSQLiteDatabase database) { database.execSQL("CREATE TABLE IF NOT EXISTS `metadata_tmp` (" + "`address` TEXT NOT NULL, `migrated` INTEGER NOT NULL, " + "`a2dpSupportsOptionalCodecs` INTEGER NOT NULL, " + "`a2dpOptionalCodecsEnabled` INTEGER NOT NULL, " + "`a2dp_connection_policy` INTEGER, `a2dp_sink_connection_policy` INTEGER, " + "`hfp_connection_policy` INTEGER, `hfp_client_connection_policy` INTEGER, " + "`hid_host_connection_policy` INTEGER, `pan_connection_policy` INTEGER, " + "`pbap_connection_policy` INTEGER, `pbap_client_connection_policy` INTEGER, " + "`map_connection_policy` INTEGER, `sap_connection_policy` INTEGER, " + "`hearing_aid_connection_policy` INTEGER, " + "`map_client_connection_policy` INTEGER, `manufacturer_name` BLOB, " + "`model_name` BLOB, `software_version` BLOB, `hardware_version` BLOB, " + "`companion_app` BLOB, `main_icon` BLOB, `is_untethered_headset` BLOB, " + "`untethered_left_icon` BLOB, `untethered_right_icon` BLOB, " + "`untethered_case_icon` BLOB, `untethered_left_battery` BLOB, " + "`untethered_right_battery` BLOB, `untethered_case_battery` BLOB, " + "`untethered_left_charging` BLOB, `untethered_right_charging` BLOB, " + "`untethered_case_charging` BLOB, `enhanced_settings_ui_uri` BLOB, " + "PRIMARY KEY(`address`))"); database.execSQL("INSERT INTO metadata_tmp (" + "address, migrated, a2dpSupportsOptionalCodecs, a2dpOptionalCodecsEnabled, " + "a2dp_connection_policy, a2dp_sink_connection_policy, hfp_connection_policy," + "hfp_client_connection_policy, hid_host_connection_policy," + "pan_connection_policy, pbap_connection_policy," + "pbap_client_connection_policy, map_connection_policy, sap_connection_policy," + "hearing_aid_connection_policy, map_client_connection_policy, " + "manufacturer_name, model_name, software_version, hardware_version, " + "companion_app, main_icon, is_untethered_headset, untethered_left_icon, " + "untethered_right_icon, untethered_case_icon, untethered_left_battery, " + "untethered_right_battery, untethered_case_battery, " + "untethered_left_charging, untethered_right_charging, " + "untethered_case_charging, enhanced_settings_ui_uri) " + "SELECT " + "address, migrated, a2dpSupportsOptionalCodecs, a2dpOptionalCodecsEnabled, " + "a2dp_priority, a2dp_sink_priority, hfp_priority, hfp_client_priority, " + "hid_host_priority, pan_priority, pbap_priority, pbap_client_priority, " + "map_priority, sap_priority, hearing_aid_priority, map_client_priority, " + "CAST (manufacturer_name AS BLOB), " + "CAST (model_name AS BLOB), " + "CAST (software_version AS BLOB), " + "CAST (hardware_version AS BLOB), " + "CAST (companion_app AS BLOB), " + "CAST (main_icon AS BLOB), " + "CAST (is_untethered_headset AS BLOB), " + "CAST (untethered_left_icon AS BLOB), " + "CAST (untethered_right_icon AS BLOB), " + "CAST (untethered_case_icon AS BLOB), " + "CAST (untethered_left_battery AS BLOB), " + "CAST (untethered_right_battery AS BLOB), " + "CAST (untethered_case_battery AS BLOB), " + "CAST (untethered_left_charging AS BLOB), " + "CAST (untethered_right_charging AS BLOB), " + "CAST (untethered_case_charging AS BLOB), " + "CAST (enhanced_settings_ui_uri AS BLOB)" + "FROM metadata"); database.execSQL("UPDATE metadata_tmp SET a2dp_connection_policy = 100 " + "WHERE a2dp_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET a2dp_sink_connection_policy = 100 " + "WHERE a2dp_sink_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hfp_connection_policy = 100 " + "WHERE hfp_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hfp_client_connection_policy = 100 " + "WHERE hfp_client_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hid_host_connection_policy = 100 " + "WHERE hid_host_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET pan_connection_policy = 100 " + "WHERE pan_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET pbap_connection_policy = 100 " + "WHERE pbap_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET pbap_client_connection_policy = 100 " + "WHERE pbap_client_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET map_connection_policy = 100 " + "WHERE map_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET sap_connection_policy = 100 " + "WHERE sap_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET hearing_aid_connection_policy = 100 " + "WHERE hearing_aid_connection_policy = 1000"); database.execSQL("UPDATE metadata_tmp SET map_client_connection_policy = 100 " + "WHERE map_client_connection_policy = 1000"); database.execSQL("DROP TABLE `metadata`"); database.execSQL("ALTER TABLE `metadata_tmp` RENAME TO `metadata`"); } }; }