From 88b7fb3af835800a856864872a2a27c0e95eb386 Mon Sep 17 00:00:00 2001 From: Geoffrey Goh Date: Wed, 20 Jan 2016 17:45:54 -0800 Subject: [PATCH] isRunningBinary --- CodePush.m | 9 ++++++--- .../java/com/microsoft/codepush/react/CodePush.java | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CodePush.m b/CodePush.m index d521d75..e9b4474 100644 --- a/CodePush.m +++ b/CodePush.m @@ -14,6 +14,7 @@ RCT_EXPORT_MODULE() static BOOL didRollback = NO; +static BOOL isRunningBinaryVersion = NO; static BOOL testConfigurationFlag = NO; // These constants represent valid deployment statuses @@ -62,6 +63,7 @@ static NSString *const PackageIsPendingKey = @"isPending"; if (error || !packageFile) { NSLog(logMessageFormat, binaryJsBundleUrl); + isRunningBinaryVersion = YES; return binaryJsBundleUrl; } @@ -73,6 +75,7 @@ static NSString *const PackageIsPendingKey = @"isPending"; NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error]; if (error || !currentPackageMetadata) { NSLog(logMessageFormat, binaryJsBundleUrl); + isRunningBinaryVersion = YES; return binaryJsBundleUrl; } @@ -82,6 +85,7 @@ static NSString *const PackageIsPendingKey = @"isPending"; // Return package file because it is newer than the app store binary's JS bundle NSURL *packageUrl = [[NSURL alloc] initFileURLWithPath:packageFile]; NSLog(logMessageFormat, packageUrl); + isRunningBinaryVersion = NO; return packageUrl; } else { #ifndef DEBUG @@ -89,6 +93,7 @@ static NSString *const PackageIsPendingKey = @"isPending"; #endif NSLog(logMessageFormat, binaryJsBundleUrl); + isRunningBinaryVersion = YES; return binaryJsBundleUrl; } } @@ -557,9 +562,7 @@ RCT_EXPORT_METHOD(getNewStatusReport:(RCTPromiseResolveBlock)resolve } } } else { - NSError *error; - NSString *currentPackageHash = [CodePushPackage getCurrentPackageHash:&error]; - if (error || currentPackageHash == nil) { + if (isRunningBinaryVersion) { // Check if the current appVersion has been reported. Use date as the binary identifier to // handle binary releases that do not modify the appVersion. NSURL *binaryJsBundleUrl = [CodePush bundleURL]; diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index a58c817..7919a45 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -40,8 +40,9 @@ import java.util.zip.ZipFile; public class CodePush { - private static boolean testConfigurationFlag = false; private static boolean didRollback = false; + private static boolean isRunningBinaryVersion = false; + private static boolean testConfigurationFlag = false; private boolean didUpdate = false; @@ -143,6 +144,7 @@ public class CodePush { if (packageFilePath == null) { // There has not been any downloaded updates. CodePushUtils.logBundleUrl(binaryJsBundleUrl); + isRunningBinaryVersion = true; return binaryJsBundleUrl; } @@ -158,6 +160,7 @@ public class CodePush { binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime && (this.isUsingTestConfiguration() || this.appVersion.equals(packageAppVersion))) { CodePushUtils.logBundleUrl(packageFilePath); + isRunningBinaryVersion = false; return packageFilePath; } else { // The binary version is newer. @@ -167,6 +170,7 @@ public class CodePush { } CodePushUtils.logBundleUrl(binaryJsBundleUrl); + isRunningBinaryVersion = true; return binaryJsBundleUrl; } } catch (NumberFormatException e) { @@ -488,9 +492,7 @@ public class CodePush { } } } else { - String currentPackageHash = null; - currentPackageHash = codePushPackage.getCurrentPackageHash(); - if (currentPackageHash == null) { + if (isRunningBinaryVersion) { // Check if the current appVersion has been reported. String binaryIdentifier = "" + getBinaryResourcesModifiedTime(); if (isDeploymentStatusNotYetReported(binaryIdentifier)) {