├── .gitignore ├── Android.mk ├── AndroidManifest.xml ├── blah ├── lib └── com.koushikdutta.rommanager.romparts.jar ├── res ├── drawable-hdpi │ └── icon.png ├── drawable-mdpi │ └── icon.png ├── layout │ ├── download.xml │ ├── main_nightly.xml │ └── main_stable.xml ├── values-cs │ └── strings.xml ├── values-da │ └── strings.xml ├── values-de │ └── strings.xml ├── values-el │ └── strings.xml ├── values-es │ └── strings.xml ├── values-fr │ └── strings.xml ├── values-he │ └── strings.xml ├── values-it │ └── strings.xml ├── values-ja │ └── strings.xml ├── values-ko │ └── strings.xml ├── values-nb │ └── strings.xml ├── values-nl │ └── strings.xml ├── values-pl │ └── strings.xml ├── values-pt-rPT │ └── strings.xml ├── values-pt │ └── strings.xml ├── values-ru │ └── strings.xml ├── values-sk │ └── strings.xml ├── values-sv │ └── strings.xml ├── values-uk │ └── strings.xml ├── values-zh-rTW │ └── strings.xml └── values │ └── strings.xml └── src ├── android └── os │ └── SystemProperties.java └── com ├── cyanogenmod └── updatenotify │ ├── C2DMReceiver.java │ ├── DownloadActivity.java │ ├── MainActivity.java │ └── utils │ ├── DeviceRegistrar.java │ ├── NightlyLicense.java │ ├── Preferences.java │ ├── RegistrationClient.java │ └── StringUtils.java └── google └── android └── c2dm ├── C2DMBaseReceiver.java ├── C2DMBroadcastReceiver.java └── C2DMessaging.java /.gitignore: -------------------------------------------------------------------------------- 1 | gen/* 2 | bin/* 3 | .project 4 | .classpath 5 | .settings/* 6 | proguard.cfg 7 | default.properties 8 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE_TAGS := optional 5 | 6 | LOCAL_STATIC_JAVA_LIBRARIES := libkoush 7 | LOCAL_SRC_FILES := $(call all-java-files-under, src) 8 | 9 | LOCAL_PACKAGE_NAME := CMUpdateNotify 10 | LOCAL_CERTIFICATE := platform 11 | 12 | include $(BUILD_PACKAGE) 13 | 14 | LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libkoush:lib/com.koushikdutta.rommanager.romparts.jar 15 | include $(BUILD_MULTI_PREBUILT) 16 | 17 | # Use the folloing include to make our test apk. 18 | include $(call all-makefiles-under,$(LOCAL_PATH)) 19 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /blah: -------------------------------------------------------------------------------- 1 | BLAH 2 | -------------------------------------------------------------------------------- /lib/com.koushikdutta.rommanager.romparts.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_CMUpdateNotify/ceec67d5a8117f23df6b538d798118256b9cc4a3/lib/com.koushikdutta.rommanager.romparts.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_CMUpdateNotify/ceec67d5a8117f23df6b538d798118256b9cc4a3/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_CMUpdateNotify/ceec67d5a8117f23df6b538d798118256b9cc4a3/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /res/layout/download.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 11 | 13 | 14 | 18 | 19 | 23 | 24 | 25 | 27 | 28 | 31 | 32 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | -------------------------------------------------------------------------------- /res/layout/main_nightly.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 14 | 15 | 19 | 20 | 23 | 26 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /res/layout/main_stable.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 13 | 14 | 17 | 20 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /res/values-cs/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Oznámení o aktualizaci CyanogenMod 5 | Přihlásit 6 | Odhlásit 7 | \? 8 | 9 | 10 | Aktualizace CyanogenMod 11 | Dostupná aktualizace 12 | Je dostupná aktualizace CyanogenMod! 13 | 14 | 15 | Oznámení o aktualizaci CyanogenMod 16 | Přihlášení provedeno 17 | Přihlášení selhalo 18 | Odhlášení provedeno 19 | Odhlášení selhalo 20 | Přihlašuji\u2026 prosím čekejte 21 | Odhlašuji\u2026 prosím čekejte 22 | Pro povolení aktivního oznámení nových verzí je potřeba provést přihlášení zařízení k aktualizačním serverům. 23 | Stabilní vydání 24 | Noční sestavení 25 | Pro povolení této vlastnosti je potřeba mít ROM Manager Premium licenci! 26 | 27 | 28 | Informace o aktualizaci 29 | Stará verze 30 | Nová verze 31 | Stáhnout 32 | 33 | -------------------------------------------------------------------------------- /res/values-da/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod Opdaterings Notifikationer 5 | Registrer 6 | Afregistrer 7 | \? 8 | 9 | 10 | CyanogenMod Opdatering Tilgængelig 11 | Opdatering Tilgængelig 12 | En CyanogenMod opdatering er tilgængelig! 13 | 14 | 15 | CyanogenMod Opdaterings Notifikationer 16 | Registrering Successfuld 17 | Registrering Fejlede 18 | Afregistrering Successfuld 19 | Afregistrering Fejlede 20 | Registrerer\u2026 Vent Venligst 21 | Afregistrerer\u2026 Vent Venligst 22 | For at aktivere push notifikationer ved nye opdateringer, 23 | skal du registrere din enhed på opdaterings serverne. 24 | Stabile Udgivelser 25 | 26 | Nightly Builds 27 | En ROM Manager Premium licens er nødvendig for at aktivere denne funktion! 28 | 29 | 30 | Opdaterings Information 31 | Gammel Version 32 | Ny Version 33 | Download 34 | 35 | -------------------------------------------------------------------------------- /res/values-de/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod Update-Benachrichtigungen 5 | Registrieren 6 | Abmelden 7 | 8 | 9 | CyanogenMod-Update verfügbar 10 | Update verfügbar 11 | Ein Update für CyanogenMod ist verfügbar! 12 | 13 | 14 | CyanogenMod Update-Benachrichtigungen 15 | Erfolgreich registriert 16 | Registrierung fehlgeschlagen 17 | Erfolgreich abgemeldet 18 | Abmeldung fehlgeschlagen 19 | Registrierung... Bitte warten 20 | Abmeldung... Bitte warten 21 | Zum Einschalten der Push-Benachrichtigungen über neue Versionen 22 | musst du dein Gerät bei den Update-Servern registrieren. 23 | Stabile Versionen 24 | Nightly Builds 25 | Für diese Funktion wird eine Premium-Lizenz des ROM Managers benötigt! 26 | 27 | 28 | Update-Information 29 | Alte Version 30 | Neue Version 31 | Download 32 | 33 | -------------------------------------------------------------------------------- /res/values-el/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ειδοποιήσεις ενημερώσεων CyanogenMod 5 | Εγγραφή 6 | Διαγραφή 7 | \? 8 | 9 | 10 | Υπάρχει διαθέσιμη ενημέρωση CyanogenMod 11 | Διαθέσιμη Ενημέρωση 12 | Είναι διαθέσιμη μία ενημέρωση για το CyanogenMod! 13 | 14 | 15 | Ειδοποιήσεις Ενημερώσεων CyanogenMod 16 | Επιτυχία Εγγραφής 17 | Αποτυχία Εγγραφής 18 | Επιτυχία Διαγραφής 19 | Αποτυχία Διαγραφής 20 | Εγγραφή\u2026 Παρακαλώ Περιμένετε 21 | Διαγραφή\u2026 Παρακαλώ Περιμένετε 22 | Για να ενεργοποιήσετε τις ειδοποιήσεις push για νέες εκδόσεις, 23 | πρέπει να εγγραφείτε στους διακομιστές ενημερώσεων. 24 | Σταθερές Εκδόσεις 25 | Nightly Builds 26 | Χρειάζεστε το ROM Manager Premium για να ενεργοποιήσετε αυτό το χαρακτηριστικό! 27 | 28 | 29 | Πληροφορίες Αναβάθμισης 30 | Παλαιά Έκδοση 31 | Νέα Έκδοση 32 | Λήψη 33 | 34 | -------------------------------------------------------------------------------- /res/values-es/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Notificaciones de actualización de CyanogenMod 5 | Registrar 6 | Anular el registro 7 | \? 8 | 9 | 10 | Actualización de CyanogenMod disponible 11 | Actualización disponible 12 | Una actualización de CyanogenMod está disponible! 13 | 14 | 15 | Notificaciones de actualización de CyanogenMod 16 | Registro realizado 17 | Anulación registro realizada 18 | Registrando... Por favor espere un momento 19 | Anulando registro... Por favor espere un momento 20 | Para habilitar la notificación de nuevas versiones, 21 | debes registrar tu dispositivo con los servidores de actualización. 22 | Versiones Estables 23 | 24 | Nightly Builds 25 | Se requiere una licencia Premium de ROM Manager para activar esta característica! 26 | 27 | 28 | Información de Actualización 29 | Versión Antigua 30 | Versión Nueva 31 | Descarga 32 | 33 | -------------------------------------------------------------------------------- /res/values-fr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Notifications de mise à jour de CyanogenMod 5 | S\'inscrire 6 | Se désinscrire 7 | \? 8 | 9 | 10 | Mise à jour de CyanogenMod disponible 11 | Mise à jour disponible 12 | Une mise à jour de CyanogenMod est disponible ! 13 | 14 | 15 | Notifications de mise à jour de CyanogenMod 16 | Enregistrement réussi 17 | Désinscription réussie 18 | Enregistrement... Veuillez patienter 19 | Désinscription... Veuillez patienter 20 | Afin d\'activer les notifications push lors de la sortie de nouvelles versions, 21 | vous devez enregistrer votre appareil auprès des serveurs de mise à jour. 22 | Versions stables 23 | 24 | Versions nightly 25 | Une license Premium de ROM Manager est nécessaire pour activer cette fonctionnalité ! 26 | 27 | 28 | Informations de la mise à jour 29 | Ancienne version 30 | Nouvelle version 31 | Télécharger 32 | 33 | -------------------------------------------------------------------------------- /res/values-he/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | הודעות עדכון של CyanogenMod 5 | הירשם 6 | בטל רישום 7 | \? 8 | 9 | 10 | קיים עדכון ל CyanogenMod 11 | עדכון זמין 12 | קיים עדכון ל CyanogenMod! 13 | 14 | 15 | הודעות עדכון של CyanogenMod 16 | הרישום עבר בהצלחה 17 | ביטול הרישום עבר בהצלחה 18 | נרשם... אנא המתן 19 | מבטל רישום... אנא המתן 20 | כדי לאפשר דיווחים על גירסאות חדשות, 21 | עליך לרשום את המכשיר עם שרתי עדכון. 22 | גרסאות יציבות 23 | גרסאות ליליות 24 | דרוש רשיון של ROM Manager Premium כדי להפוך תכונה זו לזמינה! 25 | 26 | 27 | פרטי עדכון 28 | גרסה ישנה 29 | גרסה חדשה 30 | הורדה 31 | 32 | -------------------------------------------------------------------------------- /res/values-it/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Notifiche Aggiornamenti CyanogenMod 5 | Connetti 6 | Disconnetti 7 | \? 8 | 9 | 10 | Aggiornamento CyanogenMod Disponibile! 11 | Aggiornamento Disponibile 12 | È disponibile un aggiornamento CyanogenMod! 13 | 14 | 15 | Notifiche Aggiornamenti CyanogenMod 16 | Connessione Riuscita 17 | Connessione Fallita 18 | Disconnessione Riuscita 19 | Disconnessione Fallita 20 | Connessione in corso... Attendere Prego 21 | Disconnessione in corso... Attendere Prego 22 | Per attivare le notifiche push per le nuove versioni devi 23 | aver prima connesso il tuo dispositivo ai server degli aggiornamenti. 24 | Versioni stabili 25 | 26 | Nightly Builds 27 | È richiesta una licenza ROM Manager Premium per attivare questa funzione! 28 | 29 | 30 | Informazioni aggiornamento 31 | Vecchia Versione 32 | Nuova Versione 33 | Download 34 | 35 | -------------------------------------------------------------------------------- /res/values-ja/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod更新通知 5 | 登録 6 | 登録解除 7 | \? 8 | 9 | 10 | CyanogenMod更新 11 | 更新があります 12 | CyanogenModの更新が利用できます! 13 | 14 | 15 | CyanogenMod更新通知 16 | 登録は成功しました 17 | 登録に失敗しました 18 | 登録解除は成功しました 19 | 登録解除に失敗しました 20 | 登録中... お待ちください 21 | 登録解除中... お待ちください 22 | 新バージョンのプッシュ通知を受け取るには、あなたの端末を更新サーバに登録する必要があります。 23 | 安定版リリース 24 | 25 | Nightlyビルド 26 | この機能を有効にするにはROM Manager Premiumのライセンスが必要です! 27 | 28 | 29 | 更新情報 30 | 旧バージョン 31 | 新バージョン 32 | ダウンロード 33 | 34 | -------------------------------------------------------------------------------- /res/values-ko/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod 업데이트 알림 5 | 등록 6 | 등록 해제 7 | \? 8 | 9 | 10 | CyanogenMod 업데이트 가능. 11 | 업데이트 가능 12 | CyanogenMod의 업데이트가 있습니다. 13 | 14 | 15 | CyanogenMod 업데이트 알림 16 | 등록 성공 17 | 등록 해제 성공 18 | 등록하는 중입니다.. 잠시만 기다려 주세요. 19 | 등록을 해제하는 중입니다. 잠시만 기다려 주세요. 20 | 새로운 버전에 대한 푸시 알림을 사용하기 위해서는 휴대전화를 업데이트 서버에 등록해야 합니다. 21 | 안정 버전 22 | 23 | Nightly 버전 24 | 이 기능을 사용하기 위해서는 ROM Manager의 프리미엄 라이센스가 필요합니다. 25 | 26 | 27 | 업데이트 정보 28 | 기존 버전 29 | 새 버전 30 | 다운로드 31 | 32 | -------------------------------------------------------------------------------- /res/values-nb/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod Oppdateringsmelding 5 | Registrer 6 | Avregistrer 7 | 8 | 9 | CyanogenMod-oppdatering tilgjengelig 10 | Oppdatering tilgjengelig 11 | En oppdatering til CyanogenMod er tilgjengelig 12 | 13 | 14 | CyanogenMod oppdateringsmeldinger 15 | Registrering Vellykket 16 | Avregistrering Vellykket 17 | Registrerer... Vennligst vent 18 | Avregistrerer.. Vennligst vent 19 | For å aktivere meldinger om nye versjone må du registrere din enhet opp mot oppdateringserveren 20 | Stabile utgivelser 21 | Nattlige utgivelser 22 | Denne funksjonen krever en ROM Manager Premium-lisens! 23 | 24 | 25 | Oppdateringsinformasjon 26 | Gammel versjon 27 | Ny versjon 28 | Last ned 29 | 30 | -------------------------------------------------------------------------------- /res/values-nl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod Update Notificaties 5 | Registreer 6 | Verwijder registratie 7 | \? 8 | 9 | 10 | CyanogenMod Update Beschikbaar 11 | Update Beschikbaar 12 | Er is een update voor CyanogenMod beschikbaar! 13 | 14 | 15 | CyanogenMod Update Notificaties 16 | Registratie succesvol 17 | Registratie mislukt 18 | Verwijderen van registratie gelukt 19 | Verwijderen van registratie mislukt 20 | Registreren... Wachten a.u.b. 21 | Registratie verwijderen... Wachten a.u.b. 22 | Om push notificaties voor nieuwe versies te ontvangen, 23 | dien je je toetsel te registreren bij de update servers. 24 | Stabiele versies 25 | 26 | Nightly Builds 27 | Om update notificaties te ontvangen dien je een ROM Manager Premium licensie te hebben! 28 | 29 | 30 | Update Informatie 31 | Oude Versie 32 | Nieuwe Versie 33 | Download 34 | 35 | -------------------------------------------------------------------------------- /res/values-pl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Powiadomienia o aktualizacjach CyanogenMod 5 | Zarejestruj 6 | Odrejestruj 7 | \? 8 | 9 | 10 | Dostępna aktualizacja CyanogenMod 11 | Dostępna aktualizacja 12 | Dostępna jest aktualizacja CyanogenMod! 13 | 14 | 15 | Powiadomienia o aktualizacjach CyanogenMod 16 | Rejestracja udana 17 | Odrejestrowanie udane 18 | Rejestrowanie... Proszę czekać 19 | Odrejestrowanie... Proszę czekać 20 | By umożliwić powiadamianie, 21 | musisz zarejestrować urządzenie na serwerach aktualizacji. 22 | Wydania stabilne 23 | 24 | Wydania codzienne 25 | By odblokować tą funkcję potrzebna jest licencja premium ROM Managera! 26 | 27 | 28 | Informacja o aktualizacji 29 | Stara wersja 30 | Nowa wersja 31 | Pobierz 32 | 33 | -------------------------------------------------------------------------------- /res/values-pt-rPT/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Notificações de Actualização da CyanogenMod 5 | Registar 6 | Anular Registo 7 | \? 8 | 9 | 10 | Actualização da CyanogenMod Disponível 11 | Actualização Disponível 12 | Uma actualização da CyanogenMod está disponível! 13 | 14 | 15 | Notificações de Actualização da CyanogenMod 16 | Registo Concluído 17 | Anulação do Registo Concluído 18 | A Registar... Por favor Aguarde 19 | A Anular o Registo... Por favor Aguarde 20 | Para activar as notificações Push de novas versões, 21 | tem de registar o seu dispositivo nos servidores de actualização. 22 | Stable Builds 23 | 24 | Nightly Builds 25 | É necessária uma licença do ROM Manager Premium para activar esta funcionalidade! 26 | 27 | 28 | Actualizar Informação 29 | Versão Antiga 30 | Nova Versão 31 | Transferir 32 | 33 | -------------------------------------------------------------------------------- /res/values-pt/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Notificações de Atualização CyanogenMod 5 | Registrar 6 | Desregistrar 7 | \? 8 | 9 | 10 | Atualização disponível para o CyanogenMod 11 | Atualização Disponível 12 | Uma atualização para o CyanogenMod está disponível! 13 | 14 | 15 | Notificações de atualização CyanogenMod 16 | O registro foi bem sucedido 17 | O desregistro foi bem sucedido 18 | Registrando... Aguarde por favor 19 | Desregistrando... Aguarde por favor 20 | Para habilitar notificações de novas versões, 21 | você precisa registrar seu dispositivo com os servidores de atualização. 22 | Atualizações Estáveis 23 | Builds diários 24 | É preciso lincença do ROM Managar Premium para habilitar esta função! 25 | 26 | 27 | Atualização de informação 28 | Versão Antiga 29 | Versão Nova 30 | Download 31 | Falha ao registrar 32 | Falha ao desregistrar 33 | 34 | -------------------------------------------------------------------------------- /res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Уведомления об обновлениях CyanogenMod 5 | Регистрация 6 | Отменить регистрацию 7 | \? 8 | 9 | 10 | Доступно обновление CyanogenMod 11 | Доступно обновление 12 | Доступно обновление CyanogenMod! 13 | 14 | 15 | Уведомления об обновлениях CyanogenMod 16 | Регистрация прошла успешно 17 | Не удалось зарегистрироваться 18 | Успешная отмена регистрация 19 | Ошибка отмены регистрации 20 | Регистрация... Пожалуйста, подождите 21 | Отмена регистрации... Пожалуйста, подождите 22 | Для получения уведомлений о новых версиях вы должны 23 | зарегистрировать ваше устройство на сервере обновлений. 24 | Стабильные релизы 25 | 26 | Ночные сборки 27 | Для включения этой функции требуется лицензия ROM Manager Premium! 28 | 29 | 30 | Информация об обновлении 31 | Старая версия 32 | Новая версия 33 | Скачать 34 | 35 | -------------------------------------------------------------------------------- /res/values-sk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Upozornenia na Aktualizácie CyanogenMod 5 | Registrovať 6 | Odregistrovať 7 | \? 8 | Dostupná Aktualizácia CyanogenMod 9 | Aktualizácia Dostupná 10 | Aktualizácia CyanogenMod je dostupná! 11 | Upozornenia na Aktualizácie CyanogenMod 12 | Registrácia Úspešná 13 | Registrácia Zlyhala 14 | Odregistrácia Úspešná 15 | Odregistrácia Zlyhala 16 | Registrovanie\u2026 Čakajte Prosím 17 | Odregistrovanie\u2026 Čakajte Prosím 18 | Pre povolenie notifikácií o nových verziách, 19 | musíte registrovať Vaše zariadenie s aktualizačným serverom. 20 | Stabilné Verzie 21 | Nočné Verzie 22 | Prémiová licencia ROM Manageru je potrebná pre povolenie tejto funkcie! 23 | Informácie o Aktualizácii 24 | Stará Verzia 25 | Nová Verzia 26 | Stiahnuť 27 | 28 | -------------------------------------------------------------------------------- /res/values-sv/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Uppdateringsaviseringar för CyanogenMod 4 | Registrera 5 | Avregistrera 6 | \? 7 | 8 | Uppdatering för CyanogenMod Tillgänglig 9 | Uppdatering Tillgänglig 10 | En CyanogenMod-uppdatering är tillgänglig! 11 | 12 | Uppdateringsaviseringar för CyanogenMod 13 | Registrering Lyckades 14 | Registrering Misslyckades 15 | Avregistrering Lyckades 16 | Avregistrering Misslyckades 17 | Registrerar\u2026 Var God Vänta 18 | Avregistrerar\u2026 Var God Vänta 19 | För att registrera push-aviseringar av nya versioner, 20 | behöver du registrera din enhet med uppdateringsservrarna. 21 | Stabila Utgåvor 22 | Nightly Builds 23 | En licens för ROM Manager Premium krävs för att aktivera denna funktion! 24 | 25 | Uppdateringsinformation 26 | Gammal Version 27 | Ny Version 28 | Ladda ner 29 | 30 | -------------------------------------------------------------------------------- /res/values-uk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Сповіщення про оновлення CyanogenMod 4 | Зареєструвати 5 | Скасувати реєстрацію 6 | Доступне оновлення CyanogenMod 7 | Доступно оновлення 8 | Доступне оновлення CyanogenMod! 9 | Сповіщення про оновлення CyanogenMod 10 | Успішна реєстрація 11 | Не вдалося зареєструватися 12 | Успішне скасування реєстрації 13 | Не вдалося скасувати реєстрацію 14 | Реєстрація\u2026 Зачекайте 15 | Скасування реєстрації\u2026 Зачекайте 16 | Щоб отримувати сповіщення про нові версії необхідно зареєструвати пристрій на сервері оновлень. 17 | Стабільні релізи 18 | Нічні збірки 19 | Щоб увімкнути цю функцію потрібна ліцензія на ROM Manager Premium! 20 | Інформація про оновлення 21 | Стара версія 22 | Нова версія 23 | Завантажити 24 | 25 | -------------------------------------------------------------------------------- /res/values-zh-rTW/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod 更新通知 5 | 註冊 6 | 取消註冊 7 | \? 8 | 9 | 10 | CyanogenMod 有可用的更新 11 | 有可用的更新 12 | 有 CyanogenMod 的更新可用! 13 | 14 | 15 | CyanogenMod 更新通知 16 | 註冊成功 17 | 註冊失敗 18 | 成功取消註冊 19 | 取消註冊失敗 20 | 註冊中... 請稍候 21 | 取消註冊中... 請稍候 22 | 要啟用新版本的推送通知,您必須在更新伺服器註冊您的裝置。 23 | 穩定/正式版 24 | 25 | 夜夜版本 26 | 您需要安裝 ROM Manager Premium 授權來啟用此功能! 27 | 28 | 29 | 更新資訊 30 | 舊版本 31 | 新版本 32 | 下載 33 | 34 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyanogenMod Update Notifications 5 | Register 6 | Unregister 7 | \? 8 | 9 | 10 | CyanogenMod Update Available 11 | Update Available 12 | A CyanogenMod update is available! 13 | 14 | 15 | CyanogenMod Update Notifications 16 | Registration Successful 17 | Registration Failed 18 | Unregistration Successful 19 | Unregistration Failed 20 | Registering\u2026 Please Wait 21 | Unregistering\u2026 Please Wait 22 | To enable push notifications of new versions, 23 | you must register your device with the update servers. 24 | Stable Releases 25 | 26 | Nightly Builds 27 | A ROM Manager Premium license is required to enable this feature! 28 | 29 | 30 | Update Information 31 | Old Version 32 | New Version 33 | Download 34 | 35 | -------------------------------------------------------------------------------- /src/android/os/SystemProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 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 android.os; 18 | 19 | 20 | /** 21 | * Gives access to the system properties store. The system properties 22 | * store contains a list of string key-value pairs. 23 | * 24 | * {@hide} 25 | */ 26 | public class SystemProperties 27 | { 28 | public static final int PROP_NAME_MAX = 31; 29 | public static final int PROP_VALUE_MAX = 91; 30 | 31 | private static native String native_get(String key); 32 | private static native String native_get(String key, String def); 33 | private static native int native_get_int(String key, int def); 34 | private static native long native_get_long(String key, long def); 35 | private static native boolean native_get_boolean(String key, boolean def); 36 | private static native void native_set(String key, String def); 37 | 38 | /** 39 | * Get the value for the given key. 40 | * @return an empty string if the key isn't found 41 | * @throws IllegalArgumentException if the key exceeds 32 characters 42 | */ 43 | public static String get(String key) { 44 | if (key.length() > PROP_NAME_MAX) { 45 | throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); 46 | } 47 | return native_get(key); 48 | } 49 | 50 | /** 51 | * Get the value for the given key. 52 | * @return if the key isn't found, return def if it isn't null, or an empty string otherwise 53 | * @throws IllegalArgumentException if the key exceeds 32 characters 54 | */ 55 | public static String get(String key, String def) { 56 | if (key.length() > PROP_NAME_MAX) { 57 | throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); 58 | } 59 | return native_get(key, def); 60 | } 61 | 62 | /** 63 | * Get the value for the given key, and return as an integer. 64 | * @param key the key to lookup 65 | * @param def a default value to return 66 | * @return the key parsed as an integer, or def if the key isn't found or 67 | * cannot be parsed 68 | * @throws IllegalArgumentException if the key exceeds 32 characters 69 | */ 70 | public static int getInt(String key, int def) { 71 | if (key.length() > PROP_NAME_MAX) { 72 | throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); 73 | } 74 | return native_get_int(key, def); 75 | } 76 | 77 | /** 78 | * Get the value for the given key, and return as a long. 79 | * @param key the key to lookup 80 | * @param def a default value to return 81 | * @return the key parsed as a long, or def if the key isn't found or 82 | * cannot be parsed 83 | * @throws IllegalArgumentException if the key exceeds 32 characters 84 | */ 85 | public static long getLong(String key, long def) { 86 | if (key.length() > PROP_NAME_MAX) { 87 | throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); 88 | } 89 | return native_get_long(key, def); 90 | } 91 | 92 | /** 93 | * Get the value for the given key, returned as a boolean. 94 | * Values 'n', 'no', '0', 'false' or 'off' are considered false. 95 | * Values 'y', 'yes', '1', 'true' or 'on' are considered true. 96 | * (case insensitive). 97 | * If the key does not exist, or has any other value, then the default 98 | * result is returned. 99 | * @param key the key to lookup 100 | * @param def a default value to return 101 | * @return the key parsed as a boolean, or def if the key isn't found or is 102 | * not able to be parsed as a boolean. 103 | * @throws IllegalArgumentException if the key exceeds 32 characters 104 | */ 105 | public static boolean getBoolean(String key, boolean def) { 106 | if (key.length() > PROP_NAME_MAX) { 107 | throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); 108 | } 109 | return native_get_boolean(key, def); 110 | } 111 | 112 | /** 113 | * Set the value for the given key. 114 | * @throws IllegalArgumentException if the key exceeds 32 characters 115 | * @throws IllegalArgumentException if the value exceeds 92 characters 116 | */ 117 | public static void set(String key, String val) { 118 | if (key.length() > PROP_NAME_MAX) { 119 | throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); 120 | } 121 | if (val != null && val.length() > PROP_VALUE_MAX) { 122 | throw new IllegalArgumentException("val.length > " + 123 | PROP_VALUE_MAX); 124 | } 125 | native_set(key, val); 126 | } 127 | } -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/C2DMReceiver.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify; 2 | 3 | import android.app.Notification; 4 | import android.app.NotificationManager; 5 | import android.app.PendingIntent; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.content.SharedPreferences; 9 | import android.os.Bundle; 10 | import android.util.Log; 11 | 12 | import com.cyanogenmod.updatenotify.utils.DeviceRegistrar; 13 | import com.cyanogenmod.updatenotify.utils.Preferences; 14 | import com.cyanogenmod.updatenotify.utils.StringUtils; 15 | import com.google.android.c2dm.C2DMBaseReceiver; 16 | 17 | public class C2DMReceiver extends C2DMBaseReceiver { 18 | private static final String TAG = "CMUpdateNotify-C2DMReceiver"; 19 | 20 | public C2DMReceiver() { 21 | super(DeviceRegistrar.SENDER_ID); 22 | } 23 | 24 | @Override 25 | public void onRegistered(Context context, String registration) { 26 | DeviceRegistrar.registerWithServer(context, registration); 27 | } 28 | 29 | @Override 30 | public void onUnregistered(Context context) { 31 | SharedPreferences prefs = Preferences.get(context); 32 | String deviceRegistrationID = prefs.getString(Preferences.DEVICEREGISTRATION_KEY, null); 33 | DeviceRegistrar.unregisterWithServer(context, deviceRegistrationID); 34 | } 35 | 36 | @Override 37 | public void onError(Context context, String errorId) { 38 | } 39 | 40 | @Override 41 | protected void onMessage(Context context, Intent intent) { 42 | Bundle extras = intent.getExtras(); 43 | 44 | String oldVersion = StringUtils.getModVersion(); 45 | String newVersion = extras.getString("modversion"); 46 | String url = extras.getString("url"); 47 | 48 | Log.d(TAG, "Got C2DM Message"); 49 | Log.d(TAG, "oldVersion = " + oldVersion); 50 | Log.d(TAG, "newVersion = " + newVersion); 51 | Log.d(TAG, "url = " + url); 52 | 53 | if (StringUtils.isNightly(newVersion)) { 54 | sendNotification(context, oldVersion, newVersion, url); 55 | } else { 56 | if (StringUtils.compareModVersions(newVersion, oldVersion)) { 57 | sendNotification(context, oldVersion, newVersion, url); 58 | } 59 | } 60 | } 61 | 62 | private void sendNotification(Context context, String oldVersion, String newVersion, String url) { 63 | NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 64 | 65 | // Create Notification 66 | CharSequence tickerText = getString(R.string.txt_notif_ticker); 67 | long when = System.currentTimeMillis(); 68 | Notification notification = new Notification(R.drawable.icon, tickerText, when); 69 | notification.defaults |= Notification.DEFAULT_SOUND; 70 | 71 | // Define expanded view 72 | CharSequence contentTitle = getString(R.string.txt_notif_title); 73 | CharSequence contentText = getString(R.string.txt_notif_long); 74 | Intent notificationIntent = new Intent(context, DownloadActivity.class); 75 | notificationIntent.putExtra("oldVersion", oldVersion); 76 | notificationIntent.putExtra("newVersion", newVersion); 77 | notificationIntent.putExtra("url", url); 78 | PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); 79 | 80 | notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 81 | 82 | // Fire notification 83 | nm.notify(0, notification); 84 | } 85 | } -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/DownloadActivity.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify; 2 | 3 | import java.util.ArrayList; 4 | 5 | import android.app.Activity; 6 | import android.app.NotificationManager; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | import android.os.Bundle; 10 | import android.util.Log; 11 | import android.view.View; 12 | import android.view.View.OnClickListener; 13 | import android.widget.Button; 14 | import android.widget.TextView; 15 | 16 | import com.koushikdutta.rommanager.RomPackage; 17 | import com.koushikdutta.rommanager.RomPart; 18 | 19 | public class DownloadActivity extends Activity { 20 | private static final String TAG = "CMUpdateNotify-DownloadActivity"; 21 | 22 | private TextView mNewVersionTextView; 23 | private TextView mOldVersionTextView; 24 | 25 | private Button mDownloadButton; 26 | 27 | private String mNewVersion; 28 | private String mOldVersion; 29 | private String mURL; 30 | 31 | @Override 32 | public void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.download); 35 | 36 | Intent intent = getIntent(); 37 | Bundle extras = intent.getExtras(); 38 | 39 | mURL = extras.getString("url"); 40 | mNewVersion = extras.getString("newVersion"); 41 | mOldVersion = extras.getString("oldVersion"); 42 | 43 | mNewVersionTextView = (TextView) findViewById(R.id.txt_new_version); 44 | mOldVersionTextView = (TextView) findViewById(R.id.txt_current_version); 45 | 46 | mDownloadButton = (Button) findViewById(R.id.btn_download); 47 | mDownloadButton.setOnClickListener(mDownloadListener); 48 | 49 | mNewVersionTextView.setText(mNewVersion); 50 | mOldVersionTextView.setText(mOldVersion); 51 | 52 | clearNotification(); 53 | } 54 | 55 | private void clearNotification() { 56 | NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 57 | nm.cancel(0); 58 | } 59 | 60 | private RomPackage getRomPackage(String version, String url) { 61 | ArrayList urls = new ArrayList(); 62 | urls.add(url); 63 | 64 | RomPackage romPackage = new RomPackage(); 65 | RomPart romPart = new RomPart(); 66 | 67 | romPart.setName(version + ".zip"); 68 | romPart.setUrls(urls); 69 | 70 | romPackage.setInstallScript(0); 71 | romPackage.setName(version); 72 | romPackage.setParts(new RomPart[] { romPart }); 73 | 74 | return romPackage; 75 | } 76 | 77 | private OnClickListener mDownloadListener = new OnClickListener() { 78 | @Override 79 | public void onClick(View v) { 80 | Log.d(TAG, "Starting download: " + mURL); 81 | 82 | Intent i = new Intent(); 83 | i.setClassName("com.koushikdutta.rommanager", "com.koushikdutta.rommanager.DownloadService"); 84 | i.putExtra("rompackage", getRomPackage(mNewVersion, mURL)); 85 | startService(i); 86 | finish(); 87 | } 88 | }; 89 | } 90 | -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify; 2 | 3 | import android.app.Activity; 4 | import android.app.ProgressDialog; 5 | import android.content.BroadcastReceiver; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.content.IntentFilter; 9 | import android.content.SharedPreferences; 10 | import android.os.Bundle; 11 | import android.util.Log; 12 | import android.view.View; 13 | import android.view.View.OnClickListener; 14 | import android.widget.Button; 15 | import android.widget.Toast; 16 | 17 | import com.cyanogenmod.updatenotify.utils.DeviceRegistrar; 18 | import com.cyanogenmod.updatenotify.utils.NightlyLicense; 19 | import com.cyanogenmod.updatenotify.utils.Preferences; 20 | import com.cyanogenmod.updatenotify.utils.StringUtils; 21 | import com.google.android.c2dm.C2DMessaging; 22 | 23 | public class MainActivity extends Activity { 24 | public static final String UPDATE_UI_ACTION = "com.cyanogenmod.updatenotify.UPDATE_UI"; 25 | 26 | private Button mRegisterButton; 27 | private Button mUnregisterButton; 28 | private ProgressDialog mProgressDialog; 29 | 30 | private static final String TAG = "CMUpdateNotify-MainActivity"; 31 | 32 | @Override 33 | public void onCreate(Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | if (StringUtils.isRunningNightly()) { 36 | setContentView(R.layout.main_nightly); 37 | } else { 38 | setContentView(R.layout.main_stable); 39 | } 40 | setTitle(R.string.title_main); 41 | 42 | mRegisterButton = (Button) findViewById(R.id.btn_register); 43 | mRegisterButton.setOnClickListener(mOnRegisterListener); 44 | 45 | mUnregisterButton = (Button) findViewById(R.id.btn_unregister); 46 | mUnregisterButton.setOnClickListener(mOnUnregisterListener); 47 | 48 | checkBuildType(); 49 | setupButtons(); 50 | 51 | registerReceiver(mUpdateUIReceiver, new IntentFilter(UPDATE_UI_ACTION)); 52 | } 53 | 54 | private void checkBuildType() { 55 | SharedPreferences settings = Preferences.get(this); 56 | SharedPreferences.Editor editor = settings.edit(); 57 | String buildType = settings.getString(Preferences.BUILDTYPE_KEY, null); 58 | 59 | if (buildType != null && buildType.equals("nightly") && !StringUtils.isRunningNightly()) { 60 | Log.d(TAG, "Build Changed -- Removing settings."); 61 | editor.remove(Preferences.BUILDTYPE_KEY); 62 | editor.remove(Preferences.DEVICEREGISTRATION_KEY); 63 | editor.commit(); 64 | } 65 | 66 | if (buildType != null && buildType.equals("stable") && StringUtils.isRunningNightly()) { 67 | Log.d(TAG, "Build Changed -- Removing settings."); 68 | editor.remove(Preferences.BUILDTYPE_KEY); 69 | editor.remove(Preferences.DEVICEREGISTRATION_KEY); 70 | editor.commit(); 71 | } 72 | } 73 | 74 | private void setupButtons() { 75 | SharedPreferences settings = Preferences.get(this); 76 | String deviceRegistrationId = settings.getString(Preferences.DEVICEREGISTRATION_KEY, null); 77 | if (deviceRegistrationId == null) { 78 | mRegisterButton.setEnabled(true); 79 | mUnregisterButton.setEnabled(false); 80 | } else { 81 | mRegisterButton.setEnabled(false); 82 | mUnregisterButton.setEnabled(true); 83 | } 84 | 85 | NightlyLicense nl = new NightlyLicense(this); 86 | 87 | if (StringUtils.isRunningNightly() && !nl.validLicense()) { 88 | mRegisterButton.setEnabled(false); 89 | mUnregisterButton.setEnabled(false); 90 | } 91 | } 92 | 93 | private final OnClickListener mOnRegisterListener = new OnClickListener() { 94 | @Override 95 | public void onClick(View view) { 96 | mProgressDialog = ProgressDialog.show(MainActivity.this, 97 | "", getString(R.string.txt_registering), true); 98 | mProgressDialog.show(); 99 | 100 | mRegisterButton.setEnabled(false); 101 | C2DMessaging.register(MainActivity.this, DeviceRegistrar.SENDER_ID); 102 | } 103 | }; 104 | 105 | private final OnClickListener mOnUnregisterListener = new OnClickListener() { 106 | @Override 107 | public void onClick(View view) { 108 | mProgressDialog = ProgressDialog.show(MainActivity.this, 109 | "", getString(R.string.txt_unregistering), true); 110 | mProgressDialog.show(); 111 | 112 | mUnregisterButton.setEnabled(false); 113 | C2DMessaging.unregister(MainActivity.this); 114 | } 115 | 116 | }; 117 | 118 | private final BroadcastReceiver mUpdateUIReceiver = new BroadcastReceiver() { 119 | @Override 120 | public void onReceive(Context context, Intent intent) { 121 | int status = intent.getIntExtra(DeviceRegistrar.STATUS_EXTRA, 0); 122 | 123 | if (status == DeviceRegistrar.REGISTERED_STATUS) { 124 | mUnregisterButton.setEnabled(true); 125 | mProgressDialog.dismiss(); 126 | Toast.makeText(getApplicationContext(), R.string.txt_registration_success, 10).show(); 127 | } 128 | 129 | if (status == DeviceRegistrar.UNREGISTERED_STATUS) { 130 | mRegisterButton.setEnabled(true); 131 | mProgressDialog.dismiss(); 132 | Toast.makeText(getApplicationContext(), R.string.txt_unregistration_success, 10).show(); 133 | } 134 | 135 | if (status == DeviceRegistrar.REGISTERED_FAILURE_STATUS) { 136 | mRegisterButton.setEnabled(true); 137 | mProgressDialog.dismiss(); 138 | Toast.makeText(getApplicationContext(), R.string.txt_registration_failure, 10).show(); 139 | } 140 | 141 | if (status == DeviceRegistrar.UNREGISTERED_FAILURE_STATUS) { 142 | mUnregisterButton.setEnabled(true); 143 | mProgressDialog.dismiss(); 144 | Toast.makeText(getApplicationContext(), R.string.txt_unregistration_failure, 10).show(); 145 | } 146 | } 147 | }; 148 | } 149 | -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/utils/DeviceRegistrar.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.http.HttpResponse; 7 | import org.apache.http.NameValuePair; 8 | import org.apache.http.message.BasicNameValuePair; 9 | 10 | import android.content.Context; 11 | import android.content.Intent; 12 | import android.content.SharedPreferences; 13 | import android.provider.Settings.Secure; 14 | import android.util.Log; 15 | 16 | import com.cyanogenmod.updatenotify.MainActivity; 17 | 18 | public class DeviceRegistrar { 19 | public static final String SENDER_ID = "cm.c2dm@gmail.com"; 20 | public static final String STATUS_EXTRA = "Status"; 21 | public static final int REGISTERED_STATUS = 1; 22 | public static final int UNREGISTERED_STATUS = 2; 23 | public static final int REGISTERED_FAILURE_STATUS = 3; 24 | public static final int UNREGISTERED_FAILURE_STATUS = 4; 25 | 26 | private static final String TAG = "CMUpdateNotify-DeviceRegistrar"; 27 | 28 | public static void registerWithServer(final Context context, final String deviceRegistrationID) { 29 | new Thread(new Runnable() { 30 | public void run() { 31 | String buildType = null; 32 | Intent updateUIIntent = new Intent(MainActivity.UPDATE_UI_ACTION); 33 | 34 | if (StringUtils.isRunningNightly()) { 35 | buildType = "nightly"; 36 | } else { 37 | buildType = "stable"; 38 | } 39 | 40 | try { 41 | HttpResponse res = makeRegisterRequest(context, deviceRegistrationID); 42 | if (res.getStatusLine().getStatusCode() == 200) { 43 | saveDeviceRegistration(context, deviceRegistrationID); 44 | saveBuildType(context, buildType); 45 | updateUIIntent.putExtra(STATUS_EXTRA, REGISTERED_STATUS); 46 | context.sendBroadcast(updateUIIntent); 47 | } else { 48 | Log.d(TAG, "Registration Error: " + String.valueOf(res.getStatusLine().getStatusCode())); 49 | updateUIIntent.putExtra(STATUS_EXTRA, REGISTERED_FAILURE_STATUS); 50 | context.sendBroadcast(updateUIIntent); 51 | } 52 | } catch (Exception e) { 53 | Log.d(TAG, "Exception", e); 54 | updateUIIntent.putExtra(STATUS_EXTRA, REGISTERED_FAILURE_STATUS); 55 | context.sendBroadcast(updateUIIntent); 56 | } 57 | } 58 | }).start(); 59 | } 60 | 61 | public static void unregisterWithServer(final Context context, final String deviceRegistrationID) { 62 | new Thread(new Runnable() { 63 | public void run() { 64 | Intent updateUIIntent = new Intent(MainActivity.UPDATE_UI_ACTION); 65 | 66 | try { 67 | HttpResponse res = makeUnregisterRequest(context, deviceRegistrationID); 68 | if (res.getStatusLine().getStatusCode() == 200) { 69 | removeDeviceRegistration(context); 70 | removeBuildType(context); 71 | updateUIIntent.putExtra(STATUS_EXTRA, UNREGISTERED_STATUS); 72 | context.sendBroadcast(updateUIIntent); 73 | } else { 74 | Log.d(TAG, "Unregistration Error: " + String.valueOf(res.getStatusLine().getStatusCode())); 75 | updateUIIntent.putExtra(STATUS_EXTRA, UNREGISTERED_FAILURE_STATUS); 76 | context.sendBroadcast(updateUIIntent); 77 | } 78 | } catch (Exception e) { 79 | Log.d(TAG, "Exception", e); 80 | updateUIIntent.putExtra(STATUS_EXTRA, UNREGISTERED_FAILURE_STATUS); 81 | context.sendBroadcast(updateUIIntent); 82 | } 83 | } 84 | }).start(); 85 | } 86 | 87 | private static void saveDeviceRegistration(Context context, String deviceRegistrationID) { 88 | SharedPreferences.Editor editor = Preferences.get(context).edit(); 89 | editor.putString(Preferences.DEVICEREGISTRATION_KEY, deviceRegistrationID); 90 | editor.commit(); 91 | 92 | Log.d(TAG, "Saved deviceRegistrationID=" + deviceRegistrationID); 93 | } 94 | 95 | private static void removeDeviceRegistration(Context context) { 96 | SharedPreferences.Editor editor = Preferences.get(context).edit(); 97 | editor.remove(Preferences.DEVICEREGISTRATION_KEY); 98 | editor.commit(); 99 | 100 | Log.d(TAG, "Removed deviceRegistrationID"); 101 | } 102 | 103 | private static void saveBuildType(Context context, String buildType) { 104 | SharedPreferences.Editor editor = Preferences.get(context).edit(); 105 | editor.putString(Preferences.BUILDTYPE_KEY, buildType); 106 | editor.commit(); 107 | 108 | Log.d(TAG, "Saved buildType=" + buildType); 109 | } 110 | 111 | private static void removeBuildType(Context context) { 112 | SharedPreferences.Editor editor = Preferences.get(context).edit(); 113 | editor.remove(Preferences.BUILDTYPE_KEY); 114 | editor.commit(); 115 | 116 | Log.d(TAG, "Removed buildType"); 117 | } 118 | 119 | 120 | private static HttpResponse makeRegisterRequest(Context context, String deviceRegistrationID) throws Exception { 121 | List params = new ArrayList(4); 122 | params.add(new BasicNameValuePair("deviceRegistrationId", deviceRegistrationID)); 123 | 124 | if (StringUtils.isRunningNightly()) { 125 | params.add(new BasicNameValuePair("stable", "N")); 126 | params.add(new BasicNameValuePair("nightly", "Y")); 127 | } else { 128 | params.add(new BasicNameValuePair("stable", "Y")); 129 | params.add(new BasicNameValuePair("nightly", "N")); 130 | } 131 | params.add(new BasicNameValuePair("device", StringUtils.getDevice())); 132 | 133 | String deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); 134 | params.add(new BasicNameValuePair("deviceId", deviceId)); 135 | 136 | RegistrationClient client = new RegistrationClient(); 137 | return client.registerRequest(params); 138 | } 139 | 140 | private static HttpResponse makeUnregisterRequest(Context context, String deviceRegistrationID) throws Exception { 141 | List params = new ArrayList(2); 142 | params.add(new BasicNameValuePair("deviceRegistrationId", deviceRegistrationID)); 143 | 144 | String deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); 145 | params.add(new BasicNameValuePair("deviceId", deviceId)); 146 | 147 | RegistrationClient client = new RegistrationClient(); 148 | return client.unregisterRequest(params); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/utils/NightlyLicense.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify.utils; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageInfo; 5 | import android.content.pm.PackageManager; 6 | import android.content.pm.PackageManager.NameNotFoundException; 7 | import android.util.Log; 8 | 9 | public class NightlyLicense { 10 | private PackageManager mPM; 11 | 12 | private static final String TAG = "CMUpdateNotify-NightlyLicense"; 13 | private static final String PNAME = "com.koushikdutta.rommanager.license"; 14 | private static final String SIGNATURE = "3082025f308201c8a0030201020204491395d0300d06092a864886f70d01010505003074310b3009060355040613025553310b30090603550408130257413110300e0603550407130753656174746c6531193017060355040a13106b6f757368696b64757474612e636f6d31133011060355040b130a436c6f636b776f726b73311630140603550403130d4b6f757368696b204475747461301e170d3038313130373031313134345a170d3336303332353031313134345a3074310b3009060355040613025553310b30090603550408130257413110300e0603550407130753656174746c6531193017060355040a13106b6f757368696b64757474612e636f6d31133011060355040b130a436c6f636b776f726b73311630140603550403130d4b6f757368696b20447574746130819f300d06092a864886f70d010101050003818d0030818902818100aaf2b6b9761485ad060146da376b67faceefd781bddf4ba92b0ede2d73edf1c59011e4637a9311b2c1640927b80e95ee4154dcfd2f86ff8eb4a295534d29ccb4f55d7e7e69eb20115fddc2edb422e75160c6b333a2ce05c35b67097ab14ca0ff2f63f2ecd64d9f4e4217a739cfaa0413f82b802e75992d649a157c55fc6b3a6b0203010001300d06092a864886f70d010105050003818100aaef343a4c39cabb750c1fc3c7121ac35be1023d6f80a71a48760c5345c1d9e0c8d2c20dffe1b3ed7089717964e1c6fcc122ef444ecf96b3cc448a43733807b48e409a9ca792458704d44984aab356833cfff51bab702bc371c14bf5cd43003cde3a91708364fc397535558c0009b7f033091119440129e64a31a8f15997d52d"; 15 | 16 | public NightlyLicense(Context ctx) { 17 | this.mPM = ctx.getPackageManager(); 18 | } 19 | 20 | public boolean validLicense() { 21 | boolean valid = false; 22 | try { 23 | PackageInfo pkginfo = mPM.getPackageInfo(PNAME, PackageManager.GET_SIGNATURES); 24 | String signature = pkginfo.signatures[0].toCharsString(); 25 | if (signature.equals(SIGNATURE)) { 26 | valid = true; 27 | } 28 | } catch (NameNotFoundException e) { 29 | } 30 | 31 | Log.d(TAG, "validLicense() = " + valid); 32 | return valid; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/utils/Preferences.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | public final class Preferences { 7 | public static final String DEVICEREGISTRATION_KEY = "deviceRegistrationID"; 8 | public static final String BUILDTYPE_KEY = "buildType"; 9 | 10 | public static SharedPreferences get(Context context) { 11 | return context.getSharedPreferences("CM_UPDATENOTIFY_PREFS", 0); 12 | } 13 | } -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/utils/RegistrationClient.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify.utils; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.http.HttpResponse; 6 | import org.apache.http.HttpVersion; 7 | import org.apache.http.NameValuePair; 8 | import org.apache.http.client.entity.UrlEncodedFormEntity; 9 | import org.apache.http.client.methods.HttpPost; 10 | import org.apache.http.impl.client.DefaultHttpClient; 11 | import org.apache.http.params.BasicHttpParams; 12 | import org.apache.http.params.HttpParams; 13 | import org.apache.http.params.HttpProtocolParams; 14 | 15 | public class RegistrationClient { 16 | static final String REGISTER_URL = "http://www.cyanogenmod.com/c2dm/register.php"; 17 | static final String UNREGISTER_URL = "http://www.cyanogenmod.com/c2dm/unregister.php"; 18 | 19 | public HttpResponse registerRequest(List params) throws Exception { 20 | final HttpParams httpparams = createParamsForPosting(); 21 | DefaultHttpClient httpclient = new DefaultHttpClient(); 22 | httpclient.setParams(httpparams); 23 | HttpPost httppost = new HttpPost(REGISTER_URL); 24 | httppost.setEntity(new UrlEncodedFormEntity(params)); 25 | HttpResponse res = httpclient.execute(httppost); 26 | return res; 27 | } 28 | 29 | public HttpResponse unregisterRequest(List params) throws Exception { 30 | final HttpParams httpparams = createParamsForPosting(); 31 | DefaultHttpClient httpclient = new DefaultHttpClient(); 32 | httpclient.setParams(httpparams); 33 | HttpPost httppost = new HttpPost(UNREGISTER_URL); 34 | httppost.setEntity(new UrlEncodedFormEntity(params)); 35 | HttpResponse res = httpclient.execute(httppost); 36 | return res; 37 | } 38 | 39 | private static HttpParams createParamsForPosting() { 40 | final HttpParams params = new BasicHttpParams(); 41 | HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); 42 | HttpProtocolParams.setContentCharset(params, "UTF_8"); 43 | HttpProtocolParams.setUseExpectContinue(params, false); // solves the '417' issue 44 | return params; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/cyanogenmod/updatenotify/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | package com.cyanogenmod.updatenotify.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import android.os.SystemProperties; 7 | 8 | public class StringUtils { 9 | public static String getDevice() { 10 | return SystemProperties.get("ro.product.device"); 11 | } 12 | 13 | public static String getModVersion() { 14 | return SystemProperties.get("ro.modversion"); 15 | } 16 | 17 | public static boolean isRunningNightly() { 18 | return isNightly(getModVersion()); 19 | } 20 | 21 | public static boolean compareModVersions(String newVersion, String oldVersion) { 22 | boolean newer = false; 23 | Pattern pattern = Pattern.compile("CyanogenMod-(\\d.\\d.\\d)(.?\\d?)-"); 24 | Matcher match; 25 | 26 | // Match new version. 27 | match = pattern.matcher(newVersion); 28 | while (match.find()) { 29 | if (match.groupCount() == 2) { 30 | newVersion = match.group(1).replace(".", ""); 31 | if (match.group(2).equals("")) { 32 | newVersion = newVersion + "0"; 33 | } else { 34 | newVersion = newVersion + match.group(2).replace(".", ""); 35 | } 36 | } 37 | } 38 | 39 | // Match old version 40 | match = pattern.matcher(oldVersion); 41 | while (match.find()) { 42 | if (match.groupCount() == 2) { 43 | oldVersion = match.group(1).replace(".", ""); 44 | if (match.group(2).equals("")) { 45 | oldVersion = oldVersion + "0"; 46 | } else { 47 | oldVersion = oldVersion + match.group(2).replace(".", ""); 48 | } 49 | } 50 | } 51 | 52 | if (Integer.valueOf(newVersion) > Integer.valueOf(oldVersion)) { 53 | newer = true; 54 | } else { 55 | newer = false; 56 | } 57 | 58 | return newer; 59 | } 60 | 61 | public static boolean isNightly(String modver) { 62 | boolean nightly = false; 63 | Pattern pattern = Pattern.compile("CyanogenMod-\\d-(\\d+)-NIGHTLY"); 64 | Matcher match; 65 | 66 | match = pattern.matcher(modver); 67 | 68 | while (match.find()) { 69 | if (match.groupCount() == 1) { 70 | nightly = true; 71 | } 72 | } 73 | 74 | return nightly; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/com/google/android/c2dm/C2DMBaseReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 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.google.android.c2dm; 18 | 19 | import java.io.IOException; 20 | 21 | import android.app.AlarmManager; 22 | import android.app.IntentService; 23 | import android.app.PendingIntent; 24 | import android.content.Context; 25 | import android.content.Intent; 26 | import android.os.PowerManager; 27 | import android.util.Log; 28 | 29 | /** 30 | * Base class for C2D message receiver. Includes constants for the 31 | * strings used in the protocol. 32 | */ 33 | 34 | 35 | public abstract class C2DMBaseReceiver extends IntentService { 36 | private static final String C2DM_RETRY = "com.google.android.c2dm.intent.RETRY"; 37 | 38 | public static final String REGISTRATION_CALLBACK_INTENT = "com.google.android.c2dm.intent.REGISTRATION"; 39 | private static final String C2DM_INTENT = "com.google.android.c2dm.intent.RECEIVE"; 40 | 41 | // Logging tag 42 | private static final String TAG = "C2DM"; 43 | 44 | // Extras in the registration callback intents. 45 | public static final String EXTRA_UNREGISTERED = "unregistered"; 46 | 47 | public static final String EXTRA_ERROR = "error"; 48 | 49 | public static final String EXTRA_REGISTRATION_ID = "registration_id"; 50 | 51 | public static final String ERR_SERVICE_NOT_AVAILABLE = "SERVICE_NOT_AVAILABLE"; 52 | public static final String ERR_ACCOUNT_MISSING = "ACCOUNT_MISSING"; 53 | public static final String ERR_AUTHENTICATION_FAILED = "AUTHENTICATION_FAILED"; 54 | public static final String ERR_TOO_MANY_REGISTRATIONS = "TOO_MANY_REGISTRATIONS"; 55 | public static final String ERR_INVALID_PARAMETERS = "INVALID_PARAMETERS"; 56 | public static final String ERR_INVALID_SENDER = "INVALID_SENDER"; 57 | public static final String ERR_PHONE_REGISTRATION_ERROR = "PHONE_REGISTRATION_ERROR"; 58 | 59 | // wakelock 60 | private static final String WAKELOCK_KEY = "C2DM_LIB"; 61 | 62 | private static PowerManager.WakeLock mWakeLock; 63 | private final String senderId; 64 | 65 | /** 66 | * The C2DMReceiver class must create a no-arg constructor and pass the 67 | * sender id to be used for registration. 68 | */ 69 | public C2DMBaseReceiver(String senderId) { 70 | // senderId is used as base name for threads, etc. 71 | super(senderId); 72 | this.senderId = senderId; 73 | } 74 | 75 | /** 76 | * Called when a cloud message has been received. 77 | */ 78 | protected abstract void onMessage(Context context, Intent intent); 79 | 80 | /** 81 | * Called on registration error. Override to provide better 82 | * error messages. 83 | * 84 | * This is called in the context of a Service - no dialog or UI. 85 | */ 86 | public abstract void onError(Context context, String errorId); 87 | 88 | /** 89 | * Called when a registration token has been received. 90 | */ 91 | public void onRegistered(Context context, String registrationId) throws IOException { 92 | // registrationId will also be saved 93 | } 94 | 95 | /** 96 | * Called when the device has been unregistered. 97 | */ 98 | public void onUnregistered(Context context) { 99 | } 100 | 101 | 102 | @Override 103 | public final void onHandleIntent(Intent intent) { 104 | try { 105 | Context context = getApplicationContext(); 106 | if (intent.getAction().equals(REGISTRATION_CALLBACK_INTENT)) { 107 | handleRegistration(context, intent); 108 | } else if (intent.getAction().equals(C2DM_INTENT)) { 109 | onMessage(context, intent); 110 | } else if (intent.getAction().equals(C2DM_RETRY)) { 111 | C2DMessaging.register(context, senderId); 112 | } 113 | } finally { 114 | // Release the power lock, so phone can get back to sleep. 115 | // The lock is reference counted by default, so multiple 116 | // messages are ok. 117 | 118 | // If the onMessage() needs to spawn a thread or do something else, 119 | // it should use it's own lock. 120 | mWakeLock.release(); 121 | } 122 | } 123 | 124 | 125 | /** 126 | * Called from the broadcast receiver. 127 | * Will process the received intent, call handleMessage(), registered(), etc. 128 | * in background threads, with a wake lock, while keeping the service 129 | * alive. 130 | */ 131 | static void runIntentInService(Context context, Intent intent) { 132 | if (mWakeLock == null) { 133 | // This is called from BroadcastReceiver, there is no init. 134 | PowerManager pm = 135 | (PowerManager) context.getSystemService(Context.POWER_SERVICE); 136 | mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, 137 | WAKELOCK_KEY); 138 | } 139 | mWakeLock.acquire(); 140 | 141 | // Use a naming convention, similar with how permissions and intents are 142 | // used. Alternatives are introspection or an ugly use of statics. 143 | String receiver = context.getPackageName() + ".C2DMReceiver"; 144 | intent.setClassName(context, receiver); 145 | 146 | context.startService(intent); 147 | 148 | } 149 | 150 | 151 | private void handleRegistration(final Context context, Intent intent) { 152 | final String registrationId = intent.getStringExtra(EXTRA_REGISTRATION_ID); 153 | String error = intent.getStringExtra(EXTRA_ERROR); 154 | String removed = intent.getStringExtra(EXTRA_UNREGISTERED); 155 | 156 | if (Log.isLoggable(TAG, Log.DEBUG)) { 157 | Log.d(TAG, "dmControl: registrationId = " + registrationId + 158 | ", error = " + error + ", removed = " + removed); 159 | } 160 | 161 | if (removed != null) { 162 | // Remember we are unregistered 163 | C2DMessaging.clearRegistrationId(context); 164 | onUnregistered(context); 165 | return; 166 | } else if (error != null) { 167 | // we are not registered, can try again 168 | C2DMessaging.clearRegistrationId(context); 169 | // Registration failed 170 | Log.e(TAG, "Registration error " + error); 171 | onError(context, error); 172 | if ("SERVICE_NOT_AVAILABLE".equals(error)) { 173 | long backoffTimeMs = C2DMessaging.getBackoff(context); 174 | 175 | Log.d(TAG, "Scheduling registration retry, backoff = " + backoffTimeMs); 176 | Intent retryIntent = new Intent(C2DM_RETRY); 177 | PendingIntent retryPIntent = PendingIntent.getBroadcast(context, 178 | 0 /*requestCode*/, retryIntent, 0 /*flags*/); 179 | 180 | AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 181 | am.set(AlarmManager.ELAPSED_REALTIME, 182 | backoffTimeMs, retryPIntent); 183 | 184 | // Next retry should wait longer. 185 | backoffTimeMs *= 2; 186 | C2DMessaging.setBackoff(context, backoffTimeMs); 187 | } 188 | } else { 189 | try { 190 | onRegistered(context, registrationId); 191 | C2DMessaging.setRegistrationId(context, registrationId); 192 | } catch (IOException ex) { 193 | Log.e(TAG, "Registration error " + ex.getMessage()); 194 | } 195 | } 196 | } 197 | } -------------------------------------------------------------------------------- /src/com/google/android/c2dm/C2DMBroadcastReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package com.google.android.c2dm; 4 | 5 | import android.app.Activity; 6 | import android.content.BroadcastReceiver; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | 10 | /** 11 | * Helper class to handle BroadcastReciver behavior. 12 | * - can only run for a limited amount of time - it must start a real service 13 | * for longer activity 14 | * - must get the power lock, must make sure it's released when all done. 15 | * 16 | */ 17 | public class C2DMBroadcastReceiver extends BroadcastReceiver { 18 | 19 | @Override 20 | public final void onReceive(Context context, Intent intent) { 21 | // To keep things in one place. 22 | C2DMBaseReceiver.runIntentInService(context, intent); 23 | setResult(Activity.RESULT_OK, null /* data */, null /* extra */); 24 | } 25 | } -------------------------------------------------------------------------------- /src/com/google/android/c2dm/C2DMessaging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 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.google.android.c2dm; 18 | 19 | import android.app.PendingIntent; 20 | import android.content.Context; 21 | import android.content.Intent; 22 | import android.content.SharedPreferences; 23 | import android.content.SharedPreferences.Editor; 24 | 25 | /** 26 | * Utilities for device registration. 27 | * 28 | * Will keep track of the registration token in a private preference. 29 | */ 30 | public class C2DMessaging { 31 | public static final String EXTRA_SENDER = "sender"; 32 | public static final String EXTRA_APPLICATION_PENDING_INTENT = "app"; 33 | public static final String REQUEST_UNREGISTRATION_INTENT = "com.google.android.c2dm.intent.UNREGISTER"; 34 | public static final String REQUEST_REGISTRATION_INTENT = "com.google.android.c2dm.intent.REGISTER"; 35 | public static final String LAST_REGISTRATION_CHANGE = "last_registration_change"; 36 | public static final String BACKOFF = "backoff"; 37 | public static final String GSF_PACKAGE = "com.google.android.gsf"; 38 | 39 | // package 40 | static final String PREFERENCE = "com.google.android.c2dm"; 41 | 42 | private static final long DEFAULT_BACKOFF = 30000; 43 | 44 | /** 45 | * Initiate c2d messaging registration for the current application 46 | */ 47 | public static void register(Context context, String senderId) { 48 | Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT); 49 | registrationIntent.setPackage(GSF_PACKAGE); 50 | registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT, PendingIntent.getBroadcast(context, 0, new Intent(), 0)); 51 | registrationIntent.putExtra(EXTRA_SENDER, senderId); 52 | context.startService(registrationIntent); 53 | // TODO: if intent not found, notification on need to have GSF 54 | } 55 | 56 | /** 57 | * Unregister the application. New messages will be blocked by server. 58 | */ 59 | public static void unregister(Context context) { 60 | Intent regIntent = new Intent(REQUEST_UNREGISTRATION_INTENT); 61 | regIntent.setPackage(GSF_PACKAGE); 62 | regIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT, PendingIntent.getBroadcast(context, 63 | 0, new Intent(), 0)); 64 | context.startService(regIntent); 65 | } 66 | 67 | /** 68 | * Return the current registration id. 69 | * 70 | * If result is empty, the registration has failed. 71 | * 72 | * @return registration id, or empty string if the registration is not complete. 73 | */ 74 | public static String getRegistrationId(Context context) { 75 | final SharedPreferences prefs = context.getSharedPreferences( 76 | PREFERENCE, 77 | Context.MODE_PRIVATE); 78 | String registrationId = prefs.getString("dm_registration", ""); 79 | return registrationId; 80 | } 81 | 82 | public static long getLastRegistrationChange(Context context) { 83 | final SharedPreferences prefs = context.getSharedPreferences( 84 | PREFERENCE, 85 | Context.MODE_PRIVATE); 86 | return prefs.getLong(LAST_REGISTRATION_CHANGE, 0); 87 | } 88 | 89 | static long getBackoff(Context context) { 90 | final SharedPreferences prefs = context.getSharedPreferences( 91 | PREFERENCE, 92 | Context.MODE_PRIVATE); 93 | return prefs.getLong(BACKOFF, DEFAULT_BACKOFF); 94 | } 95 | 96 | static void setBackoff(Context context, long backoff) { 97 | final SharedPreferences prefs = context.getSharedPreferences( 98 | PREFERENCE, 99 | Context.MODE_PRIVATE); 100 | Editor editor = prefs.edit(); 101 | editor.putLong(BACKOFF, backoff); 102 | editor.commit(); 103 | 104 | } 105 | 106 | // package 107 | static void clearRegistrationId(Context context) { 108 | final SharedPreferences prefs = context.getSharedPreferences( 109 | PREFERENCE, 110 | Context.MODE_PRIVATE); 111 | Editor editor = prefs.edit(); 112 | editor.putString("dm_registration", ""); 113 | editor.putLong(LAST_REGISTRATION_CHANGE, System.currentTimeMillis()); 114 | editor.commit(); 115 | 116 | } 117 | 118 | // package 119 | static void setRegistrationId(Context context, String registrationId) { 120 | final SharedPreferences prefs = context.getSharedPreferences( 121 | PREFERENCE, 122 | Context.MODE_PRIVATE); 123 | Editor editor = prefs.edit(); 124 | editor.putString("dm_registration", registrationId); 125 | editor.commit(); 126 | 127 | } 128 | } --------------------------------------------------------------------------------