Search in sources :

Example 1 with SensorManager

use of android.hardware.SensorManager in project AndroidTraining by mixi-inc.

the class DefaultModule method configure.

@SuppressWarnings("unchecked")
protected void configure() {
    bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
    bind(Context.class).toProvider(ContextProvider.class);
    bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
    bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
    bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
    bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
    bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
    bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
    bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
    bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
    bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
    bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
    bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
    bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
    bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
    bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
    bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
    bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
    bind(ObserverManager.class);
    bindProviderListener(new ObserverRegister());
    bind(StateManager.class).in(ApplicationScoped.class);
    bind(StateEventObserver.class);
    bindFieldListener(RetainState.class, new RetainStateListener());
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) InputMethodManager(android.view.inputmethod.InputMethodManager) ActivityManager(android.app.ActivityManager) WindowManager(android.view.WindowManager) PowerManager(android.os.PowerManager) AudioManager(android.media.AudioManager) StateManager(proton.inject.state.StateManager) TelephonyManager(android.telephony.TelephonyManager) Context(android.content.Context) LocationManager(android.location.LocationManager) ApplicationProvider(proton.inject.provider.ApplicationProvider) NotificationManager(android.app.NotificationManager) HandlerProvider(proton.inject.provider.HandlerProvider) RetainStateListener(proton.inject.state.RetainStateListener) SensorManager(android.hardware.SensorManager) AlarmManager(android.app.AlarmManager) Vibrator(android.os.Vibrator) KeyguardManager(android.app.KeyguardManager) ObserverRegister(proton.inject.observer.ObserverRegister)

Example 2 with SensorManager

use of android.hardware.SensorManager in project android_frameworks_base by ParanoidAndroid.

the class PowerManagerService method systemReady.

public void systemReady(TwilightService twilight, DreamManagerService dreamManager) {
    synchronized (mLock) {
        mSystemReady = true;
        mDreamManager = dreamManager;
        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mScreenBrightnessSettingMinimum = pm.getMinimumScreenBrightnessSetting();
        mScreenBrightnessSettingMaximum = pm.getMaximumScreenBrightnessSetting();
        mScreenBrightnessSettingDefault = pm.getDefaultScreenBrightnessSetting();
        SensorManager sensorManager = new SystemSensorManager(mContext, mHandler.getLooper());
        // The notifier runs on the system server's main looper so as not to interfere
        // with the animations and other critical functions of the power manager.
        mNotifier = new Notifier(Looper.getMainLooper(), mContext, mBatteryStats, createSuspendBlockerLocked("PowerManagerService.Broadcasts"), mScreenOnBlocker, mPolicy);
        // The display power controller runs on the power manager service's
        // own handler thread to ensure timely operation.
        mDisplayPowerController = new DisplayPowerController(mHandler.getLooper(), mContext, mNotifier, mLightsService, twilight, sensorManager, mDisplayManagerService, mDisplayBlanker, mDisplayPowerControllerCallbacks, mHandler);
        mWirelessChargerDetector = new WirelessChargerDetector(sensorManager, createSuspendBlockerLocked("PowerManagerService.WirelessChargerDetector"));
        mSettingsObserver = new SettingsObserver(mHandler);
        mAttentionLight = mLightsService.getLight(LightsService.LIGHT_ID_ATTENTION);
        // Register for broadcasts from other components of the system.
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
        mContext.registerReceiver(new BatteryReceiver(), filter, null, mHandler);
        filter = new IntentFilter();
        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
        mContext.registerReceiver(new BootCompletedReceiver(), filter, null, mHandler);
        filter = new IntentFilter();
        filter.addAction(Intent.ACTION_DREAMING_STARTED);
        filter.addAction(Intent.ACTION_DREAMING_STOPPED);
        mContext.registerReceiver(new DreamReceiver(), filter, null, mHandler);
        filter = new IntentFilter();
        filter.addAction(Intent.ACTION_USER_SWITCHED);
        mContext.registerReceiver(new UserSwitchedReceiver(), filter, null, mHandler);
        filter = new IntentFilter();
        filter.addAction(Intent.ACTION_DOCK_EVENT);
        mContext.registerReceiver(new DockReceiver(), filter, null, mHandler);
        // Register for settings changes.
        final ContentResolver resolver = mContext.getContentResolver();
        resolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.SCREENSAVER_ENABLED), false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP), false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK), false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.SCREEN_OFF_TIMEOUT), false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.Global.getUriFor(Settings.Global.STAY_ON_WHILE_PLUGGED_IN), false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS), false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE), false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.AUTO_BRIGHTNESS_RESPONSIVENESS), false, mSettingsObserver, UserHandle.USER_ALL);
        // Go.
        readConfigurationLocked();
        updateSettingsLocked();
        mDirty |= DIRTY_BATTERY_STATE;
        updatePowerStateLocked();
    }
}
Also used : IntentFilter(android.content.IntentFilter) SystemSensorManager(android.hardware.SystemSensorManager) ContentResolver(android.content.ContentResolver) PowerManager(android.os.PowerManager) IPowerManager(android.os.IPowerManager) SensorManager(android.hardware.SensorManager) SystemSensorManager(android.hardware.SystemSensorManager)

Example 3 with SensorManager

use of android.hardware.SensorManager in project android_frameworks_base by ResurrectionRemix.

the class GestureLauncherService method unregisterCameraLaunchGesture.

private void unregisterCameraLaunchGesture() {
    if (mRegistered) {
        mRegistered = false;
        mCameraGestureOnTimeMs = 0L;
        mCameraGestureLastEventTime = 0L;
        mCameraGestureSensor1LastOnTimeMs = 0;
        mCameraGestureSensor2LastOnTimeMs = 0;
        mCameraLaunchLastEventExtra = 0;
        SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
        sensorManager.unregisterListener(mGestureListener);
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Example 4 with SensorManager

use of android.hardware.SensorManager in project android_frameworks_base by ResurrectionRemix.

the class GestureLauncherService method registerCameraLaunchGesture.

/**
     * Registers for the camera launch gesture.
     */
private void registerCameraLaunchGesture(Resources resources) {
    if (mRegistered) {
        return;
    }
    mCameraGestureOnTimeMs = SystemClock.elapsedRealtime();
    mCameraGestureLastEventTime = mCameraGestureOnTimeMs;
    SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
    int cameraLaunchGestureId = resources.getInteger(com.android.internal.R.integer.config_cameraLaunchGestureSensorType);
    if (cameraLaunchGestureId != -1) {
        mRegistered = false;
        String sensorName = resources.getString(com.android.internal.R.string.config_cameraLaunchGestureSensorStringType);
        mCameraLaunchSensor = sensorManager.getDefaultSensor(cameraLaunchGestureId, true);
        // makes the code more robust.
        if (mCameraLaunchSensor != null) {
            if (sensorName.equals(mCameraLaunchSensor.getStringType())) {
                mRegistered = sensorManager.registerListener(mGestureListener, mCameraLaunchSensor, 0);
            } else {
                String message = String.format("Wrong configuration. Sensor type and sensor " + "string type don't match: %s in resources, %s in the sensor.", sensorName, mCameraLaunchSensor.getStringType());
                throw new RuntimeException(message);
            }
        }
        if (DBG)
            Slog.d(TAG, "Camera launch sensor registered: " + mRegistered);
    } else {
        if (DBG)
            Slog.d(TAG, "Camera launch sensor is not specified.");
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Example 5 with SensorManager

use of android.hardware.SensorManager in project android_frameworks_base by DirtyUnicorns.

the class GestureLauncherService method registerCameraLaunchGesture.

/**
     * Registers for the camera launch gesture.
     */
private void registerCameraLaunchGesture(Resources resources) {
    if (mRegistered) {
        return;
    }
    mCameraGestureOnTimeMs = SystemClock.elapsedRealtime();
    mCameraGestureLastEventTime = mCameraGestureOnTimeMs;
    SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
    int cameraLaunchGestureId = resources.getInteger(com.android.internal.R.integer.config_cameraLaunchGestureSensorType);
    if (cameraLaunchGestureId != -1) {
        mRegistered = false;
        String sensorName = resources.getString(com.android.internal.R.string.config_cameraLaunchGestureSensorStringType);
        mCameraLaunchSensor = sensorManager.getDefaultSensor(cameraLaunchGestureId, true);
        // makes the code more robust.
        if (mCameraLaunchSensor != null) {
            if (sensorName.equals(mCameraLaunchSensor.getStringType())) {
                mRegistered = sensorManager.registerListener(mGestureListener, mCameraLaunchSensor, 0);
            } else {
                String message = String.format("Wrong configuration. Sensor type and sensor " + "string type don't match: %s in resources, %s in the sensor.", sensorName, mCameraLaunchSensor.getStringType());
                throw new RuntimeException(message);
            }
        }
        if (DBG)
            Slog.d(TAG, "Camera launch sensor registered: " + mRegistered);
    } else {
        if (DBG)
            Slog.d(TAG, "Camera launch sensor is not specified.");
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Aggregations

SensorManager (android.hardware.SensorManager)89 Sensor (android.hardware.Sensor)29 SharedPreferences (android.content.SharedPreferences)12 Resources (android.content.res.Resources)8 PowerManager (android.os.PowerManager)6 ContentResolver (android.content.ContentResolver)5 IntentFilter (android.content.IntentFilter)5 SystemSensorManager (android.hardware.SystemSensorManager)5 IPowerManager (android.os.IPowerManager)5 RemoteException (android.os.RemoteException)5 WindowManager (android.view.WindowManager)5 DisplayManagerInternal (android.hardware.display.DisplayManagerInternal)4 BatteryManagerInternal (android.os.BatteryManagerInternal)4 DreamManagerInternal (android.service.dreams.DreamManagerInternal)4 IVrManager (android.service.vr.IVrManager)4 Display (android.view.Display)4 WindowManagerPolicy (android.view.WindowManagerPolicy)4 LightsManager (com.android.server.lights.LightsManager)4 SuppressLint (android.annotation.SuppressLint)3 Intent (android.content.Intent)3