summaryrefslogtreecommitdiffstats
path: root/telephony/java/android
diff options
context:
space:
mode:
authorSanket Padawe <sanketpadawe@google.com>2015-07-16 05:01:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-16 05:01:23 +0000
commitea975b122fee3ac0fe766d2b58bb420b82e5dd95 (patch)
treea3ef0e78a7957a19c6fc6ed3c497b9df6a164d94 /telephony/java/android
parentc0aa9744dc0ba9470aea6a973d955fd21de21c92 (diff)
parentdc49309cefed9519611b183ae2c616e6f0110738 (diff)
downloadframeworks_base-ea975b122fee3ac0fe766d2b58bb420b82e5dd95.zip
frameworks_base-ea975b122fee3ac0fe766d2b58bb420b82e5dd95.tar.gz
frameworks_base-ea975b122fee3ac0fe766d2b58bb420b82e5dd95.tar.bz2
Merge "Add new API for handling DB query per subId." into mnc-dev
Diffstat (limited to 'telephony/java/android')
-rw-r--r--telephony/java/android/telephony/SubscriptionManager.java181
1 files changed, 181 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index f4a6064..32b7383 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -21,12 +21,15 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.content.Intent;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.net.Uri;
import android.telephony.Rlog;
import android.os.Handler;
import android.os.Message;
import android.os.ServiceManager;
import android.os.RemoteException;
+import android.util.DisplayMetrics;
import com.android.internal.telephony.ISub;
import com.android.internal.telephony.IOnSubscriptionsChangedListener;
@@ -248,6 +251,78 @@ public class SubscriptionManager {
public static final String MNC = "mnc";
/**
+ * TelephonyProvider column name for extreme threat in CB settings
+ * @hide
+ */
+ public static final String CB_EXTREME_THREAT_ALERT = "enable_cmas_extreme_threat_alerts";
+
+ /**
+ * TelephonyProvider column name for severe threat in CB settings
+ *@hide
+ */
+ public static final String CB_SEVERE_THREAT_ALERT = "enable_cmas_severe_threat_alerts";
+
+ /**
+ * TelephonyProvider column name for amber alert in CB settings
+ *@hide
+ */
+ public static final String CB_AMBER_ALERT = "enable_cmas_amber_alerts";
+
+ /**
+ * TelephonyProvider column name for emergency alert in CB settings
+ *@hide
+ */
+ public static final String CB_EMERGENCY_ALERT = "enable_emergency_alerts";
+
+ /**
+ * TelephonyProvider column name for alert sound duration in CB settings
+ *@hide
+ */
+ public static final String CB_ALERT_SOUND_DURATION = "alert_sound_duration";
+
+ /**
+ * TelephonyProvider column name for alert reminder interval in CB settings
+ *@hide
+ */
+ public static final String CB_ALERT_REMINDER_INTERVAL = "alert_reminder_interval";
+
+ /**
+ * TelephonyProvider column name for enabling vibrate in CB settings
+ *@hide
+ */
+ public static final String CB_ALERT_VIBRATE = "enable_alert_vibrate";
+
+ /**
+ * TelephonyProvider column name for enabling alert speech in CB settings
+ *@hide
+ */
+ public static final String CB_ALERT_SPEECH = "enable_alert_speech";
+
+ /**
+ * TelephonyProvider column name for ETWS test alert in CB settings
+ *@hide
+ */
+ public static final String CB_ETWS_TEST_ALERT = "enable_etws_test_alerts";
+
+ /**
+ * TelephonyProvider column name for enable channel50 alert in CB settings
+ *@hide
+ */
+ public static final String CB_CHANNEL_50_ALERT = "enable_channel_50_alerts";
+
+ /**
+ * TelephonyProvider column name for CMAS test alert in CB settings
+ *@hide
+ */
+ public static final String CB_CMAS_TEST_ALERT= "enable_cmas_test_alerts";
+
+ /**
+ * TelephonyProvider column name for Opt out dialog in CB settings
+ *@hide
+ */
+ public static final String CB_OPT_OUT_DIALOG = "show_cmas_opt_out_dialog";
+
+ /**
* Broadcast Action: The user has changed one of the default subs related to
* data, phone calls, or sms</p>
*
@@ -1137,6 +1212,112 @@ public class SubscriptionManager {
}
/**
+ * Store properties associated with SubscriptionInfo in database
+ * @param subId Subscription Id of Subscription
+ * @param propKey Column name in database associated with SubscriptionInfo
+ * @param propValue Value to store in DB for particular subId & column name
+ * @hide
+ */
+ public static void setSubscriptionProperty(int subId, String propKey, String propValue) {
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ iSub.setSubscriptionProperty(subId, propKey, propValue);
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+ }
+
+ /**
+ * Store properties associated with SubscriptionInfo in database
+ * @param subId Subscription Id of Subscription
+ * @param propKey Column name in SubscriptionInfo database
+ * @return Value associated with subId and propKey column in database
+ * @hide
+ */
+ private static String getSubscriptionProperty(int subId, String propKey,
+ Context context) {
+ String resultValue = null;
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ resultValue = iSub.getSubscriptionProperty(subId, propKey,
+ context.getOpPackageName());
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+ return resultValue;
+ }
+
+ /**
+ * Returns boolean value corresponding to query result.
+ * @param subId Subscription Id of Subscription
+ * @param propKey Column name in SubscriptionInfo database
+ * @param defValue Default boolean value to be returned
+ * @return boolean result value to be returned
+ * @hide
+ */
+ public static boolean getBooleanSubscriptionProperty(int subId, String propKey,
+ boolean defValue, Context context) {
+ String result = getSubscriptionProperty(subId, propKey, context);
+ if (result != null) {
+ try {
+ return Integer.parseInt(result) == 1;
+ } catch (NumberFormatException err) {
+ logd("getBooleanSubscriptionProperty NumberFormat exception");
+ }
+ }
+ return defValue;
+ }
+
+ /**
+ * Returns integer value corresponding to query result.
+ * @param subId Subscription Id of Subscription
+ * @param propKey Column name in SubscriptionInfo database
+ * @param defValue Default integer value to be returned
+ * @return integer result value to be returned
+ * @hide
+ */
+ public static int getIntegerSubscriptionProperty(int subId, String propKey, int defValue,
+ Context context) {
+ String result = getSubscriptionProperty(subId, propKey, context);
+ if (result != null) {
+ try {
+ return Integer.parseInt(result);
+ } catch (NumberFormatException err) {
+ logd("getBooleanSubscriptionProperty NumberFormat exception");
+ }
+ }
+ return defValue;
+ }
+
+ /**
+ * Returns the resources associated with Subscription.
+ * @param context Context object
+ * @param subId Subscription Id of Subscription who's resources are required
+ * @return Resources associated with Subscription.
+ * @hide
+ */
+ public static Resources getResourcesForSubId(Context context, int subId) {
+ final SubscriptionInfo subInfo =
+ SubscriptionManager.from(context).getActiveSubscriptionInfo(subId);
+
+ Configuration config = context.getResources().getConfiguration();
+ Configuration newConfig = new Configuration();
+ newConfig.setTo(config);
+ if (subInfo != null) {
+ newConfig.mcc = subInfo.getMcc();
+ newConfig.mnc = subInfo.getMnc();
+ }
+ DisplayMetrics metrics = context.getResources().getDisplayMetrics();
+ DisplayMetrics newMetrics = new DisplayMetrics();
+ newMetrics.setTo(metrics);
+ return new Resources(context.getResources().getAssets(), newMetrics, newConfig);
+ }
+
+ /**
* @return true if the sub ID is active. i.e. The sub ID corresponds to a known subscription
* and the SIM providing the subscription is present in a slot and in "LOADED" state.
* @hide