|
29 | 29 | import android.text.TextUtils;
|
30 | 30 |
|
31 | 31 | import org.matrix.androidsdk.HomeServerConnectionConfig;
|
32 |
| -import org.matrix.androidsdk.rest.callback.SimpleApiCallback; |
33 |
| -import org.matrix.androidsdk.rest.client.PushersRestClient; |
34 |
| -import org.matrix.androidsdk.util.Log; |
35 |
| - |
36 | 32 | import org.matrix.androidsdk.MXSession;
|
37 | 33 | import org.matrix.androidsdk.data.Pusher;
|
38 | 34 | import org.matrix.androidsdk.listeners.IMXNetworkEventListener;
|
39 | 35 | import org.matrix.androidsdk.rest.callback.ApiCallback;
|
| 36 | +import org.matrix.androidsdk.rest.callback.SimpleApiCallback; |
| 37 | +import org.matrix.androidsdk.rest.client.PushersRestClient; |
40 | 38 | import org.matrix.androidsdk.rest.model.MatrixError;
|
41 | 39 | import org.matrix.androidsdk.rest.model.PushersResponse;
|
42 |
| - |
43 |
| -import im.vector.Matrix; |
44 |
| -import im.vector.R; |
45 |
| -import im.vector.activity.CommonActivityUtils; |
46 |
| -import im.vector.util.PreferencesManager; |
| 40 | +import org.matrix.androidsdk.util.Log; |
47 | 41 |
|
48 | 42 | import java.util.ArrayList;
|
49 | 43 | import java.util.HashMap;
|
|
52 | 46 | import java.util.Timer;
|
53 | 47 | import java.util.TimerTask;
|
54 | 48 |
|
| 49 | +import im.vector.Matrix; |
| 50 | +import im.vector.R; |
| 51 | +import im.vector.activity.CommonActivityUtils; |
| 52 | +import im.vector.util.PreferencesManager; |
| 53 | + |
55 | 54 | /**
|
56 | 55 | * Helper class to store the GCM registration ID in {@link SharedPreferences}
|
57 | 56 | */
|
@@ -1128,12 +1127,9 @@ public NotificationPrivacy getNotificationPrivacy() {
|
1128 | 1127 | boolean isContentSendingAllowed = isContentSendingAllowed();
|
1129 | 1128 | boolean isBackgroundSyncAllowed = isBackgroundSyncAllowed();
|
1130 | 1129 |
|
1131 |
| - if (isContentSendingAllowed && !isBackgroundSyncAllowed) |
1132 |
| - { |
| 1130 | + if (isContentSendingAllowed && !isBackgroundSyncAllowed) { |
1133 | 1131 | notificationPrivacy = NotificationPrivacy.REDUCED;
|
1134 |
| - } |
1135 |
| - else if (!isContentSendingAllowed && isBackgroundSyncAllowed) |
1136 |
| - { |
| 1132 | + } else if (!isContentSendingAllowed && isBackgroundSyncAllowed) { |
1137 | 1133 | notificationPrivacy = NotificationPrivacy.NORMAL;
|
1138 | 1134 | }
|
1139 | 1135 |
|
@@ -1218,10 +1214,10 @@ public void setScreenTurnedOn(boolean flag) {
|
1218 | 1214 | * @return true if the background sync is allowed
|
1219 | 1215 | */
|
1220 | 1216 | public boolean isBackgroundSyncAllowed() {
|
1221 |
| - // first check if the application has the "run in background" permission. |
| 1217 | + // If using GCM, first check if the application has the "run in background" permission. |
1222 | 1218 | // No permission, no background sync
|
1223 |
| - if (!PreferencesManager.isIgnoringBatteryOptimizations(mContext)) |
1224 |
| - { |
| 1219 | + if (hasRegistrationToken() |
| 1220 | + && !PreferencesManager.isIgnoringBatteryOptimizations(mContext)) { |
1225 | 1221 | return false;
|
1226 | 1222 | }
|
1227 | 1223 |
|
|
0 commit comments