private String updateApkInfo(Connection conn, String apkId) { ApkId apkId1 = ApkId.parse(apkId); String apkFile = ApkSFS.calculatePath(apkDir, apkId + ".apk"); String status = ""; ApkInfo apkInfo = null; if (!new File(apkFile).exists()) { status = "apk_not_exists"; } else { apkInfo = ApkInfoReader.getApkInfoByAapt(new File(apkFile)); if (apkInfo == null) status = "apk_min_target_max_version_error"; } Statement stmt = null; try { stmt = conn.createStatement(); String sql; if (apkInfo != null && status.isEmpty()) { sql = String.format( "update qapk set min_sdk_version=%s, target_sdk_version=%s, max_sdk_version=%s, tag='ok' where package='%s' and version_code=%s and architecture=%s", apkInfo.getMinSdkVersion(), apkInfo.getTargetSdkVersion(), apkInfo.getMaxSdkVersion(), apkId1.package_, apkId1.versionCode, apkId1.arch); } else { sql = String.format( "update qapk set tag='%s' where package='%s' and version_code=%s and architecture=%s", status, apkId1.package_, apkId1.versionCode, apkId1.arch); } int n = stmt.executeUpdate(sql); if (n == 0) status = "db_update_error"; } catch (Exception e) { if (stmt != null) { try { stmt.close(); } catch (SQLException ignored) { } } status = "db_error"; } try { if (status.isEmpty()) logComplete(apkId, apkInfo); else logError(apkId); } catch (Exception ignored) { } return status; }
private void logComplete(String apkId, ApkInfo apkInfo) throws Exception { appendLine(getCompletedApkIdsFile(), apkId); appendLine( getLogFile(), "OK " + now() + " - " + apkId + " - " + apkInfo.getAppName() + " - " + apkInfo.getMinSdkVersion() + ":" + apkInfo.getTargetSdkVersion() + ":" + apkInfo.getMaxSdkVersion()); }