@vanikya/ota-react-native 0.2.5 → 0.2.7
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/android/build.gradle
CHANGED
|
@@ -6,6 +6,7 @@ import android.os.Handler
|
|
|
6
6
|
import android.os.Looper
|
|
7
7
|
import android.util.Base64
|
|
8
8
|
import com.facebook.react.bridge.*
|
|
9
|
+
import com.jakewharton.processphoenix.ProcessPhoenix
|
|
9
10
|
import java.io.File
|
|
10
11
|
import java.io.FileOutputStream
|
|
11
12
|
import java.io.InputStream
|
|
@@ -303,26 +304,30 @@ class OTAUpdateModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
303
304
|
}
|
|
304
305
|
|
|
305
306
|
if (restart) {
|
|
306
|
-
android.util.Log.d("OTAUpdate", "Restarting app to apply bundle...")
|
|
307
|
+
android.util.Log.d("OTAUpdate", "Restarting app to apply bundle using ProcessPhoenix...")
|
|
307
308
|
|
|
308
309
|
// Resolve promise before restarting so JS knows it succeeded
|
|
309
310
|
promise.resolve(null)
|
|
310
311
|
|
|
311
312
|
// Give a small delay to ensure the promise is sent back to JS
|
|
312
313
|
mainHandler.postDelayed({
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
314
|
+
try {
|
|
315
|
+
// Use ProcessPhoenix for graceful app restart
|
|
316
|
+
// This properly kills the current process and starts a new one
|
|
317
|
+
val context: android.content.Context = reactApplicationContext.applicationContext
|
|
318
|
+
ProcessPhoenix.triggerRebirth(context)
|
|
319
|
+
} catch (e: Exception) {
|
|
320
|
+
android.util.Log.e("OTAUpdate", "ProcessPhoenix restart failed: ${e.message}, using fallback")
|
|
321
|
+
// Fallback to manual restart
|
|
322
|
+
val context = reactApplicationContext
|
|
323
|
+
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
324
|
+
intent?.addFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
325
|
+
intent?.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
326
|
+
intent?.addFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
|
327
|
+
context.startActivity(intent)
|
|
323
328
|
android.os.Process.killProcess(android.os.Process.myPid())
|
|
324
|
-
}
|
|
325
|
-
},
|
|
329
|
+
}
|
|
330
|
+
}, 200)
|
|
326
331
|
} else {
|
|
327
332
|
promise.resolve(null)
|
|
328
333
|
}
|
|
@@ -345,6 +350,20 @@ class OTAUpdateModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
345
350
|
promise.resolve(null)
|
|
346
351
|
}
|
|
347
352
|
|
|
353
|
+
// Reload the app - used to apply pending updates
|
|
354
|
+
@ReactMethod
|
|
355
|
+
fun reload() {
|
|
356
|
+
android.util.Log.d("OTAUpdate", "Reload requested...")
|
|
357
|
+
mainHandler.postDelayed({
|
|
358
|
+
try {
|
|
359
|
+
val context: android.content.Context = reactApplicationContext.applicationContext
|
|
360
|
+
ProcessPhoenix.triggerRebirth(context)
|
|
361
|
+
} catch (e: Exception) {
|
|
362
|
+
android.util.Log.e("OTAUpdate", "Reload failed: ${e.message}")
|
|
363
|
+
}
|
|
364
|
+
}, 100)
|
|
365
|
+
}
|
|
366
|
+
|
|
348
367
|
// Utility functions
|
|
349
368
|
|
|
350
369
|
private fun hexStringToByteArray(hex: String): ByteArray {
|
package/lib/commonjs/index.js
CHANGED
package/lib/module/index.js
CHANGED
|
@@ -10,5 +10,5 @@ export { OTAApiClient, getDeviceInfo } from './utils/api';
|
|
|
10
10
|
export { UpdateStorage, getStorageAdapter } from './utils/storage';
|
|
11
11
|
export { calculateHash, verifyBundleHash, verifySignature, verifyBundle } from './utils/verification';
|
|
12
12
|
// Version info
|
|
13
|
-
export const VERSION = '0.2.
|
|
13
|
+
export const VERSION = '0.2.7';
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -9,5 +9,5 @@ export { UpdateStorage, getStorageAdapter } from './utils/storage';
|
|
|
9
9
|
export type { StoredUpdate, StorageAdapter } from './utils/storage';
|
|
10
10
|
export { calculateHash, verifyBundleHash, verifySignature, verifyBundle, } from './utils/verification';
|
|
11
11
|
export type { VerificationResult } from './utils/verification';
|
|
12
|
-
export declare const VERSION = "0.2.
|
|
12
|
+
export declare const VERSION = "0.2.7";
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
package/src/index.ts
CHANGED