| 64 | import java.util.concurrent.CancellationException; |
| 65 | |
| 66 | public class UpdateService extends IntentService |
| 67 | { |
| 68 | // Intent defines |
| 69 | public static final String START = "UpdateService.action.START"; |
| 70 | public static final String ERROR = "UpdateService.action.ERROR"; |
| 71 | public static final String DONE = "UpdateService.action.DONE"; |
| 72 | public static final String UPDATE = "UpdateService.data.UPDATE"; |
| 73 | public static final String MESSAGE = "UpdateService.data.MESSAGE"; |
| 74 | |
| 75 | // notification defines |
| 76 | private static final int NOTIFICATION_ID = 1; |
| 77 | private static final int DOWNLOAD_COMPLETE_CODE = 1; |
| 78 | private static final int CANCEL_CODE = 2; |
| 79 | private static final String NOTIFICATION_CANCELLED = "org.csploit.android.services.UpdateService.CANCELLED"; |
| 80 | |
| 81 | private boolean |
| 82 | mRunning = false; |
| 83 | private Update |
| 84 | mCurrentTask = null; |
| 85 | final private StringBuffer |
| 86 | mErrorOutput = new StringBuffer(); |
| 87 | private Raw.RawReceiver |
| 88 | mErrorReceiver = null; |
| 89 | |
| 90 | private NotificationManager mNotificationManager = null; |
| 91 | private NotificationCompat.Builder mBuilder = null; |
| 92 | private BroadcastReceiver mReceiver = null; |
| 93 | |
| 94 | public UpdateService(){ |
| 95 | super("UpdateService"); |
| 96 | // prepare error receiver |
| 97 | mErrorReceiver = new Raw.RawReceiver() { |
| 98 | @Override |
| 99 | public void onStart(String command) { |
| 100 | mErrorOutput.delete(0, mErrorOutput.length()); |
| 101 | mErrorOutput.append("running: "); |
| 102 | mErrorOutput.append(command); |
| 103 | mErrorOutput.append("\n"); |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public void onNewLine(String line) { |
| 108 | mErrorOutput.append(line); |
| 109 | mErrorOutput.append("\n"); |
| 110 | } |
| 111 | |
| 112 | @Override |
| 113 | public void onStderr(String line) { |
| 114 | mErrorOutput.append(line); |
| 115 | mErrorOutput.append("\n"); |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public void onEnd(int exitCode) { |
| 120 | mErrorOutput.append("exitValue: "); |
| 121 | mErrorOutput.append(exitCode); |
| 122 | } |
| 123 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected