Search in sources :

Example 31 with PowerManager

use of android.os.PowerManager in project android_frameworks_base by ResurrectionRemix.

the class FingerprintManager method addLockoutResetCallback.

/**
     * @hide
     */
public void addLockoutResetCallback(final LockoutResetCallback callback) {
    if (mService != null) {
        try {
            final PowerManager powerManager = mContext.getSystemService(PowerManager.class);
            mService.addLockoutResetCallback(new IFingerprintServiceLockoutResetCallback.Stub() {

                @Override
                public void onLockoutReset(long deviceId) throws RemoteException {
                    final PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lockoutResetCallback");
                    wakeLock.acquire();
                    mHandler.post(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                callback.onLockoutReset();
                            } finally {
                                wakeLock.release();
                            }
                        }
                    });
                }
            });
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    } else {
        Log.w(TAG, "addLockoutResetCallback(): Service not connected!");
    }
}
Also used : PowerManager(android.os.PowerManager) RemoteException(android.os.RemoteException)

Example 32 with PowerManager

use of android.os.PowerManager in project android_frameworks_base by ResurrectionRemix.

the class GeofenceHardwareImpl method acquireWakeLock.

private void acquireWakeLock() {
    if (mWakeLock == null) {
        PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    }
    mWakeLock.acquire();
}
Also used : PowerManager(android.os.PowerManager)

Example 33 with PowerManager

use of android.os.PowerManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BatterySaverCondition method refreshState.

@Override
public void refreshState() {
    PowerManager powerManager = mManager.getContext().getSystemService(PowerManager.class);
    setActive(powerManager.isPowerSaveMode());
}
Also used : PowerManager(android.os.PowerManager)

Example 34 with PowerManager

use of android.os.PowerManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DockEventReceiver method beginStartingService.

/**
     * Start the service to process the current event notifications, acquiring
     * the wake lock before returning to ensure that the service will run.
     */
private static void beginStartingService(Context context, Intent intent) {
    synchronized (sStartingServiceSync) {
        if (sStartingService == null) {
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            sStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "StartingDockService");
        }
        sStartingService.acquire();
        if (context.startService(intent) == null) {
            Log.e(TAG, "Can't start DockService");
        }
    }
}
Also used : PowerManager(android.os.PowerManager)

Example 35 with PowerManager

use of android.os.PowerManager in project android_frameworks_base by DirtyUnicorns.

the class MediaPlayer method setWakeMode.

/**
     * Set the low-level power management behavior for this MediaPlayer.  This
     * can be used when the MediaPlayer is not playing through a SurfaceHolder
     * set with {@link #setDisplay(SurfaceHolder)} and thus can use the
     * high-level {@link #setScreenOnWhilePlaying(boolean)} feature.
     *
     * <p>This function has the MediaPlayer access the low-level power manager
     * service to control the device's power usage while playing is occurring.
     * The parameter is a combination of {@link android.os.PowerManager} wake flags.
     * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK}
     * permission.
     * By default, no attempt is made to keep the device awake during playback.
     *
     * @param context the Context to use
     * @param mode    the power/wake mode to set
     * @see android.os.PowerManager
     */
public void setWakeMode(Context context, int mode) {
    boolean washeld = false;
    /* Disable persistant wakelocks in media player based on property */
    if (SystemProperties.getBoolean("audio.offload.ignore_setawake", false) == true) {
        Log.w(TAG, "IGNORING setWakeMode " + mode);
        return;
    }
    if (mWakeLock != null) {
        if (mWakeLock.isHeld()) {
            washeld = true;
            mWakeLock.release();
        }
        mWakeLock = null;
    }
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(mode | PowerManager.ON_AFTER_RELEASE, MediaPlayer.class.getName());
    mWakeLock.setReferenceCounted(false);
    if (washeld) {
        mWakeLock.acquire();
    }
}
Also used : PowerManager(android.os.PowerManager)

Aggregations

PowerManager (android.os.PowerManager)598 Context (android.content.Context)112 Handler (android.os.Handler)112 Intent (android.content.Intent)93 IntentFilter (android.content.IntentFilter)72 PendingIntent (android.app.PendingIntent)46 RemoteException (android.os.RemoteException)37 IPowerManager (android.os.IPowerManager)33 SuppressLint (android.annotation.SuppressLint)30 View (android.view.View)27 IOException (java.io.IOException)27 ContentResolver (android.content.ContentResolver)26 HandlerThread (android.os.HandlerThread)26 SharedPreferences (android.content.SharedPreferences)23 KeyguardManager (android.app.KeyguardManager)18 ComponentName (android.content.ComponentName)18 Resources (android.content.res.Resources)18 TextView (android.widget.TextView)18 PackageManager (android.content.pm.PackageManager)17 Uri (android.net.Uri)16