content: package androidx.legacy.content;
  
  import android.content.BroadcastReceiver;
  import android.content.ComponentName;
  import android.content.Context;
  import android.content.Intent;
  import android.os.PowerManager;
  import android.util.Log;
  import android.util.SparseArray;
  
  @Deprecated
  public abstract class WakefulBroadcastReceiver extends BroadcastReceiver {
      private static final String EXTRA_WAKE_LOCK_ID = "androidx.contentpager.content.wakelockid";
      private static int mNextId = 1;
      private static final SparseArray<PowerManager.WakeLock> sActiveWakeLocks = new SparseArray<>();
  
      public static boolean completeWakefulIntent(Intent intent) {
          int intExtra = intent.getIntExtra(EXTRA_WAKE_LOCK_ID, 0);
          if (intExtra == 0) {
              return false;
          }
          SparseArray<PowerManager.WakeLock> sparseArray = sActiveWakeLocks;
          synchronized (sparseArray) {
              PowerManager.WakeLock wakeLock = sparseArray.get(intExtra);
              if (wakeLock != null) {
                  wakeLock.release();
                  sparseArray.remove(intExtra);
                  return true;
              }
              Log.w("WakefulBroadcastReceiv.", "No active wake lock id #" + intExtra);
              return true;
          }
      }
  
      public static ComponentName startWakefulService(Context context, Intent intent) {
          SparseArray<PowerManager.WakeLock> sparseArray = sActiveWakeLocks;
          synchronized (sparseArray) {
              int i = mNextId;
              int i2 = i;
              int i3 = i + 1;
              mNextId = i3;
              if (i3 <= 0) {
                  mNextId = 1;
              }
              intent.putExtra(EXTRA_WAKE_LOCK_ID, i2);
              ComponentName startService = context.startService(intent);
              if (startService == null) {
                  return null;
              }
              PowerManager.WakeLock newWakeLock = ((PowerManager) context.getSystemService("power")).newWakeLock(1, "androidx.core:wake:" + startService.flattenToShortString());
              newWakeLock.setReferenceCounted(false);
              newWakeLock.acquire(60000);
              sparseArray.put(i2, newWakeLock);
              return startService;
          }
      }
  }
  