本文整理汇总了Java中com.tencent.tinker.lib.tinker.TinkerInstaller.onReceiveUpgradePatch方法的典型用法代码示例。如果您正苦于以下问题:Java TinkerInstaller.onReceiveUpgradePatch方法的具体用法?Java TinkerInstaller.onReceiveUpgradePatch怎么用?Java TinkerInstaller.onReceiveUpgradePatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tencent.tinker.lib.tinker.TinkerInstaller
的用法示例。
在下文中一共展示了TinkerInstaller.onReceiveUpgradePatch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retryPatch
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
public boolean retryPatch() {
final Tinker tinker = Tinker.with(context);
if (!tinker.isMainProcess()) {
return false;
}
File patchVersionFile = tinker.getTinkerLoadResultIfPresent().patchVersionFile;
if (patchVersionFile != null) {
if (UpgradePatchRetry.getInstance(context).onPatchListenerCheck(SharePatchFileUtil.getMD5(patchVersionFile))) {
TinkerLog.i(TAG, "try to repair oat file on patch process");
TinkerInstaller.onReceiveUpgradePatch(context, patchVersionFile.getAbsolutePath());
return true;
}
// else {
// TinkerLog.i(TAG, "repair retry exceed must max time, just clean");
// checkAndCleanPatch();
// }
}
return false;
}
示例2: onPatchRetryLoad
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
public void onPatchRetryLoad() {
if (!this.isRetryEnable) {
TinkerLog.w(TAG, "onPatchRetryLoad retry disabled, just return", new Object[0]);
} else if (!Tinker.with(this.context).isMainProcess()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry is not main process, just return", new
Object[0]);
} else if (!this.retryInfoFile.exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry info not exist, just return", new Object[0]);
} else if (TinkerServiceInternals.isTinkerPatchServiceRunning(this.context)) {
TinkerLog.w(TAG, "onPatchRetryLoad tinker service is running, just return", new
Object[0]);
} else {
String path = this.tempPatchFile.getAbsolutePath();
if (path == null || !new File(path).exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is not exist, just return", path);
return;
}
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is exist, retry to patch", path);
TinkerInstaller.onReceiveUpgradePatch(this.context, path);
SampleTinkerReport.onReportRetryPatch();
}
}
示例3: handlePatchFile
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
private boolean handlePatchFile(Context context, Integer version, File patchFile) {
SharedPreferences sp = context.getSharedPreferences(
TinkerServerClient.SHARE_SERVER_PREFERENCE_CONFIG, Context.MODE_PRIVATE
);
int current = sp.getInt(TINKER_RETRY_PATCH, 0);
if (current >= TINKER_MAX_RETRY_COUNT) {
SharePatchFileUtil.safeDeleteFile(patchFile);
sp.edit().putInt(TINKER_RETRY_PATCH, 0).commit();
TinkerLog.w(TAG,
"beforePatchRequest, retry patch install more than %d times, version: %d, patch:%s",
current, version, patchFile.getPath()
);
} else {
TinkerLog.w(TAG, "beforePatchRequest, have pending patch to install, version: %d, patch:%s",
version, patchFile.getPath()
);
sp.edit().putInt(TINKER_RETRY_PATCH, ++current).commit();
TinkerInstaller.onReceiveUpgradePatch(context, patchFile.getAbsolutePath());
return true;
}
return false;
}
示例4: tryPatchFile
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
private void tryPatchFile(File patchFile, Integer newVersion) {
TinkerServerClient client = TinkerServerClient.get();
Context context = client.getContext();
//In order to calculate the user number, just report success here
String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
//update version
client.updateTinkerVersion(newVersion, patchMd5);
//delete old patch sever file
File serverDir = ServerUtils.getServerDirectory(context);
if (serverDir != null) {
File[] files = serverDir.listFiles();
if (files != null) {
String currentName = patchFile.getName();
for (File file : files) {
String fileName = file.getName();
if (fileName.equals(currentName) || fileName.equals(ServerUtils.TINKER_VERSION_FILE)) {
continue;
}
SharePatchFileUtil.safeDeleteFile(file);
}
}
client.reportPatchApplySuccess(newVersion);
//try install
TinkerInstaller.onReceiveUpgradePatch(context, patchFile.getAbsolutePath());
}
}
示例5: onLoadFileNotFound
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
/**
* try to recover patch oat file
* @param file
* @param fileType
* @param isDirectory
*/
@Override
public void onLoadFileNotFound(File file, int fileType, boolean isDirectory) {
TinkerLog.i(TAG, "patch loadReporter onLoadFileNotFound: patch file not found: %s, fileType:%d, isDirectory:%b",
file.getAbsolutePath(), fileType, isDirectory);
// only try to recover opt file
// check dex opt file at last, some phone such as VIVO/OPPO like to change dex2oat to interpreted
if (fileType == ShareConstants.TYPE_DEX_OPT) {
Tinker tinker = Tinker.with(context);
//we can recover at any process except recover process
if (tinker.isMainProcess()) {
File patchVersionFile = tinker.getTinkerLoadResultIfPresent().patchVersionFile;
if (patchVersionFile != null) {
if (UpgradePatchRetry.getInstance(context).onPatchListenerCheck(SharePatchFileUtil.getMD5(patchVersionFile))) {
TinkerLog.i(TAG, "try to repair oat file on patch process");
TinkerInstaller.onReceiveUpgradePatch(context, patchVersionFile.getAbsolutePath());
} else {
TinkerLog.i(TAG, "repair retry exceed must max time, just clean");
checkAndCleanPatch();
}
}
}
} else {
checkAndCleanPatch();
}
SampleTinkerReport.onLoadFileNotFound(fileType);
}
示例6: onPatchRetryLoad
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
public void onPatchRetryLoad() {
if (!isRetryEnable) {
TinkerLog.w(TAG, "onPatchRetryLoad retry disabled, just return");
return;
}
Tinker tinker = Tinker.with(context);
//only retry on main process
if (!tinker.isMainProcess()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry is not main process, just return");
return;
}
if (!retryInfoFile.exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry info not exist, just return");
return;
}
if (TinkerServiceInternals.isTinkerPatchServiceRunning(context)) {
TinkerLog.w(TAG, "onPatchRetryLoad tinker service is running, just return");
return;
}
//must use temp file
String path = tempPatchFile.getAbsolutePath();
if (path == null || !new File(path).exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is not exist, just return", path);
return;
}
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is exist, retry to patch", path);
TinkerInstaller.onReceiveUpgradePatch(context, path);
SampleTinkerReport.onReportRetryPatch();
}
示例7: onPatchRetryLoad
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
public boolean onPatchRetryLoad() {
if (!isRetryEnable) {
TinkerLog.w(TAG, "onPatchRetryLoad retry disabled, just return");
return false;
}
Tinker tinker = Tinker.with(context);
//only retry on main process
if (!tinker.isMainProcess()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry is not main process, just return");
return false;
}
if (!retryInfoFile.exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry info not exist, just return");
return false;
}
if (TinkerServiceInternals.isTinkerPatchServiceRunning(context)) {
TinkerLog.w(TAG, "onPatchRetryLoad tinker service is running, just return");
return false;
}
//must use temp file
String path = tempPatchFile.getAbsolutePath();
if (path == null || !new File(path).exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is not exist, just return", path);
return false;
}
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is exist, retry to patch", path);
TinkerInstaller.onReceiveUpgradePatch(context, path);
return true;
}
示例8: handleData
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
private static void handleData(Context context, JSONObject object) {
if (object != null) {
try {
patchVersion = object.optString("patch_version");
patchUrl = object.optString("download_url");
String hashValue = object.optString("hash_value");
if (!TextUtils.isEmpty(patchVersion)) {
if (TextUtils.equals(patchVersion, BuildInfo.ONE_PATCH_VERSION)) {
Helper.showLog(TAG, "patch version : " + patchVersion + " is already be " +
"patched! just return!");
return;
}
patchFile = new File(patchDir, getPatchName());
if (!patchFile.exists() || patchFile.length() <= 0) {
downloadPatch(context);
return;
}
Helper.showLog(TAG, "patch version : " + patchVersion + "is already download!" +
" just load it!");
TinkerInstaller.onReceiveUpgradePatch(MyApplication.getContext(), patchFile
.getAbsolutePath());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例9: onLoadFileNotFound
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
/**
* try to recover patch oat file
* @param file
* @param fileType
* @param isDirectory
*/
@Override
public void onLoadFileNotFound(File file, int fileType, boolean isDirectory) {
TinkerLog.i(TAG, "patch loadReporter onLoadFileNotFound: patch file not found: %s, fileType:%d, isDirectory:%b",
file.getAbsolutePath(), fileType, isDirectory);
// only try to recover opt file
// check dex opt file at last, some phone such as VIVO/OPPO like to change dex2oat to interpreted
if (fileType == ShareConstants.TYPE_DEX_OPT) {
Tinker tinker = Tinker.with(context);
//we can recover at any process except recover process
if (tinker.isMainProcess()) {
File patchVersionFile = tinker.getTinkerLoadResultIfPresent().patchVersionFile;
if (patchVersionFile != null) {
if (UpgradePatchRetry.getInstance(context).onPatchListenerCheck(SharePatchFileUtil.getMD5(patchVersionFile))) {
TinkerLog.i(TAG, "try to repair oat file on patch process");
TinkerInstaller.onReceiveUpgradePatch(context, patchVersionFile.getAbsolutePath());
} else {
TinkerLog.i(TAG, "repair retry exceed must max time, just clean");
checkAndCleanPatch();
}
}
}
} else {
checkAndCleanPatch();
}
SampleTinkerReport.onLoadFileNotFound(fileType);
}
示例10: install_patch
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入方法依赖的package包/类
public void install_patch(View view) {
TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), Environment.getExternalStorageDirectory().getAbsolutePath() + "/patch_signed_7zip.apk");
// TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), getCacheDir().getAbsolutePath() + "/patch_signed_7zip.apk");
}