Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit c3be13d

Browse files
author
max-mironov
committed
2 parents 494a98b + 3d35287 commit c3be13d

File tree

7 files changed

+90
-25
lines changed

7 files changed

+90
-25
lines changed

CodePush.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,14 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
342342
log("An update is available, but it is being ignored due to having been previously rolled back.");
343343
}
344344

345-
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE);
346-
return CodePush.SyncStatus.UP_TO_DATE;
345+
const currentPackage = await CodePush.getCurrentPackage();
346+
if (currentPackage.isPending) {
347+
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_INSTALLED);
348+
return CodePush.SyncStatus.UPDATE_INSTALLED;
349+
} else {
350+
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE);
351+
return CodePush.SyncStatus.UP_TO_DATE;
352+
}
347353
} else if (syncOptions.updateDialog) {
348354
// updateDialog supports any truthy value (e.g. true, "goo", 12),
349355
// but we should treat a non-object value as just the default dialog

android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ public class CodePushConstants {
44
public static final String ASSETS_BUNDLE_PREFIX = "assets://";
55
public static final String BINARY_MODIFIED_TIME_KEY = "binaryModifiedTime";
66
public static final String CODE_PUSH_FOLDER_PREFIX = "CodePush";
7-
public static final String CODE_PUSH_HASH_FILE_NAME = "CodePushHash.json";
7+
public static final String CODE_PUSH_HASH_FILE_NAME = "CodePushHash";
8+
public static final String CODE_PUSH_OLD_HASH_FILE_NAME = "CodePushHash.json";
89
public static final String CODE_PUSH_PREFERENCES = "CodePush";
910
public static final String CURRENT_PACKAGE_KEY = "currentPackage";
1011
public static final String DEFAULT_JS_BUNDLE_NAME = "index.android.bundle";

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import com.facebook.react.bridge.ReadableMap;
2020
import com.facebook.react.bridge.WritableMap;
2121
import com.facebook.react.modules.core.DeviceEventManagerModule;
22-
import com.facebook.react.uimanager.ReactChoreographer;
22+
import com.facebook.react.modules.core.ChoreographerCompat;
23+
import com.facebook.react.modules.core.ReactChoreographer;
2324

2425
import org.json.JSONArray;
2526
import org.json.JSONException;
@@ -254,7 +255,7 @@ public void call(DownloadProgress downloadProgress) {
254255
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
255256
@Override
256257
public void run() {
257-
ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new Choreographer.FrameCallback() {
258+
ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new ChoreographerCompat.FrameCallback() {
258259
@Override
259260
public void doFrame(long frameTimeNanos) {
260261
if (!latestDownloadProgress.isCompleted()) {

android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,15 @@ public static String getHashForBinaryContents(Context context, boolean isDebugMo
109109
try {
110110
return CodePushUtils.getStringFromInputStream(context.getAssets().open(CodePushConstants.CODE_PUSH_HASH_FILE_NAME));
111111
} catch (IOException e) {
112-
if (!isDebugMode) {
113-
// Only print this message in "Release" mode. In "Debug", we may not have the
114-
// hash if the build skips bundling the files.
115-
CodePushUtils.log("Unable to get the hash of the binary's bundled resources - \"codepush.gradle\" may have not been added to the build definition.");
112+
try {
113+
return CodePushUtils.getStringFromInputStream(context.getAssets().open(CodePushConstants.CODE_PUSH_OLD_HASH_FILE_NAME));
114+
} catch (IOException ex) {
115+
if (!isDebugMode) {
116+
// Only print this message in "Release" mode. In "Debug", we may not have the
117+
// hash if the build skips bundling the files.
118+
CodePushUtils.log("Unable to get the hash of the binary's bundled resources - \"codepush.gradle\" may have not been added to the build definition.");
119+
}
116120
}
117-
118121
return null;
119122
}
120123
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-code-push",
3-
"version": "1.17.2-beta",
3+
"version": "1000.0.0-beta",
44
"description": "React Native plugin for the CodePush service",
55
"main": "CodePush.js",
66
"typings": "typings/react-native-code-push.d.ts",
@@ -21,7 +21,7 @@
2121
"glob": "^5.0.15",
2222
"inquirer": "1.1.2",
2323
"plist": "1.2.0",
24-
"xcode": "0.9.1"
24+
"xcode": "0.9.2"
2525
},
2626
"devDependencies": {
2727
"archiver": "latest",

scripts/generateBundledResourcesHash.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ var path = require("path");
1818
var getFilesInFolder = require("./getFilesInFolder");
1919

2020
var CODE_PUSH_FOLDER_PREFIX = "CodePush";
21-
var CODE_PUSH_HASH_FILE_NAME = "CodePushHash.json";
21+
var CODE_PUSH_HASH_FILE_NAME = "CodePushHash";
22+
var CODE_PUSH_HASH_OLD_FILE_NAME = "CodePushHash.json";
2223
var HASH_ALGORITHM = "sha256";
2324
var TEMP_FILE_PATH = path.join(require("os").tmpdir(), "CodePushResourcesMap.json");
2425

@@ -72,6 +73,15 @@ function addJsBundleAndMetaToManifest() {
7273

7374
var savedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_FILE_NAME;
7475
fs.writeFileSync(savedResourcesManifestPath, finalHash);
76+
77+
// "CodePushHash.json" file name breaks flow type checking.
78+
// To fix the issue we need to delete "CodePushHash.json" file and
79+
// use "CodePushHash" file name instead to store the hash value.
80+
// Relates to https://github.com/Microsoft/react-native-code-push/issues/577
81+
var oldSavedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_OLD_FILE_NAME;
82+
if (fs.existsSync(oldSavedResourcesManifestPath)) {
83+
fs.unlinkSync(oldSavedResourcesManifestPath);
84+
}
7585
});
7686
});
7787
}

windows/CodePush.Net46/CodePushUtils.cs

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,70 @@ internal async static Task<JObject> GetJObjectFromFileAsync(IFile file)
2828

2929
static string GetDeviceIdImpl()
3030
{
31-
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
32-
ManagementObjectCollection moc = mos.Get();
33-
string mbId = String.Empty;
31+
var mbId = GetSerialNumber();
32+
var procId = GetProcId();
33+
34+
if (string.IsNullOrEmpty(procId))
35+
{
36+
procId = GetMAC();
37+
}
38+
39+
return procId + '-' + mbId;
40+
}
41+
42+
static string GetSerialNumber()
43+
{
44+
var mos = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
45+
var moc = mos.Get();
46+
var mbId = String.Empty;
47+
3448
foreach (ManagementObject mo in moc)
3549
{
3650
mbId = (string)mo["SerialNumber"];
37-
break;
51+
if (!string.IsNullOrEmpty(mbId))
52+
break;
53+
}
54+
55+
return mbId;
56+
}
57+
58+
static string GetProcId()
59+
{
60+
var mos = new ManagementObjectSearcher("Select * From Win32_processor");
61+
var moc = mos.Get();
62+
var procId = string.Empty;
63+
64+
foreach (ManagementObject mo in moc)
65+
{
66+
procId = (string)mo["ProcessorID"];
67+
if (!string.IsNullOrEmpty(procId))
68+
break;
3869
}
70+
return procId;
71+
}
3972

40-
ManagementObjectCollection mbsList = null;
41-
ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_processor");
42-
mbsList = mbs.Get();
43-
string procId = string.Empty;
44-
foreach (ManagementObject mo in mbsList)
73+
static string GetMAC()
74+
{
75+
var mos = new ManagementObjectSearcher("Select * From Win32_NetworkAdapterConfiguration");
76+
var moc = mos.Get();
77+
var mac = string.Empty;
78+
79+
foreach (ManagementObject mo in moc)
4580
{
46-
procId = mo["ProcessorID"].ToString();
47-
break;
81+
try
82+
{
83+
if ((bool)mo["IPEnabled"])
84+
{
85+
mac = (string)mo["MacAddress"];
86+
break;
87+
}
88+
}
89+
catch (Exception)
90+
{
91+
}
4892
}
4993

50-
return procId + "-" + mbId;
94+
return mac;
5195
}
5296
}
5397
}

0 commit comments

Comments
 (0)