Add latest area info broadcast to Settings status screen.
When the SIM has a Brazilian country code, add an item to the status screen to show the most recently received area info cell broadcast, requested from CellBroadcastReceiver, which also broadcasts any updates to the area info. To read the area info broadcast or request it from CellBroadcastReceiver requires READ_PHONE_STATE permission. Bug: 7445881 Change-Id: I387e23ecd0802b212ecb3e44f900a3a7a4b27e76
This commit is contained in:
@@ -1914,6 +1914,8 @@
|
|||||||
<string name="status_icc_id">ICCID</string>
|
<string name="status_icc_id">ICCID</string>
|
||||||
<!-- About phone, status item title for the type of data phone network we're connected to, for example 3G or Edge or GPRS -->
|
<!-- About phone, status item title for the type of data phone network we're connected to, for example 3G or Edge or GPRS -->
|
||||||
<string name="status_network_type">Mobile network type</string>
|
<string name="status_network_type">Mobile network type</string>
|
||||||
|
<!-- About phone, status item title for the latest area info cell broadcast received (Brazil only). -->
|
||||||
|
<string name="status_latest_area_info">Operator info</string>
|
||||||
<!-- About phone, status item title. The status of data access. For example, the value may be "Connected" -->
|
<!-- About phone, status item title. The status of data access. For example, the value may be "Connected" -->
|
||||||
<string name="status_data_state">Mobile network state</string>
|
<string name="status_data_state">Mobile network state</string>
|
||||||
<!-- About phone, status item title. The status of whether we have service. for example, the value may be "In service" -->
|
<!-- About phone, status item title. The status of whether we have service. for example, the value may be "In service" -->
|
||||||
|
@@ -42,6 +42,11 @@
|
|||||||
android:title="@string/status_network_type"
|
android:title="@string/status_network_type"
|
||||||
android:summary="@string/device_info_not_available"
|
android:summary="@string/device_info_not_available"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
<Preference android:key="latest_area_info"
|
||||||
|
style="?android:attr/preferenceInformationStyle"
|
||||||
|
android:title="@string/status_latest_area_info"
|
||||||
|
android:summary="@string/device_info_not_available"
|
||||||
|
android:persistent="false" />
|
||||||
<Preference android:key="service_state"
|
<Preference android:key="service_state"
|
||||||
style="?android:attr/preferenceInformationStyle"
|
style="?android:attr/preferenceInformationStyle"
|
||||||
android:title="@string/status_service_state"
|
android:title="@string/status_service_state"
|
||||||
|
@@ -26,7 +26,6 @@ import android.net.ConnectivityManager;
|
|||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.BatteryManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -37,6 +36,7 @@ import android.os.UserHandle;
|
|||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.telephony.CellBroadcastMessage;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
@@ -47,7 +47,6 @@ import com.android.internal.telephony.Phone;
|
|||||||
import com.android.internal.telephony.PhoneConstants;
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
import com.android.internal.telephony.PhoneFactory;
|
import com.android.internal.telephony.PhoneFactory;
|
||||||
import com.android.internal.telephony.PhoneStateIntentReceiver;
|
import com.android.internal.telephony.PhoneStateIntentReceiver;
|
||||||
import com.android.internal.telephony.TelephonyProperties;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
@@ -60,6 +59,7 @@ import java.lang.ref.WeakReference;
|
|||||||
* # Roaming
|
* # Roaming
|
||||||
* # Device Id (IMEI in GSM and MEID in CDMA)
|
* # Device Id (IMEI in GSM and MEID in CDMA)
|
||||||
* # Network type
|
* # Network type
|
||||||
|
* # Operator info (area info cell broadcast for Brazil)
|
||||||
* # Signal Strength
|
* # Signal Strength
|
||||||
* # Battery Strength : TODO
|
* # Battery Strength : TODO
|
||||||
* # Uptime
|
* # Uptime
|
||||||
@@ -74,6 +74,7 @@ public class Status extends PreferenceActivity {
|
|||||||
private static final String KEY_OPERATOR_NAME = "operator_name";
|
private static final String KEY_OPERATOR_NAME = "operator_name";
|
||||||
private static final String KEY_ROAMING_STATE = "roaming_state";
|
private static final String KEY_ROAMING_STATE = "roaming_state";
|
||||||
private static final String KEY_NETWORK_TYPE = "network_type";
|
private static final String KEY_NETWORK_TYPE = "network_type";
|
||||||
|
private static final String KEY_LATEST_AREA_INFO = "latest_area_info";
|
||||||
private static final String KEY_PHONE_NUMBER = "number";
|
private static final String KEY_PHONE_NUMBER = "number";
|
||||||
private static final String KEY_IMEI_SV = "imei_sv";
|
private static final String KEY_IMEI_SV = "imei_sv";
|
||||||
private static final String KEY_IMEI = "imei";
|
private static final String KEY_IMEI = "imei";
|
||||||
@@ -95,6 +96,7 @@ public class Status extends PreferenceActivity {
|
|||||||
KEY_OPERATOR_NAME,
|
KEY_OPERATOR_NAME,
|
||||||
KEY_ROAMING_STATE,
|
KEY_ROAMING_STATE,
|
||||||
KEY_NETWORK_TYPE,
|
KEY_NETWORK_TYPE,
|
||||||
|
KEY_LATEST_AREA_INFO,
|
||||||
KEY_PHONE_NUMBER,
|
KEY_PHONE_NUMBER,
|
||||||
KEY_IMEI,
|
KEY_IMEI,
|
||||||
KEY_IMEI_SV,
|
KEY_IMEI_SV,
|
||||||
@@ -105,6 +107,16 @@ public class Status extends PreferenceActivity {
|
|||||||
KEY_ICC_ID
|
KEY_ICC_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static final String CB_AREA_INFO_RECEIVED_ACTION =
|
||||||
|
"android.cellbroadcastreceiver.CB_AREA_INFO_RECEIVED";
|
||||||
|
|
||||||
|
static final String GET_LATEST_CB_AREA_INFO_ACTION =
|
||||||
|
"android.cellbroadcastreceiver.GET_LATEST_CB_AREA_INFO";
|
||||||
|
|
||||||
|
// Require the sender to have this permission to prevent third-party spoofing.
|
||||||
|
static final String CB_AREA_INFO_SENDER_PERMISSION =
|
||||||
|
"android.permission.RECEIVE_EMERGENCY_BROADCAST";
|
||||||
|
|
||||||
private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200;
|
private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200;
|
||||||
private static final int EVENT_SERVICE_STATE_CHANGED = 300;
|
private static final int EVENT_SERVICE_STATE_CHANGED = 300;
|
||||||
|
|
||||||
@@ -116,6 +128,7 @@ public class Status extends PreferenceActivity {
|
|||||||
private Resources mRes;
|
private Resources mRes;
|
||||||
private Preference mSignalStrength;
|
private Preference mSignalStrength;
|
||||||
private Preference mUptime;
|
private Preference mUptime;
|
||||||
|
private boolean mShowLatestAreaInfo;
|
||||||
|
|
||||||
private String sUnknown;
|
private String sUnknown;
|
||||||
|
|
||||||
@@ -176,10 +189,27 @@ public class Status extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private BroadcastReceiver mAreaInfoReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (CB_AREA_INFO_RECEIVED_ACTION.equals(action)) {
|
||||||
|
Bundle extras = intent.getExtras();
|
||||||
|
if (extras == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CellBroadcastMessage cbMessage = (CellBroadcastMessage) extras.get("message");
|
||||||
|
if (cbMessage != null && cbMessage.getServiceCategory() == 50) {
|
||||||
|
String latestAreaInfo = cbMessage.getMessageBody();
|
||||||
|
updateAreaInfo(latestAreaInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
Preference removablePref;
|
|
||||||
|
|
||||||
mHandler = new MyHandler(this);
|
mHandler = new MyHandler(this);
|
||||||
|
|
||||||
@@ -237,6 +267,11 @@ public class Status extends PreferenceActivity {
|
|||||||
removePreferenceFromScreen(KEY_MEID_NUMBER);
|
removePreferenceFromScreen(KEY_MEID_NUMBER);
|
||||||
removePreferenceFromScreen(KEY_MIN_NUMBER);
|
removePreferenceFromScreen(KEY_MIN_NUMBER);
|
||||||
removePreferenceFromScreen(KEY_ICC_ID);
|
removePreferenceFromScreen(KEY_ICC_ID);
|
||||||
|
|
||||||
|
// only show area info when SIM country is Brazil
|
||||||
|
if ("br".equals(mTelephonyManager.getSimCountryIso())) {
|
||||||
|
mShowLatestAreaInfo = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String rawNumber = mPhone.getLine1Number(); // may be null or empty
|
String rawNumber = mPhone.getLine1Number(); // may be null or empty
|
||||||
@@ -250,6 +285,10 @@ public class Status extends PreferenceActivity {
|
|||||||
mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
|
mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
|
||||||
mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
|
mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
|
||||||
mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
|
mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
|
||||||
|
|
||||||
|
if (!mShowLatestAreaInfo) {
|
||||||
|
removePreferenceFromScreen(KEY_LATEST_AREA_INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setWimaxStatus();
|
setWimaxStatus();
|
||||||
@@ -275,9 +314,16 @@ public class Status extends PreferenceActivity {
|
|||||||
updateSignalStrength();
|
updateSignalStrength();
|
||||||
updateServiceState(mPhone.getServiceState());
|
updateServiceState(mPhone.getServiceState());
|
||||||
updateDataState();
|
updateDataState();
|
||||||
|
|
||||||
mTelephonyManager.listen(mPhoneStateListener,
|
mTelephonyManager.listen(mPhoneStateListener,
|
||||||
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
|
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
|
||||||
|
if (mShowLatestAreaInfo) {
|
||||||
|
registerReceiver(mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
|
||||||
|
CB_AREA_INFO_SENDER_PERMISSION, null);
|
||||||
|
// Ask CellBroadcastReceiver to broadcast the latest area info received
|
||||||
|
Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION);
|
||||||
|
sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
|
||||||
|
CB_AREA_INFO_SENDER_PERMISSION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||||
mHandler.sendEmptyMessage(EVENT_UPDATE_STATS);
|
mHandler.sendEmptyMessage(EVENT_UPDATE_STATS);
|
||||||
@@ -291,6 +337,9 @@ public class Status extends PreferenceActivity {
|
|||||||
mPhoneStateReceiver.unregisterIntent();
|
mPhoneStateReceiver.unregisterIntent();
|
||||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
||||||
}
|
}
|
||||||
|
if (mShowLatestAreaInfo) {
|
||||||
|
unregisterReceiver(mAreaInfoReceiver);
|
||||||
|
}
|
||||||
unregisterReceiver(mBatteryInfoReceiver);
|
unregisterReceiver(mBatteryInfoReceiver);
|
||||||
mHandler.removeMessages(EVENT_UPDATE_STATS);
|
mHandler.removeMessages(EVENT_UPDATE_STATS);
|
||||||
}
|
}
|
||||||
@@ -385,6 +434,12 @@ public class Status extends PreferenceActivity {
|
|||||||
setSummaryText(KEY_OPERATOR_NAME, serviceState.getOperatorAlphaLong());
|
setSummaryText(KEY_OPERATOR_NAME, serviceState.getOperatorAlphaLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAreaInfo(String areaInfo) {
|
||||||
|
if (areaInfo != null) {
|
||||||
|
setSummaryText(KEY_LATEST_AREA_INFO, areaInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void updateSignalStrength() {
|
void updateSignalStrength() {
|
||||||
// TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener
|
// TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener
|
||||||
// should probably used instead.
|
// should probably used instead.
|
||||||
|
Reference in New Issue
Block a user