@@ -1077,7 +1077,8 @@ private void updateSearch(String search) {
1077
1077
1078
1078
private void checkDoze () {
1079
1079
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
1080
- if (Util .batteryOptimizing (this )) {
1080
+ final Intent doze = new Intent (Settings .ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS );
1081
+ if (Util .batteryOptimizing (this ) && getPackageManager ().resolveActivity (doze , 0 ) != null ) {
1081
1082
final SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences (this );
1082
1083
if (!prefs .getBoolean ("nodoze" , false )) {
1083
1084
LayoutInflater inflater = LayoutInflater .from (this );
@@ -1089,10 +1090,14 @@ private void checkDoze() {
1089
1090
.setPositiveButton (android .R .string .yes , new DialogInterface .OnClickListener () {
1090
1091
@ Override
1091
1092
public void onClick (DialogInterface dialog , int which ) {
1092
- prefs .edit ().putBoolean ("nodoze" , cbDontAsk .isChecked ()).apply ();
1093
- Intent i = new Intent (Settings .ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS )
1094
- .setData (Uri .parse ("package:" + getPackageName ()));
1095
- startActivityForResult (i , REQUEST_BATTERY_OPTIMIZATION );
1093
+ if (!Util .isPlayStoreInstall ()) {
1094
+ Intent i = new Intent (Settings .ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS )
1095
+ .setData (Uri .parse ("package:" + getPackageName ()));
1096
+ startActivityForResult (i , REQUEST_BATTERY_OPTIMIZATION );
1097
+ } else {
1098
+ startActivity (doze );
1099
+
1100
+ }
1096
1101
}
1097
1102
})
1098
1103
.setNegativeButton (android .R .string .no , new DialogInterface .OnClickListener () {
@@ -1106,7 +1111,8 @@ public void onClick(DialogInterface dialog, int which) {
1106
1111
@ Override
1107
1112
public void onDismiss (DialogInterface dialogInterface ) {
1108
1113
dialogDoze = null ;
1109
- //checkDataSaving();
1114
+ if (Util .isPlayStoreInstall ())
1115
+ checkDataSaving ();
1110
1116
}
1111
1117
})
1112
1118
.create ();
0 commit comments