Methods Summary |
---|
private static boolean | isScreenSaverActivatedOnDock(android.content.Context context)
int def = context.getResources().getBoolean(
com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault) ? 1 : 0;
return Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, def,
UserHandle.USER_CURRENT) != 0;
|
private static boolean | isScreenSaverEnabled(android.content.Context context)
int def = context.getResources().getBoolean(
com.android.internal.R.bool.config_dreamsEnabledByDefault) ? 1 : 0;
return Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.SCREENSAVER_ENABLED, def,
UserHandle.USER_CURRENT) != 0;
|
public static boolean | shouldStartDockApp(android.content.Context context, android.content.Intent intent)Returns true if the specified dock app intent should be started.
False if we should dream instead, if appropriate.
ComponentName name = intent.resolveActivity(context.getPackageManager());
return name != null && !name.equals(SOMNAMBULATOR_COMPONENT);
|
private static void | startDream(android.content.Context context, boolean docked)
try {
IDreamManager dreamManagerService = IDreamManager.Stub.asInterface(
ServiceManager.getService(DreamService.DREAM_SERVICE));
if (dreamManagerService != null && !dreamManagerService.isDreaming()) {
if (docked) {
Slog.i(TAG, "Activating dream while docked.");
// Wake up.
// The power manager will wake up the system automatically when it starts
// receiving power from a dock but there is a race between that happening
// and the UI mode manager starting a dream. We want the system to already
// be awake by the time this happens. Otherwise the dream may not start.
PowerManager powerManager =
(PowerManager)context.getSystemService(Context.POWER_SERVICE);
powerManager.wakeUp(SystemClock.uptimeMillis());
} else {
Slog.i(TAG, "Activating dream by user request.");
}
// Dream.
dreamManagerService.dream();
}
} catch (RemoteException ex) {
Slog.e(TAG, "Could not start dream when docked.", ex);
}
|
public static void | startDreamByUserRequest(android.content.Context context)Starts a dream manually.
startDream(context, false);
|
public static void | startDreamWhenDockedIfAppropriate(android.content.Context context)Starts a dream when docked if the system has been configured to do so,
otherwise does nothing.
if (!isScreenSaverEnabled(context)
|| !isScreenSaverActivatedOnDock(context)) {
Slog.i(TAG, "Dreams currently disabled for docks.");
return;
}
startDream(context, true);
|