@algocare/react-native-code-push 12.6.3 → 13.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CodePush.podspec +6 -8
- package/README.md +343 -586
- package/android/app/build.gradle +2 -1
- package/android/app/proguard-rules.pro +14 -0
- package/android/app/src/debug/AndroidManifest.xml +9 -0
- package/android/app/src/main/AndroidManifest.xml +1 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -139
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +0 -3
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +108 -63
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +2 -33
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +13 -109
- package/android/build.gradle +3 -0
- package/app.plugin.js +1 -0
- package/bin/code-push.js +6 -0
- package/cli/commands/bundleCommand/bundleCodePush.ts +118 -0
- package/cli/commands/bundleCommand/index.ts +34 -0
- package/cli/commands/createHistoryCommand/createReleaseHistory.ts +37 -0
- package/cli/commands/createHistoryCommand/createReleaseHistoryList.ts +40 -0
- package/cli/commands/createHistoryCommand/index.ts +44 -0
- package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.ts +33 -0
- package/cli/commands/createPullRequestHistoryCommand/index.ts +31 -0
- package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.ts +71 -0
- package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.ts +75 -0
- package/cli/commands/createPullRequestReleaseCommand/index.ts +74 -0
- package/cli/commands/getPackageHashCommand/index.ts +45 -0
- package/cli/commands/initCommand/index.ts +14 -0
- package/cli/commands/initCommand/initAndroid.ts +91 -0
- package/cli/commands/initCommand/initIos.ts +123 -0
- package/cli/commands/initCommand/test/initAndroid.test.ts +128 -0
- package/cli/commands/initCommand/test/initIos.test.ts +99 -0
- package/cli/commands/releaseCommand/addToReleaseHistory.ts +57 -0
- package/cli/commands/releaseCommand/index.ts +90 -0
- package/cli/commands/releaseCommand/release.ts +105 -0
- package/cli/commands/removePullRequestHistoryCommand/index.ts +37 -0
- package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.ts +28 -0
- package/cli/commands/showHistoryCommand/index.ts +31 -0
- package/cli/commands/updateHistoryCommand/index.ts +55 -0
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.ts +42 -0
- package/cli/constant.ts +4 -0
- package/cli/dist/commands/bundleCommand/bundleCodePush.js +65 -0
- package/cli/dist/commands/bundleCommand/index.js +15 -0
- package/cli/dist/commands/createHistoryCommand/createReleaseHistory.js +25 -0
- package/cli/dist/commands/createHistoryCommand/createReleaseHistoryList.js +27 -0
- package/cli/dist/commands/createHistoryCommand/index.js +20 -0
- package/cli/dist/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +23 -0
- package/cli/dist/commands/createPullRequestHistoryCommand/index.js +15 -0
- package/cli/dist/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +51 -0
- package/cli/dist/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +39 -0
- package/cli/dist/commands/createPullRequestReleaseCommand/index.js +35 -0
- package/cli/dist/commands/getPackageHashCommand/index.js +26 -0
- package/cli/dist/commands/initCommand/index.js +12 -0
- package/cli/dist/commands/initCommand/initAndroid.js +73 -0
- package/cli/dist/commands/initCommand/initIos.js +108 -0
- package/cli/dist/commands/initCommand/test/initAndroid.test.js +113 -0
- package/cli/dist/commands/initCommand/test/initIos.test.js +95 -0
- package/cli/dist/commands/releaseCommand/addToReleaseHistory.js +35 -0
- package/cli/dist/commands/releaseCommand/index.js +45 -0
- package/cli/dist/commands/releaseCommand/release.js +62 -0
- package/cli/dist/commands/removePullRequestHistoryCommand/index.js +19 -0
- package/cli/dist/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +18 -0
- package/cli/dist/commands/showHistoryCommand/index.js +15 -0
- package/cli/dist/commands/updateHistoryCommand/index.js +31 -0
- package/cli/dist/commands/updateHistoryCommand/updateReleaseHistory.js +28 -0
- package/cli/dist/constant.js +4 -0
- package/cli/dist/functions/getReactTempDir.js +10 -0
- package/cli/{functions → dist/functions}/makeCodePushBundle.js +5 -11
- package/cli/{functions → dist/functions}/prepareToBundleJS.js +2 -5
- package/cli/dist/functions/runExpoBundleCommand.js +35 -0
- package/cli/{functions → dist/functions}/runHermesEmitBinaryCommand.js +36 -71
- package/cli/{functions → dist/functions}/runReactNativeBundleCommand.js +19 -24
- package/cli/dist/index.js +54 -0
- package/cli/dist/utils/datetime.js +17 -0
- package/cli/dist/utils/file-utils.js +19 -0
- package/cli/dist/utils/fsUtils.js +44 -0
- package/cli/{utils → dist/utils}/hash-utils.js +19 -130
- package/cli/{utils → dist/utils}/promisfied-fs.js +5 -16
- package/cli/dist/utils/showLogo.js +21 -0
- package/cli/dist/utils/unzip.js +41 -0
- package/cli/{utils → dist/utils}/zip.js +15 -51
- package/cli/functions/{getReactTempDir.js → getReactTempDir.ts} +2 -6
- package/cli/functions/makeCodePushBundle.ts +26 -0
- package/cli/functions/prepareToBundleJS.ts +10 -0
- package/cli/functions/runExpoBundleCommand.ts +45 -0
- package/cli/functions/runHermesEmitBinaryCommand.ts +203 -0
- package/cli/functions/runReactNativeBundleCommand.ts +67 -0
- package/cli/index.ts +68 -0
- package/cli/package.json +35 -0
- package/cli/utils/datetime.ts +19 -0
- package/cli/utils/{file-utils.js → file-utils.ts} +4 -21
- package/cli/utils/fsUtils.ts +50 -0
- package/cli/utils/hash-utils.ts +143 -0
- package/cli/utils/promisfied-fs.ts +19 -0
- package/cli/utils/{showLogo.js → showLogo.ts} +4 -6
- package/cli/utils/unzip.ts +46 -0
- package/cli/utils/zip.ts +65 -0
- package/expo/plugin/withCodePush.js +14 -0
- package/expo/plugin/withCodePushAndroid.js +92 -0
- package/expo/plugin/withCodePushIos.js +143 -0
- package/ios/CodePush/CodePush.h +0 -16
- package/ios/CodePush/CodePush.m +30 -20
- package/ios/CodePush/CodePushConfig.m +1 -11
- package/ios/CodePush/CodePushPackage.m +12 -69
- package/ios/CodePush/CodePushUpdateUtils.m +1 -91
- package/ios/CodePush/SSZipArchive/Info.plist +26 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -1
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
- package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
- package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
- package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
- package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
- package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +244 -453
- package/ios/PrivacyInfo.xcprivacy +31 -0
- package/package.json +67 -41
- package/react-native.config.js +1 -1
- package/{AlertAdapter.js → src/AlertAdapter.js} +5 -5
- package/src/CodePush.js +947 -0
- package/{package-mixins.js → src/package-mixins.js} +1 -1
- package/{versioning → src/versioning}/BaseVersioning.js +12 -1
- package/{versioning → src/versioning}/SemverVersioning.test.js +78 -0
- package/typings/react-native-code-push.d.ts +559 -495
- package/CONTRIBUTING.md +0 -134
- package/CodePush.js +0 -972
- package/SECURITY.md +0 -41
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +0 -12
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +0 -17
- package/android/codepush.gradle +0 -162
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -164
- package/android/gradlew.bat +0 -90
- package/babel.config.js +0 -3
- package/cli/commands/bundleCommand/bundleCodePush.js +0 -57
- package/cli/commands/bundleCommand/index.js +0 -55
- package/cli/commands/common.js +0 -245
- package/cli/commands/createHistoryCommand/createReleaseHistory.js +0 -42
- package/cli/commands/createHistoryCommand/createReleaseHistoryList.js +0 -52
- package/cli/commands/createHistoryCommand/index.js +0 -95
- package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +0 -34
- package/cli/commands/createPullRequestHistoryCommand/index.js +0 -29
- package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +0 -74
- package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +0 -91
- package/cli/commands/createPullRequestReleaseCommand/index.js +0 -68
- package/cli/commands/getPackageHashCommand/index.js +0 -42
- package/cli/commands/releaseCommand/addToReleaseHistory.js +0 -85
- package/cli/commands/releaseCommand/index.js +0 -151
- package/cli/commands/releaseCommand/release.js +0 -121
- package/cli/commands/removePullRequestHistoryCommand/index.js +0 -28
- package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +0 -23
- package/cli/commands/showHistoryCommand/index.js +0 -88
- package/cli/commands/updateHistoryCommand/index.js +0 -123
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +0 -69
- package/cli/constant.js +0 -8
- package/cli/index.js +0 -63
- package/cli/utils/datetime.js +0 -22
- package/cli/utils/fsUtils.js +0 -64
- package/cli/utils/version.js +0 -26
- package/code-push.config.example.supabase.ts +0 -114
- package/code-push.config.js +0 -229
- package/code-push.config.ts +0 -175
- package/docs/api-android.md +0 -83
- package/docs/api-ios.md +0 -31
- package/docs/api-js.md +0 -592
- package/docs/multi-deployment-testing-android.md +0 -148
- package/docs/multi-deployment-testing-ios.md +0 -59
- package/docs/setup-android.md +0 -482
- package/docs/setup-ios.md +0 -280
- package/eslint.config.mjs +0 -32
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
- package/ios/CodePush/Base64/README.md +0 -47
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
- package/ios/CodePush/JWT/LICENSE +0 -19
- package/ios/CodePush/JWT/README.md +0 -489
- package/ios/CodePush/SSZipArchive/Common.h +0 -81
- package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
- package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
- package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
- package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
- package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
- package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
- package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
- package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
- package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
- package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
- package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
- package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
- package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
- package/scripts/generateBundledResourcesHash.js +0 -125
- package/scripts/getFilesInFolder.js +0 -19
- package/scripts/recordFilesBeforeBundleCommand.js +0 -41
- package/tsconfig.json +0 -20
- package/tslint.json +0 -32
- /package/{logging.js → src/logging.js} +0 -0
- /package/{versioning → src/versioning}/BaseVersioning.test.js +0 -0
- /package/{versioning → src/versioning}/IncrementalVersioning.js +0 -0
- /package/{versioning → src/versioning}/IncrementalVersioning.test.js +0 -0
- /package/{versioning → src/versioning}/SemverVersioning.js +0 -0
- /package/{versioning → src/versioning}/index.js +0 -0
package/android/app/build.gradle
CHANGED
|
@@ -6,6 +6,8 @@ def DEFAULT_TARGET_SDK_VERSION = 26
|
|
|
6
6
|
def DEFAULT_MIN_SDK_VERSION = 16
|
|
7
7
|
|
|
8
8
|
android {
|
|
9
|
+
namespace "com.microsoft.codepush.react"
|
|
10
|
+
|
|
9
11
|
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
|
|
10
12
|
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
|
|
11
13
|
|
|
@@ -27,5 +29,4 @@ android {
|
|
|
27
29
|
|
|
28
30
|
dependencies {
|
|
29
31
|
implementation "com.facebook.react:react-native:+"
|
|
30
|
-
implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3'
|
|
31
32
|
}
|
|
@@ -20,6 +20,20 @@
|
|
|
20
20
|
-keepclassmembers class com.facebook.react.ReactInstanceManager {
|
|
21
21
|
private final ** mBundleLoader;
|
|
22
22
|
}
|
|
23
|
+
# bridgeless
|
|
24
|
+
-keepclassmembers class com.facebook.react.defaults.DefaultReactHostDelegate {
|
|
25
|
+
private ** jsBundleLoader;
|
|
26
|
+
}
|
|
27
|
+
# bridgeless
|
|
28
|
+
-keepclassmembers class * extends com.facebook.react.runtime.ReactHostDelegate {
|
|
29
|
+
private ** jsBundleLoader;
|
|
30
|
+
private ** _jsBundleLoader;
|
|
31
|
+
}
|
|
32
|
+
# bridgeless
|
|
33
|
+
-keepclassmembers class com.facebook.react.runtime.ReactHostImpl {
|
|
34
|
+
private final ** mReactHostDelegate; # RN < 0.81
|
|
35
|
+
private final ** reactHostDelegate; # RN 0.81+
|
|
36
|
+
}
|
|
23
37
|
|
|
24
38
|
# Can't find referenced class org.bouncycastle.**
|
|
25
39
|
-dontwarn com.nimbusds.jose.**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
|
|
3
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
4
|
+
|
|
5
|
+
<application>
|
|
6
|
+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
|
|
7
|
+
</application>
|
|
8
|
+
|
|
9
|
+
</manifest>
|
|
@@ -3,24 +3,17 @@ package com.microsoft.codepush.react;
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.content.pm.PackageInfo;
|
|
5
5
|
import android.content.pm.PackageManager;
|
|
6
|
-
import android.content.res.Resources;
|
|
7
6
|
|
|
8
|
-
import com.facebook.react.ReactInstanceManager;
|
|
9
7
|
import com.facebook.react.ReactPackage;
|
|
10
|
-
import com.facebook.react.bridge.JavaScriptModule;
|
|
11
8
|
import com.facebook.react.bridge.NativeModule;
|
|
12
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
|
-
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
|
14
|
-
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
|
|
15
10
|
import com.facebook.react.uimanager.ViewManager;
|
|
16
11
|
|
|
17
12
|
import org.json.JSONException;
|
|
18
13
|
import org.json.JSONObject;
|
|
19
14
|
|
|
20
|
-
import java.io.File;
|
|
21
15
|
import java.util.ArrayList;
|
|
22
16
|
import java.util.List;
|
|
23
|
-
import java.lang.reflect.Method;
|
|
24
17
|
|
|
25
18
|
public class CodePush implements ReactPackage {
|
|
26
19
|
|
|
@@ -31,7 +24,7 @@ public class CodePush implements ReactPackage {
|
|
|
31
24
|
|
|
32
25
|
private boolean mDidUpdate = false;
|
|
33
26
|
|
|
34
|
-
private String mAssetsBundleFileName;
|
|
27
|
+
private String mAssetsBundleFileName = CodePushConstants.DEFAULT_JS_BUNDLE_NAME;
|
|
35
28
|
|
|
36
29
|
// Helper classes.
|
|
37
30
|
private CodePushUpdateManager mUpdateManager;
|
|
@@ -45,25 +38,25 @@ public class CodePush implements ReactPackage {
|
|
|
45
38
|
private Context mContext;
|
|
46
39
|
private final boolean mIsDebugMode;
|
|
47
40
|
|
|
48
|
-
private static String mPublicKey;
|
|
49
|
-
|
|
50
|
-
private static ReactInstanceHolder mReactInstanceHolder;
|
|
51
41
|
private static CodePush mCurrentInstance;
|
|
52
42
|
|
|
53
|
-
public CodePush(String deploymentKey, Context context) {
|
|
54
|
-
this(deploymentKey, context, false);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
43
|
public static String getServiceUrl() {
|
|
58
44
|
return mServerUrl;
|
|
59
45
|
}
|
|
60
46
|
|
|
61
|
-
public CodePush(
|
|
47
|
+
public static synchronized CodePush getInstance(Context context, boolean isDebugMode) {
|
|
48
|
+
if (mCurrentInstance == null) {
|
|
49
|
+
mCurrentInstance = new CodePush(context, isDebugMode);
|
|
50
|
+
}
|
|
51
|
+
return mCurrentInstance;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private CodePush(Context context, boolean isDebugMode) {
|
|
62
55
|
mContext = context.getApplicationContext();
|
|
63
56
|
|
|
64
57
|
mUpdateManager = new CodePushUpdateManager(context.getFilesDir().getAbsolutePath());
|
|
65
58
|
mTelemetryManager = new CodePushTelemetryManager(mContext);
|
|
66
|
-
mDeploymentKey =
|
|
59
|
+
mDeploymentKey = "deprecated_deployment_key";
|
|
67
60
|
mIsDebugMode = isDebugMode;
|
|
68
61
|
mSettingsManager = new SettingsManager(mContext);
|
|
69
62
|
|
|
@@ -78,61 +71,18 @@ public class CodePush implements ReactPackage {
|
|
|
78
71
|
|
|
79
72
|
mCurrentInstance = this;
|
|
80
73
|
|
|
81
|
-
String publicKeyFromStrings = getCustomPropertyFromStringsIfExist("PublicKey");
|
|
82
|
-
if (publicKeyFromStrings != null) mPublicKey = publicKeyFromStrings;
|
|
83
|
-
|
|
84
74
|
String serverUrlFromStrings = getCustomPropertyFromStringsIfExist("ServerUrl");
|
|
85
75
|
if (serverUrlFromStrings != null) mServerUrl = serverUrlFromStrings;
|
|
86
76
|
|
|
87
|
-
clearDebugCacheIfNeeded(null);
|
|
88
77
|
initializeUpdateAfterRestart();
|
|
89
78
|
}
|
|
90
79
|
|
|
91
|
-
public CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl) {
|
|
92
|
-
this(deploymentKey, context, isDebugMode);
|
|
93
|
-
mServerUrl = serverUrl;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public CodePush(String deploymentKey, Context context, boolean isDebugMode, int publicKeyResourceDescriptor) {
|
|
97
|
-
this(deploymentKey, context, isDebugMode);
|
|
98
|
-
|
|
99
|
-
mPublicKey = getPublicKeyByResourceDescriptor(publicKeyResourceDescriptor);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl, Integer publicKeyResourceDescriptor) {
|
|
103
|
-
this(deploymentKey, context, isDebugMode);
|
|
104
|
-
|
|
105
|
-
if (publicKeyResourceDescriptor != null) {
|
|
106
|
-
mPublicKey = getPublicKeyByResourceDescriptor(publicKeyResourceDescriptor);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
mServerUrl = serverUrl;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private String getPublicKeyByResourceDescriptor(int publicKeyResourceDescriptor){
|
|
113
|
-
String publicKey;
|
|
114
|
-
try {
|
|
115
|
-
publicKey = mContext.getString(publicKeyResourceDescriptor);
|
|
116
|
-
} catch (Resources.NotFoundException e) {
|
|
117
|
-
throw new CodePushInvalidPublicKeyException(
|
|
118
|
-
"Unable to get public key, related resource descriptor " +
|
|
119
|
-
publicKeyResourceDescriptor +
|
|
120
|
-
" can not be found", e
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (publicKey.isEmpty()) {
|
|
125
|
-
throw new CodePushInvalidPublicKeyException("Specified public key is empty");
|
|
126
|
-
}
|
|
127
|
-
return publicKey;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
80
|
private String getCustomPropertyFromStringsIfExist(String propertyName) {
|
|
131
81
|
String property;
|
|
132
|
-
|
|
82
|
+
|
|
133
83
|
String packageName = mContext.getPackageName();
|
|
134
84
|
int resId = mContext.getResources().getIdentifier("CodePush" + propertyName, "string", packageName);
|
|
135
|
-
|
|
85
|
+
|
|
136
86
|
if (resId != 0) {
|
|
137
87
|
property = mContext.getString(resId);
|
|
138
88
|
|
|
@@ -140,43 +90,10 @@ public class CodePush implements ReactPackage {
|
|
|
140
90
|
return property;
|
|
141
91
|
} else {
|
|
142
92
|
CodePushUtils.log("Specified " + propertyName + " is empty");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
private boolean isLiveReloadEnabled(ReactInstanceManager instanceManager) {
|
|
150
|
-
// Use instanceManager for checking if we use LiveReload mode. In this case we should not remove ReactNativeDevBundle.js file
|
|
151
|
-
// because we get error with trying to get this after reloading. Issue: https://github.com/microsoft/react-native-code-push/issues/1272
|
|
152
|
-
if (instanceManager != null) {
|
|
153
|
-
DevSupportManager devSupportManager = instanceManager.getDevSupportManager();
|
|
154
|
-
if (devSupportManager != null) {
|
|
155
|
-
DeveloperSettings devSettings = devSupportManager.getDevSettings();
|
|
156
|
-
Method[] methods = devSettings.getClass().getMethods();
|
|
157
|
-
for (Method m : methods) {
|
|
158
|
-
if (m.getName().equals("isReloadOnJSChangeEnabled")) {
|
|
159
|
-
try {
|
|
160
|
-
return (boolean) m.invoke(devSettings);
|
|
161
|
-
} catch (Exception x) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
93
|
}
|
|
167
94
|
}
|
|
168
95
|
|
|
169
|
-
return
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public void clearDebugCacheIfNeeded(ReactInstanceManager instanceManager) {
|
|
173
|
-
if (mIsDebugMode && mSettingsManager.isPendingUpdate(null) && !isLiveReloadEnabled(instanceManager)) {
|
|
174
|
-
// This needs to be kept in sync with https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java#L78
|
|
175
|
-
File cachedDevBundle = new File(mContext.getFilesDir(), "ReactNativeDevBundle.js");
|
|
176
|
-
if (cachedDevBundle.exists()) {
|
|
177
|
-
cachedDevBundle.delete();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
96
|
+
return null;
|
|
180
97
|
}
|
|
181
98
|
|
|
182
99
|
public boolean didUpdate() {
|
|
@@ -191,23 +108,6 @@ public class CodePush implements ReactPackage {
|
|
|
191
108
|
return mAssetsBundleFileName;
|
|
192
109
|
}
|
|
193
110
|
|
|
194
|
-
public String getPublicKey() {
|
|
195
|
-
return mPublicKey;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
long getBinaryResourcesModifiedTime() {
|
|
199
|
-
try {
|
|
200
|
-
String packageName = this.mContext.getPackageName();
|
|
201
|
-
int codePushApkBuildTimeId = this.mContext.getResources().getIdentifier(CodePushConstants.CODE_PUSH_APK_BUILD_TIME_KEY, "string", packageName);
|
|
202
|
-
// replace double quotes needed for correct restoration of long value from strings.xml
|
|
203
|
-
// https://github.com/microsoft/cordova-plugin-code-push/issues/264
|
|
204
|
-
String codePushApkBuildTime = this.mContext.getResources().getString(codePushApkBuildTimeId).replaceAll("\"","");
|
|
205
|
-
return Long.parseLong(codePushApkBuildTime);
|
|
206
|
-
} catch (Exception e) {
|
|
207
|
-
throw new CodePushUnknownException("Error in getting binary resources modified time", e);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
111
|
public String getPackageFolder() {
|
|
212
112
|
JSONObject codePushLocalPackage = mUpdateManager.getCurrentPackage();
|
|
213
113
|
if (codePushLocalPackage == null) {
|
|
@@ -349,16 +249,8 @@ public class CodePush implements ReactPackage {
|
|
|
349
249
|
|
|
350
250
|
private boolean isPackageBundleLatest(JSONObject packageMetadata) {
|
|
351
251
|
try {
|
|
352
|
-
Long binaryModifiedDateDuringPackageInstall = null;
|
|
353
|
-
String binaryModifiedDateDuringPackageInstallString = packageMetadata.optString(CodePushConstants.BINARY_MODIFIED_TIME_KEY, null);
|
|
354
|
-
if (binaryModifiedDateDuringPackageInstallString != null) {
|
|
355
|
-
binaryModifiedDateDuringPackageInstall = Long.parseLong(binaryModifiedDateDuringPackageInstallString);
|
|
356
|
-
}
|
|
357
252
|
String packageAppVersion = packageMetadata.optString("appVersion", null);
|
|
358
|
-
|
|
359
|
-
return binaryModifiedDateDuringPackageInstall != null &&
|
|
360
|
-
binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime &&
|
|
361
|
-
(isUsingTestConfiguration() || sAppVersion.equals(packageAppVersion));
|
|
253
|
+
return (isUsingTestConfiguration() || sAppVersion.equals(packageAppVersion));
|
|
362
254
|
} catch (NumberFormatException e) {
|
|
363
255
|
throw new CodePushUnknownException("Error in reading binary modified date from package metadata", e);
|
|
364
256
|
}
|
|
@@ -407,17 +299,6 @@ public class CodePush implements ReactPackage {
|
|
|
407
299
|
mSettingsManager.removeFailedUpdates();
|
|
408
300
|
}
|
|
409
301
|
|
|
410
|
-
public static void setReactInstanceHolder(ReactInstanceHolder reactInstanceHolder) {
|
|
411
|
-
mReactInstanceHolder = reactInstanceHolder;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
static ReactInstanceManager getReactInstanceManager() {
|
|
415
|
-
if (mReactInstanceHolder == null) {
|
|
416
|
-
return null;
|
|
417
|
-
}
|
|
418
|
-
return mReactInstanceHolder.getReactInstanceManager();
|
|
419
|
-
}
|
|
420
|
-
|
|
421
302
|
@Override
|
|
422
303
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
|
|
423
304
|
CodePushNativeModule codePushModule = new CodePushNativeModule(reactApplicationContext, this, mUpdateManager, mTelemetryManager, mSettingsManager);
|
|
@@ -428,12 +309,6 @@ public class CodePush implements ReactPackage {
|
|
|
428
309
|
nativeModules.add(dialogModule);
|
|
429
310
|
return nativeModules;
|
|
430
311
|
}
|
|
431
|
-
|
|
432
|
-
// Deprecated in RN v0.47.
|
|
433
|
-
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
434
|
-
return new ArrayList<>();
|
|
435
|
-
}
|
|
436
|
-
|
|
437
312
|
@Override
|
|
438
313
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
|
|
439
314
|
return new ArrayList<>();
|
|
@@ -2,7 +2,6 @@ package com.microsoft.codepush.react;
|
|
|
2
2
|
|
|
3
3
|
public class CodePushConstants {
|
|
4
4
|
public static final String ASSETS_BUNDLE_PREFIX = "assets://";
|
|
5
|
-
public static final String BINARY_MODIFIED_TIME_KEY = "binaryModifiedTime";
|
|
6
5
|
public static final String CODE_PUSH_FOLDER_PREFIX = "CodePush";
|
|
7
6
|
public static final String CODE_PUSH_HASH_FILE_NAME = "CodePushHash";
|
|
8
7
|
public static final String CODE_PUSH_OLD_HASH_FILE_NAME = "CodePushHash.json";
|
|
@@ -25,8 +24,6 @@ public class CodePushConstants {
|
|
|
25
24
|
public static final String RELATIVE_BUNDLE_PATH_KEY = "bundlePath";
|
|
26
25
|
public static final String STATUS_FILE = "codepush.json";
|
|
27
26
|
public static final String UNZIPPED_FOLDER_NAME = "unzipped";
|
|
28
|
-
public static final String CODE_PUSH_APK_BUILD_TIME_KEY = "CODE_PUSH_APK_BUILD_TIME";
|
|
29
|
-
public static final String BUNDLE_JWT_FILE = ".codepushrelease";
|
|
30
27
|
public static final String LATEST_ROLLBACK_INFO_KEY = "LATEST_ROLLBACK_INFO";
|
|
31
28
|
public static final String LATEST_ROLLBACK_PACKAGE_HASH_KEY = "packageHash";
|
|
32
29
|
public static final String LATEST_ROLLBACK_TIME_KEY = "time";
|
|
@@ -5,10 +5,14 @@ import android.content.SharedPreferences;
|
|
|
5
5
|
import android.os.AsyncTask;
|
|
6
6
|
import android.os.Handler;
|
|
7
7
|
import android.os.Looper;
|
|
8
|
-
import android.provider.Settings;
|
|
9
8
|
import android.view.View;
|
|
9
|
+
import android.view.Choreographer;
|
|
10
10
|
|
|
11
|
-
import
|
|
11
|
+
import androidx.annotation.OptIn;
|
|
12
|
+
|
|
13
|
+
import com.facebook.react.ReactDelegate;
|
|
14
|
+
import com.facebook.react.ReactHost;
|
|
15
|
+
import com.facebook.react.ReactActivity;
|
|
12
16
|
import com.facebook.react.ReactInstanceManager;
|
|
13
17
|
import com.facebook.react.ReactRootView;
|
|
14
18
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -20,9 +24,10 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
20
24
|
import com.facebook.react.bridge.ReactMethod;
|
|
21
25
|
import com.facebook.react.bridge.ReadableMap;
|
|
22
26
|
import com.facebook.react.bridge.WritableMap;
|
|
23
|
-
import com.facebook.react.
|
|
27
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI;
|
|
24
28
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
25
29
|
import com.facebook.react.modules.core.ReactChoreographer;
|
|
30
|
+
import com.facebook.react.runtime.ReactHostDelegate;
|
|
26
31
|
|
|
27
32
|
import org.json.JSONArray;
|
|
28
33
|
import org.json.JSONException;
|
|
@@ -33,7 +38,6 @@ import java.lang.reflect.Field;
|
|
|
33
38
|
import java.util.ArrayList;
|
|
34
39
|
import java.util.Date;
|
|
35
40
|
import java.util.HashMap;
|
|
36
|
-
import java.util.List;
|
|
37
41
|
import java.util.Map;
|
|
38
42
|
import java.util.UUID;
|
|
39
43
|
|
|
@@ -93,7 +97,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
private void loadBundleLegacy() {
|
|
96
|
-
final Activity currentActivity = getCurrentActivity();
|
|
100
|
+
final Activity currentActivity = getReactApplicationContext().getCurrentActivity();
|
|
97
101
|
if (currentActivity == null) {
|
|
98
102
|
// The currentActivity can be null if it is backgrounded / destroyed, so we simply
|
|
99
103
|
// no-op to prevent any null pointer exceptions.
|
|
@@ -111,7 +115,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
111
115
|
|
|
112
116
|
// Use reflection to find and set the appropriate fields on ReactInstanceManager. See #556 for a proposal for a less brittle way
|
|
113
117
|
// to approach this.
|
|
114
|
-
private void setJSBundle(
|
|
118
|
+
private void setJSBundle(String latestJSBundleFile) throws IllegalAccessException {
|
|
115
119
|
try {
|
|
116
120
|
JSBundleLoader latestJSBundleLoader;
|
|
117
121
|
if (latestJSBundleFile.toLowerCase().startsWith("assets://")) {
|
|
@@ -120,54 +124,83 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
120
124
|
latestJSBundleLoader = JSBundleLoader.createFileLoader(latestJSBundleFile);
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
ReactHost reactHost = resolveReactHost();
|
|
128
|
+
if (reactHost == null) {
|
|
129
|
+
CodePushUtils.log("Unable to resolve ReactHost");
|
|
130
|
+
// Bridge, Old Architecture
|
|
131
|
+
setJSBundleLoaderBridge(latestJSBundleLoader);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Bridgeless (RN >= 0.74)
|
|
136
|
+
setJSBundleLoaderBridgeless(reactHost, latestJSBundleLoader);
|
|
126
137
|
} catch (Exception e) {
|
|
127
138
|
CodePushUtils.log("Unable to set JSBundle - CodePush may not support this version of React Native");
|
|
128
139
|
throw new IllegalAccessException("Could not setJSBundle");
|
|
129
140
|
}
|
|
130
141
|
}
|
|
131
142
|
|
|
143
|
+
private void setJSBundleLoaderBridge(JSBundleLoader latestJSBundleLoader) throws NoSuchFieldException, IllegalAccessException {
|
|
144
|
+
ReactDelegate reactDelegate = resolveReactDelegate();
|
|
145
|
+
assert reactDelegate != null;
|
|
146
|
+
ReactInstanceManager instanceManager = reactDelegate.getReactInstanceManager();
|
|
147
|
+
Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader");
|
|
148
|
+
bundleLoaderField.setAccessible(true);
|
|
149
|
+
bundleLoaderField.set(instanceManager, latestJSBundleLoader);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@OptIn(markerClass = UnstableReactNativeAPI.class)
|
|
153
|
+
private void setJSBundleLoaderBridgeless(ReactHost reactHost, JSBundleLoader latestJSBundleLoader) throws NoSuchFieldException, IllegalAccessException {
|
|
154
|
+
// RN < 0.81
|
|
155
|
+
Field reactHostDelegateField = resolveDeclaredField(reactHost.getClass(), "mReactHostDelegate");
|
|
156
|
+
if (reactHostDelegateField == null) {
|
|
157
|
+
// RN >= 0.81
|
|
158
|
+
reactHostDelegateField = resolveDeclaredField(reactHost.getClass(), "reactHostDelegate");
|
|
159
|
+
}
|
|
160
|
+
if (reactHostDelegateField == null) {
|
|
161
|
+
throw new NoSuchFieldException("Unable to resolve ReactHostDelegate field.");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
reactHostDelegateField.setAccessible(true);
|
|
165
|
+
ReactHostDelegate reactHostDelegate = (ReactHostDelegate) reactHostDelegateField.get(reactHost);
|
|
166
|
+
assert reactHostDelegate != null;
|
|
167
|
+
|
|
168
|
+
// Expo ReactHost delegate keeps this mutable backing field specifically
|
|
169
|
+
// so integrations can override the bundle loader at runtime.
|
|
170
|
+
Field jsBundleLoaderField = resolveDeclaredField(reactHostDelegate.getClass(), "_jsBundleLoader");
|
|
171
|
+
if (jsBundleLoaderField == null) {
|
|
172
|
+
// Fallback for non-Expo delegates.
|
|
173
|
+
jsBundleLoaderField = resolveDeclaredField(reactHostDelegate.getClass(), "jsBundleLoader");
|
|
174
|
+
}
|
|
175
|
+
if (jsBundleLoaderField == null) {
|
|
176
|
+
throw new NoSuchFieldException("Unable to resolve JSBundleLoader field.");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
jsBundleLoaderField.setAccessible(true);
|
|
180
|
+
jsBundleLoaderField.set(reactHostDelegate, latestJSBundleLoader);
|
|
181
|
+
}
|
|
182
|
+
|
|
132
183
|
private void loadBundle() {
|
|
133
184
|
clearLifecycleEventListener();
|
|
134
|
-
try {
|
|
135
|
-
mCodePush.clearDebugCacheIfNeeded(resolveInstanceManager());
|
|
136
|
-
} catch(Exception e) {
|
|
137
|
-
// If we got error in out reflection we should clear debug cache anyway.
|
|
138
|
-
mCodePush.clearDebugCacheIfNeeded(null);
|
|
139
|
-
}
|
|
140
185
|
|
|
141
186
|
try {
|
|
142
|
-
// #1) Get the ReactInstanceManager instance, which is what includes the
|
|
143
|
-
// logic to reload the current React context.
|
|
144
|
-
final ReactInstanceManager instanceManager = resolveInstanceManager();
|
|
145
|
-
if (instanceManager == null) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
187
|
String latestJSBundleFile = mCodePush.getJSBundleFileInternal(mCodePush.getAssetsBundleFileName());
|
|
150
188
|
|
|
151
|
-
// #
|
|
152
|
-
setJSBundle(
|
|
189
|
+
// #1) Update the locally stored JS bundle file path
|
|
190
|
+
setJSBundle(latestJSBundleFile);
|
|
153
191
|
|
|
154
|
-
// #
|
|
192
|
+
// #2) Get the context creation method and fire it on the UI thread (which RN enforces)
|
|
155
193
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
|
156
194
|
@Override
|
|
157
195
|
public void run() {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
} catch (Exception e) {
|
|
167
|
-
// The recreation method threw an unknown exception
|
|
168
|
-
// so just simply fallback to restarting the Activity (if it exists)
|
|
169
|
-
loadBundleLegacy();
|
|
170
|
-
}
|
|
196
|
+
ReactDelegate reactDelegate = resolveReactDelegate();
|
|
197
|
+
assert reactDelegate != null;
|
|
198
|
+
|
|
199
|
+
resetReactRootViews(reactDelegate);
|
|
200
|
+
|
|
201
|
+
reactDelegate.reload();
|
|
202
|
+
|
|
203
|
+
mCodePush.initializeUpdateAfterRestart();
|
|
171
204
|
}
|
|
172
205
|
});
|
|
173
206
|
|
|
@@ -179,18 +212,19 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
179
212
|
}
|
|
180
213
|
}
|
|
181
214
|
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
reactRootView
|
|
191
|
-
|
|
215
|
+
// Fix freezing that occurs when reloading the app (RN >= 0.77.1 Old Architecture)
|
|
216
|
+
// - "Trying to add a root view with an explicit id (11) already set.
|
|
217
|
+
// React Native uses the id field to track react tags and will overwrite this field.
|
|
218
|
+
// If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView."
|
|
219
|
+
private void resetReactRootViews(ReactDelegate reactDelegate) {
|
|
220
|
+
ReactActivity currentActivity = (ReactActivity) getReactApplicationContext().getCurrentActivity();
|
|
221
|
+
if (currentActivity != null) {
|
|
222
|
+
ReactRootView reactRootView = reactDelegate.getReactRootView();
|
|
223
|
+
if (reactRootView != null) {
|
|
224
|
+
reactRootView.removeAllViews();
|
|
225
|
+
reactRootView.setId(View.NO_ID);
|
|
226
|
+
}
|
|
192
227
|
}
|
|
193
|
-
mAttachedRootViewsField.set(instanceManager, mAttachedRootViews);
|
|
194
228
|
}
|
|
195
229
|
|
|
196
230
|
private void clearLifecycleEventListener() {
|
|
@@ -201,22 +235,34 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
201
235
|
}
|
|
202
236
|
}
|
|
203
237
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return instanceManager;
|
|
238
|
+
private ReactDelegate resolveReactDelegate() {
|
|
239
|
+
ReactActivity currentActivity = (ReactActivity) getReactApplicationContext().getCurrentActivity();
|
|
240
|
+
if (currentActivity == null) {
|
|
241
|
+
return null;
|
|
209
242
|
}
|
|
210
243
|
|
|
211
|
-
|
|
212
|
-
|
|
244
|
+
return currentActivity.getReactDelegate();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private ReactHost resolveReactHost() {
|
|
248
|
+
ReactDelegate reactDelegate = resolveReactDelegate();
|
|
249
|
+
if (reactDelegate == null) {
|
|
213
250
|
return null;
|
|
214
251
|
}
|
|
215
252
|
|
|
216
|
-
|
|
217
|
-
|
|
253
|
+
return reactDelegate.getReactHost();
|
|
254
|
+
}
|
|
218
255
|
|
|
219
|
-
|
|
256
|
+
private Field resolveDeclaredField(Class<?> targetClass, String fieldName) {
|
|
257
|
+
Class<?> cursor = targetClass;
|
|
258
|
+
while (cursor != null) {
|
|
259
|
+
try {
|
|
260
|
+
return cursor.getDeclaredField(fieldName);
|
|
261
|
+
} catch (NoSuchFieldException ignored) {
|
|
262
|
+
cursor = cursor.getSuperclass();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
220
266
|
}
|
|
221
267
|
|
|
222
268
|
private void restartAppInternal(boolean onlyIfUpdateIsPending) {
|
|
@@ -294,7 +340,6 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
294
340
|
protected Void doInBackground(Void... params) {
|
|
295
341
|
try {
|
|
296
342
|
JSONObject mutableUpdatePackage = CodePushUtils.convertReadableToJsonObject(updatePackage);
|
|
297
|
-
CodePushUtils.setJSONValueForKey(mutableUpdatePackage, CodePushConstants.BINARY_MODIFIED_TIME_KEY, "" + mCodePush.getBinaryResourcesModifiedTime());
|
|
298
343
|
mUpdateManager.downloadPackage(mutableUpdatePackage, mCodePush.getAssetsBundleFileName(), new DownloadProgressCallback() {
|
|
299
344
|
private boolean hasScheduledNextFrame = false;
|
|
300
345
|
private DownloadProgress latestDownloadProgress = null;
|
|
@@ -320,7 +365,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
320
365
|
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
|
|
321
366
|
@Override
|
|
322
367
|
public void run() {
|
|
323
|
-
ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new
|
|
368
|
+
ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new Choreographer.FrameCallback() {
|
|
324
369
|
@Override
|
|
325
370
|
public void doFrame(long frameTimeNanos) {
|
|
326
371
|
if (!latestDownloadProgress.isCompleted()) {
|
|
@@ -339,7 +384,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
339
384
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
340
385
|
.emit(CodePushConstants.DOWNLOAD_PROGRESS_EVENT_NAME, latestDownloadProgress.createWritableMap());
|
|
341
386
|
}
|
|
342
|
-
}
|
|
387
|
+
});
|
|
343
388
|
|
|
344
389
|
JSONObject newPackage = mUpdateManager.getPackage(CodePushUtils.tryGetString(updatePackage, CodePushConstants.PACKAGE_HASH_KEY));
|
|
345
390
|
promise.resolve(CodePushUtils.convertJsonObjectToWritable(newPackage));
|
|
@@ -492,7 +537,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
492
537
|
return null;
|
|
493
538
|
}
|
|
494
539
|
}
|
|
495
|
-
|
|
540
|
+
|
|
496
541
|
promise.resolve("");
|
|
497
542
|
} catch(CodePushUnknownException e) {
|
|
498
543
|
CodePushUtils.log(e);
|
|
@@ -144,8 +144,7 @@ public class CodePushUpdateManager {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
public void downloadPackage(JSONObject updatePackage, String expectedBundleFileName,
|
|
147
|
-
DownloadProgressCallback progressCallback
|
|
148
|
-
String stringPublicKey) throws IOException {
|
|
147
|
+
DownloadProgressCallback progressCallback) throws IOException {
|
|
149
148
|
String newUpdateHash = updatePackage.optString(CodePushConstants.PACKAGE_HASH_KEY, null);
|
|
150
149
|
String newUpdateFolderPath = getPackageFolderPath(newUpdateHash);
|
|
151
150
|
String newUpdateMetadataPath = CodePushUtils.appendPathComponent(newUpdateFolderPath, CodePushConstants.PACKAGE_FILE_NAME);
|
|
@@ -265,37 +264,7 @@ public class CodePushUpdateManager {
|
|
|
265
264
|
CodePushUtils.log("Applying full update.");
|
|
266
265
|
}
|
|
267
266
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
String signaturePath = CodePushUpdateUtils.getSignatureFilePath(newUpdateFolderPath);
|
|
271
|
-
boolean isSignatureAppearedInBundle = FileUtils.fileAtPathExists(signaturePath);
|
|
272
|
-
|
|
273
|
-
if (isSignatureVerificationEnabled) {
|
|
274
|
-
if (isSignatureAppearedInBundle) {
|
|
275
|
-
CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash);
|
|
276
|
-
CodePushUpdateUtils.verifyUpdateSignature(newUpdateFolderPath, newUpdateHash, stringPublicKey);
|
|
277
|
-
} else {
|
|
278
|
-
throw new CodePushInvalidUpdateException(
|
|
279
|
-
"Error! Public key was provided but there is no JWT signature within app bundle to verify. " +
|
|
280
|
-
"Possible reasons, why that might happen: \n" +
|
|
281
|
-
"1. You've been released CodePush bundle update using version of CodePush CLI that is not support code signing.\n" +
|
|
282
|
-
"2. You've been released CodePush bundle update without providing --privateKeyPath option."
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
} else {
|
|
286
|
-
if (isSignatureAppearedInBundle) {
|
|
287
|
-
CodePushUtils.log(
|
|
288
|
-
"Warning! JWT signature exists in codepush update but code integrity check couldn't be performed because there is no public key configured. " +
|
|
289
|
-
"Please ensure that public key is properly configured within your application."
|
|
290
|
-
);
|
|
291
|
-
CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash);
|
|
292
|
-
} else {
|
|
293
|
-
if (isDiffUpdate) {
|
|
294
|
-
CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
267
|
+
CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash);
|
|
299
268
|
CodePushUtils.setJSONValueForKey(updatePackage, CodePushConstants.RELATIVE_BUNDLE_PATH_KEY, relativeBundlePath);
|
|
300
269
|
}
|
|
301
270
|
} else {
|