diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
commit | d24b8183b93e781080b2c16c487e60d51c12da31 (patch) | |
tree | fbb89154858984eb8e41556da7e9433040d55cd4 /packages | |
parent | f1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff) | |
download | frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.zip frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.gz frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.bz2 |
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'packages')
5 files changed, 207 insertions, 50 deletions
diff --git a/packages/SettingsProvider/etc/bookmarks.xml b/packages/SettingsProvider/etc/bookmarks.xml index 235e2ed..5fb6608 100644 --- a/packages/SettingsProvider/etc/bookmarks.xml +++ b/packages/SettingsProvider/etc/bookmarks.xml @@ -15,14 +15,44 @@ --> <bookmarks> - <bookmark package="com.android.browser" class="com.android.browser.BrowserActivity" shortcut="b" /> - <bookmark package="com.android.calendar" class="com.android.calendar.LaunchActivity" shortcut="l" /> - <bookmark package="com.android.contacts" class="com.android.contacts.DialtactsContactsEntryActivity" shortcut="c" /> - <bookmark package="com.google.android.gm" class="com.google.android.gm.ConversationListActivityGmail" shortcut="g" /> - <bookmark package="com.android.email" class="com.android.email.activity.Welcome" shortcut="e" /> - <bookmark package="com.android.im" class="com.android.im.app.ChooseAccountActivity" shortcut="i" /> - <bookmark package="com.google.android.apps.maps" class="com.google.android.maps.MapsActivity" shortcut="m" /> - <bookmark package="com.android.music" class="com.android.music.MusicBrowserActivity" shortcut="p" /> - <bookmark package="com.android.mms" class="com.android.mms.ui.ConversationList" shortcut="s" /> - <bookmark package="com.google.android.youtube" class="com.google.android.youtube.HomePage" shortcut="y" /> -</bookmarks> + <bookmark + package="com.android.browser" + class="com.android.browser.BrowserActivity" + shortcut="b" /> + <bookmark + package="com.android.contacts" + class="com.android.contacts.DialtactsContactsEntryActivity" + shortcut="c" /> + <bookmark + package="com.android.email" + class="com.android.email.activity.Welcome" + shortcut="e" /> + <bookmark + package="com.google.android.gm" + class="com.google.android.gm.ConversationListActivityGmail" + shortcut="g" /> + <bookmark + package="com.android.providers.im" + class="com.android.providers.im.LandingPage" + shortcut="i" /> + <bookmark + package="com.android.calendar" + class="com.android.calendar.LaunchActivity" + shortcut="l" /> + <bookmark + package="com.google.android.apps.maps" + class="com.google.android.maps.MapsActivity" + shortcut="m" /> + <bookmark + package="com.android.music" + class="com.android.music.MusicBrowserActivity" + shortcut="p" /> + <bookmark + package="com.android.mms" + class="com.android.mms.ui.ConversationList" + shortcut="s" /> + <bookmark + package="com.google.android.youtube" + class="com.google.android.youtube.HomePage" + shortcut="y" /> +</bookmarks>
\ No newline at end of file diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml new file mode 100644 index 0000000..72d88e2 --- /dev/null +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2009, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources> + <bool name="def_dim_screen">true</bool> + <integer name="def_screen_off_timeout">60000</integer> + <bool name="def_airplane_mode_on">false</bool> + <!-- Comma-separated list of bluetooth, wifi, and cell. --> + <string name="def_airplane_mode_radios">cell,bluetooth,wifi</string> + <bool name="def_auto_time">true</bool> + <bool name="def_accelerometer_rotation">true</bool> + <!-- Default screen brightness, from 0 to 255. 102 is 40%. --> + <integer name="def_screen_brightness">102</integer> + <fraction name="def_window_animation_scale">0%</fraction> + <fraction name="def_window_transition_scale">0%</fraction> + + <bool name="def_bluetooth_on">false</bool> + <bool name="def_install_non_market_apps">false</bool> + <!-- Comma-separated list of providers. --> + <string name="def_location_providers_allowed">network</string> + <!-- 0 == mobile, 1 == wifi. --> + <integer name="def_network_preference">1</integer> + <bool name="def_usb_mass_storage_enabled">true</bool> + <bool name="def_wifi_on">false</bool> + <bool name="def_networks_available_notification_on">true</bool> +</resources> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index e2ea85b..90acd41 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; +import android.content.res.Resources; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; @@ -63,7 +64,7 @@ class DatabaseHelper extends SQLiteOpenHelper { private static final String TAG = "SettingsProvider"; private static final String DATABASE_NAME = "settings.db"; - private static final int DATABASE_VERSION = 31; + private static final int DATABASE_VERSION = 32; private Context mContext; @@ -332,6 +333,27 @@ class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 31; } + if (upgradeVersion == 31) { + /* + * Animations are now turned off by default. + */ + db.beginTransaction(); + try { + db.execSQL("DELETE FROM system WHERE name='" + + Settings.System.WINDOW_ANIMATION_SCALE + "'"); + db.execSQL("DELETE FROM system WHERE name='" + + Settings.System.TRANSITION_ANIMATION_SCALE + "'"); + SQLiteStatement stmt = db.compileStatement("INSERT INTO system(name,value)" + + " VALUES(?,?);"); + loadDefaultAnimationSettings(stmt); + stmt.close(); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + upgradeVersion = 32; + } + if (upgradeVersion != currentVersion) { Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion + ", must wipe the settings provider"); @@ -529,28 +551,31 @@ class DatabaseHelper extends SQLiteOpenHelper { SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" + " VALUES(?,?);"); - loadSetting(stmt, Settings.System.DIM_SCREEN, 1); + Resources r = mContext.getResources(); + loadBooleanSetting(stmt, Settings.System.DIM_SCREEN, + R.bool.def_dim_screen); loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN, "1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 0); - loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, 60000); - // Allow airplane mode to turn off cell radio - loadSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS, - Settings.System.RADIO_CELL + "," - + Settings.System.RADIO_BLUETOOTH + "," + Settings.System.RADIO_WIFI); + loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, + R.integer.def_screen_off_timeout); + + loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON, + R.bool.def_airplane_mode_on); - loadSetting(stmt, Settings.System.AIRPLANE_MODE_ON, 0); + loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS, + R.string.def_airplane_mode_radios); - loadSetting(stmt, Settings.System.AUTO_TIME, 1); // Sync time to NITZ + loadBooleanSetting(stmt, Settings.System.AUTO_TIME, + R.bool.def_auto_time); // Sync time to NITZ - // Set default brightness to 40% - loadSetting(stmt, Settings.System.SCREEN_BRIGHTNESS, - (int) (android.os.Power.BRIGHTNESS_ON * 0.4f)); + loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS, + R.integer.def_screen_brightness); - // Enable normal window animations (menus, toasts); disable - // activity transition animations. - loadSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE, "1"); - loadSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE, "1"); + loadDefaultAnimationSettings(stmt); + loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION, + R.bool.def_accelerometer_rotation); + // Default date format based on build loadSetting(stmt, Settings.System.DATE_FORMAT, SystemProperties.get("ro.com.android.dateformat", @@ -558,12 +583,19 @@ class DatabaseHelper extends SQLiteOpenHelper { stmt.close(); } + private void loadDefaultAnimationSettings(SQLiteStatement stmt) { + loadFractionSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE, + R.fraction.def_window_animation_scale, 1); + loadFractionSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE, + R.fraction.def_window_transition_scale, 1); + } + private void loadSecureSettings(SQLiteDatabase db) { SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" + " VALUES(?,?);"); - // Bluetooth off - loadSetting(stmt, Settings.Secure.BLUETOOTH_ON, 0); + loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON, + R.bool.def_bluetooth_on); // Data roaming default, based on build loadSetting(stmt, Settings.Secure.DATA_ROAMING, @@ -571,22 +603,22 @@ class DatabaseHelper extends SQLiteOpenHelper { SystemProperties.get("ro.com.android.dataroaming", "false")) ? 1 : 0); - // Don't allow non-market apps to be installed - loadSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, 0); + loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, + R.bool.def_install_non_market_apps); - // Set the default location providers to network based (cell-id) - loadSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, - LocationManager.NETWORK_PROVIDER); + loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, + R.string.def_location_providers_allowed); - loadSetting(stmt, Settings.Secure.NETWORK_PREFERENCE, - ConnectivityManager.DEFAULT_NETWORK_PREFERENCE); - - // USB mass storage on by default - loadSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED, 1); + loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE, + R.integer.def_network_preference); - // WIFI on, notify about available networks - loadSetting(stmt, Settings.Secure.WIFI_ON, 0); - loadSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1); + loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED, + R.bool.def_usb_mass_storage_enabled); + + loadBooleanSetting(stmt, Settings.Secure.WIFI_ON, + R.bool.def_wifi_on); + loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, + R.bool.def_networks_available_notification_on); // Don't do this. The SystemServer will initialize ADB_ENABLED from a // persistent system property instead. @@ -600,4 +632,23 @@ class DatabaseHelper extends SQLiteOpenHelper { stmt.bindString(2, value.toString()); stmt.execute(); } + + private void loadStringSetting(SQLiteStatement stmt, String key, int resid) { + loadSetting(stmt, key, mContext.getResources().getString(resid)); + } + + private void loadBooleanSetting(SQLiteStatement stmt, String key, int resid) { + loadSetting(stmt, key, + mContext.getResources().getBoolean(resid) ? "1" : "0"); + } + + private void loadIntegerSetting(SQLiteStatement stmt, String key, int resid) { + loadSetting(stmt, key, + Integer.toString(mContext.getResources().getInteger(resid))); + } + + private void loadFractionSetting(SQLiteStatement stmt, String key, int resid, int base) { + loadSetting(stmt, key, + Float.toString(mContext.getResources().getFraction(resid, base, base))); + } } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 35bf6b0..333a450 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -40,6 +40,9 @@ public class SettingsProvider extends ContentProvider { private static final String TAG = "SettingsProvider"; private static final boolean LOCAL_LOGV = false; + private static final String TABLE_FAVORITES = "favorites"; + private static final String TABLE_OLD_FAVORITES = "old_favorites"; + private DatabaseHelper mOpenHelper; /** @@ -47,7 +50,7 @@ public class SettingsProvider extends ContentProvider { * used to access the corresponding database rows. */ private static class SqlArguments { - public final String table; + public String table; public final String where; public final String[] args; @@ -175,17 +178,30 @@ public class SettingsProvider extends ContentProvider { @Override public Cursor query(Uri url, String[] select, String where, String[] whereArgs, String sort) { SqlArguments args = new SqlArguments(url, where, whereArgs); + SQLiteDatabase db = mOpenHelper.getReadableDatabase(); + // The favorites table was moved from this provider to a provider inside Home // Home still need to query this table to upgrade from pre-cupcake builds // However, a cupcake+ build with no data does not contain this table which will // cause an exception in the SQL stack. The following line is a special case to // let the caller of the query have a chance to recover and avoid the exception - if ("favorites".equals(args.table)) return null; + if (TABLE_FAVORITES.equals(args.table)) { + return null; + } else if (TABLE_OLD_FAVORITES.equals(args.table)) { + args.table = TABLE_FAVORITES; + Cursor cursor = db.rawQuery("PRAGMA table_info(favorites);", null); + if (cursor != null) { + boolean exists = cursor.getCount() > 0; + cursor.close(); + if (!exists) return null; + } else { + return null; + } + } SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); qb.setTables(args.table); - SQLiteDatabase db = mOpenHelper.getReadableDatabase(); Cursor ret = qb.query(db, select, args.where, args.args, null, null, sort); ret.setNotificationUri(getContext().getContentResolver(), url); return ret; @@ -206,6 +222,9 @@ public class SettingsProvider extends ContentProvider { @Override public int bulkInsert(Uri uri, ContentValues[] values) { SqlArguments args = new SqlArguments(uri); + if (TABLE_FAVORITES.equals(args.table)) { + return 0; + } checkWritePermissions(args); SQLiteDatabase db = mOpenHelper.getWritableDatabase(); @@ -228,6 +247,9 @@ public class SettingsProvider extends ContentProvider { @Override public Uri insert(Uri url, ContentValues initialValues) { SqlArguments args = new SqlArguments(url); + if (TABLE_FAVORITES.equals(args.table)) { + return null; + } checkWritePermissions(args); SQLiteDatabase db = mOpenHelper.getWritableDatabase(); @@ -243,6 +265,11 @@ public class SettingsProvider extends ContentProvider { @Override public int delete(Uri url, String where, String[] whereArgs) { SqlArguments args = new SqlArguments(url, where, whereArgs); + if (TABLE_FAVORITES.equals(args.table)) { + return 0; + } else if (TABLE_OLD_FAVORITES.equals(args.table)) { + args.table = TABLE_FAVORITES; + } checkWritePermissions(args); SQLiteDatabase db = mOpenHelper.getWritableDatabase(); @@ -255,6 +282,9 @@ public class SettingsProvider extends ContentProvider { @Override public int update(Uri url, ContentValues initialValues, String where, String[] whereArgs) { SqlArguments args = new SqlArguments(url, where, whereArgs); + if (TABLE_FAVORITES.equals(args.table)) { + return 0; + } checkWritePermissions(args); SQLiteDatabase db = mOpenHelper.getWritableDatabase(); diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java index 4a1de59..8d6e272 100644 --- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java +++ b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java @@ -25,6 +25,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; +import android.database.sqlite.SQLiteFullException; import android.net.Uri; import android.os.Bundle; import android.provider.SubscribedFeeds; @@ -189,11 +190,15 @@ public class SubscribedFeedsService extends BroadcastReceiver { // mark the feeds dirty, by setting the accounts to the same value, // which will trigger a sync. - ContentValues values = new ContentValues(); - for (String account : accounts) { - values.put(SyncConstValue._SYNC_ACCOUNT, account); - contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values, - SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?", new String[] {account}); + try { + ContentValues values = new ContentValues(); + for (String account : accounts) { + values.put(SyncConstValue._SYNC_ACCOUNT, account); + contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values, + SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?", new String[] {account}); + } + } catch (SQLiteFullException e) { + Log.w(TAG, "disk full while trying to mark the feeds as dirty, skipping"); } // Schedule a refresh. |