Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 1 | package com.fairphone.updater.fragments; |
| 2 | |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 3 | import java.io.File; |
| 4 | import java.io.IOException; |
| 5 | import java.util.concurrent.TimeoutException; |
| 6 | |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 7 | import android.app.DownloadManager; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 8 | import android.app.ProgressDialog; |
| 9 | import android.content.BroadcastReceiver; |
| 10 | import android.content.Context; |
| 11 | import android.content.Intent; |
| 12 | import android.content.IntentFilter; |
| 13 | import android.content.res.Resources; |
| 14 | import android.content.res.Resources.NotFoundException; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 15 | import android.database.Cursor; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 16 | import android.os.AsyncTask; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 17 | import android.os.Bundle; |
| 18 | import android.os.Environment; |
| 19 | import android.util.Log; |
| 20 | import android.view.LayoutInflater; |
| 21 | import android.view.View; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 22 | import android.view.View.OnClickListener; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 23 | import android.view.ViewGroup; |
| 24 | import android.widget.Button; |
| 25 | import android.widget.LinearLayout; |
| 26 | import android.widget.ProgressBar; |
| 27 | import android.widget.TextView; |
| 28 | import android.widget.Toast; |
| 29 | |
Jose Pascoal | 7bf83a0 | 2014-10-13 18:30:18 +0100 | [diff] [blame] | 30 | import com.fairphone.updater.FairphoneUpdater.HeaderType; |
| 31 | import com.fairphone.updater.FairphoneUpdater.UpdaterState; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 32 | import com.fairphone.updater.R; |
Jose Pascoal | 7bf83a0 | 2014-10-13 18:30:18 +0100 | [diff] [blame] | 33 | import com.fairphone.updater.data.Version; |
| 34 | import com.fairphone.updater.data.VersionParserHelper; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 35 | import com.fairphone.updater.gappsinstaller.GappsInstallerHelper; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 36 | import com.fairphone.updater.tools.Utils; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 37 | import com.stericson.RootTools.RootTools; |
| 38 | import com.stericson.RootTools.exceptions.RootDeniedException; |
| 39 | import com.stericson.RootTools.execution.CommandCapture; |
| 40 | import com.stericson.RootTools.execution.Shell; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 41 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 42 | public class DownloadAndRestartFragment extends BaseFragment |
| 43 | { |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 44 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 45 | protected static final String TAG = DownloadAndRestartFragment.class.getSimpleName(); |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 46 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 47 | private TextView mDownloadVersionName; |
| 48 | private LinearLayout mVersionDownloadingGroup; |
| 49 | private ProgressBar mVersionDownloadProgressBar; |
| 50 | private LinearLayout mVersionInstallGroup; |
| 51 | private Button mRestartButton; |
| 52 | private Button mCancelButton; |
| 53 | private Version mSelectedVersion; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 54 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 55 | private DownloadManager mDownloadManager; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 56 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 57 | private DownloadBroadCastReceiver mDownloadBroadCastReceiver; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 58 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 59 | private long mLatestUpdateDownloadId; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 60 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 61 | @Override |
| 62 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) |
| 63 | { |
| 64 | // Inflate the layout for this fragment |
| 65 | mSelectedVersion = mainActivity.getSelectedVersion(); |
| 66 | View view = inflateViewByImageType(inflater, container); |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 67 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 68 | setupLayout(view); |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 69 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 70 | return view; |
| 71 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 72 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 73 | private void toggleDownloadProgressAndRestart() |
| 74 | { |
Jose Pascoal | 8ed98d6 | 2014-10-09 20:41:11 +0100 | [diff] [blame] | 75 | UpdaterState state = mainActivity.getCurrentUpdaterState(); |
| 76 | switch (state) |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 77 | { |
| 78 | case DOWNLOAD: |
| 79 | setupDownloadState(); |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 80 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 81 | mVersionInstallGroup.setVisibility(View.GONE); |
| 82 | mVersionDownloadingGroup.setVisibility(View.VISIBLE); |
| 83 | break; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 84 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 85 | case PREINSTALL: |
| 86 | setupPreInstallState(); |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 87 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 88 | mVersionDownloadingGroup.setVisibility(View.GONE); |
| 89 | mVersionInstallGroup.setVisibility(View.VISIBLE); |
Jose Pascoal | 8ed98d6 | 2014-10-09 20:41:11 +0100 | [diff] [blame] | 90 | |
| 91 | mRestartButton.setOnClickListener(new OnClickListener() |
| 92 | { |
| 93 | |
| 94 | @Override |
| 95 | public void onClick(View v) |
| 96 | { |
| 97 | startPreInstall(); |
| 98 | } |
| 99 | }); |
| 100 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 101 | break; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 102 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 103 | default: |
Jose Pascoal | 8ed98d6 | 2014-10-09 20:41:11 +0100 | [diff] [blame] | 104 | Log.w(TAG, "Wrong State: " + state + "\nOnly DOWNLOAD and PREINSTALL are supported"); |
| 105 | mainActivity.removeLastFragment(); |
| 106 | return; |
| 107 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 108 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 109 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 110 | mCancelButton.setOnClickListener(new OnClickListener() |
| 111 | { |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 112 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 113 | @Override |
| 114 | public void onClick(View v) |
| 115 | { |
Jose Pascoal | b397dc6 | 2014-10-13 19:26:58 +0100 | [diff] [blame^] | 116 | abortUpdateProccess(); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 117 | } |
| 118 | }); |
| 119 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 120 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 121 | private void updateHeader() |
| 122 | { |
| 123 | if (mSelectedVersion != null) |
| 124 | { |
| 125 | if (Version.IMAGE_TYPE_FAIRPHONE.equalsIgnoreCase(mSelectedVersion.getImageType())) |
| 126 | { |
| 127 | mainActivity.updateHeader(HeaderType.MAIN_FAIRPHONE, ""); |
| 128 | } |
| 129 | else if (Version.IMAGE_TYPE_AOSP.equalsIgnoreCase(mSelectedVersion.getImageType())) |
| 130 | { |
| 131 | mainActivity.updateHeader(HeaderType.MAIN_ANDROID, ""); |
| 132 | } |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | mainActivity.updateHeader(HeaderType.MAIN_FAIRPHONE, ""); |
| 137 | } |
| 138 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 139 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 140 | private void startDownloadProgressUpdateThread() |
| 141 | { |
| 142 | new Thread(new Runnable() |
| 143 | { |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 144 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 145 | @Override |
| 146 | public void run() |
| 147 | { |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 148 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 149 | boolean downloading = true; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 150 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 151 | long latestUpdateDownloadId = mainActivity.getLatestDownloadId(); |
| 152 | while (latestUpdateDownloadId != 0 && downloading) |
| 153 | { |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 154 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 155 | DownloadManager.Query q = new DownloadManager.Query(); |
| 156 | q.setFilterById(latestUpdateDownloadId); |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 157 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 158 | Cursor cursor = mDownloadManager.query(q); |
| 159 | if (cursor != null) |
| 160 | { |
| 161 | cursor.moveToFirst(); |
| 162 | try |
| 163 | { |
| 164 | int bytes_downloaded = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); |
| 165 | int bytes_total = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)); |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 166 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 167 | if ((bytes_total + 10000) > Utils.getAvailablePartitionSizeInBytes(Environment.getExternalStorageDirectory())) |
| 168 | { |
| 169 | downloading = false; |
Pedro Arelo | 773bd82 | 2014-10-10 11:57:34 +0100 | [diff] [blame] | 170 | Toast.makeText(mainActivity, getResources().getString(R.string.no_space_available_sd_card_message), Toast.LENGTH_LONG).show(); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 171 | mainActivity.changeState(UpdaterState.NORMAL); |
| 172 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 173 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 174 | if (cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_SUCCESSFUL) |
| 175 | { |
| 176 | downloading = false; |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 177 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 178 | bytes_downloaded = 0; |
| 179 | bytes_total = 0; |
| 180 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 181 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 182 | mVersionDownloadProgressBar.setProgress(bytes_downloaded); |
| 183 | mVersionDownloadProgressBar.setMax(bytes_total); |
| 184 | } catch (Exception e) |
| 185 | { |
| 186 | downloading = false; |
| 187 | Log.e(TAG, "Error updating download progress: " + e.getMessage()); |
| 188 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 189 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 190 | cursor.close(); |
| 191 | try |
| 192 | { |
| 193 | // TODO WHYYYYYY??????? |
| 194 | Thread.sleep(3000); |
| 195 | } catch (InterruptedException e) |
| 196 | { |
| 197 | e.printStackTrace(); |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | }).start(); |
| 203 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 204 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 205 | private View inflateViewByImageType(LayoutInflater inflater, ViewGroup container) |
| 206 | { |
| 207 | View view = inflater.inflate(R.layout.fragment_download_fairphone, container, false); |
| 208 | if (mSelectedVersion != null) |
| 209 | { |
| 210 | if (Version.IMAGE_TYPE_AOSP.equalsIgnoreCase(mSelectedVersion.getImageType())) |
| 211 | { |
| 212 | view = inflater.inflate(R.layout.fragment_download_android, container, false); |
| 213 | } |
| 214 | else if (Version.IMAGE_TYPE_FAIRPHONE.equalsIgnoreCase(mSelectedVersion.getImageType())) |
| 215 | { |
| 216 | view = inflater.inflate(R.layout.fragment_download_fairphone, container, false); |
| 217 | } |
| 218 | } |
| 219 | return view; |
| 220 | } |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 221 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 222 | private void setupLayout(View view) |
| 223 | { |
| 224 | mDownloadVersionName = (TextView) view.findViewById(R.id.download_version_name_text); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 225 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 226 | // download in progress group |
| 227 | mVersionDownloadingGroup = (LinearLayout) view.findViewById(R.id.version_downloading_group); |
| 228 | mVersionDownloadProgressBar = (ProgressBar) view.findViewById(R.id.version_download_progress_bar); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 229 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 230 | // restart group |
| 231 | mVersionInstallGroup = (LinearLayout) view.findViewById(R.id.version_install_group); |
| 232 | mRestartButton = (Button) view.findViewById(R.id.restart_button); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 233 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 234 | mCancelButton = (Button) view.findViewById(R.id.cancel_button); |
| 235 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 236 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 237 | @Override |
| 238 | public void onResume() |
| 239 | { |
| 240 | super.onResume(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 241 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 242 | setupInstallationReceivers(); |
| 243 | registerDownloadBroadCastReceiver(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 244 | |
Jose Pascoal | 8ed98d6 | 2014-10-09 20:41:11 +0100 | [diff] [blame] | 245 | updateHeader(); |
| 246 | mDownloadVersionName.setText(mainActivity.getVersionName(mSelectedVersion)); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 247 | toggleDownloadProgressAndRestart(); |
| 248 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 249 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 250 | @Override |
| 251 | public void onPause() |
| 252 | { |
| 253 | super.onPause(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 254 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 255 | unregisterBroadCastReceiver(); |
| 256 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 257 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 258 | private void setupInstallationReceivers() |
| 259 | { |
| 260 | mDownloadManager = (DownloadManager) mainActivity.getSystemService(Context.DOWNLOAD_SERVICE); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 261 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 262 | mDownloadBroadCastReceiver = new DownloadBroadCastReceiver(); |
| 263 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 264 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 265 | private void registerDownloadBroadCastReceiver() |
| 266 | { |
| 267 | mainActivity.registerReceiver(mDownloadBroadCastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); |
| 268 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 269 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 270 | private void unregisterBroadCastReceiver() |
| 271 | { |
| 272 | mainActivity.unregisterReceiver(mDownloadBroadCastReceiver); |
| 273 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 274 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 275 | private class DownloadBroadCastReceiver extends BroadcastReceiver |
| 276 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 277 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 278 | @Override |
| 279 | public void onReceive(Context context, Intent intent) |
| 280 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 281 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 282 | mainActivity.getLatestUpdateDownloadIdFromSharedPreference(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 283 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 284 | updateDownloadFile(); |
| 285 | } |
| 286 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 287 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 288 | private void updateDownloadFile() |
| 289 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 290 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 291 | long downloadId = mainActivity.getLatestDownloadId(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 292 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 293 | if (downloadId != 0) |
| 294 | { |
| 295 | DownloadManager.Query query = new DownloadManager.Query(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 296 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 297 | query.setFilterById(downloadId); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 298 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 299 | Cursor cursor = mDownloadManager.query(query); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 300 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 301 | if (cursor.moveToFirst()) |
| 302 | { |
| 303 | int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); |
| 304 | int status = cursor.getInt(columnIndex); |
| 305 | |
| 306 | switch (status) |
| 307 | { |
| 308 | case DownloadManager.STATUS_SUCCESSFUL: |
| 309 | mainActivity.updateStatePreference(UpdaterState.PREINSTALL); |
| 310 | toggleDownloadProgressAndRestart(); |
| 311 | break; |
| 312 | case DownloadManager.STATUS_RUNNING: |
| 313 | startDownloadProgressUpdateThread(); |
| 314 | break; |
| 315 | case DownloadManager.STATUS_FAILED: |
| 316 | Resources resources = getResources(); |
| 317 | if (mSelectedVersion != null) |
| 318 | { |
| 319 | String downloadTitle = mSelectedVersion.getName() + " " + mSelectedVersion.getImageTypeDescription(resources); |
Pedro Arelo | 773bd82 | 2014-10-10 11:57:34 +0100 | [diff] [blame] | 320 | Toast.makeText(mainActivity, resources.getString(R.string.error_downloading) + " " + downloadTitle, Toast.LENGTH_LONG).show(); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 321 | } |
| 322 | else |
| 323 | { |
Pedro Arelo | 773bd82 | 2014-10-10 11:57:34 +0100 | [diff] [blame] | 324 | Toast.makeText(mainActivity, resources.getString(R.string.error_downloading), Toast.LENGTH_LONG).show(); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 325 | } |
| 326 | mainActivity.changeState(UpdaterState.NORMAL); |
| 327 | break; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | cursor.close(); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | // ************************************************************************************ |
| 336 | // PRE INSTALL |
| 337 | // ************************************************************************************ |
| 338 | |
| 339 | private void setupPreInstallState() |
| 340 | { |
| 341 | |
| 342 | Resources resources = mainActivity.getResources(); |
| 343 | // the latest version data must exist |
| 344 | if (mSelectedVersion != null) |
| 345 | { |
| 346 | |
| 347 | // check the md5 of the file |
| 348 | File file = new File(getVersionDownloadPath(mSelectedVersion)); |
| 349 | |
| 350 | if (file.exists()) |
| 351 | { |
| 352 | if (Utils.checkMD5(mSelectedVersion.getMd5Sum(), file)) |
| 353 | { |
| 354 | copyUpdateToCache(file); |
| 355 | return; |
| 356 | } |
| 357 | else |
| 358 | { |
Pedro Arelo | 773bd82 | 2014-10-10 11:57:34 +0100 | [diff] [blame] | 359 | Toast.makeText(mainActivity, resources.getString(R.string.invalid_md5_download_message), Toast.LENGTH_LONG).show(); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 360 | removeLastUpdateDownload(); |
| 361 | } |
| 362 | } |
| 363 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 364 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 365 | // remove the updater directory |
| 366 | File fileDir = new File(Environment.getExternalStorageDirectory() + resources.getString(R.string.updaterFolder)); |
| 367 | fileDir.delete(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 368 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 369 | // else if the perfect case does not happen, reset the download |
| 370 | mainActivity.changeState(UpdaterState.NORMAL); |
| 371 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 372 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 373 | // ************************************************************************************ |
| 374 | // DOWNLOAD UPDATE |
| 375 | // ************************************************************************************ |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 376 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 377 | public void setupDownloadState() |
| 378 | { |
| 379 | // setup the download state views |
| 380 | if (mSelectedVersion == null) |
| 381 | { |
| 382 | Resources resources = getResources(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 383 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 384 | // we don't have the lastest.xml so get back to initial state |
| 385 | File updateDir = new File(Environment.getExternalStorageDirectory() + resources.getString(R.string.updaterFolder)); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 386 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 387 | updateDir.delete(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 388 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 389 | mainActivity.changeState(UpdaterState.NORMAL); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 390 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 391 | return; |
| 392 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 393 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 394 | // if there is a download ID on the shared preferences |
| 395 | if (mLatestUpdateDownloadId == 0) |
| 396 | { |
| 397 | mLatestUpdateDownloadId = mainActivity.getLatestUpdateDownloadIdFromSharedPreference(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 398 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 399 | // invalid download Id |
| 400 | if (mLatestUpdateDownloadId == 0) |
| 401 | { |
| 402 | mainActivity.changeState(UpdaterState.NORMAL); |
| 403 | return; |
| 404 | } |
| 405 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 406 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 407 | updateDownloadFile(); |
| 408 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 409 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 410 | private void startPreInstall() |
| 411 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 412 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 413 | if (RootTools.isAccessGiven()) |
| 414 | { |
| 415 | // set the command for the recovery |
| 416 | Resources resources = getResources(); |
| 417 | // Process p; |
| 418 | try |
| 419 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 420 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 421 | Shell.runRootCommand(new CommandCapture(0, "rm -f /cache/recovery/command")); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 422 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 423 | Shell.runRootCommand(new CommandCapture(0, "rm -f /cache/recovery/extendedcommand")); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 424 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 425 | Shell.runRootCommand(new CommandCapture(0, "echo '--wipe_cache' >> /cache/recovery/command")); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 426 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 427 | if (canCopyToCache()) |
| 428 | { |
| 429 | Shell.runRootCommand(new CommandCapture(0, "echo '--update_package=/" + resources.getString(R.string.recoveryCachePath) + "/" |
| 430 | + VersionParserHelper.getNameFromVersion(mSelectedVersion) + "' >> /cache/recovery/command")); |
| 431 | } |
| 432 | else |
| 433 | { |
| 434 | Shell.runRootCommand(new CommandCapture(0, "echo '--update_package=/" + resources.getString(R.string.recoverySdCardPath) |
| 435 | + resources.getString(R.string.updaterFolder) + VersionParserHelper.getNameFromVersion(mSelectedVersion) |
| 436 | + "' >> /cache/recovery/command")); |
| 437 | } |
| 438 | } catch (IOException e) |
| 439 | { |
| 440 | // TODO Auto-generated catch block |
| 441 | e.printStackTrace(); |
| 442 | } catch (NotFoundException e) |
| 443 | { |
| 444 | // TODO Auto-generated catch block |
| 445 | e.printStackTrace(); |
| 446 | } catch (TimeoutException e) |
| 447 | { |
| 448 | // TODO Auto-generated catch block |
| 449 | e.printStackTrace(); |
| 450 | } catch (RootDeniedException e) |
| 451 | { |
| 452 | // TODO Auto-generated catch block |
| 453 | e.printStackTrace(); |
| 454 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 455 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 456 | // send broadcast intent |
| 457 | Intent broadcastIntent = new Intent(); |
| 458 | broadcastIntent.setAction(GappsInstallerHelper.GAPPS_REINSTALATION); |
| 459 | mainActivity.sendBroadcast(broadcastIntent); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 460 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 461 | if (canCopyToCache()) |
| 462 | { |
| 463 | removeLastUpdateDownload(); |
| 464 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 465 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 466 | // remove the update files from data |
| 467 | removeUpdateFilesFromData(); |
| 468 | // reboot the device into recovery |
| 469 | // ((PowerManager) |
| 470 | // getSystemService(POWER_SERVICE)).reboot("recovery"); |
| 471 | try |
| 472 | { |
| 473 | mainActivity.updateStatePreference(UpdaterState.NORMAL); |
| 474 | Shell.runRootCommand(new CommandCapture(0, "reboot recovery")); |
| 475 | } catch (IOException e) |
| 476 | { |
| 477 | // TODO Auto-generated catch block |
| 478 | e.printStackTrace(); |
| 479 | } catch (TimeoutException e) |
| 480 | { |
| 481 | // TODO Auto-generated catch block |
| 482 | e.printStackTrace(); |
| 483 | } catch (RootDeniedException e) |
| 484 | { |
| 485 | // TODO Auto-generated catch block |
| 486 | e.printStackTrace(); |
| 487 | } |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | // TODO: show warning |
| 492 | } |
| 493 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 494 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 495 | private void copyUpdateToCache(File file) |
| 496 | { |
| 497 | if (canCopyToCache()) |
| 498 | { |
| 499 | CopyFileToCacheTask copyTask = new CopyFileToCacheTask(); |
| 500 | copyTask.execute(file.getPath(), Environment.getDownloadCacheDirectory() + "/" + VersionParserHelper.getNameFromVersion(mSelectedVersion)); |
| 501 | } |
| 502 | else |
| 503 | { |
| 504 | Log.d(TAG, "No space on cache. Defaulting to Sdcard"); |
Pedro Arelo | 773bd82 | 2014-10-10 11:57:34 +0100 | [diff] [blame] | 505 | Toast.makeText(mainActivity, getResources().getString(R.string.no_space_available_cache_message), Toast.LENGTH_LONG).show(); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 506 | } |
| 507 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 508 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 509 | public boolean canCopyToCache() |
| 510 | { |
| 511 | Resources resources = getResources(); |
| 512 | double cacheSize = Utils.getPartitionSizeInMBytes(Environment.getDownloadCacheDirectory()); |
| 513 | return cacheSize > resources.getInteger(R.integer.FP1CachePartitionSizeMb) && cacheSize > resources.getInteger(R.integer.minimalCachePartitionSizeMb); |
| 514 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 515 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 516 | private void clearCache() |
| 517 | { |
| 518 | File f = Environment.getDownloadCacheDirectory(); |
| 519 | File files[] = f.listFiles(); |
| 520 | if (files != null) |
| 521 | { |
| 522 | Log.d(TAG, "Size: " + files.length); |
| 523 | for (int i = 0; i < files.length; i++) |
| 524 | { |
| 525 | String filename = files[i].getName(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 526 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 527 | if (filename.endsWith(".zip")) |
| 528 | { |
| 529 | files[i].delete(); |
| 530 | Log.d(TAG, "Deleted file " + filename); |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 535 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 536 | // ************************************************************************************ |
| 537 | // Update Removal |
| 538 | // ************************************************************************************ |
| 539 | private void removeUpdateFilesFromData() |
| 540 | { |
| 541 | try |
| 542 | { |
| 543 | Shell.runRootCommand(new CommandCapture(0, getResources().getString(R.string.removePlayStoreCommand), getResources().getString( |
| 544 | R.string.removeGooglePlusCommand), getResources().getString(R.string.removeSoundSearchCommand), getResources().getString( |
| 545 | R.string.removeGmailCommand), getResources().getString(R.string.removePlayServicesCommand), getResources().getString( |
| 546 | R.string.removeQuicksearchCommand), getResources().getString(R.string.removeTalkbackCommand), getResources().getString( |
| 547 | R.string.removeText2SpeechCommand))); |
| 548 | } catch (IOException e) |
| 549 | { |
| 550 | e.printStackTrace(); |
| 551 | } catch (TimeoutException e) |
| 552 | { |
| 553 | e.printStackTrace(); |
| 554 | } catch (RootDeniedException e) |
| 555 | { |
| 556 | e.printStackTrace(); |
| 557 | } |
| 558 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 559 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 560 | public void removeLastUpdateDownload() |
| 561 | { |
| 562 | long latestUpdateDownloadId = mainActivity.getLatestUpdateDownloadIdFromSharedPreference(); |
| 563 | if (latestUpdateDownloadId != 0) |
| 564 | { |
| 565 | // residue download ID |
| 566 | mDownloadManager.remove(latestUpdateDownloadId); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 567 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 568 | mainActivity.resetLastUpdateDownloadId(); |
| 569 | } |
| 570 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 571 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 572 | private class CopyFileToCacheTask extends AsyncTask<String, Integer, Integer> |
| 573 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 574 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 575 | ProgressDialog mProgress; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 576 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 577 | @Override |
| 578 | protected Integer doInBackground(String... params) |
| 579 | { |
| 580 | // check the correct number of |
| 581 | if (params.length != 2) |
| 582 | { |
| 583 | return -1; |
| 584 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 585 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 586 | String originalFilePath = params[0]; |
| 587 | String destinyFilePath = params[1]; |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 588 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 589 | if (RootTools.isAccessGiven()) |
| 590 | { |
| 591 | clearCache(); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 592 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 593 | File otaFilePath = new File(originalFilePath); |
| 594 | File otaFileCache = new File(destinyFilePath); |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 595 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 596 | if (!otaFileCache.exists()) |
| 597 | { |
| 598 | RootTools.copyFile(otaFilePath.getPath(), otaFileCache.getPath(), false, false); |
| 599 | } |
| 600 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 601 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 602 | return 1; |
| 603 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 604 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 605 | protected void onProgressUpdate(Integer... progress) |
| 606 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 607 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 608 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 609 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 610 | protected void onPreExecute() |
| 611 | { |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 612 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 613 | if (mProgress == null) |
| 614 | { |
| 615 | String title = ""; |
Pedro Arelo | 773bd82 | 2014-10-10 11:57:34 +0100 | [diff] [blame] | 616 | String message = mainActivity.getResources().getString(R.string.please_be_patient); |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 617 | mProgress = ProgressDialog.show(mainActivity, title, message, true, false); |
| 618 | } |
| 619 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 620 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 621 | protected void onPostExecute(Integer result) |
| 622 | { |
| 623 | // disable the spinner |
| 624 | if (mProgress != null) |
| 625 | { |
| 626 | mProgress.dismiss(); |
| 627 | mProgress = null; |
| 628 | } |
| 629 | } |
| 630 | } |
Jose Pascoal | 54b3ae6 | 2014-10-07 20:29:58 +0100 | [diff] [blame] | 631 | |
Jose Pascoal | 810950b | 2014-10-09 17:16:08 +0100 | [diff] [blame] | 632 | private String getVersionDownloadPath(Version version) |
| 633 | { |
| 634 | Resources resources = mainActivity.getResources(); |
| 635 | return Environment.getExternalStorageDirectory() + resources.getString(R.string.updaterFolder) + VersionParserHelper.getNameFromVersion(version); |
| 636 | } |
Jose Pascoal | b397dc6 | 2014-10-13 19:26:58 +0100 | [diff] [blame^] | 637 | |
| 638 | public void abortUpdateProccess() |
| 639 | { |
| 640 | removeLastUpdateDownload(); |
| 641 | mainActivity.updateStatePreference(UpdaterState.NORMAL); |
| 642 | mainActivity.removeLastFragment(); |
| 643 | } |
| 644 | |
Jose Pascoal | b690af1 | 2014-10-06 18:29:26 +0100 | [diff] [blame] | 645 | } |