Merge "Append product and device parameters to download url." into nyc-mr1-dev
diff --git a/src/com/android/retaildemo/DownloadVideoTask.java b/src/com/android/retaildemo/DownloadVideoTask.java
index d635553..550409c 100644
--- a/src/com/android/retaildemo/DownloadVideoTask.java
+++ b/src/com/android/retaildemo/DownloadVideoTask.java
@@ -26,6 +26,7 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
+import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -45,6 +46,9 @@
private static final String TAG = "DownloadVideoTask";
private static final boolean DEBUG = false;
+ private static final String URL_PARAMETER_PRODUCT = "product";
+ private static final String URL_PARAMETER_DEVICE = "device";
+
private static final int MSG_CHECK_FOR_UPDATE = 1;
private static final int MSG_DOWNLOAD_COMPLETE = 2;
private static final int MSG_CLEANUP_DOWNLOAD_DIR = 3;
@@ -73,6 +77,7 @@
mDlm = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
mDownloadUrl = mContext.getString(R.string.retail_demo_video_download_url);
+ appendProductDeviceParamsToUrl();
}
public void run() {
@@ -105,7 +110,8 @@
private void startDownload() {
final DownloadManager.Request request = createDownloadRequest();
mVideoDownloadId = mDlm.enqueue(request);
- if (DEBUG) Log.d(TAG, "Started downloading the video at " + mDownloadFile.getPath());
+ if (DEBUG) Log.d(TAG, "Started downloading the video at " + mDownloadUrl
+ + " to " + mDownloadFile.getPath());
showProgressDialog();
}
@@ -160,7 +166,8 @@
}
final DownloadManager.Request request = createDownloadRequest();
mVideoUpdateDownloadId = mDlm.enqueue(request);
- if (DEBUG) Log.d(TAG, "Started downloading the updated video");
+ if (DEBUG) Log.d(TAG, "Started downloading the updated video at "
+ + mDownloadUrl);
} catch (IOException e) {
Log.e(TAG, "Error while checking for an updated video", e);
} finally {
@@ -245,6 +252,15 @@
}
};
+ private void appendProductDeviceParamsToUrl() {
+ mDownloadUrl = Uri.parse(mDownloadUrl)
+ .buildUpon()
+ .appendQueryParameter(URL_PARAMETER_PRODUCT, Build.PRODUCT)
+ .appendQueryParameter(URL_PARAMETER_DEVICE, Build.DEVICE)
+ .build()
+ .toString();
+ }
+
private void showProgressDialog() {
mProgressDialog = new ProgressDialog(mContext);
mProgressDialog.setMessage(mContext.getString(R.string.downloading_video_msg));