Search in sources :

Example 26 with IPowerManager

use of android.os.IPowerManager in project android_frameworks_base by DirtyUnicorns.

the class NightDisplayService method setBrightness.

private void setBrightness(boolean activated) {
    if (activated) {
        updateBrightnessModeValues();
    }
    if (customVal == 3) {
        return;
    }
    try {
        IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
        if (power != null) {
            if (mAutomaticBrightness) {
                power.setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(autoVal);
                AsyncTask.execute(new Runnable() {

                    public void run() {
                        if (activated) {
                            Settings.System.putFloatForUser(getContext().getContentResolver(), Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, autoVal, UserHandle.USER_CURRENT);
                        } else {
                            float userAutoVal = Settings.Secure.getFloatForUser(getContext().getContentResolver(), Settings.Secure.NIGHT_AUTOBRIGHTNESS_USERVALUE, 0, UserHandle.USER_CURRENT);
                            Settings.System.putFloatForUser(getContext().getContentResolver(), Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, userAutoVal, UserHandle.USER_CURRENT);
                        }
                    }
                });
            } else {
                power.setTemporaryScreenBrightnessSettingOverride(manualVal);
                AsyncTask.execute(new Runnable() {

                    @Override
                    public void run() {
                        if (activated) {
                            Settings.System.putIntForUser(getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, manualVal, UserHandle.USER_CURRENT);
                        } else {
                            int userManualVal = Settings.Secure.getIntForUser(getContext().getContentResolver(), Settings.Secure.NIGHT_MANBRIGHTNESS_USERVALUE, 0, UserHandle.USER_CURRENT);
                            Settings.System.putIntForUser(getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, userManualVal, UserHandle.USER_CURRENT);
                        }
                    }
                });
            }
        }
    } catch (RemoteException e) {
        Slog.w(TAG, "Setting Brightness failed: " + e);
    }
}
Also used : IPowerManager(android.os.IPowerManager) RemoteException(android.os.RemoteException)

Example 27 with IPowerManager

use of android.os.IPowerManager in project android_frameworks_base by DirtyUnicorns.

the class ShutdownActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    mReboot = Intent.ACTION_REBOOT.equals(intent.getAction());
    mConfirm = intent.getBooleanExtra(Intent.EXTRA_KEY_CONFIRM, false);
    mUserRequested = intent.getBooleanExtra(Intent.EXTRA_USER_REQUESTED_SHUTDOWN, false);
    Slog.i(TAG, "onCreate(): confirm=" + mConfirm);
    Thread thr = new Thread("ShutdownActivity") {

        @Override
        public void run() {
            IPowerManager pm = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE));
            try {
                if (mReboot) {
                    pm.reboot(mConfirm, null, false);
                } else {
                    pm.shutdown(mConfirm, mUserRequested ? PowerManager.SHUTDOWN_USER_REQUESTED : null, false);
                }
            } catch (RemoteException e) {
            }
        }
    };
    thr.start();
    finish();
    // Wait for us to tell the power manager to shutdown.
    try {
        thr.join();
    } catch (InterruptedException e) {
    }
}
Also used : IPowerManager(android.os.IPowerManager) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 28 with IPowerManager

use of android.os.IPowerManager in project android_frameworks_base by AOSPA.

the class Watchdog method rebootSystem.

/**
     * Perform a full reboot of the system.
     */
void rebootSystem(String reason) {
    Slog.i(TAG, "Rebooting system because: " + reason);
    IPowerManager pms = (IPowerManager) ServiceManager.getService(Context.POWER_SERVICE);
    try {
        pms.reboot(false, reason, false);
    } catch (RemoteException ex) {
    }
}
Also used : IPowerManager(android.os.IPowerManager) RemoteException(android.os.RemoteException)

Example 29 with IPowerManager

use of android.os.IPowerManager in project android_frameworks_base by AOSPA.

the class BrightnessLimit method onClick.

public void onClick(View v) {
    IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
    if (power != null) {
        try {
            power.setTemporaryScreenBrightnessSettingOverride(0);
        } catch (RemoteException darn) {
        }
    }
    Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 0);
}
Also used : IPowerManager(android.os.IPowerManager) RemoteException(android.os.RemoteException)

Example 30 with IPowerManager

use of android.os.IPowerManager in project android_frameworks_base by AOSPA.

the class ShellUiAutomatorBridge method isScreenOn.

@Override
public boolean isScreenOn() {
    IPowerManager pm = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE));
    boolean ret = false;
    try {
        ret = pm.isInteractive();
    } catch (RemoteException e) {
        Log.e(LOG_TAG, "Error getting screen status", e);
        throw new RuntimeException(e);
    }
    return ret;
}
Also used : IPowerManager(android.os.IPowerManager) RemoteException(android.os.RemoteException)

Aggregations

IPowerManager (android.os.IPowerManager)43 RemoteException (android.os.RemoteException)41 ContentResolver (android.content.ContentResolver)8 PowerManager (android.os.PowerManager)7 Settings (android.provider.Settings)7 Intent (android.content.Intent)6 Point (android.graphics.Point)3 ShutdownThread (com.android.server.power.ShutdownThread)1