com.tencent.tinker.lib.util.TinkerLog Java Examples

The following examples show how to use com.tencent.tinker.lib.util.TinkerLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TinkerManager.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
/**
 * you can specify all class you want.
 * sometimes, you can only install tinker in some process you want!
 *
 * @param appLike ApplicationLike
 */
public static void installTinker(ApplicationLike appLike) {
    if (isInstalled) {
        TinkerLog.w(TAG, "install tinker, but has installed, ignore");
        return;
    }
    //or you can just use DefaultLoadReporter
    LoadReporter loadReporter = new TinkerServerLoadReporter(appLike.getApplication());
    //or you can just use DefaultPatchReporter
    PatchReporter patchReporter = new DefaultPatchReporter(appLike.getApplication());
    //or you can just use DefaultPatchListener
    PatchListener patchListener = new TinkerServerPatchListener(appLike.getApplication());
    //you can set your own upgrade patch if you need
    AbstractPatch upgradePatchProcessor = new UpgradePatch();
    TinkerInstaller.install(appLike,
        loadReporter, patchReporter, patchListener,
        TinkerServerResultService.class, upgradePatchProcessor
    );

    isInstalled = true;
}
 
Example #2
Source File: TinkerClientAPI.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
/**
 * Report fail to tinkerpatch backend
 * @param patchVersion patchVersion
 * @param errCode      errCode
 */
public void reportFail(Integer patchVersion, Integer errCode) {
    Uri.Builder urlBuilder = Uri.parse(REPORT_FAIL_URL).buildUpon();
    final String url = urlBuilder.build().toString();
    FailReport report = new FailReport(this.appKey, this.appVersion, String.valueOf(patchVersion), errCode);
    TinkerClientUrl tkClientUrl = new TinkerClientUrl.Builder()
        .url(url)
        .body(report.toEncodeForm())
        .method("POST").build();

    final DataFetcher<InputStream> dataFetcher = loader.buildLoadData(tkClientUrl);
    dataFetcher.loadData(new DataFetcher.DataCallback<InputStream>() {
        @Override
        public void onDataReady(InputStream data) {
            TinkerLog.d(TAG, "reportFail successfully:"
                + ServerUtils.readStreamToString(data, ServerUtils.CHARSET));
        }

        @Override
        public void onLoadFailed(Exception e) {
            TinkerLog.e(TAG, "reportSuccess error", e);
        }
    });
}
 
Example #3
Source File: TinkerServerClient.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
/**
 * 检查服务器是否存在补丁更新
 * @param immediately 是否忽略时间间隔
 */
public void checkTinkerUpdate(boolean immediately) {
    if (!tinker.isTinkerEnabled() || !ShareTinkerInternals.isTinkerEnableWithSharedPreferences(context)) {
        TinkerLog.e(TAG, "tinker is disable, just return");
        return;
    }

    SharedPreferences sp = context.getSharedPreferences(
        SHARE_SERVER_PREFERENCE_CONFIG, Context.MODE_PRIVATE
    );
    long last = sp.getLong(TINKER_LAST_CHECK, 0);
    if (last == NEVER_CHECK_UPDATE) {
        TinkerLog.i(TAG, "tinker update is disabled, with never check flag!");
        return;
    }
    long interval = System.currentTimeMillis() - last;
    if (immediately || clientAPI.isDebug() || interval >= checkInterval) {
        sp.edit().putLong(TINKER_LAST_CHECK, System.currentTimeMillis()).commit();
        clientAPI.update(context, patchRequestCallback);
    } else {
        TinkerLog.i(TAG, "tinker sync should wait interval %ss", (checkInterval - interval) / 1000);
    }
}
 
Example #4
Source File: TinkerManager.java    From HotFixDemo with MIT License 6 votes vote down vote up
/**
 * 自定义安装Tinker(使用你自定义的reporter类:SampleLoadReporter、SamplePatchReporter、SamplePatchListener、SampleResultService)
 * you can specify all class you want.
 * sometimes, you can only install tinker in some process you want!
 */
public static void installTinker(ApplicationLike appLike) {
    if (isInstalled) {
        TinkerLog.w(TAG, "install tinker, but has installed, ignore");
        return;
    }
    //or you can just use DefaultLoadReporter
    LoadReporter loadReporter = new SampleLoadReporter(appLike.getApplication());
    //or you can just use DefaultPatchReporter
    PatchReporter patchReporter = new SamplePatchReporter(appLike.getApplication());
    //or you can just use DefaultPatchListener
    PatchListener patchListener = new SamplePatchListener(appLike.getApplication());
    //you can set your own upgrade patch if you need
    AbstractPatch upgradePatchProcessor = new UpgradePatch();

    TinkerInstaller.install(appLike,
            loadReporter, patchReporter, patchListener,
            SampleResultService.class, upgradePatchProcessor);

    isInstalled = true;
}
 
Example #5
Source File: BaseReport.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
private String getPostDataString(HashMap<String, String> params) {
    StringBuilder result = new StringBuilder();

    try {
        boolean first = true;
        for (Map.Entry<String, String> entry : params.entrySet()) {
            if (first) {
                first = false;
            } else {
                result.append('&');
            }
            result.append(URLEncoder.encode(entry.getKey(), ServerUtils.CHARSET));
            result.append('=');
            result.append(URLEncoder.encode(entry.getValue(), ServerUtils.CHARSET));
        }
    } catch (Exception e) {
        TinkerLog.e(TAG, "getPostDataString fail" + e.getMessage());
    }

    return result.toString();
}
 
Example #6
Source File: UrlConnectionStreamFetcher.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
@Override
public void loadData(final DataCallback<? super InputStream> callback) {
    ConnectionWorker worker = new ConnectionWorker(tkUrl, new DataCallback<InputStream>() {
        @Override
        public void onDataReady(InputStream data) {
            callback.onDataReady(data);
        }

        @Override
        public void onLoadFailed(Exception e) {
            callback.onLoadFailed(e);
        }
    });
    if (executor != null) {
        executor.execute(worker);
    } else {
        TinkerLog.e(TAG, "Executor is null");
    }
}
 
Example #7
Source File: DefaultPatchRequestCallback.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
@Override
public boolean onPatchUpgrade(File file, Integer newVersion, Integer currentVersion) {
    TinkerLog.i(TAG, "onPatchUpgrade, file:%s, newVersion:%d, currentVersion:%d",
        file.getPath(), newVersion, currentVersion);
    TinkerServerClient client = TinkerServerClient.get();
    Context context = client.getContext();
    client.reportPatchDownloadSuccess(newVersion);

    ShareSecurityCheck securityCheck = new ShareSecurityCheck(context);
    if (!securityCheck.verifyPatchMetaSignature(file)) {
        TinkerLog.e(TAG, "onPatchUpgrade, signature check fail. file: %s, version:%d", file.getPath(), newVersion);
        //treat it as download fail
        if (increaseDownloadError(context)) {
            //update tinker version also, don't request again
            client.updateTinkerVersion(newVersion, SharePatchFileUtil.getMD5(file));
            client.reportPatchFail(newVersion, ERROR_DOWNLOAD_CHECK_FAIL);
        }
        SharePatchFileUtil.safeDeleteFile(file);
        return false;
    }
    tryPatchFile(file, newVersion);
    return true;
}
 
Example #8
Source File: SampleTinkerReport.java    From tinker-manager with Apache License 2.0 6 votes vote down vote up
public static void onLoaded(long cost) {
    if (reporter == null) {
        return;
    }
    reporter.onReport(KEY_LOADED);

    if (cost < 0L) {
        TinkerLog.e(TAG, "hp_report report load cost failed, invalid cost");
        return;
    }

    if (cost <= 500) {
        reporter.onReport(KEY_LOADED_SUCC_COST_500_LESS);
    } else if (cost <= 1000) {
        reporter.onReport(KEY_LOADED_SUCC_COST_1000_LESS);
    } else if (cost <= 3000) {
        reporter.onReport(KEY_LOADED_SUCC_COST_3000_LESS);
    } else if (cost <= 5000) {
        reporter.onReport(KEY_LOADED_SUCC_COST_5000_LESS);
    } else {
        reporter.onReport(KEY_LOADED_SUCC_COST_OTHER);
    }
}
 
Example #9
Source File: TinkerServerManager.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
/**
 * 向服务器请求在线参数信息
 * @param configRequestCallback
 * @param immediately            是否立刻请求,忽略时间间隔限制
 */
public static void getDynamicConfig(final ConfigRequestCallback configRequestCallback, final boolean immediately) {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "checkTinkerUpdate, sTinkerServerClient == null");
        return;
    }
    Tinker tinker = sTinkerServerClient.getTinker();
    //only check at the main process
    if (tinker.isMainProcess()) {
        Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
            @Override public boolean queueIdle() {
                sTinkerServerClient.getDynamicConfig(configRequestCallback, immediately);
                return false;
            }
        });
    }
}
 
Example #10
Source File: TinkerServerManager.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
/**
 * 检查服务器是否有补丁更新
 * @param immediately 是否立刻检查,忽略时间间隔限制
 */
public static void checkTinkerUpdate(final boolean immediately) {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "checkTinkerUpdate, sTinkerServerClient == null");
        return;
    }
    Tinker tinker = sTinkerServerClient.getTinker();
    //only check at the main process
    if (tinker.isMainProcess()) {
        Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
            @Override public boolean queueIdle() {
                sTinkerServerClient.checkTinkerUpdate(immediately);
                return false;
            }
        });
    }
}
 
Example #11
Source File: TinkerServerPatchRequestCallback.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
@Override
public void onPatchRollback() {
    TinkerLog.w(TAG, "onPatchRollback");
    TinkerServerClient client = TinkerServerClient.get();

    if (!client.getTinker().isTinkerLoaded()) {
        TinkerLog.w(TAG, "onPatchRollback, tinker is not loaded, just return");
        return;
    }

    if (TinkerServerUtils.isBackground()) {
        TinkerLog.i(TAG, "onPatchRollback, it is in background, just clean patch and kill all process");
        rollbackPatchDirectly();
    } else {
        //we can wait process at background, such as onAppBackground
        //or we can restart when the screen off
        TinkerLog.i(TAG, "tinker wait screen to clean patch and kill all process");
        new TinkerServerUtils.ScreenState(client.getContext(), new TinkerServerUtils.IOnScreenOff() {
            @Override
            public void onScreenOff() {
                rollbackPatchDirectly();
            }
        });
    }
}
 
Example #12
Source File: TinkerServerPatchRequestCallback.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
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;
}
 
Example #13
Source File: SampleDexDiffPatchInternal.java    From tinker-manager with Apache License 2.0 6 votes vote down vote up
public static boolean tryRecoverDexFiles(Tinker manager, ShareSecurityCheck checker, Context context,
                                            String patchVersionDirectory, File patchFile) {
    if (!manager.isEnabledForDex()) {
        TinkerLog.w(TAG, "patch recover, dex is not enabled");
        return true;
    }
    String dexMeta = checker.getMetaContentMap().get(DEX_META_FILE);

    if (dexMeta == null) {
        TinkerLog.w(TAG, "patch recover, dex is not contained");
        return true;
    }

    long begin = SystemClock.elapsedRealtime();
    boolean result = patchDexExtractViaDexDiff(context, patchVersionDirectory, dexMeta, patchFile);
    long cost = SystemClock.elapsedRealtime() - begin;
    TinkerLog.i(TAG, "recover dex result:%b, cost:%d", result, cost);
    return result;
}
 
Example #14
Source File: SampleTinkerReport.java    From HotFixDemo with MIT License 6 votes vote down vote up
public static void onLoaded(long cost) {
    if (reporter == null) {
        return;
    }
    reporter.onReport(KEY_LOADED);

    if (cost < 0L) {
        TinkerLog.e(TAG, "hp_report report load cost failed, invalid cost");
        return;
    }

    if (cost <= 500) {
        reporter.onReport(KEY_LOADED_SUCC_COST_500_LESS);
    } else if (cost <= 1000) {
        reporter.onReport(KEY_LOADED_SUCC_COST_1000_LESS);
    } else if (cost <= 3000) {
        reporter.onReport(KEY_LOADED_SUCC_COST_3000_LESS);
    } else if (cost <= 5000) {
        reporter.onReport(KEY_LOADED_SUCC_COST_5000_LESS);
    } else {
        reporter.onReport(KEY_LOADED_SUCC_COST_OTHER);
    }
}
 
Example #15
Source File: DefaultPatchRequestCallback.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
@Override
public void onPatchDownloadFail(Exception e, Integer newVersion, Integer currentVersion) {
    TinkerLog.w(TAG, "onPatchDownloadFail e:" + e);
    //check network
    TinkerServerClient client = TinkerServerClient.get();
    //due to network, just return
    if (!NetStatusUtil.isConnected(client.getContext())) {
        TinkerLog.e(TAG, "onPatchDownloadFail, not connect to internet just return");
        return;
    }
    Context context = client.getContext();
    if (increaseDownloadError(context)) {
        client.reportPatchFail(newVersion, ERROR_DOWNLOAD_FAIL);
    }

}
 
Example #16
Source File: SampleBsDiffPatchInternal.java    From tinker-manager with Apache License 2.0 6 votes vote down vote up
public static boolean tryRecoverLibraryFiles(Tinker manager, ShareSecurityCheck checker, Context context,
                                                String patchVersionDirectory, File patchFile) {

    if (!manager.isEnabledForNativeLib()) {
        TinkerLog.w(TAG, "patch recover, library is not enabled");
        return true;
    }
    String libMeta = checker.getMetaContentMap().get(SO_META_FILE);

    if (libMeta == null) {
        TinkerLog.w(TAG, "patch recover, library is not contained");
        return true;
    }
    long begin = SystemClock.elapsedRealtime();
    boolean result = patchLibraryExtractViaBsDiff(context, patchVersionDirectory, libMeta, patchFile);
    long cost = SystemClock.elapsedRealtime() - begin;
    TinkerLog.i(TAG, "recover lib result:%b, cost:%d", result, cost);
    return result;
}
 
Example #17
Source File: SampleResDiffPatchInternal.java    From tinker-manager with Apache License 2.0 6 votes vote down vote up
public static boolean tryRecoverResourceFiles(Tinker manager, ShareSecurityCheck checker, Context context,
                                                 String patchVersionDirectory, File patchFile) {

    if (!manager.isEnabledForResource()) {
        TinkerLog.w(TAG, "patch recover, resource is not enabled");
        return true;
    }
    String resourceMeta = checker.getMetaContentMap().get(RES_META_FILE);

    if (resourceMeta == null || resourceMeta.length() == 0) {
        TinkerLog.w(TAG, "patch recover, resource is not contained");
        return true;
    }

    long begin = SystemClock.elapsedRealtime();
    boolean result = patchResourceExtractViaResourceDiff(context, patchVersionDirectory, resourceMeta, patchFile);
    long cost = SystemClock.elapsedRealtime() - begin;
    TinkerLog.i(TAG, "recover resource result:%b, cost:%d", result, cost);
    return result;
}
 
Example #18
Source File: SampleTinkerManager.java    From tinker-manager with Apache License 2.0 6 votes vote down vote up
/**
     * you can specify all class you want.
     * sometimes, you can only install com.dx168.patchsdk.sample in some process you want!
     *
     * @param appLike
     */
    public static void installTinker(ApplicationLike appLike) {
        if (isInstalled) {
            TinkerLog.w(TAG, "install com.dx168.patchsdk.sample, but has installed, ignore");
            return;
        }
        //or you can just use DefaultLoadReporter
        LoadReporter loadReporter = new SampleLoadReporter(appLike.getApplication());
        //or you can just use DefaultPatchReporter
        PatchReporter patchReporter = new SamplePatchReporter(appLike.getApplication());
        //or you can just use DefaultPatchListener
        PatchListener patchListener = new SamplePatchListener(appLike.getApplication());
        //you can set your own upgrade patch if you need
//        AbstractPatch upgradePatchProcessor = new SampleUpgradePatch();
        AbstractPatch upgradePatchProcessor = new UpgradePatch();

        TinkerInstaller.install(appLike, loadReporter, patchReporter, patchListener, SampleResultService.class,
                upgradePatchProcessor);

        isInstalled = true;
    }
 
Example #19
Source File: TinkerServerManager.java    From tinkerpatch-sdk with MIT License 6 votes vote down vote up
/**
 * 上报补丁合成情况
 * @param patchMd5
 */
public static void reportTinkerPatchListenerFail(int returnCode, String patchMd5) {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "reportTinkerPatchListenerFail, sTinkerServerClient == null");
        return;
    }
    if (returnCode == ShareConstants.ERROR_PATCH_OK) {
        return;
    }
    if (patchMd5 == null) {
        TinkerLog.e(TAG, "reportTinkerPatchListenerFail, patchMd5 == null");
        return;
    }
    if (!patchMd5.equals(sTinkerServerClient.getCurrentPatchMd5())) {
        TinkerLog.e(TAG, "reportTinkerPatchListenerFail, md5 not equal, patchMd5:%s, currentPatchMd5:%s",
            patchMd5, sTinkerServerClient.getCurrentPatchMd5()
        );
        return;
    }
    sTinkerServerClient.reportPatchFail(
        sTinkerServerClient.getCurrentPatchVersion(),
        DefaultPatchRequestCallback.ERROR_LISTENER_CHECK_FAIL
    );
}
 
Example #20
Source File: SampleDexDiffPatchInternal.java    From tinker-manager with Apache License 2.0 5 votes vote down vote up
/**
 * for ViVo or some other rom, they would make dex2oat asynchronous
 * so we need to check whether oat file is actually generated.
 * @param files
 * @param count
 * @return
 */
private static boolean checkAllDexOptFile(ArrayList<File> files, int count) {
    for (File file : files) {
        if (!SharePatchFileUtil.isLegalFile(file)) {
            TinkerLog.e(TAG, "parallel dex optimizer file %s is not exist, just wait %d times", file.getName(), count);
            return false;
        }
    }
    return true;
}
 
Example #21
Source File: TinkerServerManager.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
/**
 * 设置在线参数的时间间隔
 * @param hours 大于等于0的整数
 */
public static void setGetConfigIntervalByHours(int hours) {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "setGetConfigIntervalByHours, sTinkerServerClient == null");
        return;
    }
    sTinkerServerClient.setGetConfigIntervalByHours(hours);
}
 
Example #22
Source File: TinkerServerManager.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
/**
 * 设置条件下发的属性
 * @param key
 * @param value
 */
public void updateTinkerCondition(String key, String value) {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "updateTinkerCondition, sTinkerServerClient == null");
        return;
    }
    sTinkerServerClient.updateTinkerCondition(key, value);

}
 
Example #23
Source File: TinkerServerManager.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
/**
 * 上报补丁加载情况
 */
public static void reportTinkerLoadFail() {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "reportTinkerPatchFail, sTinkerServerClient == null");
        return;
    }
    sTinkerServerClient.reportPatchFail(
        sTinkerServerClient.getCurrentPatchVersion(),
        DefaultPatchRequestCallback.ERROR_LOAD_FAIL
    );
}
 
Example #24
Source File: TinkerServerPatchRequestCallback.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
@Override
public boolean beforePatchRequest() {
    boolean result = super.beforePatchRequest();
    if (result) {
        TinkerServerClient client = TinkerServerClient.get();
        Tinker tinker = client.getTinker();
        Context context = client.getContext();

        if (!tinker.isMainProcess()) {
            TinkerLog.e(TAG, "beforePatchRequest, only request on the main process");
            return false;
        }
        if (TinkerServerManager.isGooglePlayChannel()) {
            TinkerLog.e(TAG, "beforePatchRequest, google play channel, return false");
            return false;
        }
        // main process must be the newly version
        // check whether it is pending work
        String currentPatchMd5 = client.getCurrentPatchMd5();
        TinkerLoadResult tinkerLoadResult = tinker.getTinkerLoadResultIfPresent();

        if (tinkerLoadResult.currentVersion == null || !currentPatchMd5.equals(tinkerLoadResult.currentVersion)) {
            Integer version = client.getCurrentPatchVersion();
            if (version > 0) {
                File patchFile = ServerUtils.getServerFile(
                    context, client.getAppVersion(), String.valueOf(version)
                );
                if (patchFile.exists() && patchFile.isFile() && handlePatchFile(context, version, patchFile)) {
                    return false;
                }
            }
        }
    }
    return result;
}
 
Example #25
Source File: Debugger.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
public Integer getInteger(final String key) {
    final Object obj = values.get(key);
    if (obj instanceof Integer) {
        TinkerLog.d(TAG, "getInteger(): key=" + key + ", value=" + obj.toString());
        return (Integer) obj;
    }

    return null;
}
 
Example #26
Source File: Debugger.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
public Long getLong(final String key) {
    final Object obj = values.get(key);
    if (obj instanceof Long) {
        TinkerLog.d(TAG, "getLong(): key=" + key + ", value=" + obj.toString());
        return (Long) obj;
    }

    return null;
}
 
Example #27
Source File: Debugger.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
public Boolean getBoolean(final String key) {
    final Object obj = values.get(key);
    if (obj == null) {
        return false;
    }

    if (obj instanceof Boolean) {
        TinkerLog.d(TAG, "getBoolean(): key=" + key + ", value=" + obj.toString());
        return (Boolean) obj;
    }
    return false;
}
 
Example #28
Source File: DefaultPatchRequestCallback.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
@Override
public boolean beforePatchRequest() {
    TinkerServerClient client = TinkerServerClient.get();

    // check network
    if (!NetStatusUtil.isConnected(client.getContext())) {
        TinkerLog.e(TAG, "not connect to internet");
        return false;
    }
    if (TinkerServiceInternals.isTinkerPatchServiceRunning(client.getContext())) {
        TinkerLog.e(TAG, "tinker service is running");
        return false;
    }
    return true;
}
 
Example #29
Source File: VersionUtils.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
public boolean isUpdate(Integer version, String currentAppVersion) {
    if (!currentAppVersion.equals(appVersion)) {
        TinkerLog.d(TAG, "update return true, appVersion from %s to %s", appVersion, currentAppVersion);
        return true;
    }
    Integer current = getPatchVersion();
    if (version > current) {
        TinkerLog.d(TAG, "update return true, patchVersion from %s to %s", current, version);
        return true;
    } else {
        TinkerLog.d(TAG, "update return false, target version is not latest. current version is:" + version);
        return false;
    }
}
 
Example #30
Source File: Debugger.java    From tinkerpatch-sdk with MIT License 5 votes vote down vote up
public String getString(final String key) {
    final Object obj = values.get(key);
    if (obj instanceof String) {
        TinkerLog.d(TAG, "getString(): key=" + key + ", value=" + obj.toString());
        return (String) obj;
    }

    return null;
}