コード例 #1
0
ファイル: AndroidMqttPinger.java プロジェクト: salgol/lasso
 @TargetApi(Build.VERSION_CODES.KITKAT)
 @Override
 public void reset() {
   if (!isActive()) {
     Log.d(TAG, "Can't reset pinger because it is not active");
     return;
   }
   alarmMgr.cancel(pingerPendingIntent);
   Log.d(
       TAG,
       "Setting next keep alive to trigger in "
           + (Constants.KEEPALIVE_INTERVAL - 3000) / 1000
           + " seconds");
   Intent pingerIntent = new Intent(Constants.KEEPALIVE_INTENT_FILTER);
   pingerIntent.putExtra("device", instanceId);
   pingerPendingIntent = PendingIntent.getBroadcast(context, 61, pingerIntent, 0);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
     alarmMgr.setExact(
         AlarmManager.RTC_WAKEUP,
         System.currentTimeMillis() + keepAliveInterval - 3000,
         pingerPendingIntent);
   } else {
     alarmMgr.set(
         AlarmManager.RTC_WAKEUP,
         System.currentTimeMillis() + keepAliveInterval - 3000,
         pingerPendingIntent);
   }
 }
コード例 #2
0
 private static void scheduleWarning(
     Calendar calendar, PendingIntent pIntent, AlarmManager alarmManager) {
   Log.d("WarningAlarmManager", "Scheduling for " + calendar);
   if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
     alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent);
   } else {
     alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent);
   }
 }
コード例 #3
0
ファイル: AlarmUtils.java プロジェクト: ILIYANGERMANOV/Notes
 @TargetApi(Build.VERSION_CODES.KITKAT)
 private static void setAlarm19(
     AlarmManager alarmManager, long when, PendingIntent pendingIntent) {
   alarmManager.setExact(
       AlarmManager.RTC_WAKEUP,
       when,
       pendingIntent); // RTC_WAKEUP so ReminderService will be executed even when the phone fell
   // asleep
   // using RTC, cuz it measures elapsed time using clock, not like ELAPSED_REAL_TIME which
   // measures the time after the device has booted
 }
コード例 #4
0
  @SuppressLint("NewApi")
  public void setAlarm(Context context, long intervalMillis) {
    alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(context, AlarmReceiver.class);
    alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);

    if (Build.VERSION.SDK_INT < 19) {
      alarmMgr.set(
          AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + intervalMillis, alarmIntent);
    } else {
      alarmMgr.setExact(
          AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + intervalMillis, alarmIntent);
    }
  }
コード例 #5
0
  private void scheduleFutureNotification(MPCloudNotificationMessage message) {
    AlarmManager alarmService = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

    Intent intent = new Intent(MPService.INTERNAL_DELAYED_RECEIVE);
    intent.setClass(this, MPService.class);
    intent.putExtra(MPMessagingAPI.CLOUD_MESSAGE_EXTRA, message);

    PendingIntent pIntent =
        PendingIntent.getService(this, message.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      alarmService.setExact(AlarmManager.RTC, message.getDeliveryTime(), pIntent);
    } else {
      alarmService.set(AlarmManager.RTC, message.getDeliveryTime(), pIntent);
    }
  }
コード例 #6
0
  private static void addAlarm(Reminder reminder) {
    Context context = App.context;
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    Intent intent = new Intent(context, AlarmReceiver.class);
    intent.putExtra("reminder", reminder);

    PendingIntent pendingIntent =
        PendingIntent.getBroadcast(
            context, reminder.getVocabularyId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
      alarmManager.set(AlarmManager.RTC_WAKEUP, reminder.getTime().getTime(), pendingIntent);
    } else {
      alarmManager.setExact(AlarmManager.RTC_WAKEUP, reminder.getTime().getTime(), pendingIntent);
    }
  }
コード例 #7
0
ファイル: PollReceiver.java プロジェクト: CRSingh/cw-omnibus
  static void scheduleExactAlarm(
      Context ctxt, AlarmManager alarms, long period, boolean isDownload) {
    Intent i =
        buildBaseIntent(ctxt)
            .putExtra(EXTRA_PERIOD, period)
            .putExtra(EXTRA_IS_DOWNLOAD, isDownload);
    PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
      Log.e("PollReceiver", "allow while idle");
      alarms.setAndAllowWhileIdle(
          AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + period, pi);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      alarms.setExact(
          AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + period, pi);
    } else {
      alarms.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + period, pi);
    }
  }
コード例 #8
0
    @Override
    public void scheduleInstanceStateChange(
        Context context, Calendar time, AlarmInstance instance, int newState) {
      final long timeInMillis = time.getTimeInMillis();
      LogUtils.v(
          "Scheduling state change %d to instance %d at %s (%d)",
          newState, instance.mId, AlarmUtils.getFormattedTime(context, time), timeInMillis);
      final Intent stateChangeIntent =
          createStateChangeIntent(context, ALARM_MANAGER_TAG, instance, newState);
      // Treat alarm state change as high priority, use foreground broadcasts
      stateChangeIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
      PendingIntent pendingIntent =
          PendingIntent.getBroadcast(
              context, instance.hashCode(), stateChangeIntent, PendingIntent.FLAG_UPDATE_CURRENT);

      final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
      if (Utils.isKitKatOrLater()) {
        am.setExact(AlarmManager.RTC_WAKEUP, timeInMillis, pendingIntent);
      } else {
        am.set(AlarmManager.RTC_WAKEUP, timeInMillis, pendingIntent);
      }
    }
コード例 #9
0
  public static void schedule(Context context, long interval) {
    ComponentName receiver = new ComponentName(context, SyncBroadcastReceiver.class);
    PackageManager pm = context.getPackageManager();
    pm.setComponentEnabledSetting(
        receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

    AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(context, SyncBroadcastReceiver.class);
    PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
      alarmMgr.setExact(
          AlarmManager.ELAPSED_REALTIME_WAKEUP,
          SystemClock.elapsedRealtime() + interval,
          alarmIntent);
    } else {
      alarmMgr.setExactAndAllowWhileIdle(
          AlarmManager.ELAPSED_REALTIME_WAKEUP,
          SystemClock.elapsedRealtime() + interval,
          alarmIntent);
    }

    Log.d("DexcomShareDashclock", "Sync scheduled in " + (int) (interval / 60000) + " minutes");
  }
コード例 #10
0
  /**
   * Registers a system alarm for the start date of the task.
   *
   * @param context A Context.
   * @param taskId The row id of the task to set an alarm for.
   * @param startTime The date in milliseconds when the task starts.
   * @param taskTitle The title of the task.
   */
  @TargetApi(19)
  public static void setStartAlarm(Context context, long taskId, long startTime, String taskTitle) {
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intentAlarm = new Intent(context, StartAlarmBroadcastHandler.class);
    intentAlarm.putExtra(EXTRA_TASK_ID, taskId);
    intentAlarm.putExtra(EXTRA_TASK_START_TIME, startTime);
    intentAlarm.putExtra(EXTRA_TASK_TITLE, taskTitle);
    PendingIntent pendingIntent =
        PendingIntent.getBroadcast(
            context, REQUEST_CODE_START_ALARM, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT);

    // cancel old
    am.cancel(
        PendingIntent.getBroadcast(
            context, REQUEST_CODE_START_ALARM, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT));

    // AlarmManager API changed in v19 (KitKat) and the "set" method is not called at the exact time
    // anymore
    if (Build.VERSION.SDK_INT > 18) {
      am.setExact(AlarmManager.RTC_WAKEUP, startTime, pendingIntent);
    } else {
      am.set(AlarmManager.RTC_WAKEUP, startTime, pendingIntent);
    }
  }
コード例 #11
0
  @TargetApi(android.os.Build.VERSION_CODES.KITKAT)
  @Override
  protected void onHandleIntent(Intent intent) {
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    /*
     * Handle a possible delete intent.
     */
    if (handleDeleteIntent(this, intent)) {
      return;
    }

    /*
     * Unschedule notification service wake-ups for disabled notifications
     * and non-supporters.
     */
    if (!NotificationSettings.isNotificationsEnabled(this) || !Utils.hasAccessToX(this)) {
      // cancel any pending alarm
      AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
      Intent i = new Intent(this, OnAlarmReceiver.class);
      PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
      am.cancel(pi);

      resetLastEpisodeAirtime(prefs);

      return;
    }

    long wakeUpTime = 0;

    /*
     * Get pool of episodes which air from 12 hours ago until eternity which
     * match the users settings.
     */
    StringBuilder selection = new StringBuilder(SELECTION);
    final long fakeNow = Utils.getFakeCurrentTime(prefs);
    boolean isFavsOnly = NotificationSettings.isNotifyAboutFavoritesOnly(this);
    if (isFavsOnly) {
      selection.append(Shows.SELECTION_FAVORITES);
    }
    boolean isNoSpecials = DisplaySettings.isHidingSpecials(this);
    if (isNoSpecials) {
      selection.append(Episodes.SELECTION_NOSPECIALS);
    }
    final Cursor upcomingEpisodes =
        getContentResolver()
            .query(
                Episodes.CONTENT_URI_WITHSHOW,
                PROJECTION,
                selection.toString(),
                new String[] {String.valueOf(fakeNow - 12 * DateUtils.HOUR_IN_MILLIS)},
                SORTING);

    if (upcomingEpisodes != null) {
      int notificationThreshold = NotificationSettings.getLatestToIncludeTreshold(this);
      if (DEBUG) {
        // a week, for debugging (use only one show to get single
        // episode notifications)
        notificationThreshold = 10080;
        // notify again for same episodes
        resetLastEpisodeAirtime(prefs);
      }
      final long latestTimeToInclude = fakeNow + DateUtils.MINUTE_IN_MILLIS * notificationThreshold;
      final long nextTimePlanned = NotificationSettings.getNextToNotifyAbout(this);
      final long nextWakeUpPlanned =
          Utils.convertToFakeTime(nextTimePlanned, prefs, false)
              - DateUtils.MINUTE_IN_MILLIS * notificationThreshold;

      /*
       * Set to -1 as on first run nextTimePlanned will be 0. This assures
       * we still see notifications of upcoming episodes then.
       */
      int newEpisodesAvailable = -1;

      // Check if we did wake up earlier than planned
      if (System.currentTimeMillis() < nextWakeUpPlanned) {
        newEpisodesAvailable = 0;
        long latestTimeNotified = NotificationSettings.getLastNotified(this);

        // Check if there are any earlier episodes to notify about
        while (upcomingEpisodes.moveToNext()) {
          final long airtime = upcomingEpisodes.getLong(NotificationQuery.FIRSTAIREDMS);
          if (airtime < nextTimePlanned) {
            if (airtime > latestTimeNotified) {
              /**
               * This will not get new episodes which would have aired the same time as the last one
               * we notified about. Sad, but the best we can do right now.
               */
              newEpisodesAvailable = 1;
              break;
            }
          } else {
            break;
          }
        }
      }

      if (newEpisodesAvailable == 0) {
        // Go to sleep, wake up as planned
        wakeUpTime = nextWakeUpPlanned;
      } else {
        // Get episodes which are within the notification threshold
        // (user set) and not yet cleared
        int count = 0;
        final List<Integer> notifyPositions = Lists.newArrayList();
        final long latestTimeCleared = NotificationSettings.getLastCleared(this);

        upcomingEpisodes.moveToPosition(-1);
        while (upcomingEpisodes.moveToNext()) {
          final long airtime = upcomingEpisodes.getLong(NotificationQuery.FIRSTAIREDMS);
          if (airtime <= latestTimeToInclude) {
            count++;
            /*
             * Only add those after the last one the user cleared.
             * At most those of the last 24 hours (see query above).
             */
            if (airtime > latestTimeCleared) {
              notifyPositions.add(count);
            }
          } else {
            // Too far into the future, stop!
            break;
          }
        }

        // Notify if we found any episodes
        if (notifyPositions.size() > 0) {
          // store latest air time of all episodes we notified about
          upcomingEpisodes.moveToPosition(notifyPositions.get(notifyPositions.size() - 1));
          long latestAirtime = upcomingEpisodes.getLong(NotificationQuery.FIRSTAIREDMS);
          if (!AndroidUtils.isHoneycombOrHigher()) {
            /*
             * Everything below HC does not have delete intents, so
             * we just never notify about the same episode twice.
             */
            prefs.edit().putLong(NotificationSettings.KEY_LAST_CLEARED, latestAirtime).commit();
          }
          prefs.edit().putLong(NotificationSettings.KEY_LAST_NOTIFIED, latestAirtime).commit();

          onNotify(prefs, upcomingEpisodes, count, latestAirtime);
        }

        /*
         * Plan next episode to notify about, calc wake-up alarm as
         * early as user wants.
         */
        upcomingEpisodes.moveToPosition(-1);
        while (upcomingEpisodes.moveToNext()) {
          final long airtime = upcomingEpisodes.getLong(NotificationQuery.FIRSTAIREDMS);
          if (airtime > latestTimeToInclude) {
            // store next episode we plan to notify about
            prefs.edit().putLong(NotificationSettings.KEY_NEXT_TO_NOTIFY, airtime).commit();

            // convert it to actual device time for setting the
            // alarm
            wakeUpTime =
                Utils.convertToFakeTime(airtime, prefs, false)
                    - DateUtils.MINUTE_IN_MILLIS * notificationThreshold;

            break;
          }
        }
      }

      upcomingEpisodes.close();
    }

    // Set a default wake-up time if there are no future episodes for now
    if (wakeUpTime <= 0) {
      wakeUpTime = System.currentTimeMillis() + 6 * DateUtils.HOUR_IN_MILLIS;
    }

    AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Intent i = new Intent(this, NotificationService.class);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    if (AndroidUtils.isKitKatOrHigher()) {
      am.setExact(AlarmManager.RTC_WAKEUP, wakeUpTime, pi);
    } else {
      am.set(AlarmManager.RTC_WAKEUP, wakeUpTime, pi);
    }
  }
コード例 #12
0
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {

    // GET SETTINGS FROM SHARED PREFERENCES
    SharedPreferences settingsF = getSharedPreferences(FUZZY_STUFF, 0);
    int backgroundColorF =
        settingsF.getInt("BackgroundColorF", this.getResources().getColor(R.color.palesky));
    int textColorF = settingsF.getInt("TextColorF", this.getResources().getColor(R.color.night));
    String packageName = settingsF.getString("PackageName", "com.android.alarmclock");
    String className = settingsF.getString("ClassName", "com.android.alarmclock.AlarmClock");

    // CALCULATE ALL THE TIME DEPENDENT VARIABLES

    // reset the time dependent addition
    long alarmAddMillis = 0;

    // get time instance and values
    Calendar rightNow = Calendar.getInstance();
    int thisMin = rightNow.get(Calendar.MINUTE);
    int thisHour = rightNow.get(Calendar.HOUR);

    // set correct hour values
    nextHour = thisHour + 1;
    if (thisHour == 0) {
      thisHour = 12;
    }
    if (nextHour == 13) {
      nextHour = 1;
    }

    // set text values based on minutes
    if (thisMin >= 0 && thisMin <= 7) {
      wordA = "its";
      wordB = "about";
      wordA_B = "its_about";
      clockH = thisHour;
      nextAlarmMin = 8;
      alarmAddMillis = 0;
    }
    if (thisMin >= 8 && thisMin <= 22) {
      wordA = "quarter";
      wordB = "past";
      wordA_B = "quarter_past";
      clockH = thisHour;
      nextAlarmMin = 23;
      alarmAddMillis = 0;
    }
    if (thisMin >= 23 && thisMin <= 37) {
      wordA = "half";
      wordB = "past";
      wordA_B = "half_past";
      clockH = thisHour;
      nextAlarmMin = 38;
      alarmAddMillis = 0;
    }
    if (thisMin >= 38 && thisMin <= 52) {
      wordA = "quarter";
      wordB = "to";
      wordA_B = "quarter_to";
      clockH = nextHour;
      nextAlarmMin = 53;
      alarmAddMillis = 0;
    }
    if (thisMin >= 53 && thisMin <= 59) {
      wordA = "its";
      wordB = "about";
      wordA_B = "its_about";
      clockH = nextHour;
      nextAlarmMin = 8;
      alarmAddMillis = 3600000;
    }

    // CANCEL ANY UNSENT ALARM
    if (alarmManager != null) {
      alarmManager.cancel(pendingIntent);
    }

    // SET UP THE NEXT ALARM

    // set the time
    Calendar nextAlarm = Calendar.getInstance();
    // add one hour of millis if its for the next hour
    nextAlarm.setTimeInMillis(System.currentTimeMillis() + alarmAddMillis);
    // set the correct minute
    nextAlarm.set(Calendar.MINUTE, nextAlarmMin);
    nextAlarm.set(Calendar.SECOND, 15);
    nextAlarm.set(Calendar.MILLISECOND, 0);

    // request the alarm
    alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Intent usIntent = new Intent(this, AlarmReceiver.class);
    pendingIntent = PendingIntent.getBroadcast(this, 0, usIntent, 0);
    // use onExact for API19+
    int currentApiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentApiVersion <= 18) {
      alarmManager.set(AlarmManager.RTC, nextAlarm.getTimeInMillis(), pendingIntent);
    } else {
      alarmManager.setExact(AlarmManager.RTC, nextAlarm.getTimeInMillis(), pendingIntent);
    }

    // SET UP THE IMAGES

    // get the resource id ints for images to send by remoteviews
    int timePhraseA =
        this.getResources().getIdentifier("phr_" + wordA, "drawable", this.getPackageName());
    int timePhraseB =
        this.getResources().getIdentifier("phr_" + wordB, "drawable", this.getPackageName());
    int timePhraseA_B =
        this.getResources().getIdentifier("phr_" + wordA_B, "drawable", this.getPackageName());
    int hourWordImageCrop =
        this.getResources().getIdentifier("num_" + clockH, "drawable", this.getPackageName());
    int hourWordImageWide =
        this.getResources()
            .getIdentifier("num_" + clockH + "_w", "drawable", this.getPackageName());

    // SET THE BITMAP COLOR AND OTHER VALUES
    fillPaintF = new Paint(Paint.FILTER_BITMAP_FLAG);
    fillPaintF.setColor(textColorF);
    fillPaintF.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPurgeable = true;
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;

    // ASSEMBLE THE PENDING INTENTS

    // create the open configuration pending intent
    Intent openAWC = new Intent(this, AppWidgetConfigure.class);
    openAWC.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent openAwcPi =
        PendingIntent.getActivity(this, 0, openAWC, PendingIntent.FLAG_UPDATE_CURRENT);

    // create the open alarms pending intent - done here because it couldnt be saved in prefs
    // set up open Alarms Intent
    PendingIntent alarmPI = null;
    PackageManager packageManager = this.getPackageManager();
    Intent alarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);
    // get the activity info and attach to the intent
    try {
      ComponentName cn = new ComponentName(packageName, className);
      packageManager.getActivityInfo(cn, PackageManager.GET_META_DATA);
      alarmClockIntent.setComponent(cn);
    } catch (PackageManager.NameNotFoundException e) {
      stopSelf();
    }
    // finalize the pending intent
    alarmPI = PendingIntent.getActivity(this, 0, alarmClockIntent, 0);

    // create the refresh widget pending intent
    Intent startUpdateF = new Intent(this, UpdateService.class);
    startUpdateF.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    pendingStartUpdateF =
        PendingIntent.getService(this, 0, startUpdateF, PendingIntent.FLAG_UPDATE_CURRENT);

    // **** BACKGROUND IMAGE PREPARATION ****

    // draw an empty image
    bitmapBackgroundF = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
    // paint in the color
    Canvas canvasBackgroundF = new Canvas(bitmapBackgroundF);
    fillPaintBackgroundF = new Paint();
    fillPaintBackgroundF.setColor(backgroundColorF);
    canvasBackgroundF.drawPaint(fillPaintBackgroundF);

    // SEND ALL THE STUFF TO THE PLACED WIDGETS

    // get appwidgetmanager instance for all widgets
    AppWidgetManager localAppWidgetManager = AppWidgetManager.getInstance(this);

    // update all 4x1 widget instances
    ComponentName thisWidget4x1 = new ComponentName(getBaseContext(), WidgetProvider4x1.class);
    int[] allWidgetIds4x1 = localAppWidgetManager.getAppWidgetIds(thisWidget4x1);
    if (allWidgetIds4x1 != null) {

      // join the images together into one strip
      Bitmap bitmap4x1partA = BitmapFactory.decodeResource(getResources(), timePhraseA, options);
      Bitmap bitmap4x1partB = BitmapFactory.decodeResource(getResources(), timePhraseB, options);
      Bitmap bitmap4x1partC =
          BitmapFactory.decodeResource(getResources(), hourWordImageCrop, options);

      Bitmap bitmap4x1strip =
          Bitmap.createBitmap(
              bitmap4x1partA.getWidth() + bitmap4x1partB.getWidth() + bitmap4x1partC.getWidth(),
              bitmap4x1partA.getHeight(),
              Bitmap.Config.ARGB_8888);
      Canvas canvas4x1strip = new Canvas(bitmap4x1strip);
      canvas4x1strip.drawBitmap(bitmap4x1partA, 0, 0, null);
      canvas4x1strip.drawBitmap(bitmap4x1partB, bitmap4x1partA.getWidth(), 0, null);
      canvas4x1strip.drawBitmap(
          bitmap4x1partC, bitmap4x1partA.getWidth() + bitmap4x1partB.getWidth(), 0, null);

      // generate adjusted images if color theme isnt default

      // strip
      Bitmap bitmap4x1strip2 = bitmap4x1strip.copy(Bitmap.Config.ARGB_8888, true);
      Canvas canvas4x1strip2 = new Canvas(bitmap4x1strip2);
      canvas4x1strip2.drawPaint(fillPaintF);

      for (int widgetId : allWidgetIds4x1) {
        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widget_layout_4x1);
        remoteViews.setImageViewBitmap(R.id.imageviewBG, bitmapBackgroundF);
        remoteViews.setImageViewBitmap(R.id.imageviewABC, bitmap4x1strip2);
        remoteViews.setOnClickPendingIntent(R.id.topclickLeft, alarmPI);
        remoteViews.setOnClickPendingIntent(R.id.topclickRight, openAwcPi);
        localAppWidgetManager.updateAppWidget(widgetId, remoteViews);
      }
      bitmap4x1strip2 = null;
      canvas4x1strip2 = null;
      bitmap4x1strip = null;
      canvas4x1strip = null;
    }

    // update all 3x2 widget instances
    ComponentName thisWidget3x2 = new ComponentName(getBaseContext(), WidgetProvider3x2.class);
    int[] allWidgetIds3x2 = localAppWidgetManager.getAppWidgetIds(thisWidget3x2);
    if (allWidgetIds3x2 != null) {
      // generate adjusted images if color theme isnt default
      // time phrase
      if (bitmapTimePhraseA_B == null) {
        bitmapTimePhraseA_B1 = BitmapFactory.decodeResource(getResources(), timePhraseA_B, options);
        bitmapTimePhraseA_B = bitmapTimePhraseA_B1.copy(Bitmap.Config.ARGB_8888, true);
        canvasPhrase = new Canvas(bitmapTimePhraseA_B);
        canvasPhrase.drawPaint(fillPaintF);
      }
      // hour word
      if (bitmapHourWordImage == null) {
        bitmapHourWordImage1 =
            BitmapFactory.decodeResource(getResources(), hourWordImageWide, options);
        bitmapHourWordImage = bitmapHourWordImage1.copy(Bitmap.Config.ARGB_8888, true);
        canvasHour = new Canvas(bitmapHourWordImage);
        canvasHour.drawPaint(fillPaintF);
      }
      for (int widgetId : allWidgetIds3x2) {
        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widget_layout_3x2);
        remoteViews.setImageViewBitmap(R.id.imageviewA_B, bitmapTimePhraseA_B);
        remoteViews.setImageViewBitmap(R.id.imageviewC, bitmapHourWordImage);
        remoteViews.setImageViewBitmap(R.id.imageviewBG, bitmapBackgroundF);
        remoteViews.setOnClickPendingIntent(R.id.topclickLeft, alarmPI);
        remoteViews.setOnClickPendingIntent(R.id.topclickRight, openAwcPi);
        localAppWidgetManager.updateAppWidget(widgetId, remoteViews);
      }
    }

    // CLEAR ALL THE BITMAPS
    bitmapTimePhraseA_B = null;
    bitmapTimePhraseA_B1 = null;
    bitmapHourWordImageCrop = null;
    bitmapHourWordImageCrop1 = null;
    bitmapHourWordImage = null;
    bitmapHourWordImage1 = null;
    canvasPhrase = null;
    canvasHour = null;
    bitmapBackgroundF = null;

    stopSelf();
    return super.onStartCommand(intent, flags, startId);
  }