import android.os.IBinder;\r
import android.os.RemoteException;\r
\r
+import com.td.WaitActivity;\r
import com.td.broadcast.DelayReceiver;\r
import com.td.db.DatabaseHelper;\r
import com.td.db.PrefectureDao;\r
import com.td.utility.Debug;\r
import com.td.utility.StatusFlag;\r
+import com.td.utility.StatusFlagFactory;\r
import com.td.utility.TdException;\r
import com.td.webapi.RouteUpdater;\r
\r
public class TrainService extends Service {\r
private WeakReference<ITrainServiceCallback> callbackRef;\r
- \r
- private ITrainService.Stub impl = new ITrainService.Stub(){\r
+\r
+ private ITrainService.Stub impl = new ITrainService.Stub() {\r
public int doExecute(String branch) throws RemoteException {\r
try {\r
DatabaseHelper.init(getApplicationContext());\r
- } catch (TdException e) {\r
- // TODO \91S\91Ì\82ðtry\82Å\88Í\82Þ\r
- }\r
- Thread thread = new Thread(){\r
- public void run(){\r
- boolean status = false;\r
- StatusFlag tsSf = new StatusFlag(TrainService.this,\r
- TrainService.class.getName(), StatusFlag.TERM_30M);\r
- try {\r
- Debug.t(TrainService.this, "TrainService start");\r
+ Thread thread = new Thread() {\r
+ public void run() {\r
+ boolean status = false;\r
+ StatusFlag tsSf = StatusFlagFactory.getInstance().getStatusFlag(\r
+ TrainService.this, StatusFlagFactory.Type.TRAIN_SERVICE);\r
+ try {\r
+ Debug.t(TrainService.this, "TrainService start");\r
+\r
+ RouteUpdater ru = new RouteUpdater();\r
+ status = ru.update();\r
+ ru = null;\r
\r
- RouteUpdater ru = new RouteUpdater();\r
- status = ru.update();\r
- ru = null;\r
- \r
- if (callbackRef != null){\r
- ITrainServiceCallback callback = callbackRef.get();\r
- if (callback != null){\r
- callbackRef.clear();\r
- callback.notify("msg");\r
- callback = null;\r
+ if (callbackRef != null) {\r
+ ITrainServiceCallback callback = callbackRef\r
+ .get();\r
+ if (callback != null) {\r
+ callbackRef.clear();\r
+ callback.notify("msg",\r
+ (status) ? WaitActivity.ID_OK\r
+ : WaitActivity.ID_NG);\r
+ callback = null;\r
+ }\r
}\r
- }\r
- // \8fI\97¹\83t\83\89\83O\83Z\83b\83g\r
- tsSf.setOff();\r
- \r
- // \8fI\97¹\92Ê\92m\r
- Intent intent = new Intent(DelayReceiver.UPDATE);\r
- TrainService.this.sendBroadcast(intent); \r
+ // \8fI\97¹\83t\83\89\83O\83Z\83b\83g\r
+ if (status){\r
+ tsSf.setOff();\r
+ }\r
+ else {\r
+ tsSf.setErr();\r
+ }\r
+ \r
+ // \8fI\97¹\92Ê\92m\r
+ Intent intent = new Intent(DelayReceiver.UPDATE);\r
+ TrainService.this.sendBroadcast(intent);\r
\r
- Debug.t(TrainService.this, "TrainService end");\r
- }\r
- catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- finally {\r
- if (!status){\r
- PrefectureDao.getInstance().delete();\r
+ Debug.t(TrainService.this, "TrainService end");\r
+ } catch (RemoteException e) {\r
+ Debug.d(TrainService.this, null, e);\r
+ } finally {\r
+ if (!status) {\r
+ PrefectureDao.getInstance().delete();\r
+ }\r
+ TrainService.this.stopSelf();\r
}\r
}\r
- TrainService.this.stopSelf();\r
- }\r
- };\r
- thread.start();\r
- thread = null;\r
+ };\r
+ thread.start();\r
+ thread = null;\r
\r
+ } catch (Exception e) {\r
+ Debug.t(TrainService.this, e.getMessage());\r
+ Debug.d(TrainService.this, null, e);\r
+ throw new RemoteException();\r
+ }\r
return 0;\r
}\r
\r
TrainService.this.stopSelf();\r
}\r
};\r
- \r
+\r
@Override\r
public IBinder onBind(Intent intent) {\r
return impl;\r