Skip to content

Commit 814a594

Browse files
committed
fix dozing dialog issue
1 parent 84eee81 commit 814a594

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

app/src/main/java/eu/faircode/netguard/ActivityMain.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ protected void onActivityResult(int requestCode, int resultCode, final Intent da
574574
} else if (requestCode == REQUEST_BATTERY_OPTIMIZATION) {
575575
if (resultCode != RESULT_OK)
576576
checkDoze();
577+
else
578+
checkDataSaving();
577579

578580
} else {
579581
Log.w(TAG, "Unknown activity result request=" + requestCode);
@@ -1075,8 +1077,7 @@ private void updateSearch(String search) {
10751077

10761078
private void checkDoze() {
10771079
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
1078-
final Intent doze = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
1079-
if (Util.batteryOptimizing(this) && getPackageManager().resolveActivity(doze, 0) != null) {
1080+
if (Util.batteryOptimizing(this)) {
10801081
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
10811082
if (!prefs.getBoolean("nodoze", false)) {
10821083
LayoutInflater inflater = LayoutInflater.from(this);
@@ -1089,25 +1090,23 @@ private void checkDoze() {
10891090
@Override
10901091
public void onClick(DialogInterface dialog, int which) {
10911092
prefs.edit().putBoolean("nodoze", cbDontAsk.isChecked()).apply();
1092-
if (!Util.isPlayStoreInstall()) {
1093-
Intent i = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
1094-
.setData(Uri.parse("package:" + getPackageName()));
1095-
startActivityForResult(i, REQUEST_BATTERY_OPTIMIZATION);
1096-
} else
1097-
startActivity(doze);
1093+
Intent i = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
1094+
.setData(Uri.parse("package:" + getPackageName()));
1095+
startActivityForResult(i, REQUEST_BATTERY_OPTIMIZATION);
10981096
}
10991097
})
11001098
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
11011099
@Override
11021100
public void onClick(DialogInterface dialog, int which) {
11031101
prefs.edit().putBoolean("nodoze", cbDontAsk.isChecked()).apply();
1102+
checkDataSaving();
11041103
}
11051104
})
11061105
.setOnDismissListener(new DialogInterface.OnDismissListener() {
11071106
@Override
11081107
public void onDismiss(DialogInterface dialogInterface) {
11091108
dialogDoze = null;
1110-
checkDataSaving();
1109+
//checkDataSaving();
11111110
}
11121111
})
11131112
.create();

0 commit comments

Comments
 (0)