summaryrefslogtreecommitdiffstats
path: root/telephony/java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-13 13:04:22 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-13 13:04:22 -0700
commitba87e3e6c985e7175152993b5efcc7dd2f0e1c93 (patch)
treeee35f76532767dc29411a8738a434d1d88d330f2 /telephony/java
parentc39a6e0c51e182338deb8b63d07933b585134929 (diff)
downloadframeworks_base-ba87e3e6c985e7175152993b5efcc7dd2f0e1c93.zip
frameworks_base-ba87e3e6c985e7175152993b5efcc7dd2f0e1c93.tar.gz
frameworks_base-ba87e3e6c985e7175152993b5efcc7dd2f0e1c93.tar.bz2
auto import from //branches/cupcake_rel/...@138607
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/com/android/internal/telephony/Phone.java1
-rw-r--r--telephony/java/com/android/internal/telephony/WapPushOverSms.java40
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java18
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java33
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java2
5 files changed, 70 insertions, 24 deletions
diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java
index adc8bc1..05e61f2 100644
--- a/telephony/java/com/android/internal/telephony/Phone.java
+++ b/telephony/java/com/android/internal/telephony/Phone.java
@@ -140,6 +140,7 @@ public interface Phone {
static final String REASON_VOICE_CALL_STARTED = "2GVoiceCallStarted";
static final String REASON_PS_RESTRICT_ENABLED = "psRestrictEnabled";
static final String REASON_PS_RESTRICT_DISABLED = "psRestrictDisabled";
+ static final String REASON_SIM_LOADED = "simLoaded";
// Used for band mode selection methods
static final int BM_UNSPECIFIED = 0; // selected by baseband automatically
diff --git a/telephony/java/com/android/internal/telephony/WapPushOverSms.java b/telephony/java/com/android/internal/telephony/WapPushOverSms.java
index 66fa943..2b70162 100644
--- a/telephony/java/com/android/internal/telephony/WapPushOverSms.java
+++ b/telephony/java/com/android/internal/telephony/WapPushOverSms.java
@@ -16,11 +16,12 @@
package com.android.internal.telephony;
+import android.content.Context;
import android.content.Intent;
+import android.os.PowerManager;
import android.provider.Telephony.Sms.Intents;
import android.util.Config;
import android.util.Log;
-import com.android.internal.telephony.gsm.GSMPhone;
import com.android.internal.telephony.gsm.SimUtils;
@@ -32,12 +33,19 @@ import com.android.internal.telephony.gsm.SimUtils;
public class WapPushOverSms {
private static final String LOG_TAG = "WAP PUSH";
- private final GSMPhone mPhone;
+ private final Context mContext;
private WspTypeDecoder pduDecoder;
+ private PowerManager.WakeLock mWakeLock;
+ /**
+ * Hold the wake lock for 5 seconds, which should be enough time for
+ * any receiver(s) to grab its own wake lock.
+ */
+ private final int WAKE_LOCK_TIMEOUT = 5000;
- public WapPushOverSms(GSMPhone phone) {
- mPhone = phone;
+ public WapPushOverSms(Phone phone) {
+ mContext = phone.getContext();
+ createWakelock();
}
/**
@@ -163,8 +171,6 @@ public class WapPushOverSms {
}
}
-
-
private void dispatchWapPdu_default(
byte[] pdu, int transactionId, int pduType, String mimeType, int dataIndex) {
byte[] data;
@@ -178,8 +184,7 @@ public class WapPushOverSms {
intent.putExtra("pduType", pduType);
intent.putExtra("data", data);
- mPhone.getContext().sendBroadcast(
- intent, "android.permission.RECEIVE_WAP_PUSH");
+ sendBroadcast(intent, "android.permission.RECEIVE_WAP_PUSH");
}
private void dispatchWapPdu_PushCO(byte[] pdu, int transactionId, int pduType) {
@@ -189,8 +194,7 @@ public class WapPushOverSms {
intent.putExtra("pduType", pduType);
intent.putExtra("data", pdu);
- mPhone.getContext().sendBroadcast(
- intent, "android.permission.RECEIVE_WAP_PUSH");
+ sendBroadcast(intent, "android.permission.RECEIVE_WAP_PUSH");
}
private void dispatchWapPdu_MMS(byte[] pdu, int transactionId, int pduType, int dataIndex) {
@@ -205,7 +209,19 @@ public class WapPushOverSms {
intent.putExtra("pduType", pduType);
intent.putExtra("data", data);
- mPhone.getContext().sendBroadcast(
- intent, "android.permission.RECEIVE_MMS");
+ sendBroadcast(intent, "android.permission.RECEIVE_MMS");
+ }
+
+ private void createWakelock() {
+ PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
+ mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WapPushOverSms");
+ mWakeLock.setReferenceCounted(true);
+ }
+
+ private void sendBroadcast(Intent intent, String permission) {
+ // Hold a wake lock for WAKE_LOCK_TIMEOUT seconds, enough to give any
+ // receivers time to take their own wake locks.
+ mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
+ mContext.sendBroadcast(intent, permission);
}
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
index e664bc7..30b1be8 100644
--- a/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
@@ -199,9 +199,9 @@ final class DataConnectionTracker extends Handler
private static final int POLL_NETSTAT_SLOW_MILLIS = 5000;
/** Default ping deadline, in seconds. */
- private final int DEFAULT_PING_DEADLINE = 5;
+ private static final int DEFAULT_PING_DEADLINE = 5;
/** Default max failure count before attempting to network re-registration. */
- private final int DEFAULT_MAX_PDP_RESET_FAIL = 3;
+ private static final int DEFAULT_MAX_PDP_RESET_FAIL = 3;
/**
* After detecting a potential connection problem, this is the max number
@@ -677,8 +677,7 @@ final class DataConnectionTracker extends Handler
if ((state == State.IDLE || state == State.SCANNING)
&& (gprsState == ServiceState.STATE_IN_SERVICE || noAutoAttach)
&& phone.mSIMRecords.getRecordsLoaded()
- && ( phone.mSST.isConcurrentVoiceAndData() ||
- phone.getState() == Phone.State.IDLE )
+ && phone.getState() == Phone.State.IDLE
&& isDataAllowed()
&& !mIsPsRestricted ) {
@@ -1351,7 +1350,7 @@ final class DataConnectionTracker extends Handler
if (state == State.FAILED) {
cleanUpConnection(false, null);
}
- sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA));
+ sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA, Phone.REASON_SIM_LOADED));
break;
case EVENT_ENABLE_NEW_APN:
@@ -1362,6 +1361,10 @@ final class DataConnectionTracker extends Handler
break;
case EVENT_TRY_SETUP_DATA:
+ if (msg.obj instanceof String) {
+ reason = (String)msg.obj;
+ }
+
trySetupData(reason);
break;
@@ -1500,7 +1503,10 @@ final class DataConnectionTracker extends Handler
} else {
// we still have more apns to try
setState(State.SCANNING);
- trySetupData(reason);
+ // Wait a bit before trying the next APN, so that
+ // we're not tying up the RIL command channel
+ sendMessageDelayed(obtainMessage(EVENT_TRY_SETUP_DATA, reason),
+ RECONNECT_DELAY_INITIAL_MILLIS);
}
} else {
startDelayedRetry(cause, reason);
diff --git a/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java b/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java
index 877b734..5585524 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java
@@ -32,6 +32,7 @@ import android.net.Uri;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
+import android.os.PowerManager;
import android.provider.Telephony;
import android.provider.Settings;
import android.provider.Telephony.Sms.Intents;
@@ -122,6 +123,15 @@ final class SMSDispatcher extends Handler {
private SmsTracker mSTracker;
+ /** Wake lock to ensure device stays awake while dispatching the SMS intent. */
+ private PowerManager.WakeLock mWakeLock;
+
+ /**
+ * Hold the wake lock for 5 seconds, which should be enough time for
+ * any receiver(s) to grab its own wake lock.
+ */
+ private final int WAKE_LOCK_TIMEOUT = 5000;
+
/**
* Implement the per-application based SMS control, which only allows
* a limit on the number of SMS/MMS messages an app can send in checking
@@ -186,6 +196,8 @@ final class SMSDispatcher extends Handler {
mCm = phone.mCM;
mSTracker = null;
+ createWakelock();
+
int check_period = Settings.Gservices.getInt(mResolver,
Settings.Gservices.SMS_OUTGOING_CEHCK_INTERVAL_MS,
DEFAULT_SMS_CHECK_PERIOD);
@@ -286,6 +298,19 @@ final class SMSDispatcher extends Handler {
}
}
+ private void createWakelock() {
+ PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
+ mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SMSDispatcher");
+ mWakeLock.setReferenceCounted(true);
+ }
+
+ private void sendBroadcast(Intent intent, String permission) {
+ // Hold a wake lock for WAKE_LOCK_TIMEOUT seconds, enough to give any
+ // receivers time to take their own wake locks.
+ mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
+ mContext.sendBroadcast(intent, permission);
+ }
+
/**
* Called when SIM_FULL message is received from the RIL. Notifies interested
* parties that SIM storage for SMS messages is full.
@@ -293,7 +318,7 @@ final class SMSDispatcher extends Handler {
private void handleSimFull() {
// broadcast SIM_FULL intent
Intent intent = new Intent(Intents.SIM_FULL_ACTION);
- mPhone.getContext().sendBroadcast(intent, "android.permission.RECEIVE_SMS");
+ sendBroadcast(intent, "android.permission.RECEIVE_SMS");
}
/**
@@ -633,8 +658,7 @@ final class SMSDispatcher extends Handler {
private void dispatchPdus(byte[][] pdus) {
Intent intent = new Intent(Intents.SMS_RECEIVED_ACTION);
intent.putExtra("pdus", pdus);
- mPhone.getContext().sendBroadcast(
- intent, "android.permission.RECEIVE_SMS");
+ sendBroadcast(intent, "android.permission.RECEIVE_SMS");
}
/**
@@ -647,8 +671,7 @@ final class SMSDispatcher extends Handler {
Uri uri = Uri.parse("sms://localhost:" + port);
Intent intent = new Intent(Intents.DATA_SMS_RECEIVED_ACTION, uri);
intent.putExtra("pdus", pdus);
- mPhone.getContext().sendBroadcast(
- intent, "android.permission.RECEIVE_SMS");
+ sendBroadcast(intent, "android.permission.RECEIVE_SMS");
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
index 7152f76..89ce506 100644
--- a/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
@@ -1511,7 +1511,7 @@ final class ServiceStateTracker extends Handler
+ (c.getTimeInMillis() - System.currentTimeMillis())
+ " from " + nitz);
- SystemClock.setCurrentTimeMillis(c.getTimeInMillis());
+ setAndBroadcastNetworkSetTime(c.getTimeInMillis());
Log.i(LOG_TAG, "NITZ: after Setting time of day");
}
SystemProperties.set("gsm.nitz.time", String.valueOf(c.getTimeInMillis()));