am ea975b12: Merge "Add new API for handling DB query per subId." into mnc-dev
* commit 'ea975b122fee3ac0fe766d2b58bb420b82e5dd95': Add new API for handling DB query per subId.
This commit is contained in:
60
core/res/res/layout/common_tab_settings.xml
Normal file
60
core/res/res/layout/common_tab_settings.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2014 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@android:id/tabhost"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/tabs_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:fillViewport="true">
|
||||||
|
|
||||||
|
<TabWidget
|
||||||
|
android:id="@android:id/tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
style="?android:attr/tabWidgetStyle" />
|
||||||
|
|
||||||
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
<!-- give an empty content area to make tabhost happy -->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@android:id/tabcontent"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="0dip" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:smoothScrollbar="false" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</TabHost>
|
||||||
@@ -1360,6 +1360,7 @@
|
|||||||
<java-symbol type="layout" name="restrictions_pin_setup" />
|
<java-symbol type="layout" name="restrictions_pin_setup" />
|
||||||
<java-symbol type="layout" name="immersive_mode_cling" />
|
<java-symbol type="layout" name="immersive_mode_cling" />
|
||||||
<java-symbol type="layout" name="user_switching_dialog" />
|
<java-symbol type="layout" name="user_switching_dialog" />
|
||||||
|
<java-symbol type="layout" name="common_tab_settings" />
|
||||||
|
|
||||||
<java-symbol type="anim" name="slide_in_child_bottom" />
|
<java-symbol type="anim" name="slide_in_child_bottom" />
|
||||||
<java-symbol type="anim" name="slide_in_right" />
|
<java-symbol type="anim" name="slide_in_right" />
|
||||||
|
|||||||
@@ -21,12 +21,15 @@ import android.annotation.SdkConstant;
|
|||||||
import android.annotation.SdkConstant.SdkConstantType;
|
import android.annotation.SdkConstant.SdkConstantType;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.telephony.Rlog;
|
import android.telephony.Rlog;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
import com.android.internal.telephony.ISub;
|
import com.android.internal.telephony.ISub;
|
||||||
import com.android.internal.telephony.IOnSubscriptionsChangedListener;
|
import com.android.internal.telephony.IOnSubscriptionsChangedListener;
|
||||||
@@ -247,6 +250,78 @@ public class SubscriptionManager {
|
|||||||
*/
|
*/
|
||||||
public static final String MNC = "mnc";
|
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
|
* Broadcast Action: The user has changed one of the default subs related to
|
||||||
* data, phone calls, or sms</p>
|
* data, phone calls, or sms</p>
|
||||||
@@ -1136,6 +1211,112 @@ public class SubscriptionManager {
|
|||||||
return simState;
|
return simState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* @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.
|
* and the SIM providing the subscription is present in a slot and in "LOADED" state.
|
||||||
|
|||||||
@@ -172,6 +172,10 @@ interface ISub {
|
|||||||
|
|
||||||
int[] getActiveSubIdList();
|
int[] getActiveSubIdList();
|
||||||
|
|
||||||
|
void setSubscriptionProperty(int subId, String propKey, String propValue);
|
||||||
|
|
||||||
|
String getSubscriptionProperty(int subId, String propKey, String callingPackage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the SIM state for the slot idx
|
* Get the SIM state for the slot idx
|
||||||
* @return SIM state as the ordinal of IccCardConstants.State
|
* @return SIM state as the ordinal of IccCardConstants.State
|
||||||
|
|||||||
Reference in New Issue
Block a user