@vanikya/ota-react-native 0.2.5 → 0.2.6
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,35 @@ 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 activity = currentActivity
|
|
318
|
+
if (activity != null) {
|
|
319
|
+
ProcessPhoenix.triggerRebirth(activity)
|
|
320
|
+
} else {
|
|
321
|
+
// Fallback to context-based restart
|
|
322
|
+
ProcessPhoenix.triggerRebirth(reactApplicationContext)
|
|
323
|
+
}
|
|
324
|
+
} catch (e: Exception) {
|
|
325
|
+
android.util.Log.e("OTAUpdate", "ProcessPhoenix restart failed: ${e.message}, using fallback")
|
|
326
|
+
// Fallback to manual restart
|
|
327
|
+
val context = reactApplicationContext
|
|
328
|
+
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
329
|
+
intent?.addFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
330
|
+
intent?.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
331
|
+
intent?.addFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
|
332
|
+
context.startActivity(intent)
|
|
323
333
|
android.os.Process.killProcess(android.os.Process.myPid())
|
|
324
|
-
}
|
|
325
|
-
},
|
|
334
|
+
}
|
|
335
|
+
}, 200)
|
|
326
336
|
} else {
|
|
327
337
|
promise.resolve(null)
|
|
328
338
|
}
|
|
@@ -345,6 +355,24 @@ class OTAUpdateModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
345
355
|
promise.resolve(null)
|
|
346
356
|
}
|
|
347
357
|
|
|
358
|
+
// Reload the app - used to apply pending updates
|
|
359
|
+
@ReactMethod
|
|
360
|
+
fun reload() {
|
|
361
|
+
android.util.Log.d("OTAUpdate", "Reload requested...")
|
|
362
|
+
mainHandler.postDelayed({
|
|
363
|
+
try {
|
|
364
|
+
val activity = currentActivity
|
|
365
|
+
if (activity != null) {
|
|
366
|
+
ProcessPhoenix.triggerRebirth(activity)
|
|
367
|
+
} else {
|
|
368
|
+
ProcessPhoenix.triggerRebirth(reactApplicationContext)
|
|
369
|
+
}
|
|
370
|
+
} catch (e: Exception) {
|
|
371
|
+
android.util.Log.e("OTAUpdate", "Reload failed: ${e.message}")
|
|
372
|
+
}
|
|
373
|
+
}, 100)
|
|
374
|
+
}
|
|
375
|
+
|
|
348
376
|
// Utility functions
|
|
349
377
|
|
|
350
378
|
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.6';
|
|
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.6";
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
package/src/index.ts
CHANGED