Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,13 @@ public String getAssetsBundleFileName() {
}

long getBinaryResourcesModifiedTime() {
ZipFile applicationFile = null;
try {
ApplicationInfo ai = this.mContext.getPackageManager().getApplicationInfo(this.mContext.getPackageName(), 0);
applicationFile = new ZipFile(ai.sourceDir);
ZipEntry classesDexEntry = applicationFile.getEntry(CodePushConstants.RESOURCES_BUNDLE);
return classesDexEntry.getTime();
} catch (PackageManager.NameNotFoundException | IOException e) {
throw new CodePushUnknownException("Error in getting file information about compiled resources", e);
} finally {
if (applicationFile != null) {
try {
applicationFile.close();
} catch (IOException e) {
throw new CodePushUnknownException("Error in closing application file.", e);
}
}
String packageName = this.mContext.getPackageName();
int codePushApkBuildTimeId = this.mContext.getResources().getIdentifier(CodePushConstants.CODE_PUSH_APK_BUILD_TIME_KEY, "string", packageName);
String codePushApkBuildTime = this.mContext.getResources().getString(codePushApkBuildTimeId);
return Long.parseLong(codePushApkBuildTime);
} catch (Exception e) {
throw new CodePushUnknownException("Error in getting binary resources modified time", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public class CodePushConstants {
public static final String RESOURCES_BUNDLE = "resources.arsc";
public static final String STATUS_FILE = "codepush.json";
public static final String UNZIPPED_FOLDER_NAME = "unzipped";
public static final String CODE_PUSH_APK_BUILD_TIME_KEY = "CODE_PUSH_APK_BUILD_TIME";
}
3 changes: 3 additions & 0 deletions android/codepush.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ void runBefore(String dependentTaskName, Task task) {

gradle.projectsEvaluated {
def buildTypes = android.buildTypes.collect { type -> type.name }
android.buildTypes.each {
it.resValue 'string', "CODE_PUSH_APK_BUILD_TIME", Long.toString(System.currentTimeMillis())
}
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
if (!productFlavors) productFlavors.add('')
def nodeModulesPath;
Expand Down