summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Yakavenka <ayakav@codeaurora.org>2012-04-20 17:10:15 -0700
committerAlex Yakavenka <ayakav@codeaurora.org>2012-07-27 17:09:32 -0700
commitd8e2ecdca2d1bc91f48cea59e96aa5b0b452e8a7 (patch)
treef9206fc26e3ac08a18e9665a00eca442413c309d
parent71013cbdc4a9b1b0eaa0d21af1641f90e4e47f42 (diff)
downloadpackages_apps_Stk-d8e2ecdca2d1bc91f48cea59e96aa5b0b452e8a7.zip
packages_apps_Stk-d8e2ecdca2d1bc91f48cea59e96aa5b0b452e8a7.tar.gz
packages_apps_Stk-d8e2ecdca2d1bc91f48cea59e96aa5b0b452e8a7.tar.bz2
Stk: Fix crash due to race condition
StkAppService doesn't really need mStkService reference in the constructor. It will need it to respond to proactive command. By that time StkService has to exist (proactive command comes from it)
-rw-r--r--src/com/android/stk/StkAppService.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 1007a4a..9dcd25b 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -144,20 +144,11 @@ public class StkAppService extends Service implements Runnable {
@Override
public void onCreate() {
// Initialize members
+ // This can return null if StkService is not yet instantiated, but it's ok
+ // If this is null we will do getInstance before we need to use this
mStkService = com.android.internal.telephony.cat.CatService
.getInstance();
- // NOTE mStkService is a singleton and continues to exist even if the GSMPhone is disposed
- // after the radio technology change from GSM to CDMA so the PHONE_TYPE_CDMA check is
- // needed. In case of switching back from CDMA to GSM the GSMPhone constructor updates
- // the instance. (TODO: test).
- if ((mStkService == null)
- && (TelephonyManager.getDefault().getPhoneType()
- != TelephonyManager.PHONE_TYPE_CDMA)) {
- CatLog.d(this, " Unable to get Service handle");
- return;
- }
-
mCmdsQ = new LinkedList<DelayedCmd>();
Thread serviceThread = new Thread(null, this, "Stk App Service");
serviceThread.start();
@@ -488,6 +479,15 @@ public class StkAppService extends Service implements Runnable {
if (mCurrentCmd == null) {
return;
}
+ if (mStkService == null) {
+ mStkService = com.android.internal.telephony.cat.CatService.getInstance();
+ if (mStkService == null) {
+ // This should never happen (we should be responding only to a message
+ // that arrived from StkService). It has to exist by this time
+ throw new RuntimeException("mStkService is null when we need to send response");
+ }
+ }
+
CatResponseMessage resMsg = new CatResponseMessage(mCurrentCmd);
// set result code