diff options
8 files changed, 236 insertions, 204 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 2a47b42..56a0104 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -148,7 +148,7 @@ public final class Settings { @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_WIFI_SETTINGS = "android.settings.WIFI_SETTINGS"; - + /** * Activity Action: Show settings to allow configuration of a static IP * address for Wi-Fi. @@ -305,7 +305,7 @@ public final class Settings { @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_QUICK_LAUNCH_SETTINGS = "android.settings.QUICK_LAUNCH_SETTINGS"; - + /** * Activity Action: Show settings to manage installed applications. * <p> @@ -319,7 +319,7 @@ public final class Settings { @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS = "android.settings.MANAGE_APPLICATIONS_SETTINGS"; - + /** * Activity Action: Show settings for system update functionality. * <p> @@ -329,7 +329,7 @@ public final class Settings { * Input: Nothing. * <p> * Output: Nothing. - * + * * @hide */ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) @@ -349,7 +349,7 @@ public final class Settings { @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_SYNC_SETTINGS = "android.settings.SYNC_SETTINGS"; - + /** * Activity Action: Show settings for selecting the network operator. * <p> @@ -404,7 +404,7 @@ public final class Settings { @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_MEMORY_CARD_SETTINGS = "android.settings.MEMORY_CARD_SETTINGS"; - + // End of Intent actions for Settings private static final String JID_RESOURCE_PREFIX = "android"; @@ -495,7 +495,7 @@ public final class Settings { public static final String SYS_PROP_SETTING_VERSION = "sys.settings_system_version"; private static volatile NameValueCache mNameValueCache = null; - + private static final HashSet<String> MOVED_TO_SECURE; static { MOVED_TO_SECURE = new HashSet<String>(30); @@ -901,12 +901,12 @@ public final class Settings { * plugged in. */ public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1; - + /** * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep. */ public static final int WIFI_SLEEP_POLICY_NEVER = 2; - + /** * Whether to use static IP and other static network attributes. * <p> @@ -1115,12 +1115,12 @@ public final class Settings { * Note: This is a one-off setting that will be removed in the future * when there is profile support. For this reason, it is kept hidden * from the public APIs. - * + * * @hide */ - public static final String NOTIFICATIONS_USE_RING_VOLUME = + public static final String NOTIFICATIONS_USE_RING_VOLUME = "notifications_use_ring_volume"; - + /** * The mapping of stream type (integer) to its setting. */ @@ -1188,7 +1188,7 @@ public final class Settings { * feature converts two spaces to a "." and space. */ public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate"; - + /** * Setting to showing password characters in text editors. 1 = On, 0 = Off */ @@ -1270,13 +1270,13 @@ public final class Settings { * boolean (1 or 0). */ public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled"; - + /** * Whether the haptic feedback (long presses, ...) are enabled. The value is * boolean (1 or 0). */ public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled"; - + // Settings moved to Settings.Secure /** @@ -1321,7 +1321,7 @@ public final class Settings { */ @Deprecated public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS; - + /** * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED} * instead @@ -1334,7 +1334,7 @@ public final class Settings { */ @Deprecated public static final String LOGGING_ID = Secure.LOGGING_ID; - + /** * @deprecated Use {@link android.provider.Settings.Secure#NETWORK_PREFERENCE} instead */ @@ -1374,7 +1374,7 @@ public final class Settings { */ @Deprecated public static final String USB_MASS_STORAGE_ENABLED = Secure.USB_MASS_STORAGE_ENABLED; - + /** * @deprecated Use {@link android.provider.Settings.Secure#USE_GOOGLE_MAIL} instead */ @@ -1412,7 +1412,7 @@ public final class Settings { @Deprecated public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY; - + /** * @deprecated Use {@link android.provider.Settings.Secure#WIFI_NUM_OPEN_NETWORKS_KEPT} * instead @@ -1448,7 +1448,7 @@ public final class Settings { @Deprecated public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS = Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS; - + /** * @deprecated Use * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead @@ -1824,19 +1824,19 @@ public final class Settings { * Whether the device has been provisioned (0 = false, 1 = true) */ public static final String DEVICE_PROVISIONED = "device_provisioned"; - + /** * List of input methods that are currently enabled. This is a string * containing the IDs of all enabled input methods, each ID separated * by ':'. */ public static final String ENABLED_INPUT_METHODS = "enabled_input_methods"; - + /** * Host name and port for a user-selected proxy. */ public static final String HTTP_PROXY = "http_proxy"; - + /** * Whether the package installer should allow installation of apps downloaded from * sources other than the Android Market (vending machine). @@ -1845,12 +1845,12 @@ public final class Settings { * 0 = only allow installing from the Android Market */ public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps"; - + /** * Comma-separated list of location providers that activities may access. */ public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed"; - + /** * The Logging ID (a unique 64-bit value) as a hex string. * Used as a pseudonymous identifier for logging. @@ -1872,19 +1872,19 @@ public final class Settings { * connectivity service should touch this. */ public static final String NETWORK_PREFERENCE = "network_preference"; - - /** + + /** */ public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled"; - - /** + + /** */ public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update"; - - /** + + /** */ public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url"; - + /** * Settings classname to launch when Settings is clicked from All * Applications. Needed because of user testing between the old @@ -1892,18 +1892,18 @@ public final class Settings { */ // TODO: 881807 public static final String SETTINGS_CLASSNAME = "settings_classname"; - + /** * USB Mass Storage Enabled */ public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled"; - + /** * If this setting is set (to anything), then all references * to Gmail on the device must change to Google Mail. */ public static final String USE_GOOGLE_MAIL = "use_google_mail"; - + /** * If accessibility is enabled. */ @@ -1926,64 +1926,64 @@ public final class Settings { */ public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = "wifi_networks_available_notification_on"; - + /** * Delay (in seconds) before repeating the Wi-Fi networks available notification. * Connecting to a network will reset the timer. */ public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = "wifi_networks_available_repeat_delay"; - + /** * The number of radio channels that are allowed in the local * 802.11 regulatory domain. * @hide */ public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels"; - + /** * When the number of open networks exceeds this number, the * least-recently-used excess networks will be removed. */ public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept"; - + /** * Whether the Wi-Fi should be on. Only the Wi-Fi service should touch this. */ public static final String WIFI_ON = "wifi_on"; - + /** * The acceptable packet loss percentage (range 0 - 100) before trying * another AP on the same network. */ public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE = "wifi_watchdog_acceptable_packet_loss_percentage"; - + /** * The number of access points required for a network in order for the * watchdog to monitor it. */ public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count"; - + /** * The delay between background checks. */ public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS = "wifi_watchdog_background_check_delay_ms"; - + /** * Whether the Wi-Fi watchdog is enabled for background checking even * after it thinks the user has connected to a good access point. */ public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED = "wifi_watchdog_background_check_enabled"; - + /** * The timeout for a background ping */ public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS = "wifi_watchdog_background_check_timeout_ms"; - + /** * The number of initial pings to perform that *may* be ignored if they * fail. Again, if these fail, they will *not* be used in packet loss @@ -1992,7 +1992,7 @@ public final class Settings { */ public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT = "wifi_watchdog_initial_ignored_ping_count"; - + /** * The maximum number of access points (per network) to attempt to test. * If this number is reached, the watchdog will no longer monitor the @@ -2000,7 +2000,7 @@ public final class Settings { * networks containing multiple APs whose DNS does not respond to pings. */ public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks"; - + /** * Whether the Wi-Fi watchdog is enabled. */ @@ -2015,24 +2015,24 @@ public final class Settings { * The number of pings to test if an access point is a good connection. */ public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count"; - + /** * The delay between pings. */ public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms"; - + /** * The timeout per ping. */ public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms"; - + /** * The maximum number of times we will retry a connection to an access * point for which we have failed in acquiring an IP address from DHCP. * A value of N means that we will make N+1 connection attempts in all. */ public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count"; - + /** * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile * data connectivity to be established after a disconnect from Wi-Fi. @@ -2062,21 +2062,14 @@ public final class Settings { public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode"; /** - * represents current active phone class - * 1 = GSM-Phone, 0 = CDMA-Phone - * @hide - */ - public static final String CURRENT_ACTIVE_PHONE = "current_active_phone"; - - /** - * The preferred network mode 7 = Global - * 6 = EvDo only - * 5 = CDMA w/o EvDo - * 4 = CDMA / EvDo auto - * 3 = GSM / WCDMA auto - * 2 = WCDMA only - * 1 = GSM only - * 0 = GSM / WCDMA preferred + * The preferred network mode 7 = Global + * 6 = EvDo only + * 5 = CDMA w/o EvDo + * 4 = CDMA / EvDo auto + * 3 = GSM / WCDMA auto + * 2 = WCDMA only + * 1 = GSM only + * 0 = GSM / WCDMA preferred * @hide */ public static final String PREFERRED_NETWORK_MODE = @@ -2142,7 +2135,7 @@ public final class Settings { allowedProviders.startsWith(provider + ",") || allowedProviders.endsWith("," + provider)); } - return false; + return false; } /** @@ -2166,7 +2159,7 @@ public final class Settings { putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider); } } - + /** * Gservices settings, containing the network names for Google's * various services. This table holds simple name/addr pairs. @@ -2294,7 +2287,7 @@ public final class Settings { * Event tags from the kernel event log to upload during checkin. */ public static final String CHECKIN_EVENTS = "checkin_events"; - + /** * Event tags for list of services to upload during checkin. */ @@ -2984,7 +2977,7 @@ public final class Settings { public static final String BATTERY_DISCHARGE_DURATION_THRESHOLD = "battery_discharge_duration_threshold"; public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold"; - + /** * An email address that anr bugreports should be sent to. */ @@ -3128,7 +3121,7 @@ public final class Settings { /** * Add a new bookmark to the system. - * + * * @param cr The ContentResolver to query. * @param intent The desired target of the bookmark. * @param title Bookmark title that is shown to the user; null if none @@ -3193,7 +3186,7 @@ public final class Settings { /** * Return the title as it should be displayed to the user. This takes * care of localizing bookmarks that point to activities. - * + * * @param context A context. * @param cursor A cursor pointing to the row whose title should be * returned. The cursor must contain at least the {@link #TITLE} @@ -3208,24 +3201,24 @@ public final class Settings { throw new IllegalArgumentException( "The cursor must contain the TITLE and INTENT columns."); } - + String title = cursor.getString(titleColumn); if (!TextUtils.isEmpty(title)) { return title; } - + String intentUri = cursor.getString(intentColumn); if (TextUtils.isEmpty(intentUri)) { return ""; } - + Intent intent; try { intent = Intent.getIntent(intentUri); } catch (URISyntaxException e) { return ""; } - + PackageManager packageManager = context.getPackageManager(); ResolveInfo info = packageManager.resolveActivity(intent, 0); return info != null ? info.loadLabel(packageManager) : ""; diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index b9d567c..8df65f9 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -65,7 +65,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 = 34; - + private Context mContext; public DatabaseHelper(Context context) { @@ -81,7 +81,7 @@ class DatabaseHelper extends SQLiteOpenHelper { ");"); db.execSQL("CREATE INDEX secureIndex1 ON secure (name);"); } - + @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE system (" + @@ -134,7 +134,7 @@ class DatabaseHelper extends SQLiteOpenHelper { public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) { Log.w(TAG, "Upgrading settings database from version " + oldVersion + " to " + currentVersion); - + int upgradeVersion = oldVersion; // Pattern for upgrade blocks: @@ -143,7 +143,7 @@ class DatabaseHelper extends SQLiteOpenHelper { // .. your upgrade logic.. // upgradeVersion = [the DATABASE_VERSION you set] // } - + if (upgradeVersion == 20) { /* * Version 21 is part of the volume control refresh. There is no @@ -156,7 +156,7 @@ class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 21; } - + if (upgradeVersion < 22) { upgradeVersion = 22; // Upgrade the lock gesture storage location and format @@ -186,7 +186,7 @@ class DatabaseHelper extends SQLiteOpenHelper { } upgradeVersion = 24; } - + if (upgradeVersion == 24) { db.beginTransaction(); try { @@ -213,7 +213,7 @@ class DatabaseHelper extends SQLiteOpenHelper { } upgradeVersion = 26; } - + if (upgradeVersion == 26) { // This introduces the new secure settings table. db.beginTransaction(); @@ -225,12 +225,12 @@ class DatabaseHelper extends SQLiteOpenHelper { } upgradeVersion = 27; } - + if (upgradeVersion == 27) { // Copy settings values from 'system' to 'secure' and delete them from 'system' SQLiteStatement insertStmt = null; SQLiteStatement deleteStmt = null; - + db.beginTransaction(); try { insertStmt = @@ -271,11 +271,11 @@ class DatabaseHelper extends SQLiteOpenHelper { Settings.Secure.WIFI_WATCHDOG_PING_DELAY_MS, Settings.Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS, }; - + for (String setting : settingsToMove) { insertStmt.bindString(1, setting); insertStmt.execute(); - + deleteStmt.bindString(1, setting); deleteStmt.execute(); } @@ -291,7 +291,7 @@ class DatabaseHelper extends SQLiteOpenHelper { } upgradeVersion = 28; } - + if (upgradeVersion == 28 || upgradeVersion == 29) { // Note: The upgrade to 28 was flawed since it didn't delete the old // setting first before inserting. Combining 28 and 29 with the @@ -313,10 +313,10 @@ class DatabaseHelper extends SQLiteOpenHelper { } finally { db.endTransaction(); } - + upgradeVersion = 30; } - + if (upgradeVersion == 30) { /* * Upgrade 31 clears the title for all quick launch shortcuts so the @@ -373,7 +373,7 @@ class DatabaseHelper extends SQLiteOpenHelper { } upgradeVersion = 33; } - + if (upgradeVersion == 33) { // Set the default zoom controls to: tap-twice to bring up +/- db.beginTransaction(); @@ -405,7 +405,7 @@ class DatabaseHelper extends SQLiteOpenHelper { } private void upgradeLockPatternLocation(SQLiteDatabase db) { - Cursor c = db.query("system", new String[] {"_id", "value"}, "name='lock_pattern'", + Cursor c = db.query("system", new String[] {"_id", "value"}, "name='lock_pattern'", null, null, null, null); if (c.getCount() > 0) { c.moveToFirst(); @@ -414,7 +414,7 @@ class DatabaseHelper extends SQLiteOpenHelper { // Convert lock pattern try { LockPatternUtils lpu = new LockPatternUtils(mContext.getContentResolver()); - List<LockPatternView.Cell> cellPattern = + List<LockPatternView.Cell> cellPattern = LockPatternUtils.stringToPattern(lockPattern); lpu.saveLockPattern(cellPattern); } catch (IllegalArgumentException e) { @@ -542,12 +542,12 @@ class DatabaseHelper extends SQLiteOpenHelper { AudioManager.RINGER_MODE_NORMAL); loadVibrateSetting(db, false); - + // By default, only the ring/notification and system streams are affected loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED, (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM)); - + loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED, ((1 << AudioManager.STREAM_MUSIC) | (1 << AudioManager.STREAM_RING) | @@ -561,7 +561,7 @@ class DatabaseHelper extends SQLiteOpenHelper { if (deleteOld) { db.execSQL("DELETE FROM system WHERE name='" + Settings.System.VIBRATE_ON + "'"); } - + SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" + " VALUES(?,?);"); @@ -576,79 +576,78 @@ class DatabaseHelper extends SQLiteOpenHelper { private void loadSettings(SQLiteDatabase db) { loadSystemSettings(db); - loadSecureSettings(db); + loadSecureSettings(db); } - + private void loadSystemSettings(SQLiteDatabase db) { SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" + " VALUES(?,?);"); - + Resources r = mContext.getResources(); - loadSetting(stmt, Settings.Secure.CURRENT_ACTIVE_PHONE, - RILConstants.CDMA_PHONE); + loadBooleanSetting(stmt, Settings.System.DIM_SCREEN, R.bool.def_dim_screen); - loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN, + loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN, "1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 0); 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); - + loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS, R.string.def_airplane_mode_radios); - + loadBooleanSetting(stmt, Settings.System.AUTO_TIME, R.bool.def_auto_time); // Sync time to NITZ - + loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS, R.integer.def_screen_brightness); - + 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", + SystemProperties.get("ro.com.android.dateformat", "MM-dd-yyyy")); 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(?,?);"); - + loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON, R.bool.def_bluetooth_on); - + // Data roaming default, based on build - loadSetting(stmt, Settings.Secure.DATA_ROAMING, + loadSetting(stmt, Settings.Secure.DATA_ROAMING, "true".equalsIgnoreCase( - SystemProperties.get("ro.com.android.dataroaming", - "false")) ? 1 : 0); - + SystemProperties.get("ro.com.android.dataroaming", + "false")) ? 1 : 0); + loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, R.bool.def_install_non_market_apps); - + loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, R.string.def_location_providers_allowed); - + loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE, R.integer.def_network_preference); - + 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, @@ -660,7 +659,7 @@ class DatabaseHelper extends SQLiteOpenHelper { } // Set the preferred network mode to 0 = Global, CDMA default - loadSetting(stmt, Settings.Secure.PREFERRED_NETWORK_MODE, + loadSetting(stmt, Settings.Secure.PREFERRED_NETWORK_MODE, RILConstants.PREFERRED_NETWORK_MODE); // Enable or disable Cell Broadcast SMS @@ -668,17 +667,17 @@ class DatabaseHelper extends SQLiteOpenHelper { RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED); // Set the preferred cdma subscription to 0 = Subscription from RUIM, when available - loadSetting(stmt, Settings.Secure.PREFERRED_CDMA_SUBSCRIPTION, + loadSetting(stmt, Settings.Secure.PREFERRED_CDMA_SUBSCRIPTION, RILConstants.PREFERRED_CDMA_SUBSCRIPTION); // 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, + loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0); - + stmt.close(); } @@ -687,21 +686,21 @@ 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/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java index 1483522..7d600f0 100644 --- a/telephony/java/android/telephony/CellLocation.java +++ b/telephony/java/android/telephony/CellLocation.java @@ -62,13 +62,10 @@ public abstract class CellLocation { * @hide */ public static CellLocation newFromBundle(Bundle bundle) { - // TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0)) - // instead of SystemProperties??? - - // NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup - // ITelephony have not been created - if (RILConstants.CDMA_PHONE == SystemProperties.getInt( - Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) { + // TelephonyManager.getDefault().getPhoneType() handles the case when + // ITelephony interface is not up yet. + int type = TelephonyManager.getDefault().getPhoneType(); + if (type == RILConstants.CDMA_PHONE) { return new CdmaCellLocation(bundle); } else { return new GsmCellLocation(bundle); @@ -85,13 +82,10 @@ public abstract class CellLocation { * */ public static CellLocation getEmpty() { - // TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0)) - // instead of SystemProperties??? - - // NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup - // ITelephony have not been created - if (RILConstants.CDMA_PHONE == SystemProperties.getInt( - Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) { + // TelephonyManager.getDefault().getPhoneType() handles the case when + // ITelephony interface is not up yet. + int type = TelephonyManager.getDefault().getPhoneType(); + if (type == RILConstants.CDMA_PHONE) { return new CdmaCellLocation(); } else { return new GsmCellLocation(); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 49a7750..a79eb3a 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -16,26 +16,24 @@ package android.telephony; -import com.android.internal.telephony.*; - -import java.util.ArrayList; -import java.util.List; - -import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant; +import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; -import android.telephony.CellLocation; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.ITelephonyRegistry; +import com.android.internal.telephony.Phone; +import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.TelephonyProperties; +import java.util.List; + /** * Provides access to information about the telephony services on * the device. Applications can use the methods in this class to @@ -239,10 +237,10 @@ public class TelephonyManager { /** * Returns the neighboring cell information of the device. - * + * * @return List of NeighboringCellInfo or null if info unavailable. - * - * <p>Requires Permission: + * + * <p>Requires Permission: * (@link android.Manifest.permission#ACCESS_COARSE_UPDATES} */ public List<NeighboringCellInfo> getNeighboringCellInfo() { @@ -251,24 +249,25 @@ public class TelephonyManager { } catch (RemoteException ex) { } return null; - + } - + /** * No phone module + * */ public static final int PHONE_TYPE_NONE = 0; /** * GSM phone */ - public static final int PHONE_TYPE_GSM = 1; + public static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE; /** * CDMA phone * @hide */ - public static final int PHONE_TYPE_CDMA = 2; + public static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE; /** * Returns a constant indicating the device phone type. @@ -279,16 +278,41 @@ public class TelephonyManager { */ public int getPhoneType() { try{ - if(getITelephony().getActivePhoneType() == RILConstants.CDMA_PHONE) { - return PHONE_TYPE_CDMA; + ITelephony telephony = getITelephony(); + if (telephony != null) { + if(telephony.getActivePhoneType() == RILConstants.CDMA_PHONE) { + return PHONE_TYPE_CDMA; + } else { + return PHONE_TYPE_GSM; + } } else { - return PHONE_TYPE_GSM; + // This can happen when the ITelephony interface is not up yet. + return getPhoneTypeFromProperty(); } - }catch(RemoteException ex){ - return PHONE_TYPE_NONE; + } catch(RemoteException ex){ + // This shouldn't happen in the normal case, as a backup we + // read from the system property. + return getPhoneTypeFromProperty(); } } + + private int getPhoneTypeFromProperty() { + int type = + SystemProperties.getInt(TelephonyProperties.CURRENT_ACTIVE_PHONE, + getPhoneTypeFromNetworkType()); + return type; + } + + private int getPhoneTypeFromNetworkType() { + // When the system property CURRENT_ACTIVE_PHONE, has not been set, + // use the system property for default network type. + // This is a fail safe, and can only happen at first boot. + int mode = SystemProperties.getInt("ro.telephony.default_network", -1); + if (mode == -1) + return PHONE_TYPE_NONE; + return PhoneFactory.getPhoneType(mode); + } // // // Current Network @@ -640,8 +664,10 @@ public class TelephonyManager { /** Data connection activity: Currently both sending and receiving * IP PPP traffic. */ public static final int DATA_ACTIVITY_INOUT = DATA_ACTIVITY_IN | DATA_ACTIVITY_OUT; - /** Data connection is active, but physical link is down */ - /** @hide */ + /** + * Data connection is active, but physical link is down + * @hide + */ public static final int DATA_ACTIVITY_DORMANT = 0x00000004; /** diff --git a/telephony/java/com/android/internal/telephony/PhoneFactory.java b/telephony/java/com/android/internal/telephony/PhoneFactory.java index 3beb60a..a84f74e 100644 --- a/telephony/java/com/android/internal/telephony/PhoneFactory.java +++ b/telephony/java/com/android/internal/telephony/PhoneFactory.java @@ -107,33 +107,49 @@ public class PhoneFactory { //reads the system properties and makes commandsinterface sCommandsInterface = new RIL(context, networkMode, cdmaSubscription); - switch(networkMode) { - case RILConstants.NETWORK_MODE_WCDMA_PREF: - case RILConstants.NETWORK_MODE_GSM_ONLY: - case RILConstants.NETWORK_MODE_WCDMA_ONLY: - case RILConstants.NETWORK_MODE_GSM_UMTS: - sProxyPhone = new PhoneProxy(new GSMPhone(context, - sCommandsInterface, sPhoneNotifier)); - Log.i(LOG_TAG, "Creating GSMPhone"); - break; - case RILConstants.NETWORK_MODE_CDMA: - case RILConstants.NETWORK_MODE_CDMA_NO_EVDO: - case RILConstants.NETWORK_MODE_EVDO_NO_CDMA: - sProxyPhone = new PhoneProxy(new CDMAPhone(context, - sCommandsInterface, sPhoneNotifier)); - Log.i(LOG_TAG, "Creating CDMAPhone"); - break; - case RILConstants.NETWORK_MODE_GLOBAL: - default: - sProxyPhone = new PhoneProxy(new CDMAPhone(context, - sCommandsInterface, sPhoneNotifier)); - Log.i(LOG_TAG, "Creating CDMAPhone"); + int phoneType = getPhoneType(networkMode); + if (phoneType == RILConstants.GSM_PHONE) { + sProxyPhone = new PhoneProxy(new GSMPhone(context, + sCommandsInterface, sPhoneNotifier)); + Log.i(LOG_TAG, "Creating GSMPhone"); + } else if (phoneType == RILConstants.CDMA_PHONE) { + sProxyPhone = new PhoneProxy(new CDMAPhone(context, + sCommandsInterface, sPhoneNotifier)); + Log.i(LOG_TAG, "Creating CDMAPhone"); } + sMadeDefaults = true; } } } + /* + * This function returns the type of the phone, depending + * on the network mode. + * + * @param network mode + * @return Phone Type + */ + public static int getPhoneType(int networkMode) { + switch(networkMode) { + case RILConstants.NETWORK_MODE_CDMA: + case RILConstants.NETWORK_MODE_CDMA_NO_EVDO: + case RILConstants.NETWORK_MODE_EVDO_NO_CDMA: + return RILConstants.CDMA_PHONE; + + case RILConstants.NETWORK_MODE_WCDMA_PREF: + case RILConstants.NETWORK_MODE_GSM_ONLY: + case RILConstants.NETWORK_MODE_WCDMA_ONLY: + case RILConstants.NETWORK_MODE_GSM_UMTS: + return RILConstants.GSM_PHONE; + + case RILConstants.NETWORK_MODE_GLOBAL: + return RILConstants.CDMA_PHONE; + default: + return RILConstants.GSM_PHONE; + } + } + public static Phone getDefaultPhone() { if (sLooper != Looper.myLooper()) { throw new RuntimeException( diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java index 67ae169..453185f 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java +++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java @@ -69,6 +69,8 @@ public interface TelephonyProperties */ static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country"; + static final String CURRENT_ACTIVE_PHONE = "gsm.current.phone-type"; + //****** SIM Card /** * One of <code>"UNKNOWN"</code> <code>"ABSENT"</code> <code>"PIN_REQUIRED"</code> diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java index 3f8d40c..03f7f98 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java +++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java @@ -52,6 +52,7 @@ import com.android.internal.telephony.PhoneProxy; import com.android.internal.telephony.PhoneSubInfo; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.TelephonyIntents; +import com.android.internal.telephony.TelephonyProperties; import java.util.ArrayList; import java.util.List; @@ -126,8 +127,8 @@ public class CDMAPhone extends PhoneBase { //Change the system setting - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE); + SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE, + new Integer(RILConstants.CDMA_PHONE).toString()); } public void dispose() { diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java index 4fe1ea0..3459dcd 100755 --- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java +++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java @@ -68,6 +68,7 @@ import com.android.internal.telephony.PhoneNotifier; import com.android.internal.telephony.PhoneProxy; import com.android.internal.telephony.PhoneSubInfo; import com.android.internal.telephony.RILConstants; +import com.android.internal.telephony.TelephonyProperties; import com.android.internal.telephony.gsm.stk.StkService; import com.android.internal.telephony.test.SimulatedRadioControl; import com.android.internal.telephony.IccVmNotSupportedException; @@ -204,9 +205,9 @@ public class GSMPhone extends PhoneBase { } } - //Change the system setting - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.GSM_PHONE); + //Change the system property + SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE, + new Integer(RILConstants.GSM_PHONE).toString()); } public void dispose() { @@ -837,21 +838,21 @@ public class GSMPhone extends PhoneBase { private void storeVoiceMailNumber(String number) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor = sp.edit(); - editor.putString(VM_NUMBER, number); + editor.putString(VM_NUMBER, number); editor.commit(); setVmSimImsi(getSubscriberId()); } public String getVoiceMailNumber() { // Read from the SIM. If its null, try reading from the shared preference area. - String number = mSIMRecords.getVoiceMailNumber(); + String number = mSIMRecords.getVoiceMailNumber(); if (TextUtils.isEmpty(number)) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); number = sp.getString(VM_NUMBER, null); - } + } return number; } - + private String getVmSimImsi() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); return sp.getString(VM_SIM_IMSI, null); @@ -863,7 +864,7 @@ public class GSMPhone extends PhoneBase { editor.putString(VM_SIM_IMSI, imsi); editor.commit(); } - + public String getVoiceMailAlphaTag() { String ret; @@ -932,13 +933,13 @@ public class GSMPhone extends PhoneBase { public void setVoiceMailNumber(String alphaTag, String voiceMailNumber, Message onComplete) { - - Message resp; + + Message resp; mVmNumber = voiceMailNumber; resp = h.obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete); mSIMRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp); } - + private boolean isValidCommandInterfaceCFReason (int commandInterfaceCFReason) { switch (commandInterfaceCFReason) { case CF_REASON_UNCONDITIONAL: @@ -1317,11 +1318,11 @@ public class GSMPhone extends PhoneBase { case EVENT_SIM_RECORDS_LOADED: updateCurrentCarrierInProvider(); - + // Check if this is a different SIM than the previous one. If so unset the // voice mail number. String imsi = getVmSimImsi(); - if (imsi != null && !getSubscriberId().equals(imsi)) { + if (imsi != null && !getSubscriberId().equals(imsi)) { storeVoiceMailNumber(null); setVmSimImsi(null); } @@ -1403,7 +1404,7 @@ public class GSMPhone extends PhoneBase { onComplete.sendToTarget(); } break; - + case EVENT_SET_VM_NUMBER_DONE: ar = (AsyncResult)msg.obj; if (IccVmNotSupportedException.class.isInstance(ar.exception)) { @@ -1417,7 +1418,7 @@ public class GSMPhone extends PhoneBase { } break; - + case EVENT_GET_CALL_FORWARD_DONE: ar = (AsyncResult)msg.obj; if (ar.exception == null) { @@ -1460,7 +1461,7 @@ public class GSMPhone extends PhoneBase { /** * Sets the "current" field in the telephony provider according to the SIM's operator - * + * * @return true for success; false otherwise. */ boolean updateCurrentCarrierInProvider() { |