diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:33 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:33 -0800 |
commit | 3dec7d563a2f3e1eb967ce2054a00b6620e3558c (patch) | |
tree | aa3b0365c47cb3c1607c0dc76c8d32b4046fc287 /packages | |
parent | 15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (diff) | |
download | frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.zip frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.gz frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.bz2 |
auto import from //depot/cupcake/@137055
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java | 32 | ||||
-rw-r--r-- | packages/SubscribedFeedsProvider/AndroidManifest.xml | 5 | ||||
-rw-r--r-- | packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java | 41 | ||||
-rw-r--r-- | packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java (renamed from packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java) | 98 |
4 files changed, 111 insertions, 65 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 90acd41..f8b5700 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -27,7 +27,6 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteStatement; -import android.location.LocationManager; import android.media.AudioManager; import android.media.AudioService; import android.net.ConnectivityManager; @@ -64,7 +63,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 = 32; + private static final int DATABASE_VERSION = 33; private Context mContext; @@ -354,6 +353,24 @@ class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 32; } + if (upgradeVersion == 32) { + // The Wi-Fi watchdog SSID list is now seeded with the value of + // the property ro.com.android.wifi-watchlist + String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist"); + if (!TextUtils.isEmpty(wifiWatchList)) { + db.beginTransaction(); + try { + db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" + + Settings.Secure.WIFI_WATCHDOG_WATCH_LIST + "','" + + wifiWatchList + "');"); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + upgradeVersion = 33; + } + if (upgradeVersion != currentVersion) { Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion + ", must wipe the settings provider"); @@ -619,11 +636,20 @@ class DatabaseHelper extends SQLiteOpenHelper { R.bool.def_wifi_on); loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, R.bool.def_networks_available_notification_on); - + + String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist"); + if (!TextUtils.isEmpty(wifiWatchList)) { + loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList); + } + // Don't do this. The SystemServer will initialize ADB_ENABLED from a // persistent system property instead. //loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0); + // Allow mock locations default, based on build + loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, + "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0); + stmt.close(); } diff --git a/packages/SubscribedFeedsProvider/AndroidManifest.xml b/packages/SubscribedFeedsProvider/AndroidManifest.xml index 94c4be5..6ecda48 100644 --- a/packages/SubscribedFeedsProvider/AndroidManifest.xml +++ b/packages/SubscribedFeedsProvider/AndroidManifest.xml @@ -6,7 +6,7 @@ <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> <uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_READ" /> <uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_WRITE" /> - + <application android:process="system" android:allowClearUserData="false" android:icon="@drawable/app_icon" @@ -17,7 +17,7 @@ android:multiprocess="false" android:readPermission="android.permission.SUBSCRIBED_FEEDS_READ" android:writePermission="android.permission.SUBSCRIBED_FEEDS_WRITE" /> - <receiver android:name="SubscribedFeedsService"> + <receiver android:name="SubscribedFeedsBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.GTALK_DATA_MESSAGE_RECEIVED" /> <category android:name="GSYNC_TICKLE"/> @@ -29,5 +29,6 @@ <action android:name="com.android.subscribedfeeds.action.REFRESH" /> </intent-filter> </receiver> + <service android:name="SubscribedFeedsIntentService"/> </application> </manifest> diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java new file mode 100644 index 0000000..3513215 --- /dev/null +++ b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java @@ -0,0 +1,41 @@ +/* +** Copyright 2006, 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. +*/ + +package com.android.providers.subscribedfeeds; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +/** + * Handles the XMPP_CONNECTED_ACTION intent by updating all the + * subscribed feeds with the new jabber id and initiating a sync + * for all subscriptions. + * + * Handles the TICKLE_ACTION intent by finding the matching + * subscribed feed and intiating a sync for it. + */ +public class SubscribedFeedsBroadcastReceiver extends BroadcastReceiver { + + private static final String TAG = "Sync"; + + public void onReceive(Context context, Intent intent) { + if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received intent " + intent); + intent.setClass(context, SubscribedFeedsIntentService.class); + context.startService(intent); + } +} diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java index 8d6e272..df599c7 100644 --- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java +++ b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java @@ -1,62 +1,35 @@ -/* -** Copyright 2006, 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. -*/ - package com.android.providers.subscribedfeeds; -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; +import android.content.Intent; +import android.content.Context; import android.content.ContentResolver; import android.content.ContentValues; -import android.content.Context; -import android.content.Intent; import android.content.SharedPreferences; +import android.util.Log; +import android.util.Config; +import android.util.EventLog; +import android.app.IntentService; +import android.provider.Sync; +import android.provider.SubscribedFeeds; +import android.provider.SyncConstValue; import android.database.Cursor; import android.database.sqlite.SQLiteFullException; -import android.net.Uri; +import android.app.AlarmManager; +import android.app.PendingIntent; import android.os.Bundle; -import android.provider.SubscribedFeeds; -import android.provider.Sync; -import android.provider.SyncConstValue; +import android.os.Debug; import android.text.TextUtils; -import android.util.Config; -import android.util.EventLog; -import android.util.Log; +import android.net.Uri; import java.util.ArrayList; import java.util.Calendar; /** - * Handles the XMPP_CONNECTED_ACTION intent by updating all the - * subscribed feeds with the new jabber id and initiating a sync - * for all subscriptions. - * - * Handles the TICKLE_ACTION intent by finding the matching - * subscribed feed and intiating a sync for it. + * A service to handle various intents asynchronously. */ -public class SubscribedFeedsService extends BroadcastReceiver { - +public class SubscribedFeedsIntentService extends IntentService { private static final String TAG = "Sync"; - private static final String SUBSCRIBED_FEEDS_REFRESH_ACTION = - "com.android.subscribedfeeds.action.REFRESH"; - - private static final Intent sSubscribedFeedsRefreshIntent = - new Intent(SUBSCRIBED_FEEDS_REFRESH_ACTION); - private static final String[] sAccountProjection = new String[] {SubscribedFeeds.Accounts._SYNC_ACCOUNT}; @@ -67,11 +40,20 @@ public class SubscribedFeedsService extends BroadcastReceiver { private static final String sSubscribedFeedsPrefs = "subscribedFeeds"; - static final int LOG_TICKLE = 2742; + private static final String GTALK_DATA_MESSAGE_RECEIVED = + "android.intent.action.GTALK_DATA_MESSAGE_RECEIVED"; - public void onReceive(Context context, Intent intent) { - if ("android.intent.action.GTALK_DATA_MESSAGE_RECEIVED".equals( - intent.getAction())) { + private static final String SUBSCRIBED_FEEDS_REFRESH_ACTION = + "com.android.subscribedfeeds.action.REFRESH"; + + private static final int LOG_TICKLE = 2742; + + public SubscribedFeedsIntentService() { + super("SubscribedFeedsIntentService"); + } + + protected void onHandleIntent(Intent intent) { + if (GTALK_DATA_MESSAGE_RECEIVED.equals(intent.getAction())) { boolean fromTrustedServer = intent.getBooleanExtra("from_trusted_server", false); if (fromTrustedServer) { String account = intent.getStringExtra("account"); @@ -89,7 +71,7 @@ public class SubscribedFeedsService extends BroadcastReceiver { + account + " - " + token); } - handleTickle(context, account, token); + handleTickle(this, account, token); } else { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Ignoring tickle -- not from trusted server."); @@ -102,25 +84,23 @@ public class SubscribedFeedsService extends BroadcastReceiver { Log.d(TAG, "Received boot completed action"); } // load the time from the shared preferences and schedule an alarm - long refreshTime = context.getSharedPreferences( + long refreshTime = getSharedPreferences( sSubscribedFeedsPrefs, Context.MODE_WORLD_READABLE).getLong(sRefreshTime, 0); - scheduleRefresh(context, refreshTime); - } else if (sSubscribedFeedsRefreshIntent.getAction().equals( - intent.getAction())) { + scheduleRefresh(this, refreshTime); + } else if (SUBSCRIBED_FEEDS_REFRESH_ACTION.equals(intent.getAction())) { if (Config.LOGD) { Log.d(TAG, "Received sSubscribedFeedsRefreshIntent"); } - handleRefreshAlarm(context); + handleRefreshAlarm(this); } } - private void scheduleRefresh(Context context, long when) { AlarmManager alarmManager = (AlarmManager) context.getSystemService( Context.ALARM_SERVICE); - PendingIntent sender = PendingIntent.getBroadcast(context, - 0, sSubscribedFeedsRefreshIntent, 0); - alarmManager.set(AlarmManager.RTC, when, sender); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, + 0, new Intent(SUBSCRIBED_FEEDS_REFRESH_ACTION), 0); + alarmManager.set(AlarmManager.RTC, when, pendingIntent); } private void handleTickle(Context context, String account, String feed) { @@ -204,10 +184,8 @@ public class SubscribedFeedsService extends BroadcastReceiver { // Schedule a refresh. long refreshTime = Calendar.getInstance().getTimeInMillis() + SUBSCRIPTION_REFRESH_INTERVAL; scheduleRefresh(context, refreshTime); - SharedPreferences preferences = context - .getSharedPreferences(sSubscribedFeedsPrefs, - Context.MODE_WORLD_READABLE); - SharedPreferences.Editor editor = preferences.edit(); + SharedPreferences.Editor editor = context.getSharedPreferences(sSubscribedFeedsPrefs, + Context.MODE_WORLD_READABLE).edit(); editor.putLong(sRefreshTime, refreshTime); editor.commit(); } |