Search in sources :

Example 11 with SQLiteStatement

use of android.database.sqlite.SQLiteStatement in project android_frameworks_base by ParanoidAndroid.

the class DatabaseHelper method loadVibrateSetting.

private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) {
    if (deleteOld) {
        db.execSQL("DELETE FROM system WHERE name='" + Settings.System.VIBRATE_ON + "'");
    }
    SQLiteStatement stmt = null;
    try {
        stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" + " VALUES(?,?);");
        // Vibrate on by default for ringer, on for notification
        int vibrate = 0;
        vibrate = AudioService.getValueForVibrateSetting(vibrate, AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ONLY_SILENT);
        vibrate |= AudioService.getValueForVibrateSetting(vibrate, AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT);
        loadSetting(stmt, Settings.System.VIBRATE_ON, vibrate);
    } finally {
        if (stmt != null)
            stmt.close();
    }
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement)

Example 12 with SQLiteStatement

use of android.database.sqlite.SQLiteStatement in project android_frameworks_base by ParanoidAndroid.

the class DatabaseHelper method loadGlobalSettings.

private void loadGlobalSettings(SQLiteDatabase db) {
    SQLiteStatement stmt = null;
    try {
        stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)" + " VALUES(?,?);");
        // --- Previously in 'system'
        loadBooleanSetting(stmt, Settings.Global.AIRPLANE_MODE_ON, R.bool.def_airplane_mode_on);
        loadStringSetting(stmt, Settings.Global.AIRPLANE_MODE_RADIOS, R.string.def_airplane_mode_radios);
        loadStringSetting(stmt, Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, R.string.airplane_mode_toggleable_radios);
        loadBooleanSetting(stmt, Settings.Global.ASSISTED_GPS_ENABLED, R.bool.assisted_gps_enabled);
        loadBooleanSetting(stmt, Settings.Global.AUTO_TIME, // Sync time to NITZ
        R.bool.def_auto_time);
        loadBooleanSetting(stmt, Settings.Global.AUTO_TIME_ZONE, // Sync timezone to NITZ
        R.bool.def_auto_time_zone);
        loadSetting(stmt, Settings.Global.STAY_ON_WHILE_PLUGGED_IN, ("1".equals(SystemProperties.get("ro.kernel.qemu")) || mContext.getResources().getBoolean(R.bool.def_stay_on_while_plugged_in)) ? 1 : 0);
        loadIntegerSetting(stmt, Settings.Global.WIFI_SLEEP_POLICY, R.integer.def_wifi_sleep_policy);
        loadSetting(stmt, Settings.Global.MODE_RINGER, AudioManager.RINGER_MODE_NORMAL);
        // --- Previously in 'secure'
        loadBooleanSetting(stmt, Settings.Global.PACKAGE_VERIFIER_ENABLE, R.bool.def_package_verifier_enable);
        loadBooleanSetting(stmt, Settings.Global.WIFI_ON, R.bool.def_wifi_on);
        loadBooleanSetting(stmt, Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, R.bool.def_networks_available_notification_on);
        loadBooleanSetting(stmt, Settings.Global.BLUETOOTH_ON, R.bool.def_bluetooth_on);
        // Enable or disable Cell Broadcast SMS
        loadSetting(stmt, Settings.Global.CDMA_CELL_BROADCAST_SMS, RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED);
        // Data roaming default, based on build
        loadSetting(stmt, Settings.Global.DATA_ROAMING, "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.dataroaming", "false")) ? 1 : 0);
        loadBooleanSetting(stmt, Settings.Global.DEVICE_PROVISIONED, R.bool.def_device_provisioned);
        final int maxBytes = mContext.getResources().getInteger(R.integer.def_download_manager_max_bytes_over_mobile);
        if (maxBytes > 0) {
            loadSetting(stmt, Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE, Integer.toString(maxBytes));
        }
        final int recommendedMaxBytes = mContext.getResources().getInteger(R.integer.def_download_manager_recommended_max_bytes_over_mobile);
        if (recommendedMaxBytes > 0) {
            loadSetting(stmt, Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE, Integer.toString(recommendedMaxBytes));
        }
        // Mobile Data default, based on build
        loadSetting(stmt, Settings.Global.MOBILE_DATA, "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.mobiledata", "true")) ? 1 : 0);
        loadBooleanSetting(stmt, Settings.Global.NETSTATS_ENABLED, R.bool.def_netstats_enabled);
        loadBooleanSetting(stmt, Settings.Global.INSTALL_NON_MARKET_APPS, R.bool.def_install_non_market_apps);
        loadBooleanSetting(stmt, Settings.Global.USB_MASS_STORAGE_ENABLED, R.bool.def_usb_mass_storage_enabled);
        loadIntegerSetting(stmt, Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT, R.integer.def_max_dhcp_retries);
        loadBooleanSetting(stmt, Settings.Global.WIFI_DISPLAY_ON, R.bool.def_wifi_display_on);
        loadStringSetting(stmt, Settings.Global.LOCK_SOUND, R.string.def_lock_sound);
        loadStringSetting(stmt, Settings.Global.UNLOCK_SOUND, R.string.def_unlock_sound);
        loadIntegerSetting(stmt, Settings.Global.POWER_SOUNDS_ENABLED, R.integer.def_power_sounds_enabled);
        loadStringSetting(stmt, Settings.Global.LOW_BATTERY_SOUND, R.string.def_low_battery_sound);
        loadIntegerSetting(stmt, Settings.Global.DOCK_SOUNDS_ENABLED, R.integer.def_dock_sounds_enabled);
        loadStringSetting(stmt, Settings.Global.DESK_DOCK_SOUND, R.string.def_desk_dock_sound);
        loadStringSetting(stmt, Settings.Global.DESK_UNDOCK_SOUND, R.string.def_desk_undock_sound);
        loadStringSetting(stmt, Settings.Global.CAR_DOCK_SOUND, R.string.def_car_dock_sound);
        loadStringSetting(stmt, Settings.Global.CAR_UNDOCK_SOUND, R.string.def_car_undock_sound);
        loadStringSetting(stmt, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND, R.string.def_wireless_charging_started_sound);
        loadIntegerSetting(stmt, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, R.integer.def_dock_audio_media_enabled);
        loadSetting(stmt, Settings.Global.SET_INSTALL_LOCATION, 0);
        loadSetting(stmt, Settings.Global.DEFAULT_INSTALL_LOCATION, PackageHelper.APP_INSTALL_AUTO);
        // Set default cdma emergency tone
        loadSetting(stmt, Settings.Global.EMERGENCY_TONE, 0);
        // Set default cdma call auto retry
        loadSetting(stmt, Settings.Global.CALL_AUTO_RETRY, 0);
        // Set the preferred network mode to target desired value or Default
        // value defined in RILConstants
        int type;
        type = SystemProperties.getInt("ro.telephony.default_network", RILConstants.PREFERRED_NETWORK_MODE);
        loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, type);
    // --- New global settings start here
    } finally {
        if (stmt != null)
            stmt.close();
    }
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement)

Example 13 with SQLiteStatement

use of android.database.sqlite.SQLiteStatement in project android_frameworks_base by ParanoidAndroid.

the class DatabaseHelper method loadVibrateWhenRingingSetting.

private void loadVibrateWhenRingingSetting(SQLiteDatabase db) {
    // The default should be off. VIBRATE_SETTING_ONLY_SILENT should also be ignored here.
    // Phone app should separately check whether AudioManager#getRingerMode() returns
    // RINGER_MODE_VIBRATE, with which the device should vibrate anyway.
    int vibrateSetting = getIntValueFromSystem(db, Settings.System.VIBRATE_ON, AudioManager.VIBRATE_SETTING_OFF);
    boolean vibrateWhenRinging = ((vibrateSetting & 3) == AudioManager.VIBRATE_SETTING_ON);
    SQLiteStatement stmt = null;
    try {
        stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" + " VALUES(?,?);");
        loadSetting(stmt, Settings.System.VIBRATE_WHEN_RINGING, vibrateWhenRinging ? 1 : 0);
    } finally {
        if (stmt != null)
            stmt.close();
    }
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement)

Example 14 with SQLiteStatement

use of android.database.sqlite.SQLiteStatement in project android_frameworks_base by ParanoidAndroid.

the class DatabaseHelper method loadVolumeLevels.

/**
     * Loads the default volume levels. It is actually inserting the index of
     * the volume array for each of the volume controls.
     *
     * @param db the database to insert the volume levels into
     */
private void loadVolumeLevels(SQLiteDatabase db) {
    SQLiteStatement stmt = null;
    try {
        stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" + " VALUES(?,?);");
        loadSetting(stmt, Settings.System.VOLUME_MUSIC, AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_MUSIC]);
        loadSetting(stmt, Settings.System.VOLUME_RING, AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_RING]);
        loadSetting(stmt, Settings.System.VOLUME_SYSTEM, AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_SYSTEM]);
        loadSetting(stmt, Settings.System.VOLUME_VOICE, AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_VOICE_CALL]);
        loadSetting(stmt, Settings.System.VOLUME_ALARM, AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_ALARM]);
        loadSetting(stmt, Settings.System.VOLUME_NOTIFICATION, AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_NOTIFICATION]);
        loadSetting(stmt, Settings.System.VOLUME_BLUETOOTH_SCO, AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]);
        // By default:
        // - ringtones, notification, system and music streams are affected by ringer mode
        // on non voice capable devices (tablets)
        // - ringtones, notification and system streams are affected by ringer mode
        // on voice capable devices (phones)
        int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED);
        if (!mContext.getResources().getBoolean(com.android.internal.R.bool.config_voice_capable)) {
            ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
        }
        loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED, ringerModeAffectedStreams);
        loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED, ((1 << AudioManager.STREAM_MUSIC) | (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM)));
    } finally {
        if (stmt != null)
            stmt.close();
    }
    loadVibrateWhenRingingSetting(db);
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement)

Example 15 with SQLiteStatement

use of android.database.sqlite.SQLiteStatement in project android_frameworks_base by ParanoidAndroid.

the class DatabaseHelper method upgradeVibrateSettingFromNone.

private void upgradeVibrateSettingFromNone(SQLiteDatabase db) {
    int vibrateSetting = getIntValueFromSystem(db, Settings.System.VIBRATE_ON, 0);
    // If the ringer vibrate value is invalid, set it to the default
    if ((vibrateSetting & 3) == AudioManager.VIBRATE_SETTING_OFF) {
        vibrateSetting = AudioService.getValueForVibrateSetting(0, AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT);
    }
    // Apply the same setting to the notification vibrate value
    vibrateSetting = AudioService.getValueForVibrateSetting(vibrateSetting, AudioManager.VIBRATE_TYPE_NOTIFICATION, vibrateSetting);
    SQLiteStatement stmt = null;
    try {
        stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" + " VALUES(?,?);");
        loadSetting(stmt, Settings.System.VIBRATE_ON, vibrateSetting);
    } finally {
        if (stmt != null)
            stmt.close();
    }
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement)

Aggregations

SQLiteStatement (android.database.sqlite.SQLiteStatement)249 Cursor (android.database.Cursor)62 MediumTest (android.test.suitebuilder.annotation.MediumTest)49 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)24 SQLException (android.database.SQLException)21 Test (org.junit.Test)20 Date (java.util.Date)12 TargetApi (android.annotation.TargetApi)8 SQLiteDoneException (android.database.sqlite.SQLiteDoneException)8 SQLiteConstraintException (android.database.sqlite.SQLiteConstraintException)7 SdkSuppress (android.support.test.filters.SdkSuppress)7 ArrayList (java.util.ArrayList)5 SQLiteException (android.database.sqlite.SQLiteException)4 SQLiteFullException (android.database.sqlite.SQLiteFullException)4 Timing (com.newsrob.util.Timing)3 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)3 IOException (java.io.IOException)3 ContentValues (android.content.ContentValues)2 VisibleForTesting (android.support.annotation.VisibleForTesting)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2