List of usage examples for android.os PowerManager ON_AFTER_RELEASE
int ON_AFTER_RELEASE
To view the source code for android.os PowerManager ON_AFTER_RELEASE.
Click Source Link
From source file:com.android.screenspeak.controller.FullScreenReadControllerApp.java
@SuppressWarnings("deprecation") public FullScreenReadControllerApp(FeedbackController feedbackController, CursorController cursorController, ScreenSpeakService service) {/*from www . j ava2 s.c o m*/ if (cursorController == null) throw new IllegalStateException(); if (feedbackController == null) throw new IllegalStateException(); mCursorController = cursorController; mFeedbackController = feedbackController; mService = service; mWakeLock = ((PowerManager) service.getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); }
From source file:com.google.android.marvin.talkback.ProcessorVolumeStream.java
@SuppressWarnings("deprecation") public ProcessorVolumeStream(TalkBackService service) { mContext = service;/*from w w w.j av a 2 s . c om*/ mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); mCursorController = service.getCursorController(); mFeedbackController = service.getFeedbackController(); mLongPressHandler = new LongPressHandler(this); final PowerManager pm = (PowerManager) service.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, WL_TAG); }
From source file:com.android.talkback.controller.FullScreenReadControllerApp.java
@SuppressWarnings("deprecation") public FullScreenReadControllerApp(FeedbackController feedbackController, CursorController cursorController, TalkBackService service) {// w w w . j av a2 s .c o m if (cursorController == null) throw new IllegalStateException(); if (feedbackController == null) throw new IllegalStateException(); mCursorController = cursorController; mFeedbackController = feedbackController; mService = service; mWakeLock = ((PowerManager) service.getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); }
From source file:com.chilliworks.chillisource.core.LocalNotificationReceiver.java
/** * Called when a local notification broad cast is received. Funnels the notification * into the app if open or into the notification bar if not * //from ww w.ja v a2s. c o m * @author Steven Hendrie * * @param The context. * @param The intent. */ @SuppressWarnings("deprecation") @Override public void onReceive(Context in_context, Intent in_intent) { //evaluate whether or not the main engine activity is in the foreground boolean isAppInForeground = false; if (CSApplication.get() != null && CSApplication.get().isActive() == true) { isAppInForeground = true; } //if the main engine activity is in the foreground, simply pass the //notification into it. Otherwise display a notification. if (isAppInForeground == true) { final Intent intent = new Intent(in_intent.getAction()); Bundle mapParams = in_intent.getExtras(); Iterator<String> iter = mapParams.keySet().iterator(); while (iter.hasNext()) { String strKey = iter.next(); intent.putExtra(strKey, mapParams.get(strKey).toString()); } LocalNotificationNativeInterface localNotificationNI = (LocalNotificationNativeInterface) CSApplication .get().getSystem(LocalNotificationNativeInterface.InterfaceID); if (localNotificationNI != null) { localNotificationNI.onNotificationReceived(intent); } } else { //aquire a wake lock if (s_wakeLock != null) { s_wakeLock.release(); } PowerManager pm = (PowerManager) in_context.getSystemService(Context.POWER_SERVICE); s_wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "NotificationWakeLock"); s_wakeLock.acquire(); //pull out the information from the intent Bundle params = in_intent.getExtras(); CharSequence title = params.getString(k_paramNameTitle); CharSequence text = params.getString(k_paramNameBody); int intentId = params.getInt(LocalNotification.k_paramNameNotificationId); int paramSize = params.size(); String[] keys = new String[paramSize]; String[] values = new String[paramSize]; Iterator<String> iter = params.keySet().iterator(); int paramNumber = 0; while (iter.hasNext()) { keys[paramNumber] = iter.next(); values[paramNumber] = params.get(keys[paramNumber]).toString(); ++paramNumber; } Intent openAppIntent = new Intent(in_context, CSActivity.class); openAppIntent.setAction("android.intent.action.MAIN"); openAppIntent.addCategory("android.intent.category.LAUNCHER"); openAppIntent.putExtra(k_appOpenedFromNotification, true); openAppIntent.putExtra(k_arrayOfKeysName, keys); openAppIntent.putExtra(k_arrayOfValuesName, values); openAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent sContentIntent = PendingIntent.getActivity(in_context, intentId, openAppIntent, PendingIntent.FLAG_UPDATE_CURRENT); Bitmap largeIconBitmap = null; int LargeIconID = ResourceHelper.GetDynamicResourceIDForField(in_context, ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify_large"); //Use small icon if no large icon if (LargeIconID == 0) { LargeIconID = ResourceHelper.GetDynamicResourceIDForField(in_context, ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify"); } if (LargeIconID > 0) { largeIconBitmap = BitmapFactory.decodeResource(in_context.getResources(), LargeIconID); } Notification notification = new NotificationCompat.Builder(in_context).setContentTitle(title) .setContentText(text) .setSmallIcon(ResourceHelper.GetDynamicResourceIDForField(in_context, ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify")) .setLargeIcon(largeIconBitmap).setContentIntent(sContentIntent).build(); NotificationManager notificationManager = (NotificationManager) in_context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(intentId, notification); Toast.makeText(in_context, text, Toast.LENGTH_LONG).show(); } }
From source file:com.google.android.marvin.mytalkback.FullScreenReadController.java
@SuppressWarnings("deprecation") public FullScreenReadController(TalkBackService service) { mService = service;/*from w ww . ja va 2 s .c o m*/ mSpeechController = service.getSpeechController(); mCursorController = service.getCursorController(); mFeedbackController = MappedFeedbackController.getInstance(); final PowerManager pm = (PowerManager) service.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); setReadingState(AutomaticReadingState.STOPPED); }
From source file:com.android.switchaccess.SwitchAccessService.java
@SuppressWarnings("deprecation") @Override/*from w w w . j a va2s . c o m*/ protected void onServiceConnected() { sInstance = this; mOverlayController = new OverlayController(new SimpleOverlay(this)); mOverlayController.configureOverlay(); mOptionManager = new OptionManager(mOverlayController); mMainTreeBuilder = new MainTreeBuilder(this); mAutoScanController = new AutoScanController(mOptionManager, new Handler(), this); mKeyboardEventManager = new KeyboardEventManager(this, mOptionManager, mAutoScanController); mAnalytics = new Analytics(); mAnalytics.start(); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "SwitchAccess"); SharedPreferencesUtils.getSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); mActionProcessor = new ActionProcessor(this); mEventProcessor = new UiChangeDetector(mActionProcessor); }
From source file:com.cellbots.local.EyesView.java
public EyesView(CellDroidActivity ct, String url, boolean torch) { Log.e("remote eyes", "started " + url); mParent = ct;// ww w.java2s.com putUrl = url; PowerManager pm = (PowerManager) ct.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Cellbot Eyes"); mWakeLock.acquire(); out = new ByteArrayOutputStream(); if (putUrl != null) { isLocalUrl = putUrl.contains("127.0.0.1") || putUrl.contains("localhost"); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); mTorchMode = torch; resetConnection(); mHttpState = new HttpState(); } ct.setContentView(R.layout.eyes_main); mPreview = (SurfaceView) ct.findViewById(R.id.eyes_preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false); setTorchMode(useTorch); setTakePicture(shouldTakePicture); } }; ct.registerReceiver(mReceiver, new IntentFilter(EyesView.EYES_COMMAND)); mFrame = (FrameLayout) ct.findViewById(R.id.eyes_frame); mImageView = new ImageView(ct); mImageView.setScaleType(ScaleType.FIT_CENTER); mImageView.setBackgroundColor(Color.BLACK); setPersona(PERSONA_READY); mFrame.addView(mImageView); }
From source file:fr.bmartel.android.tictactoe.gcm.MyGcmListenerService.java
/** * Called when message is received.// w ww. j a v a2s . c om * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); if (from.startsWith("/topics/" + GameSingleton.DEVICE_ID)) { Log.d(TAG, "Message: " + message); try { JSONObject object = new JSONObject(message); ArrayList<String> eventItem = new ArrayList<>(); eventItem.add(object.toString()); broadcastUpdateStringList(BroadcastFilters.EVENT_MESSAGE, eventItem); if (!GameSingleton.activityForeground) { if (object.has(RequestConstants.DEVICE_MESSAGE_TOPIC) && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID) && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) { GameMessageTopic topic = GameMessageTopic .getTopic(object.getInt(RequestConstants.DEVICE_MESSAGE_TOPIC)); ChallengeMessage challengeMessage = new ChallengeMessage(topic, object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID), object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)); Log.i(TAG, "challenged by " + challengeMessage.getChallengerName() + " : " + challengeMessage.getChallengerId()); Intent intent2 = new Intent(this, DeviceListActivity.class); intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent2, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Fight!") .setContentText("challenged by " + challengeMessage.getChallengerName()) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(new Random().nextInt(9999), notificationBuilder.build()); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); boolean isScreenOn = pm.isScreenOn(); if (isScreenOn == false) { PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyLock"); wl.acquire(10000); PowerManager.WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyCpuLock"); wl_cpu.acquire(10000); } GameSingleton.pendingChallengeMessage = challengeMessage; GameSingleton.pendingChallenge = true; } } } catch (JSONException e) { e.printStackTrace(); } } }
From source file:com.cellbots.eyes.EyesActivity.java
/** Called when the activity is first created. */ @Override/*from w w w. j av a2s . c o m*/ public void onCreate(Bundle savedInstanceState) { Log.e("remote eyes", "started"); super.onCreate(savedInstanceState); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Cellbot Eyes"); mWakeLock.acquire(); mTorchMode = false; out = new ByteArrayOutputStream(); if ((getIntent() != null) && (getIntent().getData() != null)) { putUrl = getIntent().getData().toString(); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); Bundle extras = getIntent().getExtras(); if ((extras != null) && (extras.getBoolean("TORCH", false))) { mTorchMode = true; } } else { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); putUrl = prefs.getString("REMOTE_EYES_PUT_URL", ""); Log.e("prefs", putUrl); if (putUrl.length() < 1) { Intent i = new Intent(); i.setClass(this, PrefsActivity.class); startActivity(i); finish(); return; } else { server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); } } resetConnection(); mHttpState = new HttpState(); setContentView(R.layout.eyes_main); mPreview = (SurfaceView) findViewById(R.id.eyes_preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false); setTorchMode(useTorch); setTakePicture(shouldTakePicture); } }; this.registerReceiver(mReceiver, new IntentFilter(EyesActivity.EYES_COMMAND)); mFrame = (FrameLayout) findViewById(R.id.eyes_frame); mWebView = new WebView(this); mWebView.getSettings().setJavaScriptEnabled(true); // Use this if you want to load content locally // mWebView.loadUrl("content://com.cellbot.localpersonas/default/index.html"); mWebView.loadUrl("http://personabots.appspot.com/expressions/tuby"); mFrame.addView(mWebView); }
From source file:com.android.screenspeak.eventprocessor.ProcessorVolumeStream.java
@SuppressWarnings("deprecation") public ProcessorVolumeStream(FeedbackController feedbackController, CursorController cursorController, DimScreenController dimScreenController, ScreenSpeakService service) { if (feedbackController == null) throw new IllegalStateException("CachedFeedbackController is null"); if (cursorController == null) throw new IllegalStateException("CursorController is null"); if (dimScreenController == null) throw new IllegalStateException("DimScreenController is null"); mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); mCursorController = cursorController; mFeedbackController = feedbackController; final PowerManager pm = (PowerManager) service.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, WL_TAG); mPrefs = PreferenceManager.getDefaultSharedPreferences(service); mService = service;/*from w w w . ja v a2 s.c om*/ mDimScreenController = dimScreenController; mPatternDetector = new VolumeButtonPatternDetector(); mPatternDetector.setOnPatternMatchListener(this); }