├── library ├── .gitignore ├── consumer-rules.pro ├── src │ └── main │ │ ├── res │ │ ├── drawable-xxhdpi │ │ │ ├── tang_close.png │ │ │ ├── update_logo.png │ │ │ └── download_notification.png │ │ ├── drawable │ │ │ └── bg_tang_dialog.xml │ │ ├── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── layout │ │ │ ├── activity_transparent_layout.xml │ │ │ ├── custom_download_notification.xml │ │ │ ├── dialog_tang_update.xml │ │ │ └── progress_tang_update.xml │ │ ├── java │ │ └── com │ │ │ └── thjolin │ │ │ ├── update │ │ │ ├── configer │ │ │ │ ├── constant │ │ │ │ │ └── Constants.java │ │ │ │ └── UpgraderConfiger.java │ │ │ ├── operate │ │ │ │ ├── flow │ │ │ │ │ ├── Flow.java │ │ │ │ │ └── WorkFlow.java │ │ │ │ ├── listener │ │ │ │ │ ├── ForceExitListener.java │ │ │ │ │ ├── SelfInstallListener.java │ │ │ │ │ ├── OperateSuccessListener.java │ │ │ │ │ ├── UiListener.java │ │ │ │ │ └── LifeCycleListener.java │ │ │ │ ├── exception │ │ │ │ │ └── ParameterException.java │ │ │ │ ├── UpdateOperateInterface.java │ │ │ │ └── OperateState.java │ │ │ ├── check │ │ │ │ ├── CheckResult.java │ │ │ │ ├── CheckUpdateInterface.java │ │ │ │ └── ChekUpdateImpl.java │ │ │ ├── bean │ │ │ │ ├── ApkPatchBean.java │ │ │ │ └── ApkUpdateBean.java │ │ │ └── Upgrader.java │ │ │ ├── compose │ │ │ ├── BsPatchUtils.java │ │ │ ├── PatchComposeHelper.java │ │ │ ├── ComposeTask.java │ │ │ └── ApkUtils.java │ │ │ ├── install │ │ │ ├── GoMarketUtil.java │ │ │ └── InstallHelper.java │ │ │ └── ui │ │ │ ├── PDialog.java │ │ │ └── DefaultActivityController.java │ │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── native-lib.cpp │ │ ├── bzip2 │ │ │ ├── randtable.c │ │ │ ├── crctable.c │ │ │ └── bzlib.h │ │ └── bspatch.c │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── uudownload ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── thjolin │ │ │ └── download │ │ │ ├── permission │ │ │ ├── core │ │ │ │ ├── IPermission.java │ │ │ │ └── IPermissionImpl.java │ │ │ ├── util │ │ │ │ ├── PermissionHelper.java │ │ │ │ └── PermissionUtils.java │ │ │ └── MyPermissionActivity.java │ │ │ ├── listener │ │ │ ├── DownloadListenerWithSpeed.java │ │ │ ├── DownloadListener.java │ │ │ └── MultiDownloadListener.java │ │ │ ├── task │ │ │ ├── interceptor │ │ │ │ ├── RetryInterceptor.java │ │ │ │ ├── TaskMainInterceptor.java │ │ │ │ ├── TaskInterceptor.java │ │ │ │ ├── AbstractInterceptor.java │ │ │ │ ├── DownloadInterceptor.java │ │ │ │ ├── DatabaseInterceptor.java │ │ │ │ ├── ConnectInterceptor.java │ │ │ │ ├── StrategyInterceptor.java │ │ │ │ └── FileInterceptor.java │ │ │ ├── TaskCall.java │ │ │ ├── DownloadCall.java │ │ │ └── speed │ │ │ │ └── SpeedAssist.java │ │ │ ├── util │ │ │ ├── Logl.java │ │ │ ├── Utils.java │ │ │ └── NamedRunnable.java │ │ │ ├── constant │ │ │ ├── Lifecycle.java │ │ │ └── Status.java │ │ │ ├── database │ │ │ ├── download │ │ │ │ ├── DaoDownload.java │ │ │ │ ├── DownloadDaoFatory.java │ │ │ │ └── DaoDownloadImpl.java │ │ │ ├── base │ │ │ │ ├── BaseDb.java │ │ │ │ ├── BaseDO.java │ │ │ │ └── DaoFactory.java │ │ │ ├── DaoUtil.java │ │ │ ├── DownloadProvider.java │ │ │ └── DownloadEntity.java │ │ │ ├── http │ │ │ └── HttpUtil.java │ │ │ ├── UuDownloader.java │ │ │ └── dispatcher │ │ │ └── TaskDispatcher.java │ │ ├── res │ │ └── layout │ │ │ └── activity_tang_permission.xml │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── .gitattributes ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── app ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── xml │ │ │ ├── file_paths.xml │ │ │ └── network_security_config.xml │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── themes.xml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── menu │ │ │ └── menu_main.xml │ │ ├── values-night │ │ │ └── themes.xml │ │ ├── layout │ │ │ ├── activity_storage.xml │ │ │ ├── content_main.xml │ │ │ ├── fragment_second.xml │ │ │ ├── fragment_first.xml │ │ │ └── activity_main.xml │ │ ├── navigation │ │ │ └── nav_graph.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ └── com │ │ │ └── thjolin │ │ │ └── updatefrompatch │ │ │ ├── data │ │ │ ├── model │ │ │ │ └── LoggedInUser.java │ │ │ ├── LoginDataSource.java │ │ │ ├── Result.java │ │ │ └── LoginRepository.java │ │ │ ├── SecondFragment.java │ │ │ └── FirstFragment.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── local.properties ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /library/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /uudownload/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.c linguist-language=java 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':library' 2 | include ':app' 3 | rootProject.name = "UpdateFromPatch" 4 | include ':uudownload' 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/tang_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/library/src/main/res/drawable-xxhdpi/tang_close.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/update_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/library/src/main/res/drawable-xxhdpi/update_logo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/download_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thjolin321/android-upgrader/HEAD/library/src/main/res/drawable-xxhdpi/download_notification.png -------------------------------------------------------------------------------- /app/src/main/res/xml/file_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/configer/constant/Constants.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.configer.constant; 2 | 3 | /** 4 | * Created by th on 2021/6/15 5 | */ 6 | public class Constants { 7 | 8 | 9 | } -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/flow/Flow.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate.flow; 2 | 3 | /** 4 | * Created by th on 2021/6/15 5 | */ 6 | public interface Flow { 7 | 8 | WorkFlow getFlow(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/listener/ForceExitListener.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate.listener; 2 | 3 | /** 4 | * Created by th on 2021/7/8 5 | */ 6 | public interface ForceExitListener { 7 | 8 | void exit(); 9 | 10 | } -------------------------------------------------------------------------------- /library/src/main/res/drawable/bg_tang_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/listener/SelfInstallListener.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate.listener; 2 | 3 | /** 4 | * Created by th on 2021/7/8 5 | */ 6 | public interface SelfInstallListener { 7 | 8 | void install(String path); 9 | 10 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jun 16 16:32:19 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 4 | 16dp 5 | 16dp 6 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/permission/core/IPermission.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.permission.core; 2 | 3 | // 告诉外交 4 | public interface IPermission { 5 | 6 | void ganted(); // 已经授权 7 | 8 | void cancel(); // 取消权限 9 | 10 | void denied(); // 拒绝权限 11 | } 12 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/listener/DownloadListenerWithSpeed.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.listener; 2 | 3 | /** 4 | * Created by th on 2021/6/1 5 | */ 6 | public interface DownloadListenerWithSpeed extends DownloadListener { 7 | 8 | void speed(String speed); 9 | 10 | } -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 退出 3 | 立即下载 4 | 下载中… 5 | 重试 6 | 下载 7 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/permission/core/IPermissionImpl.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.permission.core; 2 | 3 | // 告诉外交 4 | public abstract class IPermissionImpl implements IPermission { 5 | 6 | public void cancel(){} // 取消权限 7 | 8 | public void denied(){} // 拒绝权限 9 | 10 | } 11 | -------------------------------------------------------------------------------- /library/src/main/res/layout/activity_transparent_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /uudownload/src/main/res/layout/activity_tang_permission.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/exception/ParameterException.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate.exception; 2 | 3 | /** 4 | * Created by th on 2021/6/11 5 | */ 6 | public class ParameterException extends Exception { 7 | public ParameterException() { 8 | super("参数错误"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/listener/DownloadListener.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.listener; 2 | 3 | /** 4 | * Created by th on 2021/6/1 5 | */ 6 | public interface DownloadListener { 7 | 8 | void success(String path); 9 | 10 | void progress(int progress); 11 | 12 | void failed(String msg); 13 | 14 | } -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/listener/OperateSuccessListener.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate.listener; 2 | 3 | /** 4 | * Created by th on 2021/5/24 5 | */ 6 | public interface OperateSuccessListener { 7 | 8 | void success(String msg); 9 | 10 | void failed(String msg); 11 | 12 | void progress(int progress); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /library/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | aux_source_directory(bzip2 SOURCES) 4 | 5 | add_library( 6 | bspatch_utlis 7 | 8 | SHARED 9 | native-lib.cpp 10 | bspatch.c 11 | ${SOURCES}) 12 | 13 | include_directories(bzip2) 14 | 15 | 16 | target_link_libraries( 17 | bspatch_utlis 18 | log) -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/check/CheckResult.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.check; 2 | 3 | import com.thjolin.compose.ComposeTask; 4 | import com.thjolin.download.task.DownloadTask; 5 | 6 | /** 7 | * Created by th on 2021/6/15 8 | */ 9 | public class CheckResult { 10 | 11 | public DownloadTask downloadTask; 12 | public ComposeTask composeTask; 13 | 14 | } -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/UpdateOperateInterface.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate; 2 | 3 | /** 4 | * Created by th on 2021/5/24 5 | */ 6 | public interface UpdateOperateInterface { 7 | 8 | void updateApkByPatchPath(String patchString, String nowApkPath); 9 | 10 | void updateApkByCompleteUrl(String apkUrl); 11 | 12 | void downloadFile(String url); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/check/CheckUpdateInterface.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.check; 2 | 3 | import com.thjolin.update.bean.ApkUpdateBean; 4 | import com.thjolin.update.operate.flow.Flow; 5 | 6 | /** 7 | * Created by th on 2021/5/24 8 | */ 9 | public interface CheckUpdateInterface extends Flow { 10 | 11 | int checkUpdateByHistoryVersions(ApkUpdateBean apkUpdateBean); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/listener/MultiDownloadListener.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.listener; 2 | 3 | /** 4 | * Created by th on 2021/6/1 5 | */ 6 | public interface MultiDownloadListener { 7 | 8 | // all task finish 9 | void onFinish(); 10 | 11 | // one task success 12 | void onSuccess(String url,String path); 13 | 14 | // task failed 15 | void onFailed(String url); 16 | 17 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/task/interceptor/RetryInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.task.interceptor; 2 | 3 | import com.thjolin.download.task.DownloadTask; 4 | 5 | /** 6 | * Created by th on 2021/6/1 7 | */ 8 | public class RetryInterceptor extends AbstractInterceptor implements TaskInterceptor { 9 | @Override 10 | public DownloadTask operate(DownloadTask task) { 11 | 12 | return task; 13 | } 14 | } -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file should *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=D\:\\AAA_android\\Sdk -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/task/interceptor/TaskMainInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.task.interceptor; 2 | 3 | import com.thjolin.download.task.DownloadTask; 4 | 5 | /** 6 | * Created by th on 2021/5/27 7 | */ 8 | public class TaskMainInterceptor extends AbstractInterceptor implements TaskInterceptor { 9 | 10 | @Override 11 | public DownloadTask operate(DownloadTask task) { 12 | 13 | return null; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/task/interceptor/TaskInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.task.interceptor; 2 | 3 | import com.thjolin.download.task.DownloadTask; 4 | 5 | /** 6 | * Created by th on 2021/5/27 7 | */ 8 | public interface TaskInterceptor { 9 | 10 | DownloadTask operate(DownloadTask task); 11 | 12 | TaskInterceptor next(); 13 | 14 | void setNext(TaskInterceptor taskInterceptor); 15 | 16 | void add(TaskInterceptor taskInterceptor); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/util/Logl.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.util; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * Created by th on 2021/6/2 7 | */ 8 | public class Logl { 9 | 10 | private static boolean DEBUG = true; 11 | 12 | public static void e(String str) { 13 | if (str == null && !DEBUG) return; 14 | Log.e("TAG", str); 15 | } 16 | 17 | public static void setDEBUG(boolean debug) { 18 | DEBUG = debug; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/constant/Lifecycle.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.constant; 2 | 3 | import com.thjolin.download.listener.DownloadListener; 4 | import com.thjolin.download.task.DownloadTask; 5 | 6 | /** 7 | * Created by th on 2021/5/27 8 | */ 9 | public interface Lifecycle { 10 | 11 | void init(); 12 | 13 | boolean prepare(DownloadTask task); 14 | 15 | void start(DownloadTask task, DownloadListener downloadListener); 16 | 17 | void destroy(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/compose/BsPatchUtils.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.compose; 2 | 3 | import com.thjolin.download.util.Logl; 4 | 5 | public class BsPatchUtils { 6 | 7 | static { 8 | try { 9 | System.loadLibrary("bspatch_utlis"); 10 | Logl.e("loadLibrary成功"); 11 | } catch (Exception e) { 12 | Logl.e("Exception: " + e.getMessage()); 13 | } 14 | 15 | } 16 | 17 | public static native int patch(String oldApk, String newApk, String patchFile); 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | UpdateFromPatch 3 | Settings 4 | 5 | First Fragment 6 | Second Fragment 7 | Next 8 | Previous 9 | 10 | 你好,点击Start按钮开始各方法测试。官方技术交流QQ群:1132413834 11 | 12 | -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/database/download/DaoDownload.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.database.download; 2 | 3 | import com.thjolin.download.database.DownloadEntity; 4 | import com.thjolin.download.database.base.BaseDb; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by th on 2021/6/8 10 | */ 11 | public interface DaoDownload extends BaseDb { 12 | 13 | long qureyAllCacheSize(String url); 14 | 15 | List qureyAllByUrl(String url); 16 | 17 | long deleteByUrl(String url); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/OperateState.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate; 2 | 3 | /** 4 | * Created by th on 2021/6/11 5 | */ 6 | public class OperateState { 7 | 8 | 9 | /** 10 | * 0 for check 11 | * 10 download hole apk 12 | * 11 download patch 13 | * 20 compose apk 14 | * 100 install apk 15 | * 200 install success 16 | * 17 | * -10 download failed 18 | * -20 compose failed 19 | * -100 install failed permission 20 | * 21 | * 1000 goto market 22 | */ 23 | public int state; 24 | 25 | } -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/database/download/DownloadDaoFatory.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.database.download; 2 | 3 | import com.thjolin.download.database.DownloadEntity; 4 | import com.thjolin.download.database.base.DaoFactory; 5 | 6 | /** 7 | * Created by th on 2021/6/9 8 | */ 9 | public class DownloadDaoFatory extends DaoFactory { 10 | static DaoDownload daoDownload; 11 | 12 | static { 13 | daoDownload = new DaoDownloadImpl(); 14 | daoDownload.init(getFactory().getmSqLiteDatabase(), DownloadEntity.class); 15 | } 16 | 17 | public static DaoDownload getDao() { 18 | return daoDownload; 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/thjolin/updatefrompatch/data/model/LoggedInUser.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.updatefrompatch.data.model; 2 | 3 | /** 4 | * Data class that captures user information for logged in users retrieved from LoginRepository 5 | */ 6 | public class LoggedInUser { 7 | 8 | private String userId; 9 | private String displayName; 10 | 11 | public LoggedInUser(String userId, String displayName) { 12 | this.userId = userId; 13 | this.displayName = displayName; 14 | } 15 | 16 | public String getUserId() { 17 | return userId; 18 | } 19 | 20 | public String getDisplayName() { 21 | return displayName; 22 | } 23 | } -------------------------------------------------------------------------------- /uudownload/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/listener/UiListener.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate.listener; 2 | 3 | import com.thjolin.install.InstallApkActivity; 4 | import com.thjolin.ui.PDialog; 5 | 6 | /** 7 | * Created by th on 2021/7/8 8 | */ 9 | public interface UiListener { 10 | 11 | void show(boolean showNotification, boolean forceUpdate, boolean needDownload, boolean needCompose, String apkPath, String fileName); 12 | 13 | void showNotification(); 14 | 15 | void progress(int progress); 16 | 17 | void downloadSuccess(String path); 18 | 19 | void failed(String msg); 20 | 21 | void setOnRightClick(InstallApkActivity.OnDialogClick onRightClick); 22 | 23 | } -------------------------------------------------------------------------------- /library/src/main/java/com/thjolin/update/operate/listener/LifeCycleListener.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.update.operate.listener; 2 | 3 | /** 4 | * Created by th (); on 2021/7/7 5 | */ 6 | public interface LifeCycleListener { 7 | 8 | int NO_NEED_UPGRADE = -1; 9 | int CHECK = 0; 10 | int START = 1; 11 | int DOWNLOAD = 2; 12 | int COMPOSE = 3; 13 | int INSTALL = 4; 14 | int MARKET = 99; 15 | int FINISH = 100; 16 | int UPGRADE_ERROR = -100; 17 | 18 | boolean onCheck(); 19 | 20 | void onStart(); 21 | 22 | void onDownload(); 23 | 24 | void onDownloadProgress(); 25 | 26 | void onCompose(); 27 | 28 | void onInstall(); 29 | 30 | void onError(); 31 | 32 | void onFinish(); 33 | } 34 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/database/base/BaseDb.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.database.base; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public interface BaseDb { 9 | 10 | void init(SQLiteDatabase sqLiteDatabase, Class clazz); 11 | 12 | String getTableName(); 13 | 14 | // C 15 | long insert(T obj); 16 | 17 | long insertOrUpdate(T obj); 18 | 19 | void insert(List list); 20 | 21 | // R 22 | long deletetByPrimaryKey(long id); 23 | 24 | long deletetByParamMap(Map paramMap); 25 | 26 | // U 27 | long updateByPrimaryKey(T obj, long id); 28 | 29 | // D 30 | T selectByPrimaryKey(int id); 31 | 32 | List selectByMap(Map paramMap); 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /uudownload/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /uudownload/src/main/java/com/thjolin/download/database/base/BaseDO.java: -------------------------------------------------------------------------------- 1 | package com.thjolin.download.database.base; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public abstract class BaseDO implements Serializable { 8 | 9 | long id; 10 | 11 | public long getId() { 12 | return id; 13 | } 14 | 15 | public void setId(long id) { 16 | this.id = id; 17 | } 18 | 19 | private Map queryParams; 20 | 21 | public void addQueryParam(String key, Object value) { 22 | if (queryParams == null) { 23 | queryParams = new HashMap<>(); 24 | } 25 | queryParams.put(key, value); 26 | } 27 | 28 | public void setQueryParams(Map queryParams) { 29 | this.queryParams = queryParams; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_storage.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |