Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
jberkel committed Dec 4, 2017
1 parent 452b404 commit 0d67e4b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions app/src/main/java/com/zegoggles/smssync/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public void onCreate() {
preferences = new Preferences(this);
backupJobs = new BackupJobs(this);

if (!gcmAvailable) {
if (gcmAvailable) {
setIncomingSmsBroadcastReceiverEnabled(false);
} else {
Log.v(TAG, "Google Play Services not available, forcing use of old scheduler");
preferences.setUseOldScheduler(true);
} else {
setIncomingBroadcastReceiversEnabled(false);
}

K9MailLib.setDebugStatus(new K9MailLib.DebugStatus() {
Expand All @@ -74,15 +74,15 @@ public boolean debugSensitive() {
}
});

if (DEBUG) {
if (gcmAvailable && DEBUG) {
getContentResolver().registerContentObserver(Consts.SMS_PROVIDER, true, new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
onChange(selfChange, null);
}
@Override
public void onChange(boolean selfChange, Uri uri) {
Log.v(TAG, "onChange " + uri);
Log.v(TAG, "onChange: " + uri);
}
});
}
Expand All @@ -93,19 +93,18 @@ public void onChange(boolean selfChange, Uri uri) {
if (LOCAL_LOGV) {
Log.v(TAG, "autoBackupSettingsChanged("+event+")");
}
setIncomingBroadcastReceiversEnabled(preferences.isUseOldScheduler() && preferences.isEnableAutoSync());
setIncomingSmsBroadcastReceiverEnabled(preferences.isUseOldScheduler() && preferences.isEnableAutoSync());
rescheduleJobs();
}

private void setIncomingBroadcastReceiversEnabled(boolean enabled) {
private void setIncomingSmsBroadcastReceiverEnabled(boolean enabled) {
if (LOCAL_LOGV) {
Log.v(TAG, "setIncomingBroadcastReceiversEnabled("+enabled+")");
}
final ComponentName componentName = new ComponentName(this, SmsBroadcastReceiver.class);
final int flagEnabled = enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED;
// NB: changes made via setComponentEnabledSetting are persisted across reboots
getPackageManager().setComponentEnabledSetting(componentName,
flagEnabled,
getPackageManager().setComponentEnabledSetting(
new ComponentName(this, SmsBroadcastReceiver.class),
enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED,
DONT_KILL_APP /* apply setting without restart */);
}

Expand Down

0 comments on commit 0d67e4b

Please sign in to comment.