diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkDownloadReceiver.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkDownloadReceiver.java index 5a8303eb41..27268436d2 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarkDownloadReceiver.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkDownloadReceiver.java @@ -10,10 +10,12 @@ import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; import com.mapswithme.maps.background.AbstractLogBroadcastReceiver; +import com.mapswithme.maps.base.Detachable; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.bookmarks.data.Error; import com.mapswithme.maps.bookmarks.data.Result; -import com.mapswithme.maps.base.Detachable; +import com.mapswithme.util.log.Logger; +import com.mapswithme.util.log.LoggerFactory; public class BookmarkDownloadReceiver extends AbstractLogBroadcastReceiver implements Detachable { @@ -53,17 +55,21 @@ public class BookmarkDownloadReceiver extends AbstractLogBroadcastReceiver imple @Override public void onReceiveInternal(@NonNull Context context, @NonNull Intent intent) { + Logger logger = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); + String tag = BookmarkDownloadReceiver.class.getSimpleName(); OperationStatus status = intent.getParcelableExtra(SystemDownloadCompletedService.EXTRA_DOWNLOAD_STATUS); Result result = status.getResult(); if (status.isOk() && result != null && !TextUtils.isEmpty(result.getArchiveId()) && !TextUtils.isEmpty(result.getFilePath())) { - + logger.i(tag, "Start to import downloaded bookmark"); BookmarkManager.INSTANCE.importFromCatalog(result.getArchiveId(), result.getFilePath()); return; } + logger.i(tag, "Handle download result by handler '" + mHandler + "'"); + Error error = status.getError(); if (error == null || mHandler == null) return; diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadManager.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadManager.java index ce57c43546..ed0476d5c6 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadManager.java @@ -21,7 +21,8 @@ public class BookmarksDownloadManager { private static final String QUERY_PARAM_ID_KEY = "id"; private static final String QUERY_PARAM_NAME_KEY = "name"; - private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC); + private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); + private static final String TAG = BookmarksDownloadManager.class.getSimpleName(); @NonNull private final Context mContext; @@ -48,7 +49,7 @@ public class BookmarksDownloadManager Uri srcUri = uriPair.first; Uri dstUri = uriPair.second; - LOGGER.d("Bookmarks catalog url", "Value = " + dstUri); + LOGGER.d(TAG, "Bookmarks catalog url = " + dstUri); DownloadManager.Request request = new DownloadManager .Request(dstUri) .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE) @@ -58,9 +59,14 @@ public class BookmarksDownloadManager String accessToken = Framework.nativeGetAccessToken(); if (!TextUtils.isEmpty(accessToken)) { + LOGGER.d(TAG, "User authorized"); String headerValue = HttpClient.HEADER_BEARER_PREFFIX + accessToken; request.addRequestHeader(HttpClient.HEADER_AUTHORIZATION, headerValue); } + else + { + LOGGER.d(TAG, "User not authorized"); + } String title = makeTitle(srcUri); if (!TextUtils.isEmpty(title)) diff --git a/android/src/com/mapswithme/maps/bookmarks/DefaultBookmarkDownloadController.java b/android/src/com/mapswithme/maps/bookmarks/DefaultBookmarkDownloadController.java index 36aeb1825b..7610ccedf6 100644 --- a/android/src/com/mapswithme/maps/bookmarks/DefaultBookmarkDownloadController.java +++ b/android/src/com/mapswithme/maps/bookmarks/DefaultBookmarkDownloadController.java @@ -18,8 +18,7 @@ import java.net.MalformedURLException; class DefaultBookmarkDownloadController implements BookmarkDownloadController, BookmarkDownloadHandler { - private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC); - private static final Logger BILLING_LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); + private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); private static final String TAG = DefaultBookmarkDownloadController.class.getSimpleName(); private static final String EXTRA_DOWNLOAD_URL = "extra_download_url"; @NonNull @@ -112,7 +111,7 @@ class DefaultBookmarkDownloadController implements BookmarkDownloadController, @Override public void onAuthorizationRequired() { - BILLING_LOGGER.i(TAG, "Authorization required for bookmark purchase"); + LOGGER.i(TAG, "Authorization required for bookmark purchase"); if (mCallback != null) mCallback.onAuthorizationRequired(); } @@ -120,7 +119,7 @@ class DefaultBookmarkDownloadController implements BookmarkDownloadController, @Override public void onPaymentRequired() { - BILLING_LOGGER.i(TAG, "Payment required for bookmark purchase"); + LOGGER.i(TAG, "Payment required for bookmark purchase"); if (TextUtils.isEmpty(mDownloadUrl)) throw new IllegalStateException("Download url must be non-null if payment required!"); diff --git a/android/src/com/mapswithme/maps/bookmarks/OperationStatus.java b/android/src/com/mapswithme/maps/bookmarks/OperationStatus.java index 33f614a72e..eae310ada2 100644 --- a/android/src/com/mapswithme/maps/bookmarks/OperationStatus.java +++ b/android/src/com/mapswithme/maps/bookmarks/OperationStatus.java @@ -70,4 +70,13 @@ public class OperationStatus implements Parcelable dest.writeParcelable(mResult, flags); dest.writeParcelable(mError, flags); } + + @Override + public String toString() + { + return "OperationStatus{" + + "mResult=" + mResult + + ", mError=" + mError + + '}'; + } } diff --git a/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedService.java b/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedService.java index a9469f6574..4736606908 100644 --- a/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedService.java +++ b/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedService.java @@ -15,6 +15,8 @@ import com.mapswithme.maps.bookmarks.data.Error; import com.mapswithme.maps.bookmarks.data.Result; import com.mapswithme.util.Utils; import com.mapswithme.util.concurrency.UiThread; +import com.mapswithme.util.log.Logger; +import com.mapswithme.util.log.LoggerFactory; import java.io.IOException; @@ -41,6 +43,9 @@ public class SystemDownloadCompletedService extends JobIntentService throw new IllegalStateException("Failed to get a download manager"); final OperationStatus status = doInBackground(manager, intent); + Logger logger = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); + String tag = SystemDownloadCompletedService.class.getSimpleName(); + logger.i(tag, "Download status: " + status); UiThread.run(new SendStatusTask(getApplicationContext(), status)); } diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Error.java b/android/src/com/mapswithme/maps/bookmarks/data/Error.java index c961ee5b2e..24579d69f6 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/Error.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/Error.java @@ -63,6 +63,15 @@ public class Error implements Parcelable dest.writeString(mMessage); } + @Override + public String toString() + { + return "Error{" + + "mHttpCode=" + mHttpCode + + ", mMessage='" + mMessage + '\'' + + '}'; + } + public static final Creator CREATOR = new Creator() { @Override diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Result.java b/android/src/com/mapswithme/maps/bookmarks/data/Result.java index 1f5d50825e..d15e8afae9 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/Result.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/Result.java @@ -48,6 +48,15 @@ public class Result implements Parcelable dest.writeString(mArchiveId); } + @Override + public String toString() + { + return "Result{" + + "mFilePath='" + mFilePath + '\'' + + ", mArchiveId='" + mArchiveId + '\'' + + '}'; + } + public static final Creator CREATOR = new Creator() { @Override