summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSander Alewijnse <salewijnse@google.com>2014-07-29 12:01:38 +0100
committerSander Alewijnse <salewijnse@google.com>2014-07-31 09:16:46 +0000
commita87863a8bddb033ca9ace11e7d78932d70d08ce3 (patch)
tree4bbd16fdf6b8a8149309b5f3f287a631fba5640b
parentd5ce9759524740cfb02638fd1d7b44315957b422 (diff)
downloadframeworks_base-a87863a8bddb033ca9ace11e7d78932d70d08ce3.zip
frameworks_base-a87863a8bddb033ca9ace11e7d78932d70d08ce3.tar.gz
frameworks_base-a87863a8bddb033ca9ace11e7d78932d70d08ce3.tar.bz2
Fix deadlock window manager and device policy manager.
Removed all communication from wm to device policy manager. Added initialization of cache in wm by dpms. Change-Id: Ifa0b8bfcd625464b156d5cc0fb66d342deda1c27
-rw-r--r--core/java/android/view/IWindowManager.aidl5
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java41
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java28
-rw-r--r--tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java2
4 files changed, 35 insertions, 41 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 5157c41..83767cb 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -150,10 +150,9 @@ interface IWindowManager
void setStrictModeVisualIndicatorPreference(String enabled);
/**
- * Update the windowmanagers cached value of
- * {@link android.app.admin.DevicePolicyManager#getScreenCaptureDisabled(null, userId)}
+ * Set whether screen capture is disabled for all windows of a specific user
*/
- void updateScreenCaptureDisabled(int userId);
+ void setScreenCaptureDisabled(int userId, boolean disabled);
// These can only be called with the SET_ORIENTATION permission.
/**
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 670ba55..80dfb91 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -19,7 +19,6 @@ package com.android.server.wm;
import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
-import android.app.admin.DevicePolicyManager;
import android.app.AppOpsManager;
import android.util.ArraySet;
import android.util.TimeUtils;
@@ -2455,37 +2454,24 @@ public class WindowManagerService extends IWindowManager.Stub
*/
boolean isScreenCaptureDisabledLocked(int userId) {
Boolean disabled = mScreenCaptureDisabled.get(userId);
- if (disabled != null) {
- return disabled;
- }
-
- // mScreenCaptureDisabled not set yet, try to update it.
- updateScreenCaptureDisabledLocked(userId);
- disabled = mScreenCaptureDisabled.get(userId);
if (disabled == null) {
- // Not able to update, return false by default.
return false;
- } else {
- return disabled;
}
+ return disabled;
}
/**
- * Update mScreenCaptureDisabled for specific user according to the device policy manager.
+ * Set mScreenCaptureDisabled for specific user
*/
@Override
- public void updateScreenCaptureDisabled(int userId) {
- mH.sendMessage(mH.obtainMessage(H.UPDATE_SCRN_CAP, userId, 0 /* unused argument */));
- }
+ public void setScreenCaptureDisabled(int userId, boolean disabled) {
+ int callingUid = Binder.getCallingUid();
+ if (callingUid != Process.SYSTEM_UID) {
+ throw new SecurityException("Only system can call setScreenCaptureDisabled.");
+ }
- void updateScreenCaptureDisabledLocked(int userId) {
- DevicePolicyManager dpm = (DevicePolicyManager) mContext
- .getSystemService(Context.DEVICE_POLICY_SERVICE);
- if (dpm != null) {
- boolean disabled = dpm.getScreenCaptureDisabled(null, userId);
+ synchronized(mWindowMap) {
mScreenCaptureDisabled.put(userId, disabled);
- } else {
- Slog.e(TAG, "Could not get DevicePolicyManager.");
}
}
@@ -7293,9 +7279,7 @@ public class WindowManagerService extends IWindowManager.Stub
public static final int NEW_ANIMATOR_SCALE = 34;
- public static final int UPDATE_SCRN_CAP = 35;
-
- public static final int SHOW_DISPLAY_MASK = 36;
+ public static final int SHOW_DISPLAY_MASK = 35;
@Override
public void handleMessage(Message msg) {
@@ -7776,13 +7760,6 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
break;
-
- case UPDATE_SCRN_CAP: {
- synchronized (mWindowMap) {
- updateScreenCaptureDisabledLocked(msg.arg1);
- }
- }
- break;
}
if (DEBUG_WINDOW_TRACE) {
Slog.v(TAG, "handleMessage: exit");
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 6ab504c..c6730bf 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -791,6 +791,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
policyFile.delete();
Slog.i(LOG_TAG, "Removed device policy file " + policyFile.getAbsolutePath());
}
+ updateScreenCaptureDisabledInWindowManager(userHandle, false /* default value */);
}
void loadDeviceOwner() {
@@ -1367,6 +1368,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
new SetupContentObserver(mHandler).register(mContext.getContentResolver());
// Initialize the user setup state, to handle the upgrade case.
updateUserSetupComplete();
+
+ // Update the screen capture disabled cache in the window manager
+ List<UserInfo> users = mUserManager.getUsers(true);
+ final int N = users.size();
+ for (int i = 0; i < N; i++) {
+ int userHandle = users.get(i).id;
+ updateScreenCaptureDisabledInWindowManager(userHandle,
+ getScreenCaptureDisabled(null, userHandle));
+ }
+
}
private void cleanUpOldUsers() {
@@ -3062,11 +3073,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
if (ap.disableScreenCapture != disabled) {
ap.disableScreenCapture = disabled;
saveSettingsLocked(userHandle);
- try {
- getWindowManager().updateScreenCaptureDisabled(userHandle);
- } catch (RemoteException e) {
- Log.w(LOG_TAG, "Unable to notify WindowManager.", e);
- }
+ updateScreenCaptureDisabledInWindowManager(userHandle, disabled);
}
}
}
@@ -3097,6 +3104,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
+ private void updateScreenCaptureDisabledInWindowManager(int userHandle, boolean disabled) {
+ long ident = Binder.clearCallingIdentity();
+ try {
+ getWindowManager().setScreenCaptureDisabled(userHandle, disabled);
+ } catch (RemoteException e) {
+ Log.w(LOG_TAG, "Unable to notify WindowManager.", e);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
/**
* The system property used to share the state of the camera. The native camera service
* is expected to read this property and act accordingly.
diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
index 2ffe4a2..09b57fe 100644
--- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
+++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
@@ -360,7 +360,7 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
- public void updateScreenCaptureDisabled(int userId) {
+ public void setScreenCaptureDisabled(int userId, boolean disabled) {
// TODO Auto-generated method stub
}