| 48 | } |
| 49 | |
| 50 | @NonNull |
| 51 | @Override |
| 52 | public Result doWork() { |
| 53 | Thread.currentThread().setPriority(THREAD_PRIORITY_BACKGROUND); |
| 54 | final Context context = getApplicationContext(); |
| 55 | |
| 56 | try { |
| 57 | semaphore.acquire(); |
| 58 | |
| 59 | EntityLog.log(context, EntityLog.Type.Rules, "Cloud sync execute"); |
| 60 | CloudSync.execute(context, "sync", false); |
| 61 | EntityLog.log(context, EntityLog.Type.Rules, "Cloud sync completed"); |
| 62 | |
| 63 | return Result.success(); |
| 64 | } catch (Throwable ex) { |
| 65 | Log.e(ex); |
| 66 | return Result.failure(); |
| 67 | } finally { |
| 68 | semaphore.release(); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | static void init(Context context) { |
| 73 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |