Search in sources :

Example 61 with PowerManager

use of android.os.PowerManager in project glasquare by davidvavra.

the class BaseActivity method acquireWakeLock.

public void acquireWakeLock() {
    if (wakeLock == null) {
        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "glasquare");
        wakeLock.acquire();
    }
}
Also used : PowerManager(android.os.PowerManager)

Example 62 with PowerManager

use of android.os.PowerManager in project android-sms-relay by nyaruka.

the class WakefulIntentService method getLock.

private static synchronized PowerManager.WakeLock getLock(Context context) {
    if (lockStatic == null) {
        PowerManager mgr = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, NAME);
        lockStatic.setReferenceCounted(true);
    }
    return (lockStatic);
}
Also used : PowerManager(android.os.PowerManager)

Example 63 with PowerManager

use of android.os.PowerManager in project Etar-Calendar by Etar-Group.

the class AlertReceiver method beginStartingService.

/**
     * Start the service to process the current event notifications, acquiring
     * the wake lock before returning to ensure that the service will run.
     */
public static void beginStartingService(Context context, Intent intent) {
    synchronized (mStartingServiceSync) {
        if (mStartingService == null) {
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            mStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "StartingAlertService");
            mStartingService.setReferenceCounted(false);
        }
        mStartingService.acquire();
        context.startService(intent);
    }
}
Also used : PowerManager(android.os.PowerManager)

Example 64 with PowerManager

use of android.os.PowerManager in project XobotOS by xamarin.

the class IccCard method onIccSwap.

private void onIccSwap(boolean isAdded) {
    // TODO: Here we assume the device can't handle SIM hot-swap
    //      and has to reboot. We may want to add a property,
    //      e.g. REBOOT_ON_SIM_SWAP, to indicate if modem support
    //      hot-swap.
    DialogInterface.OnClickListener listener = null;
    // TODO: SimRecords is not reset while SIM ABSENT (only reset while
    //       Radio_off_or_not_available). Have to reset in both both
    //       added or removed situation.
    listener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                if (mDbg)
                    log("Reboot due to SIM swap");
                PowerManager pm = (PowerManager) mPhone.getContext().getSystemService(Context.POWER_SERVICE);
                pm.reboot("SIM is added.");
            }
        }
    };
    Resources r = Resources.getSystem();
    String title = (isAdded) ? r.getString(R.string.sim_added_title) : r.getString(R.string.sim_removed_title);
    String message = (isAdded) ? r.getString(R.string.sim_added_message) : r.getString(R.string.sim_removed_message);
    String buttonTxt = r.getString(R.string.sim_restart_button);
    AlertDialog dialog = new AlertDialog.Builder(mPhone.getContext()).setTitle(title).setMessage(message).setPositiveButton(buttonTxt, listener).create();
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    dialog.show();
}
Also used : PowerManager(android.os.PowerManager) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Resources(android.content.res.Resources)

Example 65 with PowerManager

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

the class MediaFrameworkTest method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.surface_view);
    mSurfaceView = (SurfaceView) findViewById(R.id.surface_view);
    mOverlayView = (ImageView) findViewById(R.id.overlay_layer);
    ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    mSurfaceHolder.addCallback(this);
    //Get the midi fd
    midiafd = this.getResources().openRawResourceFd(R.raw.testmidi);
    //Get the mp3 fd
    mp3afd = this.getResources().openRawResourceFd(R.raw.testmp3);
    mOverlayView.setLayoutParams(lp);
    mDestBitmap = Bitmap.createBitmap((int) 640, (int) 480, Bitmap.Config.ARGB_8888);
    mOverlayView.setImageBitmap(mDestBitmap);
    //Acquire the full wake lock to keep the device up
    PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "MediaFrameworkTest");
    mWakeLock.acquire();
}
Also used : PowerManager(android.os.PowerManager) ViewGroup(android.view.ViewGroup)

Aggregations

PowerManager (android.os.PowerManager)289 IntentFilter (android.content.IntentFilter)50 Intent (android.content.Intent)44 Handler (android.os.Handler)33 RemoteException (android.os.RemoteException)31 PendingIntent (android.app.PendingIntent)29 HandlerThread (android.os.HandlerThread)26 Context (android.content.Context)24 IPowerManager (android.os.IPowerManager)21 View (android.view.View)19 Resources (android.content.res.Resources)15 AlarmManager (android.app.AlarmManager)11 SharedPreferences (android.content.SharedPreferences)11 TextView (android.widget.TextView)11 NotificationCompat (android.support.v4.app.NotificationCompat)10 ComponentName (android.content.ComponentName)9 KeyguardManager (android.app.KeyguardManager)8 Vibrator (android.os.Vibrator)8 MotionEvent (android.view.MotionEvent)8 ContentResolver (android.content.ContentResolver)7