diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-10-11 15:58:37 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-10-11 16:29:41 -0700 |
commit | 11159e9a785a143c9f3765bdf5a5ccfd77842d7a (patch) | |
tree | 4a114325a3b6d4ce0e7ab7753d02e9c62e6492b9 /packages/SystemUI/src | |
parent | 487bb6e20b96aa6920e08669a260118a40e604d5 (diff) | |
download | frameworks_base-11159e9a785a143c9f3765bdf5a5ccfd77842d7a.zip frameworks_base-11159e9a785a143c9f3765bdf5a5ccfd77842d7a.tar.gz frameworks_base-11159e9a785a143c9f3765bdf5a5ccfd77842d7a.tar.bz2 |
Do not launch Somnambulator as a dock app.
Fixes a black flash that occurred when the device was docked
because the UiModeManagerService was launching the Somnambulator
to start the dream when docked. This caused an unnecessary
activity transition and could in fact make dreaming less
reliable than if the UiModeManagerService started the dream itself.
Moved common code from UiModeManagerService and Somnambulator
to Sandman to ensure it is kept in sync.
Bug: 7328545
Change-Id: I46102784e2ab1acc0241d43a48abf0581278af24
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/Somnambulator.java | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/Somnambulator.java b/packages/SystemUI/src/com/android/systemui/Somnambulator.java index 9356ff2..0dd6d92 100644 --- a/packages/SystemUI/src/com/android/systemui/Somnambulator.java +++ b/packages/SystemUI/src/com/android/systemui/Somnambulator.java @@ -1,4 +1,4 @@ -/*); +/* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,38 +18,23 @@ package com.android.systemui; import android.app.Activity; import android.content.Intent; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.os.UserHandle; -import android.provider.Settings; -import android.service.dreams.DreamService; -import android.service.dreams.IDreamManager; -import android.util.Slog; - +import android.service.dreams.Sandman; + +/** + * A simple activity that launches a dream. + * <p> + * Note: This Activity is special. If this class is moved to another package or + * renamed, be sure to update the component name in {@link Sandman}. + * </p> + */ public class Somnambulator extends Activity { - public static final String TAG = "Somnambulator"; - - public static final int DEFAULT_SCREENSAVER_ENABLED = 1; - public static final int DEFAULT_SCREENSAVER_ACTIVATED_ON_DOCK = 1; - public Somnambulator() { } - private boolean isScreenSaverEnabled() { - return Settings.Secure.getIntForUser(getContentResolver(), - Settings.Secure.SCREENSAVER_ENABLED, DEFAULT_SCREENSAVER_ENABLED, - UserHandle.USER_CURRENT) != 0; - } - - private boolean isScreenSaverActivatedOnDock() { - return Settings.Secure.getIntForUser(getContentResolver(), - Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, - DEFAULT_SCREENSAVER_ACTIVATED_ON_DOCK, UserHandle.USER_CURRENT) != 0; - } - @Override public void onStart() { super.onStart(); + final Intent launchIntent = getIntent(); final String action = launchIntent.getAction(); if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { @@ -64,23 +49,12 @@ public class Somnambulator extends Activity { setResult(RESULT_OK, resultIntent); } else { boolean docked = launchIntent.hasCategory(Intent.CATEGORY_DESK_DOCK); - - if (docked && !(isScreenSaverEnabled() && isScreenSaverActivatedOnDock())) { - Slog.i(TAG, "Dreams currently disabled for docks."); + if (docked) { + Sandman.startDreamWhenDockedIfAppropriate(this); } else { - IDreamManager somnambulist = IDreamManager.Stub.asInterface( - ServiceManager.checkService(DreamService.DREAM_SERVICE)); - if (somnambulist != null) { - try { - Slog.v(TAG, "Dreaming on " + (docked ? "dock insertion" : "user request")); - somnambulist.dream(); - } catch (RemoteException e) { - // fine, stay asleep then - } - } + Sandman.startDreamByUserRequest(this); } } finish(); } - } |