android.hardware.TriggerEvent Java Examples

The following examples show how to use android.hardware.TriggerEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeviceIdleController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onTrigger(TriggerEvent event) {
    synchronized (DeviceIdleController.this) {
        active = false;
        motionLocked();
    }
}
 
Example #2
Source File: WakeGestureListener.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onTrigger(TriggerEvent event) {
    synchronized (mLock) {
        mTriggerRequested = false;
        mHandler.post(mWakeUpRunnable);
    }
}
 
Example #3
Source File: GestureLauncherService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onTrigger(TriggerEvent event) {
    if (DBG_CAMERA_LIFT) Slog.d(TAG, String.format("onTrigger event - time: %d, name: %s",
            event.timestamp, event.sensor.getName()));
    if (!mCameraLiftRegistered) {
      if (DBG_CAMERA_LIFT) Slog.d(TAG, "Ignoring camera lift event because it's " +
              "unregistered.");
      return;
    }
    if (event.sensor == mCameraLiftTriggerSensor) {
        Resources resources = mContext.getResources();
        SensorManager sensorManager = (SensorManager) mContext.getSystemService(
                Context.SENSOR_SERVICE);
        boolean keyguardShowingAndNotOccluded =
                mWindowManagerInternal.isKeyguardShowingAndNotOccluded();
        boolean interactive = mPowerManager.isInteractive();
        if (DBG_CAMERA_LIFT) {
            float[] values = event.values;
            Slog.d(TAG, String.format("Received a camera lift trigger " +
                    "event: values=[%.4f], keyguard showing: %b, interactive: %b", values[0],
                    keyguardShowingAndNotOccluded, interactive));
        }
        if (keyguardShowingAndNotOccluded || !interactive) {
            if (handleCameraGesture(true /* useWakelock */,
                    StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER)) {
                MetricsLogger.action(mContext, MetricsEvent.ACTION_CAMERA_LIFT_TRIGGER);
            }
        } else {
            if (DBG_CAMERA_LIFT) Slog.d(TAG, "Ignoring lift event");
        }

        mCameraLiftRegistered = sensorManager.requestTriggerSensor(
                mCameraLiftTriggerListener, mCameraLiftTriggerSensor);

        if (DBG_CAMERA_LIFT) Slog.d(TAG, "Camera lift trigger sensor re-registered: " +
                mCameraLiftRegistered);
        return;
    }
}
 
Example #4
Source File: BumpMonitor.java    From haven with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTrigger(TriggerEvent event) {
    Log.i("BumpMonitor", "Sensor triggered");
    //value[0] = 1.0 when the sensor triggers. 1.0 is the only allowed value.
    long curTime = System.currentTimeMillis();
    // only allow one update every 100ms.
    if (event.sensor.getType() == Sensor.TYPE_SIGNIFICANT_MOTION) {
        if ((curTime - lastUpdate) > CHECK_INTERVAL) {
            lastUpdate = curTime;

            /*
             * Send Alert
             */
            Message message = new Message();
            message.what = EventTrigger.BUMP;
            message.getData().putString(MonitorService.KEY_PATH, "BUMPED!");

            try {
                if (serviceMessenger != null) {
                    serviceMessenger.send(message);
                }
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    //re-register the listener (it finishes after each event)
    boolean registered = sensorMgr.requestTriggerSensor(sensorListener, bumpSensor);
    Log.i("BumpMonitor", "Significant motion sensor re-registered: "+registered);

}
 
Example #5
Source File: MainActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 4 votes vote down vote up
@Override
public void onTrigger(TriggerEvent event) {
  // TODO React to trigger event.
}
 
Example #6
Source File: MainActivity.java    From SensorAnnotations with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@OnTrigger
public void testSignificantMotionTrigger(@NonNull TriggerEvent event) {
    updateTextViewWithEventData(mSignificantMotionEventOutputTextView, event);
}
 
Example #7
Source File: MainActivity.java    From SensorAnnotations with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
void updateTextViewWithEventData(@NonNull TextView textView, @NonNull TriggerEvent event) {
    updateTextViewWithEventData(textView, event.timestamp, event.values);
}