[android] Added logging to BookmarkBackpuController

This commit is contained in:
Alexander Zatsepin 2018-05-08 14:34:37 +03:00 committed by Aleksandr Zatsepin
parent 459e404403
commit a2056fbbb4
2 changed files with 28 additions and 2 deletions

View file

@ -19,6 +19,8 @@ import com.mapswithme.util.DateUtils;
import com.mapswithme.util.DialogUtils;
import com.mapswithme.util.NetworkPolicy;
import com.mapswithme.util.Utils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import com.mapswithme.util.statistics.Statistics;
import java.util.Date;
@ -38,6 +40,8 @@ import static com.mapswithme.maps.bookmarks.data.BookmarkManager.CLOUD_USER_INTE
public class BookmarkBackupController implements Authorizer.Callback,
BookmarkManager.BookmarksCloudListener
{
private static final String TAG = BookmarkBackupController.class.getSimpleName();
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
@NonNull
private final FragmentActivity mContext;
@NonNull
@ -91,6 +95,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
}
NetworkPolicy.NetworkPolicyListener policyListener = policy -> {
LOGGER.d(TAG, "Request bookmark restoring");
BookmarkManager.INSTANCE.requestRestoring();
};
@ -197,12 +202,14 @@ public class BookmarkBackupController implements Authorizer.Callback,
@Override
public void onAuthorizationStart()
{
LOGGER.d(TAG, "onAuthorizationStart");
updateWidget();
}
@Override
public void onAuthorizationFinish(boolean success)
{
LOGGER.d(TAG, "onAuthorizationFinish, success: " + success);
if (success)
{
Notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED);
@ -219,18 +226,22 @@ public class BookmarkBackupController implements Authorizer.Callback,
@Override
public void onSocialAuthenticationError(@Framework.AuthTokenType int type, @Nullable String error)
{
LOGGER.w(TAG, "onSocialAuthenticationError, type: " + Statistics.getAuthProvider(type) +
" error: " + error);
Statistics.INSTANCE.trackBmSyncProposalError(type, error);
}
@Override
public void onSocialAuthenticationCancel(@Framework.AuthTokenType int type)
{
LOGGER.i(TAG, "onSocialAuthenticationCancel, type: " + Statistics.getAuthProvider(type));
Statistics.INSTANCE.trackBmSyncProposalError(type, "Cancel");
}
@Override
public void onSynchronizationStarted(@BookmarkManager.SynchronizationType int type)
{
LOGGER.d(TAG, "onSynchronizationStarted, type: " + Statistics.getSynchronizationType(type));
switch (type)
{
case CLOUD_BACKUP:
@ -250,6 +261,8 @@ public class BookmarkBackupController implements Authorizer.Callback,
@BookmarkManager.SynchronizationResult int result,
@NonNull String errorString)
{
LOGGER.d(TAG, "onSynchronizationFinished, type: " + Statistics.getSynchronizationType(type)
+ ", result: " + result + ", errorString = " + errorString);
hideRestoringProgressDialog();
updateWidget();
@ -276,6 +289,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
R.string.error_system_message);
break;
case CLOUD_INVALID_CALL:
throw new AssertionError("Check correctness of cloud api usage!");
case CLOUD_USER_INTERRUPTED:
case CLOUD_SUCCESS:
// Do nothing.
@ -290,6 +304,8 @@ public class BookmarkBackupController implements Authorizer.Callback,
public void onRestoreRequested(@BookmarkManager.RestoringRequestResult int result,
long backupTimestampInMs)
{
LOGGER.d(TAG, "onRestoreRequested, result: " + result + ", backupTimestampInMs = "
+ backupTimestampInMs);
hideRestoringProgressDialog();
final DialogInterface.OnClickListener cancelListener
@ -328,6 +344,6 @@ public class BookmarkBackupController implements Authorizer.Callback,
@Override
public void onRestoredFilesPrepared()
{
// No op.
LOGGER.d(TAG, "onRestoredFilesPrepared()");
}
}

View file

@ -104,6 +104,7 @@ import static com.mapswithme.util.statistics.Statistics.EventParam.RESTAURANT_LO
import static com.mapswithme.util.statistics.Statistics.EventParam.STATE;
import static com.mapswithme.util.statistics.Statistics.EventParam.TYPE;
import static com.mapswithme.util.statistics.Statistics.EventParam.VALUE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.BACKUP;
import static com.mapswithme.util.statistics.Statistics.ParamValue.BOOKING_COM;
import static com.mapswithme.util.statistics.Statistics.ParamValue.FACEBOOK;
import static com.mapswithme.util.statistics.Statistics.ParamValue.GOOGLE;
@ -111,6 +112,7 @@ import static com.mapswithme.util.statistics.Statistics.ParamValue.HOLIDAY;
import static com.mapswithme.util.statistics.Statistics.ParamValue.MAPSME;
import static com.mapswithme.util.statistics.Statistics.ParamValue.OPENTABLE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.PHONE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.RESTORE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.SEARCH_BOOKING_COM;
import static com.mapswithme.util.statistics.Statistics.ParamValue.UNKNOWN;
import static com.mapswithme.util.statistics.Statistics.ParamValue.VIATOR;
@ -415,6 +417,8 @@ public enum Statistics
static final String AUTH = "auth";
static final String USER_INTERRUPTED = "user_interrupted";
static final String INVALID_CALL = "invalid_call";
static final String BACKUP = "backup";
static final String RESTORE = "restore";
}
// Initialized once in constructor and does not change until the process restarts.
@ -994,7 +998,7 @@ public enum Statistics
}
@NonNull
private static String getAuthProvider(@Framework.AuthTokenType int type)
public static String getAuthProvider(@Framework.AuthTokenType int type)
{
switch (type)
{
@ -1013,6 +1017,12 @@ public enum Statistics
}
}
@NonNull
public static String getSynchronizationType(@BookmarkManager.SynchronizationType int type)
{
return type == 0 ? BACKUP : RESTORE;
}
public void trackDiscoveryOpen()
{
trackEvent(DISCOVERY_OPEN, params().add(NETWORK, getConnectionState()));