diff options
Diffstat (limited to 'services/java')
4 files changed, 48 insertions, 56 deletions
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index 4ae9eb5..2b5544b 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -1375,29 +1375,30 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { } private void updateTouchExplorationLocked(UserState userState) { - userState.mIsTouchExplorationEnabled = false; + boolean enabled = false; final int serviceCount = userState.mBoundServices.size(); for (int i = 0; i < serviceCount; i++) { Service service = userState.mBoundServices.get(i); - if (tryEnableTouchExplorationLocked(service)) { + if (canRequestAndRequestsTouchExplorationLocked(service)) { + enabled = true; break; } } + if (enabled != userState.mIsTouchExplorationEnabled) { + userState.mIsTouchExplorationEnabled = enabled; + Settings.Secure.putIntForUser(mContext.getContentResolver(), + Settings.Secure.TOUCH_EXPLORATION_ENABLED, enabled ? 1 : 0, + userState.mUserId); + } } - private boolean tryEnableTouchExplorationLocked(Service service) { + private boolean canRequestAndRequestsTouchExplorationLocked(Service service) { + // Service not ready or cannot request the feature - well nothing to do. if (!service.canReceiveEventsLocked() || !service.mRequestTouchExplorationMode) { return false; } - UserState userState = getUserStateLocked(service.mUserId); - if (userState.mIsTouchExplorationEnabled) { - return false; - } // UI test automation service can always enable it. if (service.mIsAutomation) { - userState.mIsTouchExplorationEnabled = true; - Settings.Secure.putIntForUser(mContext.getContentResolver(), - Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1, service.mUserId); return true; } if (service.mResolveInfo.serviceInfo.applicationInfo.targetSdkVersion @@ -1405,29 +1406,21 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { // Up to JB-MR1 we had a white list with services that can enable touch // exploration. When a service is first started we show a dialog to the // use to get a permission to white list the service. - if (!userState.mTouchExplorationGrantedServices.contains(service.mComponentName)) { - if (mEnableTouchExplorationDialog == null - || (mEnableTouchExplorationDialog != null - && !mEnableTouchExplorationDialog.isShowing())) { - mMainHandler.obtainMessage( - MainHandler.MSG_SHOW_ENABLED_TOUCH_EXPLORATION_DIALOG, - service).sendToTarget(); - } - } else { - userState.mIsTouchExplorationEnabled = true; - Settings.Secure.putIntForUser(mContext.getContentResolver(), - Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1, service.mUserId); + UserState userState = getUserStateLocked(service.mUserId); + if (userState.mTouchExplorationGrantedServices.contains(service.mComponentName)) { return true; + } else if (mEnableTouchExplorationDialog == null + || !mEnableTouchExplorationDialog.isShowing()) { + mMainHandler.obtainMessage( + MainHandler.MSG_SHOW_ENABLED_TOUCH_EXPLORATION_DIALOG, + service).sendToTarget(); } } else { // Starting in JB-MR2 we request an accessibility service to declare // certain capabilities in its meta-data to allow it to enable the // corresponding features. - if (service.mIsAutomation || (service.mAccessibilityServiceInfo.getCapabilities() + if ((service.mAccessibilityServiceInfo.getCapabilities() & AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION) != 0) { - userState.mIsTouchExplorationEnabled = true; - Settings.Secure.putIntForUser(mContext.getContentResolver(), - Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1, service.mUserId); return true; } } @@ -1435,29 +1428,29 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { } private void updateEnhancedWebAccessibilityLocked(UserState userState) { - userState.mIsEnhancedWebAccessibilityEnabled = false; + boolean enabled = false; final int serviceCount = userState.mBoundServices.size(); for (int i = 0; i < serviceCount; i++) { Service service = userState.mBoundServices.get(i); - if (tryEnableEnhancedWebAccessibilityLocked(service)) { - return; + if (canRequestAndRequestsEnhancedWebAccessibilityLocked(service)) { + enabled = true; + break; } } + if (enabled != userState.mIsEnhancedWebAccessibilityEnabled) { + userState.mIsEnhancedWebAccessibilityEnabled = enabled; + Settings.Secure.putIntForUser(mContext.getContentResolver(), + Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, enabled ? 1 : 0, + userState.mUserId); + } } - private boolean tryEnableEnhancedWebAccessibilityLocked(Service service) { + private boolean canRequestAndRequestsEnhancedWebAccessibilityLocked(Service service) { if (!service.canReceiveEventsLocked() || !service.mRequestEnhancedWebAccessibility ) { return false; } - UserState userState = getUserStateLocked(service.mUserId); - if (userState.mIsEnhancedWebAccessibilityEnabled) { - return false; - } if (service.mIsAutomation || (service.mAccessibilityServiceInfo.getCapabilities() & AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY) != 0) { - userState.mIsEnhancedWebAccessibilityEnabled = true; - Settings.Secure.putIntForUser(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, 1, userState.mUserId); return true; } return false; diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 1203e02..198851c 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -50,6 +50,7 @@ import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; +import android.os.SystemProperties; import android.os.SystemService; import android.os.UserHandle; import android.os.WorkSource; @@ -364,8 +365,6 @@ public final class PowerManagerService extends IPowerManager.Stub private long mLastWarningAboutUserActivityPermission = Long.MIN_VALUE; private native void nativeInit(); - private static native void nativeShutdown(); - private static native void nativeReboot(String reason) throws IOException; private static native void nativeSetPowerState(boolean screenOn, boolean screenBright); private static native void nativeAcquireSuspendBlocker(String name); @@ -2164,18 +2163,26 @@ public final class PowerManagerService extends IPowerManager.Stub * to be clean. Most people should use {@link ShutdownThread} for a clean shutdown. */ public static void lowLevelShutdown() { - nativeShutdown(); + SystemProperties.set("sys.powerctl", "shutdown"); } /** - * Low-level function to reboot the device. + * Low-level function to reboot the device. On success, this function + * doesn't return. If more than 5 seconds passes from the time, + * a reboot is requested, this method returns. * * @param reason code to pass to the kernel (e.g. "recovery"), or null. - * @throws IOException if reboot fails for some reason (eg, lack of - * permission) */ - public static void lowLevelReboot(String reason) throws IOException { - nativeReboot(reason); + public static void lowLevelReboot(String reason) { + if (reason == null) { + reason = ""; + } + SystemProperties.set("sys.powerctl", "reboot," + reason); + try { + Thread.sleep(20000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } @Override // Watchdog.Monitor implementation diff --git a/services/java/com/android/server/power/ShutdownThread.java b/services/java/com/android/server/power/ShutdownThread.java index c7f7390..ba321bc 100644 --- a/services/java/com/android/server/power/ShutdownThread.java +++ b/services/java/com/android/server/power/ShutdownThread.java @@ -490,11 +490,8 @@ public final class ShutdownThread extends Thread { public static void rebootOrShutdown(boolean reboot, String reason) { if (reboot) { Log.i(TAG, "Rebooting, reason: " + reason); - try { - PowerManagerService.lowLevelReboot(reason); - } catch (Exception e) { - Log.e(TAG, "Reboot failed, will attempt shutdown instead", e); - } + PowerManagerService.lowLevelReboot(reason); + Log.e(TAG, "Reboot failed, will attempt shutdown instead"); } else if (SHUTDOWN_VIBRATE_MS > 0) { // vibrate before shutting down Vibrator vibrator = new SystemVibrator(); diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 106cedc..c45d786 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -525,13 +525,8 @@ final class WindowState implements WindowManagerPolicy.WindowState { // Now make sure the window fits in the overall display. Gravity.applyDisplay(mAttrs.gravity, df, mFrame); - // Make sure the overscan, content and visible frames are inside of the + // Make sure the content and visible frames are inside of the // final window frame. - mOverscanFrame.set(Math.max(mOverscanFrame.left, mFrame.left), - Math.max(mOverscanFrame.top, mFrame.top), - Math.min(mOverscanFrame.right, mFrame.right), - Math.min(mOverscanFrame.bottom, mFrame.bottom)); - mContentFrame.set(Math.max(mContentFrame.left, mFrame.left), Math.max(mContentFrame.top, mFrame.top), Math.min(mContentFrame.right, mFrame.right), |
