mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-09-06 09:33:15 +00:00
41 lines
1.9 KiB
Diff
41 lines
1.9 KiB
Diff
![]() |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Luca Stefani <luca.stefani.ge1@gmail.com>
|
||
|
Date: Thu, 20 Jan 2022 18:43:00 +0530
|
||
|
Subject: [PATCH] Delay FCM registration until it's actually required
|
||
|
|
||
|
Most users / carriers don't need this, so let's avoid registering it for everyone.
|
||
|
|
||
|
Change-Id: I3f57ce0a1184a510d09638c703236989f8596c5f
|
||
|
---
|
||
|
.../fcm/FcmRegistrationService.java | 9 ++++++++-
|
||
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/src/com/android/imsserviceentitlement/fcm/FcmRegistrationService.java b/src/com/android/imsserviceentitlement/fcm/FcmRegistrationService.java
|
||
|
index 184740d..cb777a3 100644
|
||
|
--- a/src/com/android/imsserviceentitlement/fcm/FcmRegistrationService.java
|
||
|
+++ b/src/com/android/imsserviceentitlement/fcm/FcmRegistrationService.java
|
||
|
@@ -30,6 +30,7 @@ import com.android.imsserviceentitlement.R;
|
||
|
import com.android.imsserviceentitlement.job.JobManager;
|
||
|
import com.android.imsserviceentitlement.utils.TelephonyUtils;
|
||
|
|
||
|
+import com.google.common.collect.ImmutableSet;
|
||
|
import com.google.firebase.FirebaseApp;
|
||
|
import com.google.firebase.FirebaseOptions;
|
||
|
import com.google.firebase.iid.FirebaseInstanceId;
|
||
|
@@ -110,8 +111,14 @@ public class FcmRegistrationService extends JobService {
|
||
|
* The token changes when the InstanceID becomes invalid (e.g. app data is deleted).
|
||
|
*/
|
||
|
protected void onHandleWork(JobParameters params) {
|
||
|
+ ImmutableSet<Integer> subIds = TelephonyUtils.getSubIdsWithFcmSupported(this);
|
||
|
+ if (subIds.size() == 0 && mFakeInstanceID == null) {
|
||
|
+ jobFinished(params, false);
|
||
|
+ return;
|
||
|
+ }
|
||
|
+
|
||
|
boolean wantsReschedule = false;
|
||
|
- for (int subId : TelephonyUtils.getSubIdsWithFcmSupported(this)) {
|
||
|
+ for (int subId : subIds) {
|
||
|
if (!updateFcmToken(getFirebaseInstanceId(), subId)) {
|
||
|
wantsReschedule = true;
|
||
|
}
|