Skip to content

Commit

Permalink
refactor android side plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
parveshneedhoo committed Aug 22, 2024
1 parent 5005ce3 commit ae16170
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/android/AckDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class AckDatabase extends RoomDatabase {
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE upload_events ADD COLUMN uploadDuration INTEGER NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE upload_events ADD COLUMN startUploadTime INTEGER NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE upload_events ADD COLUMN endUploadTime INTEGER NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE upload_events ADD COLUMN finishUploadTime INTEGER NOT NULL DEFAULT 0");
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/android/FileTransferBackground.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void sendProgress(final String id, int progressPercent) {
}
}

private void sendSuccess(final String id, final String response, int statusCode, long uploadDuration, long uploadStartTime, long uploadEndTime) {
private void sendSuccess(final String id, final String response, int statusCode, long uploadDuration, long startUploadTime, long finishUploadTime) {
if (response != null && !response.isEmpty()) {
logMessage("eventLabel='Uploader onSuccess' uploadId='" + id + "' response='" + response.substring(0, Math.min(2000, response.length() - 1)) + "'");
} else {
Expand All @@ -96,8 +96,8 @@ private void sendSuccess(final String id, final String response, int statusCode,
.put("serverResponse", response)
.put("statusCode", statusCode)
.put("uploadDuration", uploadDuration)
.put("uploadStartTime", uploadStartTime)
.put("uploadEndTime", uploadEndTime)
.put("startUploadTime", startUploadTime)
.put("finishUploadTime", finishUploadTime)
);
} catch (JSONException e) {
// Can't really happen but just in case
Expand Down
20 changes: 10 additions & 10 deletions src/android/UploadEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public UploadEvent(@NonNull final String id, @NonNull final Data outputData) {
this.id = id;
this.outputData = outputData;
this.uploadDuration = outputData.getLong(UploadTask.KEY_OUTPUT_UPLOAD_DURATION, 0);
this.uploadStartTime = outputData.getLong(UploadTask.KEY_OUTPUT_UPLOAD_START_TIME, 0);
this.uploadEndTime = outputData.getLong(UploadTask.KEY_OUTPUT_UPLOAD_END_TIME, 0);
this.startUploadTime = outputData.getLong(UploadTask.KEY_OUTPUT_UPLOAD_START_TIME, 0);
this.finishUploadTime = outputData.getLong(UploadTask.KEY_OUTPUT_UPLOAD_END_TIME, 0);
}

@NonNull
Expand All @@ -46,19 +46,19 @@ public void setUploadDuration(long uploadDuration) {
this.uploadDuration = uploadDuration;
}

public long getUploadStartTime() {
return uploadStartTime;
public long getStartUploadTime() {
return startUploadTime;
}

public void setUploadStartTime(long uploadStartTime) {
this.uploadStartTime = uploadStartTime;
public void setStartUploadTime(long startUploadTime) {
this.startUploadTime = startUploadTime;
}

public long getUploadEndTime() {
return uploadEndTime;
public long getFinishUploadTime() {
return finishUploadTime;
}

public void setUploadEndTime(long uploadEndTime) {
this.uploadEndTime = uploadEndTime;
public void setFinishUploadTime(long finishUploadTime) {
this.finishUploadTime = finishUploadTime;
}
}
8 changes: 4 additions & 4 deletions src/android/UploadTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void release() { }
private static Semaphore concurrentUploads = new Semaphore(concurrency, true);
private static Mutex concurrencyLock = new Mutex();
private long startUploadTime;
private long endUploadTime;
private long finishUploadTime;
private long uploadDuration;

public UploadTask(@NonNull Context context, @NonNull WorkerParameters workerParams) {
Expand Down Expand Up @@ -255,8 +255,8 @@ public Result doWork() {
return Result.retry();
}
} finally {
endUploadTime = System.currentTimeMillis();
uploadDuration = endUploadTime - startUploadTime;
finishUploadTime = System.currentTimeMillis();
uploadDuration = finishUploadTime - startUploadTime;
// Always remove ourselves from the notification
uploadForegroundNotification.done(getId());
}
Expand All @@ -268,7 +268,7 @@ public Result doWork() {
.putInt(KEY_OUTPUT_STATUS_CODE, (!DEBUG_SKIP_UPLOAD) ? response.code() : 200)
.putLong(KEY_OUTPUT_UPLOAD_DURATION, uploadDuration)
.putLong(KEY_OUTPUT_UPLOAD_START_TIME, startUploadTime)
.putLong(KEY_OUTPUT_UPLOAD_END_TIME, endUploadTime);
.putLong(KEY_OUTPUT_UPLOAD_END_TIME, finishUploadTime);

// Try read the response body, if any
try {
Expand Down

0 comments on commit ae16170

Please sign in to comment.