Skip to content

Commit

Permalink
Add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
SanojPunchihewa committed Jul 24, 2019
1 parent a066756 commit 834698d
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class UpdateManager {

private static final String TAG = "UpdateManager";
private static final String TAG = "InUpdateManager";

private static UpdateManager instance;

Expand All @@ -39,11 +39,13 @@ public static UpdateManager Builder() {
if (instance == null) {
instance = new UpdateManager();
}
Log.i(TAG, "Instance created");
Log.d(TAG, "Instance created");
return instance;
}

public UpdateManager mode(int mode) {
String strMode = mode == FLEXIBLE ? "FLEXIBLE" : "IMMEDIATE";
Log.d(TAG, "Set update mode to : " + strMode);
this.mode = mode;
return this;
}
Expand All @@ -59,25 +61,26 @@ public void start(Activity activity) {

private void checkUpdate(final Activity activity) {
// Checks that the platform will allow the specified type of update.
Log.d(TAG, "Checking for updates");
appUpdateInfoTask.addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() {
@Override
public void onSuccess(AppUpdateInfo appUpdateInfo) {
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(mode)) {
// Request the update.
Log.i(TAG, "Update available");
Log.d(TAG, "Update available");
availableVersionCode = appUpdateInfo.availableVersionCode();
startUpdate(activity, appUpdateInfo);
} else {
Log.i(TAG, "No update available");
Log.d(TAG, "No Update available");
}
}
});
}

private void startUpdate(Activity activity, AppUpdateInfo appUpdateInfo) {
try {
Log.i(TAG, "Starting update");
Log.d(TAG, "Starting update");
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
mode,
Expand Down Expand Up @@ -107,6 +110,7 @@ public void onStateUpdate(InstallState installState) {
if (installState.installStatus() == InstallStatus.DOWNLOADED) {
// After the update is downloaded, show a notification
// and request user confirmation to restart the app.
Log.d(TAG, "An update has been downloaded");
popupSnackbarForCompleteUpdate(activity);
}
}
Expand All @@ -131,6 +135,7 @@ public void onSuccess(AppUpdateInfo appUpdateInfo) {
// If the update is downloaded but not installed,
// notify the user to complete the update.
if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
Log.d(TAG, "An update has been downloaded");
instance.popupSnackbarForCompleteUpdate(activity);
}
}
Expand All @@ -153,7 +158,7 @@ public void onSuccess(AppUpdateInfo appUpdateInfo) {
activity,
UpdateManagerConstant.REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
Log.d(TAG, e.getMessage());
}
}
}
Expand Down

0 comments on commit 834698d

Please sign in to comment.