Merge "Put screensavers back in the icebox for now. DO NOT MERGE." into ics-mr1

This commit is contained in:
Daniel Sandler
2011-12-01 06:29:53 -08:00
committed by Android (Google) Code Review
7 changed files with 1 additions and 269 deletions

View File

@ -4019,28 +4019,6 @@ public final class Settings {
public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
"setup_prepaid_detection_redir_host";
/**
* Whether the screensaver is enabled.
* @hide
*/
public static final String SCREENSAVER_ENABLED = "screensaver_enabled";
/**
* The user's chosen screensaver component.
*
* This component will be launched by the PhoneWindowManager after a timeout when not on
* battery, or upon dock insertion (if SCREENSAVER_ACTIVATE_ON_DOCK is set to 1).
* @hide
*/
public static final String SCREENSAVER_COMPONENT = "screensaver_component";
/**
* Whether the screensaver should be automatically launched when the device is inserted
* into a (desk) dock.
* @hide
*/
public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock";
/** {@hide} */
public static final String NETSTATS_ENABLED = "netstats_enabled";
/** {@hide} */

View File

@ -741,7 +741,4 @@
<string name="config_wimaxServiceClassname"></string>
<!-- Name of the wimax state tracker clas -->
<string name="config_wimaxStateTrackerClassname"></string>
<!-- Name of screensaver components to look for if none has been chosen by the user -->
<string name="config_defaultDreamComponent">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
</resources>

View File

@ -46,26 +46,6 @@
</intent-filter>
</receiver>
<!-- should you need to launch the screensaver, this is a good way to do it -->
<activity android:name=".DreamsDockLauncher"
android:theme="@android:style/Theme.Dialog"
android:label="@string/dreams_dock_launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- launch screensaver on (desk) dock event -->
<receiver android:name=".DreamsDockLauncher$DockEventReceiver"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.DOCK_EVENT" />
</intent-filter>
</receiver>
<activity android:name=".usb.UsbStorageActivity"
android:label="@*android:string/usb_storage_activity_title"
android:excludeFromRecents="true">

View File

@ -362,7 +362,4 @@
<!-- Content description of the clear button in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_clear_all">Clear all notifications.</string>
<!-- Description of the desk dock action that invokes the Android Dreams screen saver feature -->
<string name="dreams_dock_launcher">Activate screen saver</string>
</resources>

View File

@ -1,78 +0,0 @@
package com.android.systemui;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Slog;
public class DreamsDockLauncher extends Activity {
private static final String TAG = "DreamsDockLauncher";
// Launch the screen saver if started as an activity.
@Override
protected void onCreate (Bundle icicle) {
super.onCreate(icicle);
launchDream(this);
finish();
}
private static void launchDream(Context context) {
try {
String component = Settings.Secure.getString(
context.getContentResolver(), Settings.Secure.SCREENSAVER_COMPONENT);
if (component == null) {
component = context.getResources().getString(
com.android.internal.R.string.config_defaultDreamComponent);
}
if (component != null) {
// dismiss the notification shade, recents, etc.
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
ComponentName cn = ComponentName.unflattenFromString(component);
Intent zzz = new Intent(Intent.ACTION_MAIN)
.setComponent(cn)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_NO_USER_ACTION
| Intent.FLAG_FROM_BACKGROUND
| Intent.FLAG_ACTIVITY_NO_HISTORY
);
Slog.v(TAG, "Starting screen saver on dock event: " + component);
context.startActivity(zzz);
} else {
Slog.e(TAG, "Couldn't start screen saver: none selected");
}
} catch (android.content.ActivityNotFoundException exc) {
// no screensaver? give up
Slog.e(TAG, "Couldn't start screen saver: none installed");
}
}
// Trap low-level dock events and launch the screensaver.
public static class DockEventReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
final boolean activateOnDock = 0 != Settings.Secure.getInt(
context.getContentResolver(),
Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, 1);
if (!activateOnDock) return;
if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) {
Bundle extras = intent.getExtras();
int state = extras
.getInt(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED);
if (state == Intent.EXTRA_DOCK_STATE_DESK
|| state == Intent.EXTRA_DOCK_STATE_LE_DESK
|| state == Intent.EXTRA_DOCK_STATE_HE_DESK) {
launchDream(context);
}
}
}
}
}

View File

@ -164,9 +164,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true;
static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false;
// Should screen savers use their own timeout, or the SCREEN_OFF_TIMEOUT?
static final boolean SEPARATE_TIMEOUT_FOR_SCREEN_SAVER = false;
static final int LONG_PRESS_POWER_NOTHING = 0;
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
@ -423,12 +420,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int mLockScreenTimeout;
boolean mLockScreenTimerActive;
// visual screen saver support
int mScreenSaverTimeout = 0;
boolean mScreenSaverEnabledByUser = false;
boolean mScreenSaverMayRun = true; // false if a wakelock is held
boolean mPluggedIn;
// Behavior of ENDCALL Button. (See Settings.System.END_BUTTON_BEHAVIOR.)
int mEndcallBehavior;
@ -491,12 +482,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Settings.Secure.DEFAULT_INPUT_METHOD), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
"fancy_rotation_anim"), false, this);
resolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.SCREENSAVER_ENABLED), false, this);
if (SEPARATE_TIMEOUT_FOR_SCREEN_SAVER) {
resolver.registerContentObserver(Settings.Secure.getUriFor(
"screensaver_timeout"), false, this);
} // otherwise SCREEN_OFF_TIMEOUT will do nicely
updateSettings();
}
@ -804,14 +789,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Intent.EXTRA_DOCK_STATE_UNDOCKED);
}
// watch the plug to know whether to trigger the screen saver
filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
intent = context.registerReceiver(mPowerReceiver, filter);
if (intent != null) {
mPluggedIn = (0 != intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0));
}
mVibrator = new Vibrator();
mLongPressVibePattern = getLongIntArray(mContext.getResources(),
com.android.internal.R.array.config_longPressVibePattern);
@ -960,23 +937,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHasSoftInput = hasSoftInput;
updateRotation = true;
}
mScreenSaverEnabledByUser = 0 != Settings.Secure.getInt(resolver,
Settings.Secure.SCREENSAVER_ENABLED, 1);
if (SEPARATE_TIMEOUT_FOR_SCREEN_SAVER) {
mScreenSaverTimeout = Settings.Secure.getInt(resolver,
"screensaver_timeout", 0);
} else {
mScreenSaverTimeout = Settings.System.getInt(resolver,
Settings.System.SCREEN_OFF_TIMEOUT, 0);
if (mScreenSaverTimeout > 0) {
// We actually want to activate the screensaver just before the
// power manager's screen timeout
mScreenSaverTimeout -= 5000;
}
}
updateScreenSaverTimeoutLocked();
}
if (updateRotation) {
updateRotation(true);
@ -3028,15 +2988,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
};
BroadcastReceiver mPowerReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
mPluggedIn = (0 != intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0));
if (localLOGV) Log.v(TAG, "BATTERY_CHANGED: " + intent + " plugged=" + mPluggedIn);
}
}
};
/** {@inheritDoc} */
public void screenTurnedOff(int why) {
EventLog.writeEvent(70000, 0);
@ -3048,7 +2999,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
synchronized (mLock) {
updateOrientationListenerLp();
updateLockScreenTimeout();
updateScreenSaverTimeoutLocked();
}
}
@ -3095,7 +3045,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mScreenOnEarly = true;
updateOrientationListenerLp();
updateLockScreenTimeout();
updateScreenSaverTimeoutLocked();
}
}
@ -3490,85 +3439,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout);
}
}
synchronized (mLock) {
// Only posts messages; holds no additional locks.
updateScreenSaverTimeoutLocked();
}
}
Runnable mScreenSaverActivator = new Runnable() {
public void run() {
if (!(mScreenSaverMayRun && mScreenOnEarly)) {
Log.w(TAG, "mScreenSaverActivator ran, but the screensaver should not be showing. Who's driving this thing?");
return;
}
if (!mPluggedIn) {
if (localLOGV) Log.v(TAG, "mScreenSaverActivator: not running screen saver when not plugged in");
return;
}
// Quick fix for automation tests.
// The correct fix is to move this triggering logic to PowerManager, where more complete
// information about wakelocks (including StayOnWhilePluggedIn) is available.
if (Settings.System.getInt(mContext.getContentResolver(),
Settings.System.STAY_ON_WHILE_PLUGGED_IN,
BatteryManager.BATTERY_PLUGGED_AC) != 0) {
Log.v(TAG, "mScreenSaverActivator: not running screen saver when STAY_ON_WHILE_PLUGGED_IN");
return;
}
if (localLOGV) Log.v(TAG, "mScreenSaverActivator entering dreamland");
try {
String component = Settings.Secure.getString(
mContext.getContentResolver(), Settings.Secure.SCREENSAVER_COMPONENT);
if (component == null) {
component = mContext.getResources().getString(R.string.config_defaultDreamComponent);
}
if (component != null) {
// dismiss the notification shade, recents, etc.
mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT));
ComponentName cn = ComponentName.unflattenFromString(component);
Intent intent = new Intent(Intent.ACTION_MAIN)
.setComponent(cn)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_NO_USER_ACTION
| Intent.FLAG_FROM_BACKGROUND
| Intent.FLAG_ACTIVITY_NO_HISTORY
);
mContext.startActivity(intent);
} else {
Log.e(TAG, "Couldn't start screen saver: none selected");
}
} catch (android.content.ActivityNotFoundException exc) {
// no screensaver? give up
Log.e(TAG, "Couldn't start screen saver: none installed");
}
}
};
// Must call while holding mLock
private void updateScreenSaverTimeoutLocked() {
if (mScreenSaverActivator == null) return;
mHandler.removeCallbacks(mScreenSaverActivator);
if (mScreenSaverEnabledByUser && mScreenSaverMayRun && mScreenOnEarly && mScreenSaverTimeout > 0) {
if (localLOGV)
Log.v(TAG, "scheduling screensaver for " + mScreenSaverTimeout + "ms from now");
mHandler.postDelayed(mScreenSaverActivator, mScreenSaverTimeout);
} else {
if (localLOGV) {
if (!mScreenSaverEnabledByUser || mScreenSaverTimeout == 0)
Log.v(TAG, "screen saver disabled by user");
else if (!mScreenOnEarly)
Log.v(TAG, "screen saver disabled while screen off");
else
Log.v(TAG, "screen saver disabled by wakelock");
}
}
}
Runnable mScreenLockTimeout = new Runnable() {
@ -3774,11 +3644,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
public void screenOnStartedLw() {
// The window manager has just grabbed a wake lock. This is our cue to disable the screen
// saver.
synchronized (mLock) {
mScreenSaverMayRun = false;
}
}
public void screenOnStoppedLw() {
@ -3787,13 +3652,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
long curTime = SystemClock.uptimeMillis();
mPowerManager.userActivity(curTime, false, LocalPowerManager.OTHER_EVENT);
}
synchronized (mLock) {
// even if the keyguard is up, now that all the wakelocks have been released, we
// should re-enable the screen saver
mScreenSaverMayRun = true;
updateScreenSaverTimeoutLocked();
}
}
}

View File

@ -65,7 +65,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
// Enable launching of applications when entering the dock.
private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true;
private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = false;
private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = true;
private static final int MSG_UPDATE_TWILIGHT = 0;
private static final int MSG_ENABLE_LOCATION_UPDATES = 1;