mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-30 15:13:02 +00:00
Start TriggerReceiver service from GServicesProvider
This commit is contained in:
parent
c28376543f
commit
41e4c8c1af
3 changed files with 12 additions and 11 deletions
|
@ -18,7 +18,6 @@ import java.io.File;
|
|||
|
||||
public class CheckinPrefs implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public static final String PREF_ENABLE_CHECKIN = "checkin_enable_service";
|
||||
public static final String START_PREF_ENABLE_CHECKIN = "start_checkin_enable_service";
|
||||
private static CheckinPrefs INSTANCE;
|
||||
|
||||
public static CheckinPrefs get(Context context) {
|
||||
|
@ -69,15 +68,7 @@ public class CheckinPrefs implements SharedPreferences.OnSharedPreferenceChangeL
|
|||
}
|
||||
|
||||
public static void setEnabled(Context context, boolean newStatus) {
|
||||
boolean changed = false;
|
||||
if (!PreferenceManager.getDefaultSharedPreferences(context).getBoolean(START_PREF_ENABLE_CHECKIN, true)) {
|
||||
changed = CheckinPrefs.get(context).isEnabled() != newStatus;
|
||||
} else {
|
||||
if (CheckinPrefs.get(context).isEnabled()) {
|
||||
changed = true;
|
||||
}
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(START_PREF_ENABLE_CHECKIN, false).apply();
|
||||
}
|
||||
boolean changed = CheckinPrefs.get(context).isEnabled() != newStatus;
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(PREF_ENABLE_CHECKIN, newStatus).apply();
|
||||
if (!changed) return;
|
||||
if (newStatus) {
|
||||
|
|
|
@ -36,7 +36,6 @@ public class GcmPrefs implements SharedPreferences.OnSharedPreferenceChangeListe
|
|||
public static final String PREF_FULL_LOG = "gcm_full_log";
|
||||
public static final String PREF_LAST_PERSISTENT_ID = "gcm_last_persistent_id";
|
||||
public static final String PREF_CONFIRM_NEW_APPS = "gcm_confirm_new_apps";
|
||||
public static final String START_PREF_ENABLE_GCM = "start_gcm_enable_mcs_service";
|
||||
public static final String PREF_ENABLE_GCM = "gcm_enable_mcs_service";
|
||||
|
||||
public static final String PREF_NETWORK_MOBILE = "gcm_network_mobile";
|
||||
|
|
|
@ -18,12 +18,16 @@ package org.microg.gms.gservices;
|
|||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import org.microg.gms.checkin.CheckinPrefs;
|
||||
import org.microg.gms.gcm.GcmPrefs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -52,6 +56,13 @@ public class GServicesProvider extends ContentProvider {
|
|||
@Override
|
||||
public boolean onCreate() {
|
||||
databaseHelper = new DatabaseHelper(getContext());
|
||||
if (CheckinPrefs.get(getContext()).isEnabled()) {
|
||||
getContext().sendOrderedBroadcast(new Intent(getContext(), org.microg.gms.checkin.TriggerReceiver.class), null);
|
||||
}
|
||||
if (GcmPrefs.get(getContext()).isEnabled()) {
|
||||
getContext().sendBroadcast(new Intent(org.microg.gms.gcm.TriggerReceiver.FORCE_TRY_RECONNECT, null, getContext(), org.microg.gms.gcm.TriggerReceiver.class));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue