类android.os.IPowerManager源码实例Demo

下面列出了怎么用android.os.IPowerManager的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: AndroidComponentPlugin   文件: ContextImpl.java
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    if (service == null) {
        Log.wtf(TAG, "Failed to get power manager service.");
    }
    return new PowerManager(ctx.getOuterContext(),
            service, ctx.mMainThread.getHandler());
}
 
源代码2 项目: AndroidComponentPlugin   文件: ContextImpl.java
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    if (service == null) {
        Log.wtf(TAG, "Failed to get power manager service.");
    }
    return new PowerManager(ctx.getOuterContext(),
            service, ctx.mMainThread.getHandler());
}
 
源代码3 项目: android_9.0.0_r45   文件: Watchdog.java
/**
 * 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) {
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: SystemServiceRegistry.java
@Override
public PowerManager createService(ContextImpl ctx) throws ServiceNotFoundException {
    IBinder b = ServiceManager.getServiceOrThrow(Context.POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    return new PowerManager(ctx.getOuterContext(),
            service, ctx.mMainThread.getHandler());
}
 
源代码5 项目: rebootmenu   文件: SuJavaPlugin.java
private static void lockScreenWithIPowerManager() {
    Log.v(TAG, "lockScreenWithIPowerManager()");
    IPowerManager iPowerManager = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE));
    if (iPowerManager == null) return;
    //Go to sleep reason code: Going to sleep due by application request.
    final int GO_TO_SLEEP_REASON_APPLICATION = 0;
    long uptimeMillis = SystemClock.uptimeMillis();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        iPowerManager.goToSleep(uptimeMillis, GO_TO_SLEEP_REASON_APPLICATION, 0);
    else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        iPowerManager.goToSleep(uptimeMillis, GO_TO_SLEEP_REASON_APPLICATION);
    else
        iPowerManager.goToSleep(uptimeMillis);
}
 
源代码6 项目: rebootmenu   文件: SuJavaPlugin.java
@SuppressWarnings("SameParameterValue")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static void shutdownWithIPowerManager(boolean confirm, boolean wait) {
    Log.v(TAG, "shutdownWithIPowerManager(...)");
    IPowerManager iPowerManager = Objects.requireNonNull(IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE)));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        // @param reason code to pass to android_reboot() (e.g. "userrequested"), or null.
        // @hide The value to pass as the 'reason' argument to android_reboot().
        @SuppressWarnings("SpellCheckingInspection") final String SHUTDOWN_USER_REQUESTED = "userrequested";
        iPowerManager.shutdown(confirm, SHUTDOWN_USER_REQUESTED, wait);
        return;
    }
    iPowerManager.shutdown(confirm, wait);
}
 
源代码7 项目: Study_Android_Demo   文件: SettingsHelper.java
private void setBrightness(int brightness) {
    try {
        IPowerManager power = IPowerManager.Stub.asInterface(
                ServiceManager.getService("power"));
        if (power != null) {
            power.setTemporaryScreenBrightnessSettingOverride(brightness);
        }
    } catch (RemoteException doe) {

    }
}
 
源代码8 项目: Study_Android_Demo   文件: SettingsHelper.java
private void setBrightness(int brightness) {
    try {
        IPowerManager power = IPowerManager.Stub.asInterface(
                ServiceManager.getService("power"));
        if (power != null) {
            power.setTemporaryScreenBrightnessSettingOverride(brightness);
        }
    } catch (RemoteException doe) {

    }
}
 
源代码9 项目: PhoneProfilesPlus   文件: CmdGoToSleep.java
private static boolean doSleep() {
    try {
        IPowerManager adapter = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); // service list | grep IPowerManager
        adapter.goToSleep(SystemClock.uptimeMillis(), 0, 0);
        return true;
    } catch (Throwable e) {
        //Log.e("CmdGoToSleep.doSleep", Log.getStackTraceString(e));
        PPApplication.recordException(e);
        return false;
    }
}
 
源代码10 项目: AndroidComponentPlugin   文件: ContextImpl.java
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    return new PowerManager(service, ctx.mMainThread.getHandler());
}
 
源代码11 项目: AndroidComponentPlugin   文件: ContextImpl.java
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    return new PowerManager(service, ctx.mMainThread.getHandler());
}
 
源代码12 项目: AndroidComponentPlugin   文件: ContextImpl.java
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    return new PowerManager(ctx.getOuterContext(),
            service, ctx.mMainThread.getHandler());
}
 
源代码13 项目: AndroidComponentPlugin   文件: ContextImpl.java
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    return new PowerManager(ctx.getOuterContext(),
            service, ctx.mMainThread.getHandler());
}
 
源代码14 项目: AndroidComponentPlugin   文件: ContextImpl.java
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(POWER_SERVICE);
    IPowerManager service = IPowerManager.Stub.asInterface(b);
    return new PowerManager(ctx.getOuterContext(),
            service, ctx.mMainThread.getHandler());
}
 
PowerManagerShellCommand(IPowerManager service) {
    mInterface = service;
}
 
 类所在包
 同包方法