Commit 5081e7c
authored
Disconnect from Remote Config real-time server when app is backgrounded. (#6816)
This PR focuses on enhancing the reliability and efficiency of the
Remote Config real-time stream, particularly concerning background app
states. We've refined the ``ConfigRealtimeHttpClient`` to retrieve and
manage the underlying input and error streams more effectively, ensuring
proper closure even in error scenarios. Additionally, the
``closeRealtimeHttpStream`` method now explicitly closes these streams
using the acquired references.
A key improvement is the robust handling of the app's background state.
The ``setRealtimeBackgroundState`` method is now synchronized to
guarantee thread-safe updates and will immediately close the real-time
HTTP connection when the app transitions to the background. This
background state is also reflected in ``ConfigAutoFetch``, allowing for
conditional exception logging during real-time stream listening,
ensuring logs are only generated when the app is actively in the
foreground. Furthermore, ``ConfigAutoFetch`` now maintains a dedicated
``InputStream`` reference to ensure proper stream closure, and a
separate reference is kept in ``beginRealtimeHttpStream`` to handle
potential early closure scenarios before ``ConfigAutoFetch`` is reached.1 parent 58b9da4 commit 5081e7c
File tree
5 files changed
+164
-51
lines changed- firebase-config
- src
- main/java/com/google/firebase/remoteconfig/internal
- test/java/com/google/firebase/remoteconfig
5 files changed
+164
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
Lines changed: 25 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
| |||
105 | 111 | | |
106 | 112 | | |
107 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
108 | 117 | | |
109 | | - | |
| 118 | + | |
110 | 119 | | |
111 | | - | |
112 | 120 | | |
113 | | - | |
114 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
115 | 127 | | |
116 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
117 | 137 | | |
118 | 138 | | |
119 | 139 | | |
| |||
186 | 206 | | |
187 | 207 | | |
188 | 208 | | |
189 | | - | |
190 | 209 | | |
191 | 210 | | |
192 | 211 | | |
| |||
firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigRealtimeHandler.java
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
Lines changed: 84 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| |||
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| 118 | + | |
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
| |||
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
391 | 397 | | |
392 | 398 | | |
393 | 399 | | |
394 | | - | |
395 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
396 | 416 | | |
397 | 417 | | |
398 | 418 | | |
399 | 419 | | |
400 | 420 | | |
401 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
402 | 436 | | |
403 | 437 | | |
404 | 438 | | |
| |||
469 | 503 | | |
470 | 504 | | |
471 | 505 | | |
472 | | - | |
| 506 | + | |
473 | 507 | | |
474 | 508 | | |
475 | 509 | | |
| |||
489 | 523 | | |
490 | 524 | | |
491 | 525 | | |
492 | | - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
493 | 530 | | |
494 | 531 | | |
495 | 532 | | |
496 | 533 | | |
497 | 534 | | |
498 | 535 | | |
499 | | - | |
500 | 536 | | |
501 | 537 | | |
502 | 538 | | |
| 539 | + | |
| 540 | + | |
503 | 541 | | |
504 | 542 | | |
505 | 543 | | |
| |||
509 | 547 | | |
510 | 548 | | |
511 | 549 | | |
512 | | - | |
| 550 | + | |
513 | 551 | | |
514 | 552 | | |
515 | 553 | | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
523 | 567 | | |
524 | | - | |
| 568 | + | |
| 569 | + | |
525 | 570 | | |
526 | 571 | | |
| 572 | + | |
527 | 573 | | |
528 | | - | |
| 574 | + | |
| 575 | + | |
529 | 576 | | |
530 | 577 | | |
531 | 578 | | |
| |||
556 | 603 | | |
557 | 604 | | |
558 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
559 | 610 | | |
560 | 611 | | |
561 | 612 | | |
562 | 613 | | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
| 614 | + | |
| 615 | + | |
570 | 616 | | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
576 | 620 | | |
577 | 621 | | |
578 | 622 | | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
579 | 636 | | |
0 commit comments