Merge changes I0da0f04f,I93197665 into ics-mr1
* changes: Offer the user an option to launch Dreams when docked. Teach UiModeMgr about high-end and low-end desk docks.
This commit is contained in:
committed by
Android (Google) Code Review
commit
010bb273a5
@@ -46,6 +46,16 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<!-- handle dock insertion, launch screensaver instead -->
|
||||||
|
<activity android:name=".DreamsDockLauncher"
|
||||||
|
android:label="@string/dreams_dock_launcher">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.DESK_DOCK" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".usb.UsbStorageActivity"
|
<activity android:name=".usb.UsbStorageActivity"
|
||||||
android:excludeFromRecents="true">
|
android:excludeFromRecents="true">
|
||||||
</activity>
|
</activity>
|
||||||
|
|||||||
@@ -351,4 +351,7 @@
|
|||||||
|
|
||||||
<!-- Content description of the clear button in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
<!-- 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>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
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";
|
||||||
|
@Override
|
||||||
|
protected void onCreate (Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
try {
|
||||||
|
String component = Settings.Secure.getString(
|
||||||
|
getContentResolver(), Settings.Secure.DREAM_COMPONENT);
|
||||||
|
if (component != null) {
|
||||||
|
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
|
||||||
|
);
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,10 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (getResultCode() != Activity.RESULT_OK) {
|
if (getResultCode() != Activity.RESULT_OK) {
|
||||||
|
if (LOG) {
|
||||||
|
Slog.v(TAG, "Handling broadcast result for action " + intent.getAction()
|
||||||
|
+ ": canceled: " + getResultCode());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +156,12 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LOG) {
|
||||||
|
Slog.v(TAG, String.format(
|
||||||
|
"Handling broadcast result for action %s: enable=0x%08x disable=0x%08x category=%s",
|
||||||
|
intent.getAction(), enableFlags, disableFlags, category));
|
||||||
|
}
|
||||||
|
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
// This is the new activity that will serve as home while
|
// This is the new activity that will serve as home while
|
||||||
// we are in care mode.
|
// we are in care mode.
|
||||||
@@ -424,11 +434,22 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final static boolean isDeskDockState(int state) {
|
||||||
|
switch (state) {
|
||||||
|
case Intent.EXTRA_DOCK_STATE_DESK:
|
||||||
|
case Intent.EXTRA_DOCK_STATE_LE_DESK:
|
||||||
|
case Intent.EXTRA_DOCK_STATE_HE_DESK:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final void updateConfigurationLocked(boolean sendIt) {
|
final void updateConfigurationLocked(boolean sendIt) {
|
||||||
int uiMode = Configuration.UI_MODE_TYPE_NORMAL;
|
int uiMode = Configuration.UI_MODE_TYPE_NORMAL;
|
||||||
if (mCarModeEnabled) {
|
if (mCarModeEnabled) {
|
||||||
uiMode = Configuration.UI_MODE_TYPE_CAR;
|
uiMode = Configuration.UI_MODE_TYPE_CAR;
|
||||||
} else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) {
|
} else if (isDeskDockState(mDockState)) {
|
||||||
uiMode = Configuration.UI_MODE_TYPE_DESK;
|
uiMode = Configuration.UI_MODE_TYPE_DESK;
|
||||||
}
|
}
|
||||||
if (mCarModeEnabled) {
|
if (mCarModeEnabled) {
|
||||||
@@ -477,7 +498,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_CAR) {
|
if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_CAR) {
|
||||||
adjustStatusBarCarModeLocked();
|
adjustStatusBarCarModeLocked();
|
||||||
oldAction = UiModeManager.ACTION_EXIT_CAR_MODE;
|
oldAction = UiModeManager.ACTION_EXIT_CAR_MODE;
|
||||||
} else if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_DESK) {
|
} else if (isDeskDockState(mLastBroadcastState)) {
|
||||||
oldAction = UiModeManager.ACTION_EXIT_DESK_MODE;
|
oldAction = UiModeManager.ACTION_EXIT_DESK_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,12 +512,12 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
mLastBroadcastState = Intent.EXTRA_DOCK_STATE_CAR;
|
mLastBroadcastState = Intent.EXTRA_DOCK_STATE_CAR;
|
||||||
action = UiModeManager.ACTION_ENTER_CAR_MODE;
|
action = UiModeManager.ACTION_ENTER_CAR_MODE;
|
||||||
}
|
}
|
||||||
} else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) {
|
} else if (isDeskDockState(mDockState)) {
|
||||||
if (mLastBroadcastState != Intent.EXTRA_DOCK_STATE_DESK) {
|
if (!isDeskDockState(mLastBroadcastState)) {
|
||||||
if (oldAction != null) {
|
if (oldAction != null) {
|
||||||
mContext.sendBroadcast(new Intent(oldAction));
|
mContext.sendBroadcast(new Intent(oldAction));
|
||||||
}
|
}
|
||||||
mLastBroadcastState = Intent.EXTRA_DOCK_STATE_DESK;
|
mLastBroadcastState = mDockState;
|
||||||
action = UiModeManager.ACTION_ENTER_DESK_MODE;
|
action = UiModeManager.ACTION_ENTER_DESK_MODE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -505,6 +526,12 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
|
if (LOG) {
|
||||||
|
Slog.v(TAG, String.format(
|
||||||
|
"updateLocked: preparing broadcast: action=%s enable=0x%08x disable=0x%08x",
|
||||||
|
action, enableFlags, disableFlags));
|
||||||
|
}
|
||||||
|
|
||||||
// Send the ordered broadcast; the result receiver will receive after all
|
// Send the ordered broadcast; the result receiver will receive after all
|
||||||
// broadcasts have been sent. If any broadcast receiver changes the result
|
// broadcasts have been sent. If any broadcast receiver changes the result
|
||||||
// code from the initial value of RESULT_OK, then the result receiver will
|
// code from the initial value of RESULT_OK, then the result receiver will
|
||||||
@@ -526,7 +553,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
|
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
|
||||||
homeIntent = buildHomeIntent(Intent.CATEGORY_CAR_DOCK);
|
homeIntent = buildHomeIntent(Intent.CATEGORY_CAR_DOCK);
|
||||||
}
|
}
|
||||||
} else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) {
|
} else if (isDeskDockState(mDockState)) {
|
||||||
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
|
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
|
||||||
homeIntent = buildHomeIntent(Intent.CATEGORY_DESK_DOCK);
|
homeIntent = buildHomeIntent(Intent.CATEGORY_DESK_DOCK);
|
||||||
}
|
}
|
||||||
@@ -535,6 +562,12 @@ class UiModeManagerService extends IUiModeManager.Stub {
|
|||||||
homeIntent = buildHomeIntent(Intent.CATEGORY_HOME);
|
homeIntent = buildHomeIntent(Intent.CATEGORY_HOME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LOG) {
|
||||||
|
Slog.v(TAG, "updateLocked: null action, mDockState="
|
||||||
|
+ mDockState +", firing homeIntent: " + homeIntent);
|
||||||
|
}
|
||||||
|
|
||||||
if (homeIntent != null) {
|
if (homeIntent != null) {
|
||||||
try {
|
try {
|
||||||
mContext.startActivity(homeIntent);
|
mContext.startActivity(homeIntent);
|
||||||
|
|||||||
Reference in New Issue
Block a user