use of android.net.Uri in project enroscar by stanfy.
the class StreamingPlaybackImpl method getCurrentTrackInfo.
@Override
public Bundle getCurrentTrackInfo() throws RemoteException {
final Bundle bundle = new Bundle();
if (service.getAlbum() != null) {
bundle.putString(StreamingPlaybackService.EXTRA_TRACK_ALBUM, service.getAlbum());
}
if (service.getAuthor() != null) {
bundle.putString(StreamingPlaybackService.EXTRA_TRACK_AUTHOR, service.getAuthor());
}
if (service.getTitle() != null) {
bundle.putString(StreamingPlaybackService.EXTRA_TRACK_TITLE, service.getTitle());
}
final Uri uri = getCurrentUrl();
if (uri != null) {
bundle.putParcelable(StreamingPlaybackService.EXTRA_TRACK_URL, uri);
}
return bundle;
}
use of android.net.Uri in project platform_frameworks_base by android.
the class PackageMonitor method getPackageName.
String getPackageName(Intent intent) {
Uri uri = intent.getData();
String pkg = uri != null ? uri.getSchemeSpecificPart() : null;
return pkg;
}
use of android.net.Uri in project platform_frameworks_base by android.
the class DownloadManagerBaseTest method doEnqueue.
private long doEnqueue(int location) throws Exception {
Uri uri = getServerUri(DEFAULT_FILENAME);
Request request = new Request(uri).setTitle(DEFAULT_FILENAME);
if (location == DOWNLOAD_TO_SYSTEM_CACHE) {
request.setDestinationToSystemCache();
}
return mDownloadManager.enqueue(request);
}
use of android.net.Uri in project platform_frameworks_base by android.
the class DownloadManagerFunctionalTest method testDownloadToExternal.
/**
* Tests trying to download a file to SD card.
*/
@LargeTest
public void testDownloadToExternal() throws Exception {
String localDownloadDirectory = Environment.getExternalStorageDirectory().getPath();
File downloadedFile = new File(localDownloadDirectory, DEFAULT_FILENAME);
// make sure the file doesn't already exist in the directory
downloadedFile.delete();
try {
byte[] blobData = generateData(DEFAULT_FILE_SIZE, DataType.TEXT);
// Prepare the mock server with a standard response
enqueueResponse(buildResponse(HTTP_OK, blobData));
Uri uri = getServerUri(DEFAULT_FILENAME);
Request request = new Request(uri);
Uri localUri = Uri.fromFile(downloadedFile);
request.setDestinationUri(localUri);
long dlRequest = mDownloadManager.enqueue(request);
// wait for the download to complete
waitForDownloadOrTimeout(dlRequest);
verifyAndCleanupSingleFileDownload(dlRequest, blobData);
assertEquals(1, mReceiver.numDownloadsCompleted());
} finally {
downloadedFile.delete();
}
}
use of android.net.Uri in project platform_frameworks_base by android.
the class DownloadManagerFunctionalTest method testDownloadNoWifi.
/**
* Tests that a download set for Wifi does not progress while Wifi is disabled, but resumes
* once Wifi is re-enabled.
*/
@LargeTest
public void testDownloadNoWifi() throws Exception {
// wait only 60 seconds before giving up
long timeout = 60 * 1000;
// 140k
int fileSize = 1024;
byte[] blobData = generateData(fileSize, DataType.TEXT);
setWiFiStateOn(false);
enqueueResponse(buildResponse(HTTP_OK, blobData));
try {
Uri uri = getServerUri(DEFAULT_FILENAME);
Request request = new Request(uri);
request.setAllowedNetworkTypes(Request.NETWORK_WIFI);
long dlRequest = mDownloadManager.enqueue(request);
// wait for the download to complete
boolean success = waitForDownloadOrTimeoutNoThrow(dlRequest, WAIT_FOR_DOWNLOAD_POLL_TIME, timeout);
assertFalse("Download proceeded without Wifi connection!", success);
setWiFiStateOn(true);
waitForDownloadOrTimeout(dlRequest);
assertEquals(1, mReceiver.numDownloadsCompleted());
} finally {
setWiFiStateOn(true);
}
}
Aggregations