Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions app/src/main/java/com/dhangofa/networktoggle/BootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,20 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

public class BootReceiver extends BroadcastReceiver {

private static final String PREFS_NAME = "NetTogglePrefs";
private static final String STATE_KEY = "net_state";
private static final String AUTO_SIM_ERROR_KEY = "auto_sim_error";

private static final int STATE_UNKNOWN = 0;
import com.dhangofa.networktoggle.config.AppPreferences;

public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (context == null || intent == null) {
return;
}
if (context == null || intent == null) return;

String action = intent.getAction();

if (!Intent.ACTION_BOOT_COMPLETED.equals(action)
&& !Intent.ACTION_MY_PACKAGE_REPLACED.equals(action)) {
return;
}

SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);

prefs.edit()
.putInt(STATE_KEY, STATE_UNKNOWN)
.putBoolean(AUTO_SIM_ERROR_KEY, false)
.apply();
new AppPreferences(context).clearTransientState();
}
}
Loading
Loading