forked from organicmaps/organicmaps
[android] Added additional logs for bookmark payment flow
This commit is contained in:
parent
78077de0a8
commit
3f1ecca1aa
7 changed files with 51 additions and 8 deletions
|
@ -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<BookmarkDownloadHandler>
|
||||
{
|
||||
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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!");
|
||||
|
||||
|
|
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Error> CREATOR = new Creator<Error>()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -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<Result> CREATOR = new Creator<Result>()
|
||||
{
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue