├── Android.mk ├── AndroidManifest.xml ├── jni ├── Android.mk └── android_rockchip_update_UpdateService.cpp ├── res ├── drawable-hdpi │ ├── icon.png │ └── ota_update.png ├── drawable-mdpi │ ├── ic_dialog_alert.png │ ├── icon.png │ └── ota_update.png ├── layout │ ├── download_notify.xml │ ├── notify_dialog.xml │ ├── package_download.xml │ └── setting.xml ├── values-pl-rPL │ └── strings.xml ├── values-ru-rRU │ └── strings.xml ├── values-zh-rCN │ └── strings.xml ├── values-zh-rTW │ └── strings.xml └── values │ └── strings.xml └── src └── android └── rockchip └── update ├── service ├── CustomerHttpClient.java ├── FileDownloadTask.java ├── FileInfo.java ├── FirmwareUpdatingActivity.java ├── InvalidFirmwareImageActivity.java ├── NoImageActivity.java ├── NotifyDeleteActivity.java ├── OtaUpdateNotifyActivity.java ├── PackageDownloadActivity.java ├── RKUpdateReceiver.java ├── RKUpdateService.java ├── RecoverySystem.java ├── Setting.java └── UpdateAndRebootActivity.java └── util └── RegetInfoUtil.java /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE_TAGS := optional 5 | 6 | LOCAL_PACKAGE_NAME := RKUpdateService 7 | LOCAL_CERTIFICATE := platform 8 | LOCAL_SRC_FILES := $(call all-subdir-java-files) 9 | LOCAL_JNI_SHARED_LIBRARIES := rockchip_update_jni 10 | LOCAL_PROGUARD_ENABLED := disabled 11 | 12 | include $(BUILD_PACKAGE) 13 | 14 | include $(call all-makefiles-under,$(LOCAL_PATH)) 15 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 57 | 58 | 63 | 64 | 69 | 70 | 75 | 76 | 81 | 82 | 88 | 89 | 94 | 95 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := rockchip_update_jni 6 | LOCAL_MODULE_TAGS := optional 7 | LOCAL_PRELINK_MODULE := false 8 | LOCAL_SRC_FILES := android_rockchip_update_UpdateService.cpp 9 | LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) 10 | LOCAL_SHARED_LIBRARIES := liblog libutils 11 | 12 | include $(BUILD_SHARED_LIBRARY) 13 | -------------------------------------------------------------------------------- /jni/android_rockchip_update_UpdateService.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #define LOG_TAG __FILE__ 8 | #include 9 | 10 | static int read_file(const char* path, int offset, int len, char* buf) 11 | { 12 | int result, ret; 13 | int fd = open(path, O_RDWR); 14 | if (fd < 0) { 15 | LOGE("Fail to open image file file '%s', error : '%s'.", 16 | path, strerror(errno)); 17 | return fd; 18 | } 19 | if (lseek(fd, offset, SEEK_SET) < 0) { 20 | LOGE("Fail to seek image file file '%s', error : '%s'.", 21 | path, strerror(errno)); 22 | result = -1; 23 | goto clean_and_return; 24 | } 25 | ret = read(fd, buf, len); 26 | if (ret < 0) { 27 | LOGE("Fail to read image file file '%s', bytes read : '%d', error : '%s'.", 28 | path, ret, strerror(errno)); 29 | result = errno; 30 | goto clean_and_return; 31 | } 32 | result = 0; 33 | clean_and_return: 34 | if (fd) close(fd); 35 | return result; 36 | } 37 | 38 | static jstring getImageProductName(JNIEnv* env, jobject object, jstring j_path) 39 | { 40 | jstring result = NULL; 41 | const char* path = env->GetStringUTFChars(j_path, 0); 42 | if (!path) { 43 | LOGE("Failed to get utf-8 path from 'j_path'."); 44 | return NULL; 45 | } 46 | LOGD("Image file path : '%s'.", path); 47 | char buf[64]; 48 | int offset = 0; 49 | int ret = read_file(path, offset, sizeof(buf), buf); 50 | if (ret) { 51 | LOGE("Fail to read image file file '%s', error : '%s'.", 52 | path, strerror(errno)); 53 | goto clean_and_return; 54 | } 55 | if (*(unsigned*)(buf)==0x57464B52) 56 | offset = *(unsigned*)(buf+0x21); 57 | ret = read_file(path, offset+8, sizeof(buf), buf); 58 | if (ret) { 59 | LOGE("Fail to read image file file '%s', error : '%s'.", 60 | path, strerror(errno)); 61 | goto clean_and_return; 62 | } 63 | ret = strlen(buf); 64 | if (ret >= 64) { 65 | LOGE("Read invalid (too long) name info(length : '%d'). " 66 | "Image file must be invalid!", ret); 67 | goto clean_and_return; 68 | } 69 | LOGD("Porduce name : '%s'.", buf); 70 | result = env->NewStringUTF(buf); 71 | clean_and_return: 72 | env->ReleaseStringUTFChars(j_path, path); 73 | return result; 74 | } 75 | 76 | static jstring getImageVersion(JNIEnv* env, jobject object, jstring j_path) 77 | { 78 | jstring result = NULL; 79 | const char* path = env->GetStringUTFChars(j_path, 0); 80 | if (!path) { 81 | LOGE("Failed to get utf-8 path from 'j_path'."); 82 | return NULL; 83 | } 84 | LOGD("Image file path : '%s'.", path); 85 | char buf[64]; 86 | int offset = 0; 87 | int ret = read_file(path, offset, sizeof(buf), buf); 88 | if (ret) { 89 | LOGE("Fail to read image file file '%s', error : '%s'.", 90 | path, strerror(errno)); 91 | goto clean_and_return; 92 | } 93 | if (*(unsigned*)(buf)==0x57464B52) 94 | offset = *(unsigned*)(buf+0x21); 95 | ret = read_file(path, offset+0x84, 4, buf); 96 | if (ret) { 97 | LOGE("Fail to read image file file '%s', error : '%s'.", 98 | path, strerror(errno)); 99 | goto clean_and_return; 100 | } 101 | sprintf(buf, "%d.%d.%d", buf[3], buf[2], buf[0] + (buf[1]<<8)); 102 | LOGD("Image version : '%s'.", buf); 103 | result = env->NewStringUTF(buf); 104 | clean_and_return: 105 | env->ReleaseStringUTFChars(j_path, path); 106 | return result; 107 | } 108 | 109 | static JNINativeMethod gMethods[] = { 110 | { "getImageVersion", "(Ljava/lang/String;)Ljava/lang/String;", (void*)getImageVersion}, 111 | { "getImageProductName", "(Ljava/lang/String;)Ljava/lang/String;", (void*)getImageProductName } 112 | }; 113 | #define gMethodsCount (sizeof(gMethods) / sizeof(gMethods[0])) 114 | 115 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) 116 | { 117 | const char* name = "android/rockchip/update/service/RKUpdateService"; 118 | JNIEnv* env = NULL; 119 | jclass gClass; 120 | LOGI("JNI_OnLoad"); 121 | if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_4) != JNI_OK) { 122 | LOGE( "ERROR: GetEnv failed"); 123 | return -1; 124 | } 125 | if ((gClass = env->FindClass(name)) == NULL) { 126 | LOGE("Native registration unable to find class '%s'", name); 127 | goto clean_and_return; 128 | } 129 | if (env->RegisterNatives(gClass, gMethods, gMethodsCount) < 0) { 130 | fprintf(stderr, "RegisterNatives failed for '%s'", name); 131 | goto clean_and_return; 132 | } 133 | return JNI_VERSION_1_4; 134 | clean_and_return: 135 | LOGE("ERROR: registerNatives failed"); 136 | return -1; 137 | } 138 | -------------------------------------------------------------------------------- /res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msink/android_packages_apps_rkupdateservice/c4a00ecbb2fe41acd9834f5d637adbdf61072a39/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ota_update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msink/android_packages_apps_rkupdateservice/c4a00ecbb2fe41acd9834f5d637adbdf61072a39/res/drawable-hdpi/ota_update.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_dialog_alert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msink/android_packages_apps_rkupdateservice/c4a00ecbb2fe41acd9834f5d637adbdf61072a39/res/drawable-mdpi/ic_dialog_alert.png -------------------------------------------------------------------------------- /res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msink/android_packages_apps_rkupdateservice/c4a00ecbb2fe41acd9834f5d637adbdf61072a39/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ota_update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msink/android_packages_apps_rkupdateservice/c4a00ecbb2fe41acd9834f5d637adbdf61072a39/res/drawable-mdpi/ota_update.png -------------------------------------------------------------------------------- /res/layout/download_notify.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /res/layout/notify_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 16 |