Пример #1
0
 @Override
 public void onReceive(Context context, Intent intent) {
   if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
     mScreenOn = true;
     reportVisibility();
   } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
     mScreenOn = false;
     reportVisibility();
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   if (ACTION_TURN_FLASHLIGHT_OFF.equals(intent.getAction())) {
     mHandler.post(mKillFlashlightRunnable);
   } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction()) && disableOnScreenOff()) {
     disableTorchOnScreenOff();
   } else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
     setNotificationShown(true);
   }
 }
Пример #3
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (Intent.ACTION_SCREEN_ON.equals(action)) {
     startWatch();
   } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
     // 锁屏
     isRunning = false;
     mFrees.clear();
   } else {
     // 获得放行的包名
     String packageName = intent.getStringExtra(LockActivity.KEY_PKG);
     mFrees.add(packageName);
   }
 }
Пример #4
0
        @Override
        public void onReceive(Context context, Intent intent) {

          if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
            if (mIntentDeRegistered) {
              mIntentDeRegistered = false;
            }
            loadLyricsToView();
            scrollLyrics(true);
          } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
            if (!mIntentDeRegistered) {
              mIntentDeRegistered = true;
            }
          }
        }
Пример #5
0
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();

          if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
            int ringerMode =
                intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, AudioManager.RINGER_MODE_NORMAL);
            configureForRingerMode(ringerMode);
          } else if (Intent.ACTION_SCREEN_ON.equals(action)) {
            provideScreenStateChangeFeedback(INDEX_SCREEN_ON);
          } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
            provideScreenStateChangeFeedback(INDEX_SCREEN_OFF);
          } else {
            Log.w(LOG_TAG, "Registered for but not handling action " + action);
          }
        }
Пример #6
0
        @Override
        public void onReceive(Context context, Intent intent) {
          Log.i(TAG, "Received " + intent);
          Util.logExtras(intent);

          SharedPreferences prefs =
              PreferenceManager.getDefaultSharedPreferences(SinkholeService.this);
          int delay = Integer.parseInt(prefs.getString("screen_delay", "0"));
          boolean interactive = Intent.ACTION_SCREEN_ON.equals(intent.getAction());

          AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
          PendingIntent pi =
              PendingIntent.getBroadcast(
                  context,
                  0,
                  new Intent(ACTION_SCREEN_OFF_DELAYED),
                  PendingIntent.FLAG_UPDATE_CURRENT);
          am.cancel(pi);

          if (interactive || delay == 0) {
            last_interactive = interactive;
            reload(null, "interactive state changed", SinkholeService.this);
          } else {
            if (ACTION_SCREEN_OFF_DELAYED.equals(intent.getAction())) {
              last_interactive = interactive;
              reload(null, "interactive state changed", SinkholeService.this);
            } else {
              if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
                am.set(AlarmManager.RTC_WAKEUP, new Date().getTime() + delay * 60 * 1000L, pi);
              else
                am.setAndAllowWhileIdle(
                    AlarmManager.RTC_WAKEUP, new Date().getTime() + delay * 60 * 1000L, pi);
            }
          }

          // Start/stop stats
          PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
          mServiceHandler.sendEmptyMessage(pm.isInteractive() ? MSG_STATS_START : MSG_STATS_STOP);
        }
Пример #7
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (action.equals(Configer.Action.MV_CTL_PLAY)) {
     do_resume();
   } else if (action.equals(Configer.Action.MV_CTL_PAUSE)) {
     do_pause();
   } else if (action.equals(Configer.Action.MV_CTL_PLAY_PAUSE)) {
     togglePlay();
   } else if (action.equals(Configer.Action.MV_CTL_NEXT)) {
     next(true);
   } else if (action.equals(Configer.Action.MV_CTL_PREV)) {
     prev(true);
   } else if (Intent.ACTION_SCREEN_ON.equals(action)) {
     // mScreenStateListener.onScreenOn();
   } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
     // mScreenStateListener.onScreenOff();
     onExitProc();
   } else if (action.equals(Configer.Action.ACT_EXIT)) {
     onExitProc();
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
     int state = intent.getIntExtra("state", 0);
     if (state == 0 && mTvOut._isEnabled()) {
       // Disable when cable is unplugged
       mWasOn = false;
       disable();
       stopSelf();
     }
   } else if (Intent.ACTION_SCREEN_ON.equals(action)) {
     if (mWasOn) {
       enable();
       mWasOn = false;
     }
   } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
     if (mTvOut._isEnabled()) {
       mWasOn = true;
       disable();
     }
   }
 }
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();

          if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
            mBatteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
            mBatteryCharging =
                intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0)
                    == BatteryManager.BATTERY_STATUS_CHARGING;
            if (mBatteryCharging && mBatteryLevel < 100 && shouldAnimateCharging) {
              start();
            } else {
              stop();
            }
            setProgress(mBatteryLevel);
          } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
            stop();
          } else if (Intent.ACTION_SCREEN_ON.equals(action)) {
            if (mBatteryCharging && mBatteryLevel < 100) {
              start();
            }
          }
        }
Пример #10
0
  @Override
  public void onReceive(Context context, Intent intent) {

    SharedPreferences sharedPreferences = context.getSharedPreferences("TRIP", 1);
    boolean isTripStarted = sharedPreferences.getBoolean("isTripStarted", false);

    //		Log.v("SafeCell :", "LockReceiver : isTripStarted : " + isTripStarted);
    //		Log.v("SafeCell :", "LockReceiver : Tracking Screen IsBackground : " +
    // TrackingScreenActivity.isBackground);

    if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
      //			Log.v("SafeCell :", "ACTION_SCREEN_OFF");
      wasLoacked = true;
    } else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {

      if (wasLoacked) {
        if (isTripStarted && !(TrackingScreenActivity.isBackground))
          TrackingService.deleteLastInterruption();
      }

      //			Log.v("SafeCell :", "ACTION_SCREEN_ON");
      wasLoacked = false;
    }
  }