diff options
author | Amit Mahajan <amitmahajan@google.com> | 2014-11-25 20:39:06 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-11-25 20:39:09 +0000 |
commit | 3749541a206390054b22d5f5bddc1b43f348f433 (patch) | |
tree | 9fadb32395377dd196a5faae3dd706f4a1710787 /telephony | |
parent | dec3f138c2f6a31879b0fe055a26d618e4874bb5 (diff) | |
parent | 421a53900dbdfabb5ab7b6cf6da798ac64bbaa87 (diff) | |
download | frameworks_base-3749541a206390054b22d5f5bddc1b43f348f433.zip frameworks_base-3749541a206390054b22d5f5bddc1b43f348f433.tar.gz frameworks_base-3749541a206390054b22d5f5bddc1b43f348f433.tar.bz2 |
Merge "Adding helper functions to retrieve settings that are stored per subId." into lmp-mr1-dev
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 40a8ed4..868b770 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -19,8 +19,11 @@ package android.telephony; import android.annotation.SystemApi; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.provider.Settings; +import android.provider.Settings.SettingNotFoundException; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; @@ -3524,4 +3527,48 @@ public class TelephonyManager { } return false; } + + /** + * This function retrieves value for setting "name+subId", and if that is not found + * retrieves value for setting "name", and if that is not found uses def as default + * + * @hide */ + public static int getIntWithSubId(ContentResolver cr, String name, int subId, int def) { + return Settings.Global.getInt(cr, name + subId, Settings.Global.getInt(cr, name, def)); + } + + /** + * This function retrieves value for setting "name+subId", and if that is not found + * retrieves value for setting "name", and if that is not found throws + * SettingNotFoundException + * + * @hide */ + public static int getIntWithSubId(ContentResolver cr, String name, int subId) + throws SettingNotFoundException { + try { + return Settings.Global.getInt(cr, name + subId); + } catch (SettingNotFoundException e) { + try { + int val = Settings.Global.getInt(cr, name); + /* We are now moving from 'setting' to 'setting+subId', and using the value stored + * for 'setting' as default. Reset the default (since it may have a user set + * value). */ + int default_val = val; + if (name.equals(Settings.Global.MOBILE_DATA)) { + default_val = "true".equalsIgnoreCase( + SystemProperties.get("ro.com.android.mobiledata", "true")) ? 1 : 0; + } + + if (default_val != val) { + Settings.Global.putInt(cr, name, default_val); + } + + return val; + } catch (SettingNotFoundException exc) { + throw new SettingNotFoundException(name); + } + } + } } + + |