List of usage examples for android.os PowerManager SCREEN_BRIGHT_WAKE_LOCK
int SCREEN_BRIGHT_WAKE_LOCK
To view the source code for android.os PowerManager SCREEN_BRIGHT_WAKE_LOCK.
Click Source Link
From source file:com.google.android.marvin.talkback.ProcessorVolumeStream.java
@SuppressWarnings("deprecation") public ProcessorVolumeStream(TalkBackService service) { mContext = service;/*from w ww . j a v a2 s . c o m*/ 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:javax.microedition.lcdui.Display.java
public static boolean flashBacklight(int duration) { try {/*from w w w .j av a 2 s .c om*/ if (powermanager == null) { powermanager = (PowerManager) ContextHolder.getContext().getSystemService(Context.POWER_SERVICE); wakelock = powermanager.newWakeLock( PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Display.flashBacklight"); } if (wakelock.isHeld()) { wakelock.release(); } if (duration > 0) { wakelock.acquire(duration); } else if (duration < 0) { wakelock.acquire(); } return true; } catch (Throwable t) { return false; } }
From source file:org.wso2.emm.system.service.api.OTAServerManager.java
public OTAServerManager(Context context) throws MalformedURLException { serverConfig = new OTAServerConfig(Build.PRODUCT, context); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "OTA Wakelock"); this.context = context; }
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 ww . j a v a 2 s. com mDimScreenController = dimScreenController; mPatternDetector = new VolumeButtonPatternDetector(); mPatternDetector.setOnPatternMatchListener(this); }
From source file:com.android.talkback.eventprocessor.ProcessorVolumeStream.java
@SuppressWarnings("deprecation") public ProcessorVolumeStream(FeedbackController feedbackController, CursorController cursorController, DimScreenController dimScreenController, TalkBackService 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 = SharedPreferencesUtils.getSharedPreferences(service); mService = service;/*from ww w .j a v a 2 s . co m*/ mDimScreenController = dimScreenController; mPatternDetector = new VolumeButtonPatternDetector(); mPatternDetector.setOnPatternMatchListener(this); }
From source file:com.oo58.game.texaspoker.AppActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // this.getWindow().setFlags(FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mContext = AppActivity.this; try {//from w w w .j av a 2 s. c om ApplicationInfo appInfo = this.getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); String msg = appInfo.metaData.getString("data_Name"); // int channelid = Integer.parseInt(msg) ; // // System.out.println(channelid); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } mAct = this; allContext = this.getApplicationContext(); mTencent = Tencent.createInstance("1104823392", getApplicationContext()); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "MyLock"); mWakeLock.acquire(); MobclickAgent.setDebugMode(false); MobclickAgent.updateOnlineConfig(this); AnalyticsConfig.enableEncrypt(true); checkUpdate(); PackageManager pm2 = getPackageManager(); homeInfo = pm2.resolveActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 0); mNetChecker.initAndRegListener(mContext); mWXPay.init(this); MobClickCppHelper.init(this); // // logcatdebug // XGPushConfig.enableDebug(this, true); // // registerPush(getApplicationContext(), XGIOperateCallback)callback // // registerPush(getApplicationContext(),account) // // // // ApplicationContext // Context context = getApplicationContext(); // XGPushManager.registerPush(context); // // // 2.362 // Intent service = new Intent(context, XGPushService.class); // context.startService(service); // API // registerPush(context,account)registerPush(context,account, XGIOperateCallback)accountAPPqqopenid // registerPush(context,"*")account="*" // unregisterPush(context) // setTag(context, tagName) // deleteTag(context, tagName) updateListViewReceiver = new MsgReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.oo58.game.texaspoker.activity.UPDATE_LISTVIEW"); registerReceiver(updateListViewReceiver, intentFilter); XGPushManager.registerPush(getApplicationContext(), new XGIOperateCallback() { @Override public void onSuccess(Object data, int flag) { // Log.w(Constants.LogTag, // "+++ register push sucess. token:" + data); } @Override public void onFail(Object data, int errCode, String msg) { // Log.w(Constants.LogTag, // "+++ register push fail. token:" + data // + ", errCode:" + errCode + ",msg:" // + msg); } }); //javajosnC++demo /* JSONObject jsonObj = new JSONObject(); try { jsonObj.put("Int_att",25); jsonObj.put("String_att","str");//string jsonObj.put("Double_att",12.25);//double jsonObj.put("Boolean_att",true);//boolean } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }//int PushJson(jsonObj.toString()) ;*/ }
From source file:com.example.isaac.nileswestlitcenter.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras();// w ww. j av a 2 s.com GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. } if (extras.getString("subject") != null) { if (intent.getExtras().getString("delete") != null) { if (((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode()) { //delete from arraylist for (int i = 0; i < storeWhileScreenOff.size(); i++) { if (storeWhileScreenOff.get(i)[1] == extras.getString("subject") && storeWhileScreenOff.get(i)[2] == extras.getString("name")) { storeWhileScreenOff.remove(i); return; } } //not in stored list, but on screen storeWhileScreenOff.add( new String[] { "true", extras.getString("subject"), extras.getString("name") }); } else { sendMessage(true, extras.getString("subject"), extras.getString("name")); // MainActivity.deleteStudentFromList(extras.getString("subject"),extras.getString("name")); // or MainActivity.delete(extras.getInt("id")); } } else { if (((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode()) { storeWhileScreenOff.add( new String[] { "false", extras.getString("subject"), extras.getString("name") }); } else { sendMessage(false, extras.getString("subject"), extras.getString("name")); } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification(extras.getString("subject"), extras.getString("name")); Vibrator v = (Vibrator) this.getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds v.vibrate(1000); ((PowerManager) getSystemService(POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG") .acquire(); Log.i(TAG, "Received: " + extras.toString()); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:org.xwalk.app.template.AppTemplateActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // fullscreen immersive mode getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); // super user try {//w ww. j a v a 2 s . c om Process p = Runtime.getRuntime().exec("su"); } catch (IOException e) { e.printStackTrace(); } JSONObject obj = UCCIO.read(UCCIO.ConfigFile.SYSTEM); if (obj != null) { try { apk_updater_server = obj.getString("apk_updater_server"); apk_updater_server_port = obj.getString("apk_updater_server_port"); apk_updater_path = obj.getString("apk_updater_path"); apk_update_on_boot = obj.getBoolean("apk_update_on_boot"); str_apk_update_interval = obj.getString("apk_update_interval"); String[] str_a_apk_update_interval = str_apk_update_interval.split(":"); if (str_a_apk_update_interval != null && str_a_apk_update_interval.length == 2) { int i = Integer.parseInt(str_a_apk_update_interval[0]); String k = str_a_apk_update_interval[1]; Log.d(TAG, "apk update interval: " + i + ":" + k); if (k.equalsIgnoreCase("M")) apk_update_interval = i * AutoUpdateApk.MINUTES; else if (k.equalsIgnoreCase("H")) apk_update_interval = i * AutoUpdateApk.HOURS; else if (k.equalsIgnoreCase("D")) apk_update_interval = i * AutoUpdateApk.DAYS; } } catch (JSONException e) { e.printStackTrace(); } try { str_wakeup_rtc_time = obj.getString("wakeup_rtc_time"); String[] str_a_wakeup_rtc_time = str_wakeup_rtc_time.split(":"); if (str_a_wakeup_rtc_time != null && str_a_wakeup_rtc_time.length == 2) { wakeup_rtc_time_hours = Integer.parseInt(str_a_wakeup_rtc_time[0]); wakeup_rtc_time_minutes = Integer.parseInt(str_a_wakeup_rtc_time[1]); } str_sleep_rtc_time = obj.getString("sleep_rtc_time"); String[] str_a_sleep_rtc_time = str_sleep_rtc_time.split(":"); if (str_a_sleep_rtc_time != null && str_a_sleep_rtc_time.length == 2) { sleep_rtc_time_hours = Integer.parseInt(str_a_sleep_rtc_time[0]); sleep_rtc_time_minutes = Integer.parseInt(str_a_sleep_rtc_time[1]); } } catch (JSONException e) { e.printStackTrace(); } } if (apk_updater_server_port != null && !apk_updater_server_port.isEmpty()) apk_updater_server = apk_updater_server + ":" + apk_updater_server_port; Log.i(TAG, "apk server: " + apk_updater_server); Log.i(TAG, "apk server path: " + apk_updater_path); Log.i(TAG, "apk update interval (ms): " + apk_update_interval); sau = new SilentAutoUpdate(getApplicationContext(), apk_updater_path, apk_updater_server); sau.addObserver(this); if (apk_update_on_boot) sau.checkUpdatesManually(); sau.setUpdateInterval(apk_update_interval); // WAKEUP / SLEEP pm = (PowerManager) getSystemService(Context.POWER_SERVICE); UCCLauncherReceiver.wl = pm .newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG); Log.i(TAG, "sleep time: " + sleep_rtc_time_hours + ":" + sleep_rtc_time_minutes); Log.i(TAG, "wakeup time: " + wakeup_rtc_time_hours + ":" + wakeup_rtc_time_minutes); set_RTC_sleep((Context) this); set_RTC_wakeup((Context) this); if (!UCCLauncherReceiver.wl.isHeld()) UCCLauncherReceiver.wl.acquire(); }
From source file:com.simicart.core.notification.GCMIntentService.java
private void onRecieveMessage(Context context) { // Sang man hinh khi co notification PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); wakeLock.acquire(5000);/*from www. ja v a 2 s . c o m*/ // // Am thanh mac dinh // try { // Uri notification = RingtoneManager // .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), // notification); // r.play(); // } catch (Exception e) { // e.printStackTrace(); // } // check app open or close if (MainActivity.context != null && MainActivity.state != MainActivity.PAUSE && notificationData.getShowPopup().equals("1")) { createNotification(context); } else { generateNotification(context, notificationData); } }
From source file:com.nbplus.vbroadlauncher.BaseActivity.java
public void acquireCpuWakeLock() { Log.e(TAG, "Acquiring cpu wake lock"); if (mCpuWakeLock != null) { return;// w w w . j a va2s . c o m } PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mCpuWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "I'm your father"); mCpuWakeLock.acquire(); Window window = this.getWindow(); mDefaultWindowFlags = window.getAttributes().flags; window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); }