aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/services/UpdaterWebService.java17
-rw-r--r--src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java29
2 files changed, 29 insertions, 17 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/UpdaterWebService.java b/src/main/java/eu/siacs/conversations/services/UpdaterWebService.java
index 1001562dc..faad2fd93 100644
--- a/src/main/java/eu/siacs/conversations/services/UpdaterWebService.java
+++ b/src/main/java/eu/siacs/conversations/services/UpdaterWebService.java
@@ -18,13 +18,12 @@ import org.apache.http.params.HttpParams;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.ui.UpdaterActivity.MyWebReceiver;
public class UpdaterWebService extends IntentService{
- private static final String LOG_TAG = "MyWebService";
- public static final String REQUEST_STRING = "myRequest";
- public static final String RESPONSE_STRING = "myResponse";
- public static final String RESPONSE_MESSAGE = "myResponseMessage";
+ public static final String REQUEST_STRING = "";
+ public static final String RESPONSE_MESSAGE = "";
private String URL = null;
private static final int REGISTRATION_TIMEOUT = 3 * 1000;
@@ -38,7 +37,7 @@ public class UpdaterWebService extends IntentService{
protected void onHandleIntent(Intent intent) {
String requestString = intent.getStringExtra(REQUEST_STRING);
- Log.v(LOG_TAG, requestString);
+ Log.d(Config.LOGTAG, "AppUpdater: " + requestString);
String responseMessage = "";
try {
@@ -63,19 +62,19 @@ public class UpdaterWebService extends IntentService{
}
else{
- Log.w("HTTP1:",statusLine.getReasonPhrase());
+ Log.d(Config.LOGTAG, "AppUpdater: HTTP1:" + statusLine.getReasonPhrase());
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
- Log.w("HTTP2:",e );
+ Log.d(Config.LOGTAG, "AppUpdater: HTTP2:" + e);
responseMessage = e.getMessage();
} catch (IOException e) {
- Log.w("HTTP3:",e );
+ Log.d(Config.LOGTAG, "AppUpdater: HTTP3:" + e);
responseMessage = e.getMessage();
}catch (Exception e) {
- Log.w("HTTP4:",e );
+ Log.d(Config.LOGTAG, "AppUpdater: HTTP4:" + e);
responseMessage = e.getMessage();
}
diff --git a/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java b/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java
index 3df4dca75..7f721f0e6 100644
--- a/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java
@@ -22,6 +22,8 @@ import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
+import java.io.File;
+
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.services.UpdaterWebService;
@@ -126,9 +128,9 @@ public class UpdaterActivity extends Activity {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
- Log.v(LOG_TAG, String.valueOf(i));
+ Log.d(Config.LOGTAG, "AppUpdater: " + String.valueOf(i));
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
- Log.v(LOG_TAG, "connected!");
+ Log.d(Config.LOGTAG, "AppUpdater: connected to update Server!");
return true;
}
}
@@ -146,7 +148,7 @@ public class UpdaterActivity extends Activity {
public void onReceive(Context context, Intent intent) {
String reponseMessage = intent.getStringExtra(UpdaterWebService.RESPONSE_MESSAGE);
- Log.v(LOG_TAG, reponseMessage);
+ Log.d(Config.LOGTAG, "AppUpdater: " + reponseMessage);
//parse the JSON response
JSONObject responseObj;
@@ -179,6 +181,7 @@ public class UpdaterActivity extends Activity {
appURI = responseObj.getString("appURI");
//check if we need to upgrade?
if(latestVersionCode > versionCode){
+ Log.d(Config.LOGTAG, "AppUpdater: update available");
//enable touch events
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
@@ -199,6 +202,18 @@ public class UpdaterActivity extends Activity {
request.setAllowedOverRoaming(false);
request.setTitle("Conversations Update");
request.setDestinationInExternalFilesDir(UpdaterActivity.this, Environment.DIRECTORY_DOWNLOADS, "Conversations.apk");
+ //delete old downloaded version files
+ File dir = new File(getExternalFilesDir(null), Environment.DIRECTORY_DOWNLOADS);
+ Log.d(Config.LOGTAG, "AppUpdater - Delete old update files in: " + dir);
+ if (dir.isDirectory())
+ {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++)
+ {
+ new File(dir, children[i]).delete();
+ }
+ }
+
downloadReference = downloadManager.enqueue(request);
Toast.makeText(getApplicationContext(),
getText(R.string.download_started),
@@ -219,7 +234,7 @@ public class UpdaterActivity extends Activity {
Toast.makeText(getApplicationContext(),
getText(R.string.no_update_available),
Toast.LENGTH_SHORT).show();
-
+ Log.d(Config.LOGTAG, "AppUpdater: no update available");
UpdaterActivity.this.finish();
}
@@ -242,16 +257,14 @@ public class UpdaterActivity extends Activity {
long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
if(downloadReference == referenceId){
- Log.v(LOG_TAG, "Downloading of the new app version complete");
+ Log.d(Config.LOGTAG, "AppUpdater: Downloading of the new app version complete. Starting installation");
//start the installation of the latest version
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType(downloadManager.getUriForDownloadedFile(downloadReference),
"application/vnd.android.package-archive");
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(installIntent);
-
}
}
};
-
-}
+} \ No newline at end of file