am 68fdeeae: Merge "StkAppSerice: Stop the service when CatService Instance is null"
* commit '68fdeeae67e8f8e13978e3adbad0429815439f83':
StkAppSerice: Stop the service when CatService Instance is null
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 5bf3103..f729e88 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -144,11 +144,6 @@
@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();
-
mCmdsQ = new LinkedList<DelayedCmd>();
Thread serviceThread = new Thread(null, this, "Stk App Service");
serviceThread.start();
@@ -160,8 +155,17 @@
@Override
public void onStart(Intent intent, int startId) {
- waitForLooper();
+ mStkService = com.android.internal.telephony.cat.CatService
+ .getInstance();
+
+ if (mStkService == null) {
+ stopSelf();
+ CatLog.d(this, " Unable to get Service handle");
+ return;
+ }
+
+ waitForLooper();
// onStart() method can be passed a null intent
// TODO: replace onStart() with onStartCommand()
if (intent == null) {