some more widget-related bullshit

This commit is contained in:
Andrew Dolgov 2017-05-30 12:51:18 +03:00
parent efb22befbd
commit bfaafc92cb

View File

@ -1,10 +1,13 @@
package org.fox.ttrss.widget;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.util.Log;
@ -39,6 +42,14 @@ public class WidgetUpdateService extends Service {
public void onStart(Intent intent, int startId) {
Log.d(TAG, "onStart");
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (pm.isDeviceIdleMode()) {
Log.d(TAG, "device in idle mode, bailing out");
return;
}
}
try {
sendResultIntent(-1, UPDATE_IN_PROGRESS);
@ -100,7 +111,7 @@ public class WidgetUpdateService extends Service {
@Override
protected void onLoginFailed(int requestId, ApiRequest ar) {
Log.d(TAG, "login failed: " + ar.getErrorMessage());
Log.d(TAG, "login failed: " + getString(ar.getErrorMessage()));
++m_updateFailures;
sendResultIntent(-1, UPDATE_RESULT_ERROR_LOGIN);