@Test public void testCancelAlarm() { OneTimeWorkRequest work = new OneTimeWorkRequest.Builder(TestWorker.class).build(); insertWork(work); String workSpecId = work.getStringId(); SystemIdInfo systemIdInfo = new SystemIdInfo(workSpecId, 1); mDatabase.systemIdInfoDao().insertSystemIdInfo(systemIdInfo); Alarms.cancelAlarm(mContext, mWorkManager, workSpecId); SystemIdInfo updatedSystemIdInfo = mDatabase.systemIdInfoDao().getSystemIdInfo(workSpecId); assertThat(updatedSystemIdInfo, is(nullValue())); }
public static void cancelAlarm( @NonNull Context context, @NonNull WorkManagerImpl workManager, @NonNull String workSpecId) { WorkDatabase workDatabase = workManager.getWorkDatabase(); SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao(); SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workSpecId); if (systemIdInfo != null) { cancelExactAlarm(context, workSpecId, systemIdInfo.systemId); Log.d(TAG, String.format("Removing SystemIdInfo for workSpecId (%s)", workSpecId)); systemIdInfoDao.removeSystemIdInfo(workSpecId); } }
Alarms { public static void cancelAlarm( @NonNull Context context, @NonNull WorkManagerImpl workManager, @NonNull String workSpecId) { WorkDatabase workDatabase = workManager.getWorkDatabase(); SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao(); SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workSpecId); if (systemIdInfo != null) { cancelExactAlarm(context, workSpecId, systemIdInfo.systemId); Log.d(TAG, String.format("Removing SystemIdInfo for workSpecId (%s)", workSpecId)); systemIdInfoDao.removeSystemIdInfo(workSpecId); } } }
Alarms { public static void cancelAlarm( @NonNull Context context, @NonNull WorkManagerImpl workManager, @NonNull String workSpecId) { WorkDatabase workDatabase = workManager.getWorkDatabase(); SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao(); SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workSpecId); if (systemIdInfo != null) { cancelExactAlarm(context, workSpecId, systemIdInfo.systemId); Log.d(TAG, String.format("Removing SystemIdInfo for workSpecId (%s)", workSpecId)); systemIdInfoDao.removeSystemIdInfo(workSpecId); } } private  Alarms(); }
Alarms { public static void cancelAlarm( @NonNull Context context, @NonNull WorkManagerImpl workManager, @NonNull String workSpecId) { WorkDatabase workDatabase = workManager.getWorkDatabase(); SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao(); SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workSpecId); if (systemIdInfo != null) { cancelExactAlarm(context, workSpecId, systemIdInfo.systemId); Log.d(TAG, String.format("Removing SystemIdInfo for workSpecId (%s)", workSpecId)); systemIdInfoDao.removeSystemIdInfo(workSpecId); } } private  Alarms(); static void setAlarm(
            @NonNull Context context,
            @NonNull WorkManagerImpl workManager,
            @NonNull String workSpecId,
            long triggerAtMillis); static void cancelAlarm(
            @NonNull Context context,
            @NonNull WorkManagerImpl workManager,
            @NonNull String workSpecId); }
Alarms { public static void cancelAlarm( @NonNull Context context, @NonNull WorkManagerImpl workManager, @NonNull String workSpecId) { WorkDatabase workDatabase = workManager.getWorkDatabase(); SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao(); SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workSpecId); if (systemIdInfo != null) { cancelExactAlarm(context, workSpecId, systemIdInfo.systemId); Log.d(TAG, String.format("Removing SystemIdInfo for workSpecId (%s)", workSpecId)); systemIdInfoDao.removeSystemIdInfo(workSpecId); } } private  Alarms(); static void setAlarm(
            @NonNull Context context,
            @NonNull WorkManagerImpl workManager,
            @NonNull String workSpecId,
            long triggerAtMillis); static void cancelAlarm(
            @NonNull Context context,
            @NonNull WorkManagerImpl workManager,
            @NonNull String workSpecId);  }