List of usage examples for android.view Display STATE_DOZE
int STATE_DOZE
To view the source code for android.view Display STATE_DOZE.
Click Source Link
From source file:com.sssemil.advancedsettings.MainService.java
@Override public void onDisplayChanged(int displayId) { try {//www .ja va 2 s .co m mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); mDisplayManager.registerDisplayListener(MainService.this, null); switch (mDisplayManager.getDisplay(displayId).getState()) { case Display.STATE_DOZE_SUSPEND: case Display.STATE_DOZE: try { //TODO: Need to fix screen_saver_brightness_settings. SELinux problems? Thread.sleep(3); int brightness = Integer .parseInt(mSharedPreferences.getString("screen_saver_brightness_settings", String.valueOf(Utils.getDeviceCfg(MainService.this).brightnessDefault))); boolean do_brightness = mSharedPreferences.getBoolean("manage_screen_saver_brightness_settings", false); if (do_brightness) { Log.i(TAG, "echo \"" + brightness + "\" > " + Utils.getDeviceCfg(MainService.this).brightnessPath); Runtime rt = Runtime.getRuntime(); String[] commands = { "su", "-c", "echo \"" + brightness + "\" > " + Utils.getDeviceCfg(MainService.this).brightnessPath }; Process proc = rt.exec(commands); BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream())); String s; while ((s = stdInput.readLine()) != null) { System.out.println(s); } while ((s = stdError.readLine()) != null) { System.out.println(s); } } } catch (IOException | InterruptedException e) { if (BuildConfig.DEBUG) { Log.d(TAG, "catch " + e.toString() + " hit in run", e); } } /*PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WakeLock"); wakeLock.acquire();*/ break; default: break; } } catch (NullPointerException e) { e.printStackTrace(); } }