├── MODULE_LICENSE_APACHE2 ├── ui ├── res │ ├── drawable-hdpi │ │ ├── ic_menu_desk_clock.png │ │ ├── ic_launcher_download.png │ │ ├── ic_launcher_drm_file.png │ │ └── ic_download_misc_file_type.png │ ├── drawable-mdpi │ │ ├── ic_menu_desk_clock.png │ │ ├── ic_launcher_download.png │ │ ├── ic_launcher_drm_file.png │ │ └── ic_download_misc_file_type.png │ ├── values │ │ └── dimen.xml │ ├── anim │ │ ├── footer_appear.xml │ │ └── footer_disappear.xml │ ├── menu │ │ └── download_menu.xml │ ├── layout │ │ ├── list_group_header.xml │ │ ├── download_list.xml │ │ └── download_list_item.xml │ ├── values-zh-rTW │ │ └── strings.xml │ ├── values-zh-rCN │ │ └── strings.xml │ ├── values-ja │ │ └── strings.xml │ ├── values-ko │ │ └── strings.xml │ ├── values-cs │ │ └── strings.xml │ ├── values-ru │ │ └── strings.xml │ ├── values-da │ │ └── strings.xml │ ├── values-tr │ │ └── strings.xml │ ├── values-nb │ │ └── strings.xml │ ├── values-es-rUS │ │ └── strings.xml │ ├── values-nl │ │ └── strings.xml │ ├── values-pl │ │ └── strings.xml │ ├── values-sv │ │ └── strings.xml │ ├── values-es │ │ └── strings.xml │ ├── values-it │ │ └── strings.xml │ ├── values-el │ │ └── strings.xml │ ├── values-pt │ │ └── strings.xml │ ├── values-pt-rPT │ │ └── strings.xml │ ├── values-fr │ │ └── strings.xml │ └── values-de │ │ └── strings.xml ├── Android.mk ├── AndroidManifest.xml └── src │ └── com │ └── android │ └── providers │ └── downloads │ └── ui │ ├── DateSortedDownloadAdapter.java │ └── DownloadItem.java ├── Android.mk ├── tests ├── permission │ ├── Android.mk │ ├── AndroidManifest.xml │ └── src │ │ └── com │ │ └── android │ │ └── providers │ │ └── downloads │ │ └── permission │ │ └── tests │ │ └── DownloadProviderPermissionsTest.java ├── public_api_access │ ├── Android.mk │ └── AndroidManifest.xml ├── Android.mk ├── AndroidManifest.xml └── src │ ├── com │ └── android │ │ └── providers │ │ └── downloads │ │ ├── ThreadingTest.java │ │ ├── FakeSystemFacade.java │ │ └── AbstractPublicApiTest.java │ └── tests │ └── http │ ├── RecordedRequest.java │ └── MockResponse.java ├── res ├── values │ └── styles.xml ├── values-zh-rCN │ └── strings.xml ├── values-zh-rTW │ └── strings.xml ├── values-ja │ └── strings.xml ├── values-ko │ └── strings.xml ├── layout │ └── status_bar_ongoing_event_progress_bar.xml ├── values-nb │ └── strings.xml ├── values-sv │ └── strings.xml ├── values-cs │ └── strings.xml ├── values-ru │ └── strings.xml ├── values-da │ └── strings.xml ├── values-tr │ └── strings.xml ├── values-es │ └── strings.xml ├── values-pt │ └── strings.xml ├── values-es-rUS │ └── strings.xml └── values-pl │ └── strings.xml ├── src └── com │ └── android │ └── providers │ └── downloads │ ├── SystemFacade.java │ ├── RealSystemFacade.java │ └── SizeLimitActivity.java ├── CleanSpec.mk └── AndroidManifest.xml /MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/res/drawable-hdpi/ic_menu_desk_clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-hdpi/ic_menu_desk_clock.png -------------------------------------------------------------------------------- /ui/res/drawable-mdpi/ic_menu_desk_clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-mdpi/ic_menu_desk_clock.png -------------------------------------------------------------------------------- /ui/res/drawable-hdpi/ic_launcher_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-hdpi/ic_launcher_download.png -------------------------------------------------------------------------------- /ui/res/drawable-hdpi/ic_launcher_drm_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-hdpi/ic_launcher_drm_file.png -------------------------------------------------------------------------------- /ui/res/drawable-mdpi/ic_launcher_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-mdpi/ic_launcher_download.png -------------------------------------------------------------------------------- /ui/res/drawable-mdpi/ic_launcher_drm_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-mdpi/ic_launcher_drm_file.png -------------------------------------------------------------------------------- /ui/res/drawable-hdpi/ic_download_misc_file_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-hdpi/ic_download_misc_file_type.png -------------------------------------------------------------------------------- /ui/res/drawable-mdpi/ic_download_misc_file_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redux/android_packages_providers_DownloadProvider/gingerbread/ui/res/drawable-mdpi/ic_download_misc_file_type.png -------------------------------------------------------------------------------- /ui/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE_TAGS := optional 5 | 6 | LOCAL_SRC_FILES := $(call all-java-files-under, src) 7 | 8 | LOCAL_PACKAGE_NAME := DownloadProviderUi 9 | LOCAL_CERTIFICATE := media 10 | 11 | include $(BUILD_PACKAGE) 12 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE_TAGS := optional 5 | 6 | LOCAL_SRC_FILES := $(call all-java-files-under, src) 7 | 8 | 9 | LOCAL_PACKAGE_NAME := DownloadProvider 10 | LOCAL_CERTIFICATE := media 11 | LOCAL_STATIC_JAVA_LIBRARIES := guava 12 | 13 | include $(BUILD_PACKAGE) 14 | 15 | # build UI + tests 16 | include $(call all-makefiles-under,$(LOCAL_PATH)) 17 | -------------------------------------------------------------------------------- /tests/permission/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # We only want this apk build for tests. 5 | LOCAL_MODULE_TAGS := tests 6 | 7 | # Include all test java files. 8 | LOCAL_SRC_FILES := $(call all-java-files-under, src) 9 | 10 | LOCAL_JAVA_LIBRARIES := android.test.runner 11 | LOCAL_PACKAGE_NAME := DownloadProviderPermissionTests 12 | 13 | include $(BUILD_PACKAGE) 14 | 15 | -------------------------------------------------------------------------------- /tests/public_api_access/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # We only want this apk build for tests. 5 | LOCAL_MODULE_TAGS := tests 6 | 7 | # Include all test java files. 8 | LOCAL_SRC_FILES := $(call all-java-files-under, src) 9 | 10 | LOCAL_JAVA_LIBRARIES := android.test.runner 11 | LOCAL_PACKAGE_NAME := DownloadPublicApiAccessTests 12 | 13 | include $(BUILD_PACKAGE) 14 | 15 | -------------------------------------------------------------------------------- /tests/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # We only want this apk build for tests. 5 | LOCAL_MODULE_TAGS := tests 6 | 7 | # Include all test java files. 8 | LOCAL_SRC_FILES := $(call all-java-files-under, src) 9 | LOCAL_INSTRUMENTATION_FOR := DownloadProvider 10 | LOCAL_JAVA_LIBRARIES := android.test.runner 11 | LOCAL_PACKAGE_NAME := DownloadProviderTests 12 | LOCAL_CERTIFICATE := media 13 | 14 | include $(BUILD_PACKAGE) 15 | 16 | # additionally, build sub-tests in a separate .apk 17 | include $(call all-makefiles-under,$(LOCAL_PATH)) 18 | -------------------------------------------------------------------------------- /ui/res/values/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 40dip 19 | 20 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /ui/res/anim/footer_appear.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 25 | 26 | -------------------------------------------------------------------------------- /ui/res/anim/footer_disappear.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 25 | 26 | -------------------------------------------------------------------------------- /ui/res/menu/download_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 21 | 24 | 25 | -------------------------------------------------------------------------------- /ui/res/layout/list_group_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 25 | -------------------------------------------------------------------------------- /ui/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/public_api_access/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 33 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /tests/permission/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 35 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/src/com/android/providers/downloads/ThreadingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.providers.downloads; 18 | 19 | import android.app.DownloadManager; 20 | import android.test.suitebuilder.annotation.LargeTest; 21 | 22 | /** 23 | * Download manager tests that require multithreading. 24 | */ 25 | @LargeTest 26 | public class ThreadingTest extends AbstractPublicApiTest { 27 | private static class FakeSystemFacadeWithThreading extends FakeSystemFacade { 28 | @Override 29 | public void startThread(Thread thread) { 30 | thread.start(); 31 | } 32 | } 33 | 34 | public ThreadingTest() { 35 | super(new FakeSystemFacadeWithThreading()); 36 | } 37 | 38 | @Override 39 | protected void tearDown() throws Exception { 40 | Thread.sleep(50); // give threads a chance to finish 41 | super.tearDown(); 42 | } 43 | 44 | /** 45 | * Test for race conditions when the service is flooded with startService() calls while running 46 | * a download. 47 | */ 48 | public void testFloodServiceWithStarts() throws Exception { 49 | enqueueResponse(HTTP_OK, FILE_CONTENT); 50 | Download download = enqueueRequest(getRequest()); 51 | while (download.getStatus() != DownloadManager.STATUS_SUCCESSFUL) { 52 | startService(null); 53 | Thread.sleep(10); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/com/android/providers/downloads/SystemFacade.java: -------------------------------------------------------------------------------- 1 | 2 | package com.android.providers.downloads; 3 | 4 | import android.app.Notification; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager.NameNotFoundException; 7 | 8 | 9 | interface SystemFacade { 10 | /** 11 | * @see System#currentTimeMillis() 12 | */ 13 | public long currentTimeMillis(); 14 | 15 | /** 16 | * @return Network type (as in ConnectivityManager.TYPE_*) of currently active network, or null 17 | * if there's no active connection. 18 | */ 19 | public Integer getActiveNetworkType(); 20 | 21 | /** 22 | * @see android.telephony.TelephonyManager#isNetworkRoaming 23 | */ 24 | public boolean isNetworkRoaming(); 25 | 26 | /** 27 | * @return maximum size, in bytes, of downloads that may go over a mobile connection; or null if 28 | * there's no limit 29 | */ 30 | public Long getMaxBytesOverMobile(); 31 | 32 | /** 33 | * @return recommended maximum size, in bytes, of downloads that may go over a mobile 34 | * connection; or null if there's no recommended limit. The user will have the option to bypass 35 | * this limit. 36 | */ 37 | public Long getRecommendedMaxBytesOverMobile(); 38 | 39 | /** 40 | * Send a broadcast intent. 41 | */ 42 | public void sendBroadcast(Intent intent); 43 | 44 | /** 45 | * Returns true if the specified UID owns the specified package name. 46 | */ 47 | public boolean userOwnsPackage(int uid, String pckg) throws NameNotFoundException; 48 | 49 | /** 50 | * Post a system notification to the NotificationManager. 51 | */ 52 | public void postNotification(long id, Notification notification); 53 | 54 | /** 55 | * Cancel a system notification. 56 | */ 57 | public void cancelNotification(long id); 58 | 59 | /** 60 | * Cancel all system notifications. 61 | */ 62 | public void cancelAllNotifications(); 63 | 64 | /** 65 | * Start a thread. 66 | */ 67 | public void startThread(Thread thread); 68 | } 69 | -------------------------------------------------------------------------------- /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # ************************************************ 48 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 49 | # ************************************************ 50 | -------------------------------------------------------------------------------- /ui/src/com/android/providers/downloads/ui/DateSortedDownloadAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package com.android.providers.downloads.ui; 19 | 20 | import com.android.providers.downloads.ui.DownloadItem.DownloadSelectListener; 21 | 22 | import android.app.DownloadManager; 23 | import android.content.Context; 24 | import android.database.Cursor; 25 | import android.view.View; 26 | import android.view.ViewGroup; 27 | import android.widget.RelativeLayout; 28 | 29 | /** 30 | * Adapter for a date-sorted list of downloads. Delegates all the real work to 31 | * {@link DownloadAdapter}. 32 | */ 33 | public class DateSortedDownloadAdapter extends DateSortedExpandableListAdapter { 34 | private DownloadAdapter mDelegate; 35 | 36 | public DateSortedDownloadAdapter(Context context, Cursor cursor, 37 | DownloadSelectListener selectionListener) { 38 | super(context, cursor, 39 | cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP)); 40 | mDelegate = new DownloadAdapter(context, cursor, selectionListener); 41 | } 42 | 43 | @Override 44 | public View getChildView(int groupPosition, int childPosition, 45 | boolean isLastChild, View convertView, ViewGroup parent) { 46 | // The layout file uses a RelativeLayout, whereas the GroupViews use TextView. 47 | if (null == convertView || !(convertView instanceof RelativeLayout)) { 48 | convertView = mDelegate.newView(); 49 | } 50 | 51 | // Bail early if the Cursor is closed. 52 | if (!moveCursorToChildPosition(groupPosition, childPosition)) { 53 | return convertView; 54 | } 55 | 56 | mDelegate.bindView(convertView); 57 | return convertView; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/src/tests/http/RecordedRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package tests.http; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * An HTTP request that came into the mock web server. 23 | */ 24 | public final class RecordedRequest { 25 | private final String requestLine; 26 | private final List headers; 27 | private final List chunkSizes; 28 | private final int bodySize; 29 | private final byte[] body; 30 | private final int sequenceNumber; 31 | 32 | RecordedRequest(String requestLine, List headers, List chunkSizes, 33 | int bodySize, byte[] body, int sequenceNumber) { 34 | this.requestLine = requestLine; 35 | this.headers = headers; 36 | this.chunkSizes = chunkSizes; 37 | this.bodySize = bodySize; 38 | this.body = body; 39 | this.sequenceNumber = sequenceNumber; 40 | } 41 | 42 | public String getRequestLine() { 43 | return requestLine; 44 | } 45 | 46 | public List getHeaders() { 47 | return headers; 48 | } 49 | 50 | /** 51 | * Returns the sizes of the chunks of this request's body, or an empty list 52 | * if the request's body was empty or unchunked. 53 | */ 54 | public List getChunkSizes() { 55 | return chunkSizes; 56 | } 57 | 58 | /** 59 | * Returns the total size of the body of this POST request (before 60 | * truncation). 61 | */ 62 | public int getBodySize() { 63 | return bodySize; 64 | } 65 | 66 | /** 67 | * Returns the body of this POST request. This may be truncated. 68 | */ 69 | public byte[] getBody() { 70 | return body; 71 | } 72 | 73 | /** 74 | * Returns the index of this request on its HTTP connection. Since a single 75 | * HTTP connection may serve multiple requests, each request is assigned its 76 | * own sequence number. 77 | */ 78 | public int getSequenceNumber() { 79 | return sequenceNumber; 80 | } 81 | 82 | @Override public String toString() { 83 | return requestLine; 84 | } 85 | 86 | public String getMethod() { 87 | return getRequestLine().split(" ")[0]; 88 | } 89 | 90 | public String getPath() { 91 | return getRequestLine().split(" ")[1]; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /tests/src/com/android/providers/downloads/FakeSystemFacade.java: -------------------------------------------------------------------------------- 1 | package com.android.providers.downloads; 2 | 3 | import android.app.Notification; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager.NameNotFoundException; 6 | import android.net.ConnectivityManager; 7 | import android.test.AssertionFailedError; 8 | 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | import java.util.LinkedList; 12 | import java.util.List; 13 | import java.util.Map; 14 | import java.util.Queue; 15 | 16 | public class FakeSystemFacade implements SystemFacade { 17 | long mTimeMillis = 0; 18 | Integer mActiveNetworkType = ConnectivityManager.TYPE_WIFI; 19 | boolean mIsRoaming = false; 20 | Long mMaxBytesOverMobile = null; 21 | Long mRecommendedMaxBytesOverMobile = null; 22 | List mBroadcastsSent = new ArrayList(); 23 | Map mActiveNotifications = new HashMap(); 24 | List mCanceledNotifications = new ArrayList(); 25 | Queue mStartedThreads = new LinkedList(); 26 | 27 | void incrementTimeMillis(long delta) { 28 | mTimeMillis += delta; 29 | } 30 | 31 | public long currentTimeMillis() { 32 | return mTimeMillis; 33 | } 34 | 35 | public Integer getActiveNetworkType() { 36 | return mActiveNetworkType; 37 | } 38 | 39 | public boolean isNetworkRoaming() { 40 | return mIsRoaming; 41 | } 42 | 43 | public Long getMaxBytesOverMobile() { 44 | return mMaxBytesOverMobile ; 45 | } 46 | 47 | public Long getRecommendedMaxBytesOverMobile() { 48 | return mRecommendedMaxBytesOverMobile ; 49 | } 50 | 51 | @Override 52 | public void sendBroadcast(Intent intent) { 53 | mBroadcastsSent.add(intent); 54 | } 55 | 56 | @Override 57 | public boolean userOwnsPackage(int uid, String pckg) throws NameNotFoundException { 58 | return true; 59 | } 60 | 61 | @Override 62 | public void postNotification(long id, Notification notification) { 63 | if (notification == null) { 64 | throw new AssertionFailedError("Posting null notification"); 65 | } 66 | mActiveNotifications.put(id, notification); 67 | } 68 | 69 | @Override 70 | public void cancelNotification(long id) { 71 | Notification notification = mActiveNotifications.remove(id); 72 | if (notification != null) { 73 | mCanceledNotifications.add(notification); 74 | } 75 | } 76 | 77 | @Override 78 | public void cancelAllNotifications() { 79 | for (long id : mActiveNotifications.keySet()) { 80 | cancelNotification(id); 81 | } 82 | } 83 | 84 | @Override 85 | public void startThread(Thread thread) { 86 | mStartedThreads.add(thread); 87 | } 88 | 89 | public void runAllThreads() { 90 | while (!mStartedThreads.isEmpty()) { 91 | mStartedThreads.poll().run(); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /ui/res/layout/download_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 23 | 24 | 27 | 30 | 33 | 40 | 41 | 42 | 43 | 55 |