diff options
Diffstat (limited to 'services/java/com')
9 files changed, 176 insertions, 58 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index 9c533da..85bc259 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -386,6 +386,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private Locale mLastSystemLocale; private final MyPackageMonitor mMyPackageMonitor = new MyPackageMonitor(); private final IPackageManager mIPackageManager; + private boolean mInputBoundToKeyguard; class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { @@ -877,10 +878,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub final boolean hardKeyShown = haveHardKeyboard && conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES; - final boolean isScreenLocked = mKeyguardManager != null - && mKeyguardManager.isKeyguardLocked() - && mKeyguardManager.isKeyguardSecure(); - mImeWindowVis = (!isScreenLocked && (mInputShown || hardKeyShown)) ? + final boolean isScreenLocked = + mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); + final boolean isScreenSecurelyLocked = + isScreenLocked && mKeyguardManager.isKeyguardSecure(); + final boolean inputShown = mInputShown && (!isScreenLocked || mInputBoundToKeyguard); + mImeWindowVis = (!isScreenSecurelyLocked && (inputShown || hardKeyShown)) ? (InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE) : 0; updateImeWindowStatusLocked(); } @@ -1124,6 +1127,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return mNoBinding; } + if (mCurClient == null) { + mInputBoundToKeyguard = mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); + if (DEBUG) { + Slog.v(TAG, "New bind. keyguard = " + mInputBoundToKeyguard); + } + } + if (mCurClient != cs) { // If the client is changing, we need to switch over to the new // one. @@ -2486,10 +2496,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub map.put(id, p); // Valid system default IMEs and IMEs that have English subtypes are enabled - // by default, unless there's a hard keyboard and the system IME was explicitly - // disabled - if ((isValidSystemDefaultIme(p, mContext) || isSystemImeThatHasEnglishSubtype(p)) - && (!haveHardKeyboard || disabledSysImes.indexOf(id) < 0)) { + // by default + if ((isValidSystemDefaultIme(p, mContext) || isSystemImeThatHasEnglishSubtype(p))) { setInputMethodEnabledLocked(id, true); } diff --git a/services/java/com/android/server/NetworkTimeUpdateService.java b/services/java/com/android/server/NetworkTimeUpdateService.java index 790be55..3bfd190 100644 --- a/services/java/com/android/server/NetworkTimeUpdateService.java +++ b/services/java/com/android/server/NetworkTimeUpdateService.java @@ -57,15 +57,6 @@ public class NetworkTimeUpdateService { private static final int EVENT_POLL_NETWORK_TIME = 2; private static final int EVENT_NETWORK_CONNECTED = 3; - /** Normal polling frequency */ - private static final long POLLING_INTERVAL_MS = 24L * 60 * 60 * 1000; // 24 hrs - /** Try-again polling interval, in case the network request failed */ - private static final long POLLING_INTERVAL_SHORTER_MS = 60 * 1000L; // 60 seconds - /** Number of times to try again */ - private static final int TRY_AGAIN_TIMES_MAX = 3; - /** If the time difference is greater than this threshold, then update the time. */ - private static final int TIME_ERROR_THRESHOLD_MS = 5 * 1000; - private static final String ACTION_POLL = "com.android.server.NetworkTimeUpdateService.action.POLL"; private static int POLL_REQUEST = 0; @@ -86,6 +77,15 @@ public class NetworkTimeUpdateService { private SettingsObserver mSettingsObserver; // The last time that we successfully fetched the NTP time. private long mLastNtpFetchTime = NOT_SET; + + // Normal polling frequency + private final long mPollingIntervalMs; + // Try-again polling interval, in case the network request failed + private final long mPollingIntervalShorterMs; + // Number of times to try again + private final int mTryAgainTimesMax; + // If the time difference is greater than this threshold, then update the time. + private final int mTimeErrorThresholdMs; // Keeps track of how many quick attempts were made to fetch NTP time. // During bootup, the network may not have been up yet, or it's taking time for the // connection to happen. @@ -97,6 +97,15 @@ public class NetworkTimeUpdateService { mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); Intent pollIntent = new Intent(ACTION_POLL, null); mPendingPollIntent = PendingIntent.getBroadcast(mContext, POLL_REQUEST, pollIntent, 0); + + mPollingIntervalMs = mContext.getResources().getInteger( + com.android.internal.R.integer.config_ntpPollingInterval); + mPollingIntervalShorterMs = mContext.getResources().getInteger( + com.android.internal.R.integer.config_ntpPollingIntervalShorter); + mTryAgainTimesMax = mContext.getResources().getInteger( + com.android.internal.R.integer.config_ntpRetry); + mTimeErrorThresholdMs = mContext.getResources().getInteger( + com.android.internal.R.integer.config_ntpThreshold); } /** Initialize the receivers and initiate the first NTP request */ @@ -143,35 +152,35 @@ public class NetworkTimeUpdateService { if (!isAutomaticTimeRequested()) return; final long refTime = SystemClock.elapsedRealtime(); - // If NITZ time was received less than POLLING_INTERVAL_MS time ago, + // If NITZ time was received less than mPollingIntervalMs time ago, // no need to sync to NTP. - if (mNitzTimeSetTime != NOT_SET && refTime - mNitzTimeSetTime < POLLING_INTERVAL_MS) { - resetAlarm(POLLING_INTERVAL_MS); + if (mNitzTimeSetTime != NOT_SET && refTime - mNitzTimeSetTime < mPollingIntervalMs) { + resetAlarm(mPollingIntervalMs); return; } final long currentTime = System.currentTimeMillis(); if (DBG) Log.d(TAG, "System time = " + currentTime); // Get the NTP time - if (mLastNtpFetchTime == NOT_SET || refTime >= mLastNtpFetchTime + POLLING_INTERVAL_MS + if (mLastNtpFetchTime == NOT_SET || refTime >= mLastNtpFetchTime + mPollingIntervalMs || event == EVENT_AUTO_TIME_CHANGED) { if (DBG) Log.d(TAG, "Before Ntp fetch"); // force refresh NTP cache when outdated - if (mTime.getCacheAge() >= POLLING_INTERVAL_MS) { + if (mTime.getCacheAge() >= mPollingIntervalMs) { mTime.forceRefresh(); } // only update when NTP time is fresh - if (mTime.getCacheAge() < POLLING_INTERVAL_MS) { + if (mTime.getCacheAge() < mPollingIntervalMs) { final long ntp = mTime.currentTimeMillis(); mTryAgainCounter = 0; // If the clock is more than N seconds off or this is the first time it's been // fetched since boot, set the current time. - if (Math.abs(ntp - currentTime) > TIME_ERROR_THRESHOLD_MS + if (Math.abs(ntp - currentTime) > mTimeErrorThresholdMs || mLastNtpFetchTime == NOT_SET) { // Set the system time if (DBG && mLastNtpFetchTime == NOT_SET - && Math.abs(ntp - currentTime) <= TIME_ERROR_THRESHOLD_MS) { + && Math.abs(ntp - currentTime) <= mTimeErrorThresholdMs) { Log.d(TAG, "For initial setup, rtc = " + currentTime); } if (DBG) Log.d(TAG, "Ntp time to be set = " + ntp); @@ -186,17 +195,17 @@ public class NetworkTimeUpdateService { } else { // Try again shortly mTryAgainCounter++; - if (mTryAgainCounter <= TRY_AGAIN_TIMES_MAX) { - resetAlarm(POLLING_INTERVAL_SHORTER_MS); + if (mTryAgainTimesMax < 0 || mTryAgainCounter <= mTryAgainTimesMax) { + resetAlarm(mPollingIntervalShorterMs); } else { // Try much later mTryAgainCounter = 0; - resetAlarm(POLLING_INTERVAL_MS); + resetAlarm(mPollingIntervalMs); } return; } } - resetAlarm(POLLING_INTERVAL_MS); + resetAlarm(mPollingIntervalMs); } /** diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index fa84f48..e2be577 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -1128,13 +1128,13 @@ public class NotificationManagerService extends INotificationManager.Stub final boolean hasCustomVibrate = notification.vibrate != null; // new in 4.2: if there was supposed to be a sound and we're in vibrate mode, - // and no other vibration is specified, we apply the default vibration anyway + // and no other vibration is specified, we fall back to vibration final boolean convertSoundToVibration = !hasCustomVibrate && hasValidSound && (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE); - // The DEFAULT_VIBRATE flag trumps any custom vibration. + // The DEFAULT_VIBRATE flag trumps any custom vibration AND the fallback. final boolean useDefaultVibrate = (notification.defaults & Notification.DEFAULT_VIBRATE) != 0; @@ -1147,8 +1147,8 @@ public class NotificationManagerService extends INotificationManager.Stub // does not have the VIBRATE permission. long identity = Binder.clearCallingIdentity(); try { - mVibrator.vibrate(convertSoundToVibration ? mFallbackVibrationPattern - : mDefaultVibrationPattern, + mVibrator.vibrate(useDefaultVibrate ? mDefaultVibrationPattern + : mFallbackVibrationPattern, ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); } finally { Binder.restoreCallingIdentity(identity); diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index 671cbfe..65bfa7e 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -87,7 +87,9 @@ import com.android.internal.statusbar.IStatusBarService; import org.xmlpull.v1.XmlPullParserException; +import java.io.FileDescriptor; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -122,6 +124,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { private static final String TEMPORARY_ENABLE_ACCESSIBILITY_UNTIL_KEYGUARD_REMOVED = "temporaryEnableAccessibilityStateUntilKeyguardRemoved"; + private static final String FUNCTION_DUMP = "dump"; + private static final char COMPONENT_NAME_SEPARATOR = ':'; private static final int OWN_PROCESS_ID = android.os.Process.myPid(); @@ -1258,6 +1262,46 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { } } + @Override + public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) { + mSecurityPolicy.enforceCallingPermission(Manifest.permission.DUMP, FUNCTION_DUMP); + synchronized (mLock) { + pw.println("ACCESSIBILITY MANAGER (dumpsys accessibility)"); + pw.println(); + pw.println("Ui automation service: bound=" + (mUiAutomationService != null)); + pw.println(); + if (mUiAutomationService != null) { + mUiAutomationService.dump(fd, pw, args); + pw.println(); + } + final int userCount = mUserStates.size(); + for (int i = 0; i < userCount; i++) { + UserState userState = mUserStates.valueAt(i); + pw.append("User state[attributes:{id=" + userState.mUserId); + pw.append(", currentUser=" + (userState.mUserId == mCurrentUserId)); + pw.append(", accessibilityEnabled=" + userState.mIsAccessibilityEnabled); + pw.append(", touchExplorationEnabled=" + userState.mIsTouchExplorationEnabled); + pw.append(", displayMagnificationEnabled=" + + userState.mIsDisplayMagnificationEnabled); + pw.append("}"); + pw.println(); + pw.append(" services:{"); + final int serviceCount = userState.mServices.size(); + for (int j = 0; j < serviceCount; j++) { + if (j > 0) { + pw.append(", "); + pw.println(); + pw.append(" "); + } + Service service = userState.mServices.get(j); + service.dump(fd, pw, args); + } + pw.println("}]"); + pw.println(); + } + } + } + private class AccessibilityConnectionWrapper implements DeathRecipient { private final int mWindowId; private final int mUserId; @@ -1894,6 +1938,23 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { } } + @Override + public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) { + mSecurityPolicy.enforceCallingPermission(Manifest.permission.DUMP, FUNCTION_DUMP); + synchronized (mLock) { + pw.append("Service[label=" + mAccessibilityServiceInfo.getResolveInfo() + .loadLabel(mContext.getPackageManager())); + pw.append(", feedbackType" + + AccessibilityServiceInfo.feedbackTypeToString(mFeedbackType)); + pw.append(", canRetrieveScreenContent=" + mCanRetrieveScreenContent); + pw.append(", eventTypes=" + + AccessibilityEvent.eventTypeToString(mEventTypes)); + pw.append(", notificationTimeout=" + mNotificationTimeout); + pw.append("]"); + } + } + + @Override public void onServiceDisconnected(ComponentName componentName) { /* do nothing - #binderDied takes care */ } @@ -2313,7 +2374,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { } if (!hasPermission(permission)) { throw new SecurityException("You do not have " + permission - + " required to call " + function); + + " required to call " + function + " from pid=" + + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); } } diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 8650192..2690442 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -618,8 +618,19 @@ public final class PowerManagerService extends IPowerManager.Stub } } + private static boolean isScreenLock(final WakeLock wakeLock) { + switch (wakeLock.mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK) { + case PowerManager.FULL_WAKE_LOCK: + case PowerManager.SCREEN_BRIGHT_WAKE_LOCK: + case PowerManager.SCREEN_DIM_WAKE_LOCK: + return true; + } + return false; + } + private void applyWakeLockFlagsOnAcquireLocked(WakeLock wakeLock) { - if ((wakeLock.mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0) { + if ((wakeLock.mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0 && + isScreenLock(wakeLock)) { wakeUpNoUpdateLocked(SystemClock.uptimeMillis()); } } diff --git a/services/java/com/android/server/wm/AppWindowAnimator.java b/services/java/com/android/server/wm/AppWindowAnimator.java index ca94d04..e044c6d 100644 --- a/services/java/com/android/server/wm/AppWindowAnimator.java +++ b/services/java/com/android/server/wm/AppWindowAnimator.java @@ -100,6 +100,10 @@ public class AppWindowAnimator { animInitialized = false; } clearThumbnail(); + if (mAppToken.deferClearAllDrawn) { + mAppToken.allDrawn = false; + mAppToken.deferClearAllDrawn = false; + } } public void clearThumbnail() { diff --git a/services/java/com/android/server/wm/AppWindowToken.java b/services/java/com/android/server/wm/AppWindowToken.java index 7efffe5..3ec6d26 100644 --- a/services/java/com/android/server/wm/AppWindowToken.java +++ b/services/java/com/android/server/wm/AppWindowToken.java @@ -64,6 +64,9 @@ class AppWindowToken extends WindowToken { int numDrawnWindows; boolean inPendingTransaction; boolean allDrawn; + // Set to true when this app creates a surface while in the middle of an animation. In that + // case do not clear allDrawn until the animation completes. + boolean deferClearAllDrawn; // Is this token going to be hidden in a little while? If so, it // won't be taken into account for setting the screen orientation. diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 5adc082..f8a2b0c 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -4295,6 +4295,7 @@ public class WindowManagerService extends IWindowManager.Stub // the new one. if (ttoken.allDrawn) { wtoken.allDrawn = true; + wtoken.deferClearAllDrawn = ttoken.deferClearAllDrawn; } if (ttoken.firstWindowDrawn) { wtoken.firstWindowDrawn = true; @@ -4425,6 +4426,7 @@ public class WindowManagerService extends IWindowManager.Stub } } + @Override public void setAppWillBeHidden(IBinder token) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "setAppWillBeHidden()")) { @@ -4548,6 +4550,7 @@ public class WindowManagerService extends IWindowManager.Stub return delayed; } + @Override public void setAppVisibility(IBinder token, boolean visible) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "setAppVisibility()")) { @@ -4602,6 +4605,7 @@ public class WindowManagerService extends IWindowManager.Stub // its windows to be ready. if (wtoken.hidden) { wtoken.allDrawn = false; + wtoken.deferClearAllDrawn = false; wtoken.waitingToShow = true; if (wtoken.clientHidden) { @@ -4700,6 +4704,7 @@ public class WindowManagerService extends IWindowManager.Stub } } + @Override public void startAppFreezingScreen(IBinder token, int configChanges) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "setAppFreezingScreen()")) { @@ -4723,6 +4728,7 @@ public class WindowManagerService extends IWindowManager.Stub } } + @Override public void stopAppFreezingScreen(IBinder token, boolean force) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "setAppFreezingScreen()")) { @@ -5583,7 +5589,7 @@ public class WindowManagerService extends IWindowManager.Stub if (!mSystemBooted && !haveBootMsg) { return; } - + // If we are turning on the screen after the boot is completed // normally, don't do so until we have the application and // wallpaper. @@ -5733,7 +5739,7 @@ public class WindowManagerService extends IWindowManager.Stub * Takes a snapshot of the screen. In landscape mode this grabs the whole screen. * In portrait mode, it grabs the upper region of the screen based on the vertical dimension * of the target image. - * + * * @param displayId the Display to take a screenshot of. * @param width the width of the target bitmap * @param height the height of the target bitmap @@ -5808,7 +5814,7 @@ public class WindowManagerService extends IWindowManager.Stub if (maxLayer < ws.mWinAnimator.mSurfaceLayer) { maxLayer = ws.mWinAnimator.mSurfaceLayer; } - + // Don't include wallpaper in bounds calculation if (!ws.mIsWallpaper) { final Rect wf = ws.mFrame; @@ -8708,6 +8714,7 @@ public class WindowManagerService extends IWindowManager.Stub // this guy's animations regardless of whether it's // gotten drawn. wtoken.allDrawn = true; + wtoken.deferClearAllDrawn = false; } if (mNextAppTransitionThumbnail != null && topOpeningApp != null @@ -8878,6 +8885,7 @@ public class WindowManagerService extends IWindowManager.Stub winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING; if (w.mAppToken != null) { w.mAppToken.allDrawn = false; + w.mAppToken.deferClearAllDrawn = false; } } if (!mResizingWindows.contains(w)) { @@ -8953,27 +8961,29 @@ public class WindowManagerService extends IWindowManager.Stub // so we want to leave all of them as undimmed (for // performance reasons). mInnerFields.mObscured = true; - } else if (canBeSeen && (attrFlags & FLAG_DIM_BEHIND) != 0 - && !(w.mAppToken != null && w.mAppToken.hiddenRequested) + } + } + + private void handleFlagDimBehind(WindowState w, int innerDw, int innerDh) { + final WindowManager.LayoutParams attrs = w.mAttrs; + if ((attrs.flags & FLAG_DIM_BEHIND) != 0 + && w.isDisplayedLw() && !w.mExiting) { - if (localLOGV) Slog.v(TAG, "Win " + w + " obscured=" + mInnerFields.mObscured); - if (!mInnerFields.mDimming) { - //Slog.i(TAG, "DIM BEHIND: " + w); - mInnerFields.mDimming = true; - final WindowStateAnimator winAnimator = w.mWinAnimator; - if (!mAnimator.isDimmingLocked(winAnimator)) { - final int width, height; - if (attrs.type == TYPE_BOOT_PROGRESS) { - final DisplayInfo displayInfo = w.mDisplayContent.getDisplayInfo(); - width = displayInfo.logicalWidth; - height = displayInfo.logicalHeight; - } else { - width = innerDw; - height = innerDh; - } - startDimmingLocked( - winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount, width, height); + mInnerFields.mDimming = true; + final WindowStateAnimator winAnimator = w.mWinAnimator; + if (!mAnimator.isDimmingLocked(winAnimator)) { + final int width, height; + if (attrs.type == TYPE_BOOT_PROGRESS) { + final DisplayInfo displayInfo = w.mDisplayContent.getDisplayInfo(); + width = displayInfo.logicalWidth; + height = displayInfo.logicalHeight; + } else { + width = innerDw; + height = innerDh; } + if (localLOGV) Slog.v(TAG, "Win " + w + " start dimming."); + startDimmingLocked( + winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount, width, height); } } } @@ -9152,6 +9162,10 @@ public class WindowManagerService extends IWindowManager.Stub handleNotObscuredLocked(w, currentTime, innerDw, innerDh); } + if (!mInnerFields.mDimming) { + handleFlagDimBehind(w, innerDw, innerDh); + } + if (isDefaultDisplay && obscuredChanged && (mWallpaperTarget == w) && w.isVisibleLw()) { // This is the wallpaper target and its obscured state diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 7b30c89..4ecc191 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -626,7 +626,14 @@ class WindowStateAnimator { "createSurface " + this + ": mDrawState=DRAW_PENDING"); mDrawState = DRAW_PENDING; if (mWin.mAppToken != null) { - mWin.mAppToken.allDrawn = false; + if (mWin.mAppToken.mAppAnimator.animation == null) { + mWin.mAppToken.allDrawn = false; + mWin.mAppToken.deferClearAllDrawn = false; + } else { + // Currently animating, persist current state of allDrawn until animation + // is complete. + mWin.mAppToken.deferClearAllDrawn = true; + } } mService.makeWindowFreezingScreenIfNeededLocked(mWin); |