summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/jni/android/graphics/Typeface.cpp16
-rw-r--r--core/res/res/drawable-hdpi/toast_frame.9.pngbin1053 -> 1573 bytes
-rw-r--r--core/res/res/drawable-hdpi/toast_frame_holo.9.pngbin1573 -> 0 bytes
-rw-r--r--core/res/res/drawable-ldpi/toast_frame.9.pngbin1180 -> 3268 bytes
-rw-r--r--core/res/res/drawable-mdpi/toast_frame.9.pngbin666 -> 965 bytes
-rw-r--r--core/res/res/drawable-mdpi/toast_frame_holo.9.pngbin965 -> 0 bytes
-rw-r--r--core/res/res/drawable-xhdpi/toast_frame.9.pngbin1557 -> 2090 bytes
-rw-r--r--core/res/res/drawable-xhdpi/toast_frame_holo.9.pngbin2090 -> 0 bytes
-rw-r--r--core/res/res/drawable-xxhdpi/toast_frame.9.pngbin3137 -> 2323 bytes
-rw-r--r--core/res/res/drawable-xxhdpi/toast_frame_holo.9.pngbin2323 -> 0 bytes
-rw-r--r--core/res/res/values/arrays.xml2
-rw-r--r--core/res/res/values/themes.xml4
-rw-r--r--graphics/java/android/graphics/Bitmap.java5
-rw-r--r--packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java5
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java5
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java31
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java18
-rw-r--r--packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java41
-rw-r--r--policy/src/com/android/internal/policy/impl/BarController.java10
-rw-r--r--services/java/com/android/server/am/ActivityStack.java5
-rwxr-xr-xservices/java/com/android/server/pm/PackageManagerService.java12
-rw-r--r--services/java/com/android/server/power/DisplayPowerController.java122
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java3
23 files changed, 163 insertions, 116 deletions
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index a7a0bb2..ccd75d5 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -34,6 +34,13 @@ static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name,
if (NULL != name) {
AutoJavaStringToUTF8 str(env, name);
face = SkTypeface::CreateFromName(str.c_str(), style);
+ // Try to find the closest matching font, using the standard heuristic
+ if (NULL == face) {
+ face = SkTypeface::CreateFromName(str.c_str(), (SkTypeface::Style)(style ^ SkTypeface::kItalic));
+ }
+ for (int i = 0; NULL == face && i < 4; i++) {
+ face = SkTypeface::CreateFromName(str.c_str(), (SkTypeface::Style)i);
+ }
}
// return the default font at the best style if no exact match exists
@@ -45,8 +52,13 @@ static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name,
static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* family, int style) {
SkTypeface* face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style);
- // return the default font at the best style if the requested style does not
- // exist in the provided family
+ // Try to find the closest matching font, using the standard heuristic
+ if (NULL == face) {
+ face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)(style ^ SkTypeface::kItalic));
+ }
+ for (int i = 0; NULL == face && i < 4; i++) {
+ face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)i);
+ }
if (NULL == face) {
face = SkTypeface::CreateFromName(NULL, (SkTypeface::Style)style);
}
diff --git a/core/res/res/drawable-hdpi/toast_frame.9.png b/core/res/res/drawable-hdpi/toast_frame.9.png
index ca65994..a804a8a 100644
--- a/core/res/res/drawable-hdpi/toast_frame.9.png
+++ b/core/res/res/drawable-hdpi/toast_frame.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/toast_frame_holo.9.png b/core/res/res/drawable-hdpi/toast_frame_holo.9.png
deleted file mode 100644
index a804a8a..0000000
--- a/core/res/res/drawable-hdpi/toast_frame_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-ldpi/toast_frame.9.png b/core/res/res/drawable-ldpi/toast_frame.9.png
index 3b344ff..e64dc75 100644
--- a/core/res/res/drawable-ldpi/toast_frame.9.png
+++ b/core/res/res/drawable-ldpi/toast_frame.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/toast_frame.9.png b/core/res/res/drawable-mdpi/toast_frame.9.png
index 9e93fe7..778e4e6 100644
--- a/core/res/res/drawable-mdpi/toast_frame.9.png
+++ b/core/res/res/drawable-mdpi/toast_frame.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/toast_frame_holo.9.png b/core/res/res/drawable-mdpi/toast_frame_holo.9.png
deleted file mode 100644
index 778e4e6..0000000
--- a/core/res/res/drawable-mdpi/toast_frame_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/toast_frame.9.png b/core/res/res/drawable-xhdpi/toast_frame.9.png
index 1f63420..77e69c7 100644
--- a/core/res/res/drawable-xhdpi/toast_frame.9.png
+++ b/core/res/res/drawable-xhdpi/toast_frame.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/toast_frame_holo.9.png b/core/res/res/drawable-xhdpi/toast_frame_holo.9.png
deleted file mode 100644
index 77e69c7..0000000
--- a/core/res/res/drawable-xhdpi/toast_frame_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xxhdpi/toast_frame.9.png b/core/res/res/drawable-xxhdpi/toast_frame.9.png
index 882b9c6..edecb63 100644
--- a/core/res/res/drawable-xxhdpi/toast_frame.9.png
+++ b/core/res/res/drawable-xxhdpi/toast_frame.9.png
Binary files differ
diff --git a/core/res/res/drawable-xxhdpi/toast_frame_holo.9.png b/core/res/res/drawable-xxhdpi/toast_frame_holo.9.png
deleted file mode 100644
index edecb63..0000000
--- a/core/res/res/drawable-xxhdpi/toast_frame_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index ef30b98..91af50a 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -22,7 +22,7 @@
<!-- Do not translate. These are all of the drawable resources that should be preloaded by
the zygote process before it starts forking application processes. -->
<array name="preloaded_drawables">
- <item>@drawable/toast_frame_holo</item>
+ <item>@drawable/toast_frame</item>
<item>@drawable/btn_check_on_pressed_holo_light</item>
<item>@drawable/btn_check_on_pressed_holo_dark</item>
<item>@drawable/btn_check_on_holo_light</item>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 4c80e7d..c8d9fc6 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -1048,7 +1048,7 @@ please see themes_device_defaults.xml.
<item name="presentationTheme">@android:style/Theme.Holo.Dialog.Presentation</item>
<!-- Toast attributes -->
- <item name="toastFrameBackground">@android:drawable/toast_frame_holo</item>
+ <item name="toastFrameBackground">@android:drawable/toast_frame</item>
<!-- Panel attributes -->
<item name="panelBackground">@android:drawable/menu_hardkey_panel_holo_dark</item>
@@ -1363,7 +1363,7 @@ please see themes_device_defaults.xml.
<item name="presentationTheme">@android:style/Theme.Holo.Light.Dialog.Presentation</item>
<!-- Toast attributes -->
- <item name="toastFrameBackground">@android:drawable/toast_frame_holo</item>
+ <item name="toastFrameBackground">@android:drawable/toast_frame</item>
<!-- Panel attributes -->
<item name="panelBackground">@android:drawable/menu_hardkey_panel_holo_light</item>
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 4c7395c..8c38d25 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -1167,6 +1167,11 @@ public final class Bitmap implements Parcelable {
* @see #reconfigure(int, int, Config)
*/
public final int getAllocationByteCount() {
+ if (mBuffer == null) {
+ // native backed bitmaps don't support reconfiguration,
+ // so alloc size is always content size
+ return getByteCount();
+ }
return mBuffer.length;
}
diff --git a/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java b/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java
index 7d1f24f..3dc4d5c 100644
--- a/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java
+++ b/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java
@@ -243,11 +243,12 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
final float pvTransX = pvWidth < thisWidth ? (thisWidth - pvWidth) / 2 : 0;
final float pvTransY = pvHeight < thisHeight ? (thisHeight - pvHeight) / 2 : 0;
- mPreview.setPivotX(0);
+ final boolean isRtl = mPreview.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
+ mPreview.setPivotX(isRtl ? mPreview.width : 0);
mPreview.setPivotY(0);
mPreview.setScaleX(pvScale);
mPreview.setScaleY(pvScale);
- mPreview.setTranslationX(pvTransX);
+ mPreview.setTranslationX((isRtl ? -1 : 1) * pvTransX);
mPreview.setTranslationY(pvTransY);
mRenderedSize.set(width, height);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
index 9a1aa5b..0a915ea 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
@@ -99,6 +99,11 @@ public abstract class KeyguardActivityLauncher {
public void launchCamera(Handler worker, Runnable onSecureCameraStarted) {
LockPatternUtils lockPatternUtils = getLockPatternUtils();
+
+ // Workaround to avoid camera release/acquisition race when resuming face unlock
+ // after showing lockscreen camera (bug 11063890).
+ KeyguardUpdateMonitor.getInstance(getContext()).setAlternateUnlockEnabled(false);
+
if (lockPatternUtils.isSecure()) {
// Launch the secure version of the camera
if (wouldLaunchResolverActivity(SECURE_CAMERA_INTENT)) {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
index fdc06a6..1bae9b8 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
@@ -218,7 +218,7 @@ public class KeyguardHostView extends KeyguardViewBase {
mTransportState = (dcs.clearing ? TRANSPORT_GONE :
(isMusicPlaying(dcs.playbackState) ? TRANSPORT_VISIBLE : TRANSPORT_INVISIBLE));
- if (DEBUG) Log.v(TAG, "Initial transport state: "
+ if (DEBUGXPORT) Log.v(TAG, "Initial transport state: "
+ mTransportState + ", pbstate=" + dcs.playbackState);
}
@@ -1369,7 +1369,7 @@ public class KeyguardHostView extends KeyguardViewBase {
}
}
- Runnable mSwitchPageRunnable = new Runnable() {
+ private final Runnable mSwitchPageRunnable = new Runnable() {
@Override
public void run() {
showAppropriateWidgetPage();
@@ -1438,7 +1438,7 @@ public class KeyguardHostView extends KeyguardViewBase {
mAppWidgetToShow = ss.appWidgetToShow;
setInsets(ss.insets);
if (DEBUG) Log.d(TAG, "onRestoreInstanceState, transport=" + mTransportState);
- post(mSwitchPageRunnable);
+ mSwitchPageRunnable.run();
}
@Override
@@ -1472,10 +1472,21 @@ public class KeyguardHostView extends KeyguardViewBase {
}
private void showAppropriateWidgetPage() {
- int state = mTransportState;
- ensureTransportPresentOrRemoved(state);
- int pageToShow = getAppropriateWidgetPage(state);
- mAppWidgetContainer.setCurrentPage(pageToShow);
+ final int state = mTransportState;
+ final boolean transportAdded = ensureTransportPresentOrRemoved(state);
+ final int pageToShow = getAppropriateWidgetPage(state);
+ if (!transportAdded) {
+ mAppWidgetContainer.setCurrentPage(pageToShow);
+ } else if (state == TRANSPORT_VISIBLE) {
+ // If the transport was just added, we need to wait for layout to happen before
+ // we can set the current page.
+ post(new Runnable() {
+ @Override
+ public void run() {
+ mAppWidgetContainer.setCurrentPage(pageToShow);
+ }
+ });
+ }
}
/**
@@ -1499,12 +1510,11 @@ public class KeyguardHostView extends KeyguardViewBase {
*
* @param state
*/
- private void ensureTransportPresentOrRemoved(int state) {
+ private boolean ensureTransportPresentOrRemoved(int state) {
final boolean showing = getWidgetPosition(R.id.keyguard_transport_control) != -1;
final boolean visible = state == TRANSPORT_VISIBLE;
final boolean shouldBeVisible = state == TRANSPORT_INVISIBLE && isMusicPlaying(state);
if (!showing && (visible || shouldBeVisible)) {
- if (DEBUGXPORT) Log.v(TAG, "add transport");
// insert to left of camera if it exists, otherwise after right-most widget
int lastWidget = mAppWidgetContainer.getChildCount() - 1;
int position = 0; // handle no widget case
@@ -1512,13 +1522,16 @@ public class KeyguardHostView extends KeyguardViewBase {
position = mAppWidgetContainer.isCameraPage(lastWidget) ?
lastWidget : lastWidget + 1;
}
+ if (DEBUGXPORT) Log.v(TAG, "add transport at " + position);
mAppWidgetContainer.addWidget(getOrCreateTransportControl(), position);
+ return true;
} else if (showing && state == TRANSPORT_GONE) {
if (DEBUGXPORT) Log.v(TAG, "remove transport");
mAppWidgetContainer.removeWidget(getOrCreateTransportControl());
mTransportControl = null;
KeyguardUpdateMonitor.getInstance(getContext()).dispatchSetBackground(null);
}
+ return false;
}
private CameraWidgetFrame findCameraPage() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
index 37504fb..2eef2b3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -314,11 +314,19 @@ class QuickSettings {
collapsePanels();
final UserManager um = UserManager.get(mContext);
if (um.getUsers(true).size() > 1) {
- try {
- WindowManagerGlobal.getWindowManagerService().lockNow(null);
- } catch (RemoteException e) {
- Log.e(TAG, "Couldn't show user switcher", e);
- }
+ // Since keyguard and systemui were merged into the same process to save
+ // memory, they share the same Looper and graphics context. As a result,
+ // there's no way to allow concurrent animation while keyguard inflates.
+ // The workaround is to add a slight delay to allow the animation to finish.
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ try {
+ WindowManagerGlobal.getWindowManagerService().lockNow(null);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Couldn't show user switcher", e);
+ }
+ }
+ }, 400); // TODO: ideally this would be tied to the collapse of the panel
} else {
Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent(
mContext, v, ContactsContract.Profile.CONTENT_URI,
diff --git a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
index 9201b71..57c0581 100644
--- a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
+++ b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
@@ -329,40 +329,15 @@ public class WallpaperCropActivity extends Activity {
// Get the crop
boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
- Point minDims = new Point();
- Point maxDims = new Point();
+
Display d = getWindowManager().getDefaultDisplay();
- d.getCurrentSizeRange(minDims, maxDims);
Point displaySize = new Point();
d.getSize(displaySize);
-
- int maxDim = Math.max(maxDims.x, maxDims.y);
- final int minDim = Math.min(minDims.x, minDims.y);
- int defaultWallpaperWidth;
- if (isScreenLarge(getResources())) {
- defaultWallpaperWidth = (int) (maxDim *
- wallpaperTravelToScreenWidthRatio(maxDim, minDim));
- } else {
- defaultWallpaperWidth = Math.max((int)
- (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
- }
-
boolean isPortrait = displaySize.x < displaySize.y;
- int portraitHeight;
- if (isPortrait) {
- portraitHeight = mCropView.getHeight();
- } else {
- // TODO: how to actually get the proper portrait height?
- // This is not quite right:
- portraitHeight = Math.max(maxDims.x, maxDims.y);
- }
- if (android.os.Build.VERSION.SDK_INT >=
- android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
- Point realSize = new Point();
- d.getRealSize(realSize);
- portraitHeight = Math.max(realSize.x, realSize.y);
- }
+
+ Point defaultWallpaperSize = getDefaultWallpaperSize(getResources(),
+ getWindowManager());
// Get the crop
RectF cropRect = mCropView.getCrop();
int cropRotation = mCropView.getImageRotation();
@@ -381,7 +356,7 @@ public class WallpaperCropActivity extends Activity {
// (or all the way to the left, in RTL)
float extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left;
// Cap the amount of extra width
- float maxExtraSpace = defaultWallpaperWidth / cropScale - cropRect.width();
+ float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width();
extraSpace = Math.min(extraSpace, maxExtraSpace);
if (ltr) {
@@ -392,10 +367,10 @@ public class WallpaperCropActivity extends Activity {
// ADJUST CROP HEIGHT
if (isPortrait) {
- cropRect.bottom = cropRect.top + portraitHeight / cropScale;
+ cropRect.bottom = cropRect.top + defaultWallpaperSize.y / cropScale;
} else { // LANDSCAPE
float extraPortraitHeight =
- portraitHeight / cropScale - cropRect.height();
+ defaultWallpaperSize.y / cropScale - cropRect.height();
float expandHeight =
Math.min(Math.min(rotatedInSize[1] - cropRect.bottom, cropRect.top),
extraPortraitHeight / 2);
@@ -763,7 +738,7 @@ public class WallpaperCropActivity extends Activity {
protected void updateWallpaperDimensions(int width, int height) {
String spKey = getSharedPreferencesKey();
- SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE);
+ SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = sp.edit();
if (width != 0 && height != 0) {
editor.putInt(WALLPAPER_WIDTH_KEY, width);
diff --git a/policy/src/com/android/internal/policy/impl/BarController.java b/policy/src/com/android/internal/policy/impl/BarController.java
index 8d97fc8..c38ad04 100644
--- a/policy/src/com/android/internal/policy/impl/BarController.java
+++ b/policy/src/com/android/internal/policy/impl/BarController.java
@@ -129,8 +129,8 @@ public class BarController {
final boolean wasAnim = mWin.isAnimatingLw();
final boolean change = show ? mWin.showLw(true) : mWin.hideLw(true);
final int state = computeStateLw(wasVis, wasAnim, mWin, change);
- updateStateLw(state);
- return change;
+ final boolean stateChanged = updateStateLw(state);
+ return change || stateChanged;
}
private int computeStateLw(boolean wasVis, boolean wasAnim, WindowState win, boolean change) {
@@ -139,6 +139,8 @@ public class BarController {
final boolean anim = win.isAnimatingLw();
if (mState == StatusBarManager.WINDOW_STATE_HIDING && !change && !vis) {
return StatusBarManager.WINDOW_STATE_HIDDEN;
+ } else if (mState == StatusBarManager.WINDOW_STATE_HIDDEN && vis) {
+ return StatusBarManager.WINDOW_STATE_SHOWING;
} else if (change) {
if (wasVis && vis && !wasAnim && anim) {
return StatusBarManager.WINDOW_STATE_HIDING;
@@ -150,7 +152,7 @@ public class BarController {
return mState;
}
- private void updateStateLw(final int state) {
+ private boolean updateStateLw(final int state) {
if (state != mState) {
mState = state;
if (DEBUG) Slog.d(mTag, "mState: " + StatusBarManager.windowStateToString(state));
@@ -169,7 +171,9 @@ public class BarController {
}
}
});
+ return true;
}
+ return false;
}
public boolean checkHiddenLw() {
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 8337613..809452c 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -565,7 +565,7 @@ final class ActivityStack {
// Move userId's tasks to the top.
int index = mTaskHistory.size();
- for (int i = 0; i < index; ++i) {
+ for (int i = 0; i < index; ) {
TaskRecord task = mTaskHistory.get(i);
if (task.userId == userId) {
if (DEBUG_TASKS) Slog.d(TAG, "switchUserLocked: stack=" + getStackId() +
@@ -573,6 +573,9 @@ final class ActivityStack {
mTaskHistory.remove(i);
mTaskHistory.add(task);
--index;
+ // Use same value for i.
+ } else {
+ ++i;
}
}
if (VALIDATE_TOKENS) {
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 3d6b3c9..7291dd4 100755
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -4959,6 +4959,18 @@ public class PackageManagerService extends IPackageManager.Stub {
permissionMap.put(p.info.name, bp);
}
if (bp.perm == null) {
+ if (bp.sourcePackage != null
+ && !bp.sourcePackage.equals(p.info.packageName)) {
+ // If this is a permission that was formerly defined by a non-system
+ // app, but is now defined by a system app (following an upgrade),
+ // discard the previous declaration and consider the system's to be
+ // canonical.
+ if (isSystemApp(p.owner)) {
+ Slog.i(TAG, "New decl " + p.owner + " of permission "
+ + p.info.name + " is system");
+ bp.sourcePackage = null;
+ }
+ }
if (bp.sourcePackage == null
|| bp.sourcePackage.equals(p.info.packageName)) {
BasePermission tree = findPermissionTreeLP(p.info.name);
diff --git a/services/java/com/android/server/power/DisplayPowerController.java b/services/java/com/android/server/power/DisplayPowerController.java
index 976a328..60d44c7 100644
--- a/services/java/com/android/server/power/DisplayPowerController.java
+++ b/services/java/com/android/server/power/DisplayPowerController.java
@@ -298,6 +298,10 @@ final class DisplayPowerController {
// True if mAmbientLux holds a valid value.
private boolean mAmbientLuxValid;
+ // The ambient light level threshold at which to brighten or darken the screen.
+ private float mBrighteningLuxThreshold;
+ private float mDarkeningLuxThreshold;
+
// The most recent light sample.
private float mLastObservedLux;
@@ -945,12 +949,24 @@ final class DisplayPowerController {
mLastObservedLuxTime = time;
}
+ private void setAmbientLux(float lux) {
+ mAmbientLux = lux;
+ mBrighteningLuxThreshold = mAmbientLux * (1.0f + BRIGHTENING_LIGHT_HYSTERESIS);
+ mDarkeningLuxThreshold = mAmbientLux * (1.0f - DARKENING_LIGHT_HYSTERESIS);
+ }
+
private void updateAmbientLux(long time) {
// If the light sensor was just turned on then immediately update our initial
// estimate of the current ambient light level.
- if (!mAmbientLuxValid
- || (time - mLightSensorEnableTime) < mLightSensorWarmUpTimeConfig) {
- mAmbientLux = mRecentShortTermAverageLux;
+ if (!mAmbientLuxValid) {
+ final long timeWhenSensorWarmedUp =
+ mLightSensorWarmUpTimeConfig + mLightSensorEnableTime;
+ if (time < timeWhenSensorWarmedUp) {
+ mHandler.sendEmptyMessageAtTime(MSG_LIGHT_SENSOR_DEBOUNCED,
+ timeWhenSensorWarmedUp);
+ return;
+ }
+ setAmbientLux(mRecentShortTermAverageLux);
mAmbientLuxValid = true;
mDebounceLuxDirection = 0;
mDebounceLuxTime = time;
@@ -961,98 +977,90 @@ final class DisplayPowerController {
+ ", mAmbientLux=" + mAmbientLux);
}
updateAutoBrightness(true);
- return;
- }
-
- // Determine whether the ambient environment appears to be brightening.
- float brighteningLuxThreshold = mAmbientLux * (1.0f + BRIGHTENING_LIGHT_HYSTERESIS);
- if (mRecentShortTermAverageLux > brighteningLuxThreshold
- && mRecentLongTermAverageLux > brighteningLuxThreshold) {
+ } else if (mRecentShortTermAverageLux > mBrighteningLuxThreshold
+ && mRecentLongTermAverageLux > mBrighteningLuxThreshold) {
+ // The ambient environment appears to be brightening.
if (mDebounceLuxDirection <= 0) {
mDebounceLuxDirection = 1;
mDebounceLuxTime = time;
if (DEBUG) {
Slog.d(TAG, "updateAmbientLux: Possibly brightened, waiting for "
+ BRIGHTENING_LIGHT_DEBOUNCE + " ms: "
- + "brighteningLuxThreshold=" + brighteningLuxThreshold
+ + "mBrighteningLuxThreshold=" + mBrighteningLuxThreshold
+ ", mRecentShortTermAverageLux=" + mRecentShortTermAverageLux
+ ", mRecentLongTermAverageLux=" + mRecentLongTermAverageLux
+ ", mAmbientLux=" + mAmbientLux);
}
}
long debounceTime = mDebounceLuxTime + BRIGHTENING_LIGHT_DEBOUNCE;
- if (time >= debounceTime) {
- mAmbientLux = mRecentShortTermAverageLux;
- if (DEBUG) {
- Slog.d(TAG, "updateAmbientLux: Brightened: "
- + "brighteningLuxThreshold=" + brighteningLuxThreshold
- + ", mRecentShortTermAverageLux=" + mRecentShortTermAverageLux
- + ", mRecentLongTermAverageLux=" + mRecentLongTermAverageLux
- + ", mAmbientLux=" + mAmbientLux);
- }
- updateAutoBrightness(true);
- } else {
+ if (time < debounceTime) {
mHandler.sendEmptyMessageAtTime(MSG_LIGHT_SENSOR_DEBOUNCED, debounceTime);
+ return;
}
- return;
- }
-
- // Determine whether the ambient environment appears to be darkening.
- float darkeningLuxThreshold = mAmbientLux * (1.0f - DARKENING_LIGHT_HYSTERESIS);
- if (mRecentShortTermAverageLux < darkeningLuxThreshold
- && mRecentLongTermAverageLux < darkeningLuxThreshold) {
+ setAmbientLux(mRecentShortTermAverageLux);
+ if (DEBUG) {
+ Slog.d(TAG, "updateAmbientLux: Brightened: "
+ + "mBrighteningLuxThreshold=" + mBrighteningLuxThreshold
+ + ", mRecentShortTermAverageLux=" + mRecentShortTermAverageLux
+ + ", mRecentLongTermAverageLux=" + mRecentLongTermAverageLux
+ + ", mAmbientLux=" + mAmbientLux);
+ }
+ updateAutoBrightness(true);
+ } else if (mRecentShortTermAverageLux < mDarkeningLuxThreshold
+ && mRecentLongTermAverageLux < mDarkeningLuxThreshold) {
+ // The ambient environment appears to be darkening.
if (mDebounceLuxDirection >= 0) {
mDebounceLuxDirection = -1;
mDebounceLuxTime = time;
if (DEBUG) {
Slog.d(TAG, "updateAmbientLux: Possibly darkened, waiting for "
+ DARKENING_LIGHT_DEBOUNCE + " ms: "
- + "darkeningLuxThreshold=" + darkeningLuxThreshold
+ + "mDarkeningLuxThreshold=" + mDarkeningLuxThreshold
+ ", mRecentShortTermAverageLux=" + mRecentShortTermAverageLux
+ ", mRecentLongTermAverageLux=" + mRecentLongTermAverageLux
+ ", mAmbientLux=" + mAmbientLux);
}
}
long debounceTime = mDebounceLuxTime + DARKENING_LIGHT_DEBOUNCE;
- if (time >= debounceTime) {
- // Be conservative about reducing the brightness, only reduce it a little bit
- // at a time to avoid having to bump it up again soon.
- mAmbientLux = Math.max(mRecentShortTermAverageLux, mRecentLongTermAverageLux);
- if (DEBUG) {
- Slog.d(TAG, "updateAmbientLux: Darkened: "
- + "darkeningLuxThreshold=" + darkeningLuxThreshold
- + ", mRecentShortTermAverageLux=" + mRecentShortTermAverageLux
- + ", mRecentLongTermAverageLux=" + mRecentLongTermAverageLux
- + ", mAmbientLux=" + mAmbientLux);
- }
- updateAutoBrightness(true);
- } else {
+ if (time < debounceTime) {
mHandler.sendEmptyMessageAtTime(MSG_LIGHT_SENSOR_DEBOUNCED, debounceTime);
+ return;
}
- return;
- }
-
- // No change or change is within the hysteresis thresholds.
- if (mDebounceLuxDirection != 0) {
+ // Be conservative about reducing the brightness, only reduce it a little bit
+ // at a time to avoid having to bump it up again soon.
+ setAmbientLux(Math.max(mRecentShortTermAverageLux, mRecentLongTermAverageLux));
+ if (DEBUG) {
+ Slog.d(TAG, "updateAmbientLux: Darkened: "
+ + "mDarkeningLuxThreshold=" + mDarkeningLuxThreshold
+ + ", mRecentShortTermAverageLux=" + mRecentShortTermAverageLux
+ + ", mRecentLongTermAverageLux=" + mRecentLongTermAverageLux
+ + ", mAmbientLux=" + mAmbientLux);
+ }
+ updateAutoBrightness(true);
+ } else if (mDebounceLuxDirection != 0) {
+ // No change or change is within the hysteresis thresholds.
mDebounceLuxDirection = 0;
mDebounceLuxTime = time;
if (DEBUG) {
Slog.d(TAG, "updateAmbientLux: Canceled debounce: "
- + "brighteningLuxThreshold=" + brighteningLuxThreshold
- + ", darkeningLuxThreshold=" + darkeningLuxThreshold
+ + "mBrighteningLuxThreshold=" + mBrighteningLuxThreshold
+ + ", mDarkeningLuxThreshold=" + mDarkeningLuxThreshold
+ ", mRecentShortTermAverageLux=" + mRecentShortTermAverageLux
+ ", mRecentLongTermAverageLux=" + mRecentLongTermAverageLux
+ ", mAmbientLux=" + mAmbientLux);
}
}
- // If the light level does not change, then the sensor may not report
- // a new value. This can cause problems for the auto-brightness algorithm
- // because the filters might not be updated. To work around it, we want to
- // make sure to update the filters whenever the observed light level could
- // possibly exceed one of the hysteresis thresholds.
- if (mLastObservedLux > brighteningLuxThreshold
- || mLastObservedLux < darkeningLuxThreshold) {
+ // Now that we've done all of that, we haven't yet posted a debounce
+ // message. So consider the case where current lux is beyond the
+ // threshold. It's possible that the light sensor may not report values
+ // if the light level does not change, so we need to occasionally
+ // synthesize sensor readings in order to make sure the brightness is
+ // adjusted accordingly. Note these thresholds may have changed since
+ // we entered the function because we called setAmbientLux and
+ // updateAutoBrightness along the way.
+ if (mLastObservedLux > mBrighteningLuxThreshold
+ || mLastObservedLux < mDarkeningLuxThreshold) {
mHandler.sendEmptyMessageAtTime(MSG_LIGHT_SENSOR_DEBOUNCED,
time + SYNTHETIC_LIGHT_SENSOR_RATE_MILLIS);
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index a645c01..e1e9f5c 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -8269,7 +8269,8 @@ public class WindowManagerService extends IWindowManager.Stub
// windows, since that means "perform layout as normal,
// just don't display").
if (!gone || !win.mHaveFrame || win.mLayoutNeeded
- || win.isConfigChanged()
+ || win.mAttrs.type == TYPE_KEYGUARD && win.isConfigChanged()
+ || mOpeningApps.contains(win.mAppToken)
|| win.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
if (!win.mLayoutAttached) {
if (initial) {