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();
}
}
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);
}
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);
}
}
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();
}
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();
}
Aggregations