Skip to content

Commit c2211c5

Browse files
committed
Revert "add bundlehash"
This reverts commit 210e6bb.
1 parent 210e6bb commit c2211c5

File tree

28 files changed

+3
-345
lines changed

28 files changed

+3
-345
lines changed

android/jni/Android.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ LOCAL_SRC_FILES := \
2424
../../cpp/patch_core/archive_patch_core.cpp \
2525
../../cpp/patch_core/patch_core.cpp \
2626
../../cpp/patch_core/patch_core_android.cpp \
27-
../../cpp/patch_core/sha256_util.cpp \
2827
../../cpp/patch_core/state_core.cpp \
2928
../../cpp/patch_core/update_core_android.cpp \
30-
lzma/C/Sha256.c \
3129
$(Hdp_Files)
3230

3331
include $(BUILD_SHARED_LIBRARY)
-4.22 KB
Binary file not shown.
-3.58 KB
Binary file not shown.

android/lib/x86/librnupdate.so

-5.33 KB
Binary file not shown.

android/lib/x86_64/librnupdate.so

-4.95 KB
Binary file not shown.

android/src/main/java/cn/reactnative/modules/update/UpdateContext.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
import android.content.SharedPreferences;
55
import android.content.pm.PackageInfo;
66
import android.content.pm.PackageManager;
7-
import android.content.res.AssetManager;
87
import android.os.Build;
98
import android.os.Environment;
109
import android.util.Log;
1110
import com.facebook.react.ReactInstanceManager;
12-
import java.io.ByteArrayOutputStream;
1311
import java.io.File;
14-
import java.io.IOException;
15-
import java.io.InputStream;
1612
import java.util.concurrent.Executor;
1713
import java.util.concurrent.Executors;
1814

@@ -39,9 +35,6 @@ public class UpdateContext {
3935
private static final int STATE_OP_CLEAR_ROLLBACK_MARK = 5;
4036
private static final int STATE_OP_RESOLVE_LAUNCH = 6;
4137
private static final String KEY_FIRST_LOAD_MARKED = "firstLoadMarked";
42-
private static final String KEY_BUNDLE_HASH_CACHE_IDENTITY = "bundleHashCacheIdentity";
43-
private static final String KEY_BUNDLE_HASH_CACHE_VALUE = "bundleHashCacheValue";
44-
private static final String EMBEDDED_BUNDLE_ASSET_NAME = "index.android.bundle";
4538

4639
// Singleton instance
4740
private static UpdateContext sInstance;
@@ -62,8 +55,6 @@ private static native StateCoreResult runStateCore(
6255
boolean flagB
6356
);
6457

65-
private static native String hashBytes(byte[] data);
66-
6758
public UpdateContext(Context context) {
6859
this.context = context.getApplicationContext();
6960
this.executor = Executors.newSingleThreadExecutor();
@@ -119,47 +110,6 @@ public boolean getIsUsingBundleUrl() {
119110
return isUsingBundleUrl;
120111
}
121112

122-
public String getBundleHash() {
123-
String identity = "embedded:" + getPackageVersion() + ":" + getBuildTime();
124-
String cachedIdentity = sp.getString(KEY_BUNDLE_HASH_CACHE_IDENTITY, null);
125-
String cachedValue = sp.getString(KEY_BUNDLE_HASH_CACHE_VALUE, null);
126-
if (identity.equals(cachedIdentity) && cachedValue != null && !cachedValue.isEmpty()) {
127-
return cachedValue;
128-
}
129-
130-
String bundleHash = hashAsset(EMBEDDED_BUNDLE_ASSET_NAME);
131-
if (bundleHash == null) {
132-
return "";
133-
}
134-
135-
SharedPreferences.Editor editor = sp.edit();
136-
editor.putString(KEY_BUNDLE_HASH_CACHE_IDENTITY, identity);
137-
editor.putString(KEY_BUNDLE_HASH_CACHE_VALUE, bundleHash);
138-
persistEditor(editor, "cache bundle hash");
139-
return bundleHash;
140-
}
141-
142-
private String hashAsset(String assetName) {
143-
try (InputStream stream = context.getAssets().open(assetName, AssetManager.ACCESS_STREAMING)) {
144-
return hashInputStream(stream);
145-
} catch (IOException e) {
146-
if (DEBUG) {
147-
Log.w(TAG, "Failed to hash asset bundle " + assetName, e);
148-
}
149-
return null;
150-
}
151-
}
152-
153-
private String hashInputStream(InputStream stream) throws IOException {
154-
ByteArrayOutputStream output = new ByteArrayOutputStream();
155-
byte[] buffer = new byte[8192];
156-
int read;
157-
while ((read = stream.read(buffer)) != -1) {
158-
output.write(buffer, 0, read);
159-
}
160-
return hashBytes(output.toByteArray());
161-
}
162-
163113
private void enqueue(DownloadTaskParams params) {
164114
executor.execute(new DownloadTask(context, params));
165115
}

android/src/main/java/cn/reactnative/modules/update/UpdateModuleSupport.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ static Map<String, Object> getConstants(UpdateContext updateContext) {
2323
constants.put("currentVersion", currentVersion);
2424
constants.put("currentVersionInfo", updateContext.getKv("hash_" + currentVersion));
2525
constants.put("buildTime", updateContext.getBuildTime());
26-
constants.put("bundleHash", updateContext.getBundleHash());
2726
constants.put("isUsingBundleUrl", updateContext.getIsUsingBundleUrl());
2827

2928
boolean isFirstTime = updateContext.consumeFirstLoadMarker();

cpp/patch_core/sha256_util.cpp

Lines changed: 0 additions & 49 deletions
This file was deleted.

cpp/patch_core/sha256_util.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

cpp/patch_core/tests/patch_core_test.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "../archive_patch_core.h"
22
#include "../patch_core.h"
3-
#include "../sha256_util.h"
43
#include "../state_core.h"
54

65
#include <cstdio>
@@ -443,15 +442,6 @@ void TestArchivePatchCoreSupportsCustomBundlePatchEntry() {
443442
ExpectEq(plan.merge_source_subdir, "", "custom bundle patch merge subdir mismatch");
444443
}
445444

446-
void TestSha256UtilGeneratesStableDigest() {
447-
const std::string digest = pushy::crypto::Sha256Hex("abc", 3);
448-
ExpectEq(
449-
digest,
450-
"ba7816bf8f01cfea414140de5dae2223"
451-
"b00361a396177a9cb410ff61f20015ad",
452-
"sha256 digest mismatch");
453-
}
454-
455445
} // namespace
456446

457447
int main() {
@@ -467,7 +457,6 @@ int main() {
467457
{"ArchivePatchCoreBuildPlanAndCopyGroups", TestArchivePatchCoreBuildPlanAndCopyGroups},
468458
{"ArchivePatchCoreRejectsMissingEntries", TestArchivePatchCoreRejectsMissingEntries},
469459
{"ArchivePatchCoreSupportsCustomBundlePatchEntry", TestArchivePatchCoreSupportsCustomBundlePatchEntry},
470-
{"Sha256UtilGeneratesStableDigest", TestSha256UtilGeneratesStableDigest},
471460
};
472461

473462
for (const auto& test : tests) {

0 commit comments

Comments
 (0)