Merge "Fix issue #2544466: Car Home brightness icon comes and goes while phone is in car dock in FRE83"

This commit is contained in:
Dianne Hackborn
2010-03-26 00:55:35 -07:00
committed by Android (Google) Code Review
11 changed files with 132 additions and 27 deletions

View File

@@ -25508,6 +25508,8 @@
deprecated="not deprecated"
visibility="public"
>
<parameter name="flags" type="int">
</parameter>
</method>
<method name="getCurrentModeType"
return="int"
@@ -25584,6 +25586,17 @@
visibility="public"
>
</field>
<field name="DISABLE_CAR_MODE_GO_HOME"
type="int"
transient="false"
volatile="false"
value="1"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MODE_NIGHT_AUTO"
type="int"
transient="false"

View File

@@ -30,7 +30,7 @@ interface IUiModeManager {
/**
* Disables the car mode.
*/
void disableCarMode();
void disableCarMode(int flags);
/**
* Return the current running mode.

View File

@@ -116,12 +116,22 @@ public class UiModeManager {
}
/**
* Turn off special mode if currently in car mode.
* Flag for use with {@link #disableCarMode(int)}: go to the normal
* home activity as part of the disable. Disabling this way ensures
* a clean transition between the current activity (in car mode) and
* the original home activity (which was typically last running without
* being in car mode).
*/
public void disableCarMode() {
public static final int DISABLE_CAR_MODE_GO_HOME = 0x0001;
/**
* Turn off special mode if currently in car mode.
* @param flags May be 0 or {@link #DISABLE_CAR_MODE_GO_HOME}.
*/
public void disableCarMode(int flags) {
if (mService != null) {
try {
mService.disableCarMode();
mService.disableCarMode(flags);
} catch (RemoteException e) {
Log.e(TAG, "disableCarMode: RemoteException", e);
}

View File

@@ -1855,7 +1855,8 @@ public final class ViewRoot extends Handler implements ViewParent,
if (mWinFrame.width() == msg.arg1 && mWinFrame.height() == msg.arg2
&& mPendingContentInsets.equals(ri.coveredInsets)
&& mPendingVisibleInsets.equals(ri.visibleInsets)) {
&& mPendingVisibleInsets.equals(ri.visibleInsets)
&& ((ResizedInfo)msg.obj).newConfig == null) {
break;
}
// fall through...

View File

@@ -18,6 +18,7 @@ package com.android.internal.app;
import android.app.Activity;
import android.app.IUiModeManager;
import android.app.UiModeManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -32,7 +33,7 @@ public class DisableCarModeActivity extends Activity {
try {
IUiModeManager uiModeManager = IUiModeManager.Stub.asInterface(
ServiceManager.getService("uimode"));
uiModeManager.disableCarMode();
uiModeManager.disableCarMode(UiModeManager.DISABLE_CAR_MODE_GO_HOME);
} catch (RemoteException e) {
Log.e(TAG, "Failed to disable car mode", e);
}

View File

@@ -20,14 +20,15 @@
<!-- This version zooms the new non-wallpaper up out of the
wallpaper, without zooming the wallpaper itself. -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale=".5" android:toXScale="1.0"
android:fromYScale=".5" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:interpolator="@anim/decelerate_interpolator"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="0" android:toAlpha="1.0"
android:duration="@android:integer/config_mediumAnimTime"/>
android:interpolator="@anim/accelerate_decelerate_interpolator"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>
<!-- This version zooms the new non-wallpaper down on top of the

View File

@@ -17,7 +17,7 @@
*/
-->
<!-- This version zooms the new non-wallpaper up out of the
<!-- This version zooms the exiting non-wallpaper down in to the
wallpaper, without zooming the wallpaper itself. -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@anim/decelerate_interpolator"

View File

@@ -16,16 +16,17 @@
** limitations under the License.
*/
-->
<!-- This version zooms the new non-wallpaper up out of the
<!-- This version zooms the exiting non-wallpaper down in to the
wallpaper, without zooming the wallpaper itself. -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:interpolator="@anim/decelerate_interpolator"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:interpolator="@anim/accelerate_decelerate_interpolator"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>

View File

@@ -144,6 +144,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
// change.
Configuration newConfig = null;
if (mHoldingConfiguration) {
mHoldingConfiguration = false;
updateConfigurationLocked(false);
newConfig = mConfiguration;
}
@@ -151,7 +152,6 @@ class UiModeManagerService extends IUiModeManager.Stub {
ActivityManagerNative.getDefault().startActivityWithConfig(
null, intent, null, null, 0, null, null, 0, false, false,
newConfig);
mContext.startActivity(intent);
mHoldingConfiguration = false;
} catch (RemoteException e) {
Slog.w(TAG, e.getCause());
@@ -190,7 +190,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
mCharging = (intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0);
synchronized (mLock) {
if (mSystemReady) {
updateLocked();
updateLocked(0);
}
}
}
@@ -300,11 +300,11 @@ class UiModeManagerService extends IUiModeManager.Stub {
Settings.Secure.UI_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO);
}
public void disableCarMode() {
public void disableCarMode(int flags) {
synchronized (mLock) {
setCarModeLocked(false);
if (mSystemReady) {
updateLocked();
updateLocked(flags);
}
}
}
@@ -316,7 +316,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
synchronized (mLock) {
setCarModeLocked(true);
if (mSystemReady) {
updateLocked();
updateLocked(0);
}
}
}
@@ -347,7 +347,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
Settings.Secure.UI_NIGHT_MODE, mode);
Binder.restoreCallingIdentity(ident);
mNightMode = mode;
updateLocked();
updateLocked(0);
}
}
}
@@ -360,7 +360,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
synchronized (mLock) {
mSystemReady = true;
mCarModeEnabled = mDockState == Intent.EXTRA_DOCK_STATE_CAR;
updateLocked();
updateLocked(0);
mHandler.sendEmptyMessage(MSG_ENABLE_LOCATION_UPDATES);
}
}
@@ -381,7 +381,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
mDockState = newState;
setCarModeLocked(mDockState == Intent.EXTRA_DOCK_STATE_CAR);
if (mSystemReady) {
updateLocked();
updateLocked(0);
}
}
}
@@ -424,7 +424,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
}
}
final void updateLocked() {
final void updateLocked(int flags) {
long ident = Binder.clearCallingIdentity();
try {
@@ -475,7 +475,25 @@ class UiModeManagerService extends IUiModeManager.Stub {
mHoldingConfiguration = true;
}
updateConfigurationLocked(true);
if (oldAction != null && (flags&UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) {
// We are exiting the special mode, and have been asked to return
// to the main home screen while doing so. To keep this clean, we
// have the activity manager switch the configuration for us at the
// same time as the switch.
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
updateConfigurationLocked(false);
ActivityManagerNative.getDefault().startActivityWithConfig(
null, intent, null, null, 0, null, null, 0, false, false,
mConfiguration);
} catch (RemoteException e) {
Slog.w(TAG, e.getCause());
}
} else {
updateConfigurationLocked(true);
}
// keep screen on when charging and in car mode
boolean keepScreenOn = mCharging &&
@@ -548,7 +566,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
if (isDoingNightMode() && mLocation != null
&& mNightMode == UiModeManager.MODE_NIGHT_AUTO) {
updateTwilightLocked();
updateLocked();
updateLocked(0);
}
}
break;
@@ -576,7 +594,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
if (isDoingNightMode() && mLocation != null
&& mNightMode == UiModeManager.MODE_NIGHT_AUTO) {
updateTwilightLocked();
updateLocked();
updateLocked(0);
}
}
}

View File

@@ -69,7 +69,6 @@ import android.content.pm.PathPermission;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Uri;
@@ -782,6 +781,12 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
*/
int mConfigurationSeq = 0;
/**
* Set when we know we are going to be calling updateConfiguration()
* soon, so want to skip intermediate config checks.
*/
boolean mConfigWillChange;
/**
* Hardware-reported OpenGLES version.
*/
@@ -3663,12 +3668,17 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
} else {
callingPid = callingUid = -1;
}
mConfigWillChange = config != null && mConfiguration.diff(config) != 0;
final long origId = Binder.clearCallingIdentity();
int res = startActivityLocked(caller, intent, resolvedType,
grantedUriPermissions, grantedMode, aInfo,
resultTo, resultWho, requestCode, callingPid, callingUid,
onlyIfNeeded, componentSpecified);
if (config != null) {
if (config != null && mConfigWillChange) {
// If the caller also wants to switch to a new configuration,
// do so now. This allows a clean switch, as we are waiting
// for the current activity to pause (so we will not destroy
@@ -3677,6 +3687,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
"updateConfiguration()");
updateConfigurationLocked(config, null);
}
Binder.restoreCallingIdentity(origId);
if (outResult != null) {
@@ -9705,6 +9716,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
pw.println(" ");
pw.println(" mHomeProcess: " + mHomeProcess);
pw.println(" mConfiguration: " + mConfiguration);
pw.println(" mConfigWillChange: " + mConfigWillChange);
pw.println(" mSleeping=" + mSleeping + " mShuttingDown=" + mShuttingDown);
if (mDebugApp != null || mOrigDebugApp != null || mDebugTransient
|| mOrigWaitForDebugger) {
@@ -13452,6 +13464,12 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
*/
private final boolean ensureActivityConfigurationLocked(HistoryRecord r,
int globalChanges) {
if (!mConfigWillChange) {
if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
"Skipping config check (will change): " + r);
return true;
}
if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
"Ensuring correct configuration: " + r);

View File

@@ -17,9 +17,10 @@
package com.android.server.status;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -31,6 +32,8 @@ import com.android.internal.R;
public class StatusBarView extends FrameLayout {
private static final String TAG = "StatusBarView";
static final int DIM_ANIM_TIME = 400;
StatusBarService mService;
boolean mTracking;
int mStartX, mStartY;
@@ -38,6 +41,10 @@ public class StatusBarView extends FrameLayout {
ViewGroup mStatusIcons;
View mDate;
FixedSizeDrawable mBackground;
boolean mNightMode = false;
int mStartAlpha = 0, mEndAlpha = 0;
long mEndTime = 0;
public StatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -60,7 +67,30 @@ public class StatusBarView extends FrameLayout {
super.onAttachedToWindow();
mService.onBarViewAttached();
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
boolean nightMode = (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK)
== Configuration.UI_MODE_NIGHT_YES;
if (mNightMode != nightMode) {
mNightMode = nightMode;
mStartAlpha = getCurAlpha();
mEndAlpha = mNightMode ? 0x80 : 0x00;
mEndTime = SystemClock.uptimeMillis() + DIM_ANIM_TIME;
invalidate();
}
}
int getCurAlpha() {
long time = SystemClock.uptimeMillis();
if (time > mEndTime) {
return mEndAlpha;
}
return mEndAlpha
- (int)(((mEndAlpha-mStartAlpha) * (mEndTime-time) / DIM_ANIM_TIME));
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
@@ -97,6 +127,18 @@ public class StatusBarView extends FrameLayout {
mBackground.setFixedBounds(-mDate.getLeft(), -mDate.getTop(), (r-l), (b-t));
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
int alpha = getCurAlpha();
if (alpha != 0) {
canvas.drawARGB(alpha, 0, 0, 0);
}
if (alpha != mEndAlpha) {
invalidate();
}
}
/**
* Gets the left position of v in this view. Throws if v is not
* a child of this.