Skip to content

Commit eb9fdca

Browse files
DvTonderrmcc
authored andcommitted
CMUpdate: Switch to DownloadManager, major cleanup and fixes
Changes include: - Integrating the ApplyUpdate stuff into the main activity - Fixing some additional bugs relating to activities - This change includes a squashed commit by Nebkat with Change-Id: I55567e83d5c4df4883aa457a4cab58a123f4b388 - When checking for downloaded zips, ignore folders - Make sure updateLayout is called after user accepts dialog - Remove unused custom exception - Switch over to DownloadManager - Remove unused services/aidls - Fix a couple of derps - Added MD5 checking of downloaded file - When reinstantiating, check if previous download was successful and update preference accordingly - Added BroadcastReceivers for the DownloadManager - Fix restart of app not recognizing inprogress download - Prevent multiple downloads on app restart - Added back isStorageRemovable check, renamed as isAlternateStorage - Moved MD5 checking to BroadcastReceiver - Fix in-progress url and md5 state preservation between app restarts - Hide backup rom functionality until better solution is found - Add user-agent to API and download requests Credit to Devatwork and Nebkat for their help Change-Id: I6a11d383c489b1bbf4fbcf4e198db3f208b0fe75
1 parent bcbe964 commit eb9fdca

20 files changed

+625
-1233
lines changed

Android.mk

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ include $(CLEAR_VARS)
44
LOCAL_MODULE_TAGS := optional
55

66
LOCAL_SRC_FILES := $(call all-java-files-under, src)
7-
LOCAL_SRC_FILES += src/com/cyanogenmod/updater/interfaces/IDownloadServiceCallback.aidl \
8-
src/com/cyanogenmod/updater/interfaces/IUpdateCheckServiceCallback.aidl \
9-
src/com/cyanogenmod/updater/interfaces/IUpdateCheckService.aidl \
10-
src/com/cyanogenmod/updater/interfaces/IDownloadService.aidl
7+
LOCAL_SRC_FILES += src/com/cyanogenmod/updater/interfaces/IUpdateCheckServiceCallback.aidl \
8+
src/com/cyanogenmod/updater/interfaces/IUpdateCheckService.aidl
119

1210
LOCAL_PACKAGE_NAME := CMUpdater
1311

AndroidManifest.xml

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.cyanogenmod.updater"
3-
android:versionCode="1"
4-
android:versionName="1.0" >
3+
android:versionCode="2"
4+
android:versionName="2.0" >
55

66
<uses-sdk
77
android:minSdkVersion="16"
@@ -31,34 +31,33 @@
3131
</intent-filter>
3232
</activity>
3333

34-
<activity
35-
android:name=".ApplyUpdate"
36-
android:configChanges="orientation|screenSize|keyboardHidden"
37-
android:launchMode="singleTop"
38-
android:excludeFromRecents="true" >
39-
</activity>
40-
4134
<service android:name="com.cyanogenmod.updater.service.UpdateCheckService"
4235
android:process="com.cyanogenmod.updater.updater.service.UpdateCheckService">
4336
<intent-filter>
4437
<action android:name="com.cyanogenmod.updater.interfaces.IUpdateCheckService"/>
4538
</intent-filter>
4639
</service>
4740

48-
<service android:name="com.cyanogenmod.updater.service.DownloadService"
49-
android:process="com.cyanogenmod.updater.service.DownloadService">
41+
<receiver android:name="com.cyanogenmod.updater.receiver.StartupReceiver">
5042
<intent-filter>
51-
<action android:name="com.cyanogenmod.updater.interfaces.IDownloadService"/>
43+
<action android:name="android.intent.action.BOOT_COMPLETED"/>
44+
<category android:name="android.intent.category.HOME"/>
5245
</intent-filter>
53-
</service>
46+
</receiver>
47+
<receiver android:name="com.cyanogenmod.updater.receiver.DownloadCompletedReceiver">
48+
<intent-filter>
49+
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
50+
<category android:name="android.intent.category.HOME"/>
51+
</intent-filter>
52+
</receiver>
5453

55-
<receiver android:name="com.cyanogenmod.updater.receiver.StartupReceiver">
54+
<receiver android:name="com.cyanogenmod.updater.receiver.NotificationClickReceiver">
5655
<intent-filter>
57-
<action android:name="android.intent.action.BOOT_COMPLETED"/>
56+
<action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED"/>
5857
<category android:name="android.intent.category.HOME"/>
5958
</intent-filter>
6059
</receiver>
6160

6261
</application>
6362

64-
</manifest>
63+
</manifest>

res/values/strings.xml

+6-16
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<string name="dialog_yes">Yes</string>
1616
<string name="dialog_no">No</string>
1717
<string name="dialog_update">Update</string>
18-
<string name="dialog_backup_and_update">Backup &amp; Apply</string>
1918

2019
<!-- Settings strings -->
2120
<string name="available_updates_title">Available updates</string>
@@ -48,21 +47,12 @@
4847
<string name="not_new_updates_found_body">{0} update(s) available for download</string>
4948

5049
<!-- Downloads -->
51-
<string name="minutes">min</string>
52-
<string name="seconds">sec</string>
53-
<string name="download_resume_not_supported">Resume not supported by server</string>
54-
<string name="download_resume_download">Resuming download</string>
50+
<string name="confirm_download_cancelation_dialog_title">Cancel download</string>
51+
<string name="confirm_download_cancelation_dialog_message">You are about to cancel the current download, OK to proceed?</string>
52+
<string name="download_cancelled">Download cancelled</string>
53+
<string name="download_already_running">A download is already running</string>
5554
<string name="unable_to_download_file">Unable to download the update file</string>
56-
<string name="download_not_enough_space">Not enough space on SDCard to download the update</string>
57-
<string name="not_update_download_error_ticker">An error occurred while downloading the update</string>
58-
<string name="not_update_download_error_title">An error occurred while downloading the update</string>
59-
<string name="notification_tickertext">Downloading update</string>
60-
<string name="notification_finished">Download finished</string>
61-
<string name="exception_while_downloading">An error occurred while trying to download the update</string>
62-
<string name="confirm_download_cancelation_dialog_title">Cancel download?</string>
63-
<string name="confirm_download_cancelation_dialog_message">You can resume it later by downloading the same update again</string>
64-
<string name="download_canceled_toast_message">Download cancelled</string>
65-
<string name="downloading_update">Downloading update</string>
55+
<string name="download_not_found">Download not found</string>
6656

6757
<!-- MD5 related strings -->
6858
<string name="apply_existing_update_md5error_message">Error. MD5 checksum missmatch</string>
@@ -81,7 +71,7 @@
8171
<string name="confirm_delete_all_dialog_message">You are about to delete all downloaded update files, OK to proceed?</string>
8272
<string name="delete_single_update_success_message">Update {0} deleted</string>
8373
<string name="delete_updates_failure_message">There was an error deleting the update file</string>
84-
<string name="delete_updates_noFolder_message">Update Folder not found</string>
74+
<string name="delete_updates_noFolder_message">Update folder not found</string>
8575
<string name="delete_updates_success_message">All downloaded updates deleted</string>
8676

8777
<!-- System info strings -->

res/xml/main.xml

+2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333
android:entries="@array/update_type_entries"
3434
android:entryValues="@array/update_type_values"/>
3535

36+
<!-- TODO: add this back once we have a way of doing backups that is not recovery specific
3637
<CheckBoxPreference
3738
android:key="pref_backup_rom"
3839
android:defaultValue="true"
3940
android:title="@string/backup_rom_title"
4041
android:summary="@string/backup_rom_summary" />
42+
-->
4143

4244
<PreferenceCategory
4345
android:key="updates_category"

src/com/cyanogenmod/updater/ApplyUpdate.java

-109
This file was deleted.

0 commit comments

Comments
 (0)