summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android/server')
-rw-r--r--services/java/com/android/server/AppWidgetServiceImpl.java19
-rw-r--r--services/java/com/android/server/NativeDaemonConnector.java3
-rw-r--r--services/java/com/android/server/NetworkManagementService.java2
-rw-r--r--services/java/com/android/server/StatusBarManagerService.java3
-rw-r--r--services/java/com/android/server/WifiService.java2
-rw-r--r--services/java/com/android/server/accessibility/AccessibilityManagerService.java13
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java37
-rwxr-xr-xservices/java/com/android/server/am/ActivityStack.java5
-rw-r--r--services/java/com/android/server/wm/WindowStateAnimator.java126
9 files changed, 139 insertions, 71 deletions
diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/AppWidgetServiceImpl.java
index 23f2fdd..df2e1aa 100644
--- a/services/java/com/android/server/AppWidgetServiceImpl.java
+++ b/services/java/com/android/server/AppWidgetServiceImpl.java
@@ -49,6 +49,7 @@ import android.util.Pair;
import android.util.Slog;
import android.util.TypedValue;
import android.util.Xml;
+import android.view.WindowManager;
import android.widget.RemoteViews;
import com.android.internal.appwidget.IAppWidgetHost;
@@ -171,6 +172,7 @@ class AppWidgetServiceImpl {
boolean mSafeMode;
int mUserId;
boolean mStateLoaded;
+ int mMaxWidgetBitmapMemory;
// These are for debugging only -- widgets are going missing in some rare instances
ArrayList<Provider> mDeletedProviders = new ArrayList<Provider>();
@@ -181,6 +183,14 @@ class AppWidgetServiceImpl {
mPm = AppGlobals.getPackageManager();
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
mUserId = userId;
+ computeMaximumWidgetBitmapMemory();
+ }
+
+ void computeMaximumWidgetBitmapMemory() {
+ WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
+ int height = wm.getDefaultDisplay().getRawHeight();
+ int width = wm.getDefaultDisplay().getRawWidth();
+ mMaxWidgetBitmapMemory = 4 * width * height;
}
public void systemReady(boolean safeMode) {
@@ -806,6 +816,15 @@ class AppWidgetServiceImpl {
if (appWidgetIds == null) {
return;
}
+
+ int bitmapMemoryUsage = views.estimateMemoryUsage();
+ if (bitmapMemoryUsage > mMaxWidgetBitmapMemory) {
+ throw new IllegalArgumentException("RemoteViews for widget update exceeds maximum" +
+ " bitmap memory usage (used: " + bitmapMemoryUsage + ", max: " +
+ mMaxWidgetBitmapMemory + ") The total memory cannot exceed that required to" +
+ " fill the device's screen once.");
+ }
+
if (appWidgetIds.length == 0) {
return;
}
diff --git a/services/java/com/android/server/NativeDaemonConnector.java b/services/java/com/android/server/NativeDaemonConnector.java
index 6a6c585..a15d3bb 100644
--- a/services/java/com/android/server/NativeDaemonConnector.java
+++ b/services/java/com/android/server/NativeDaemonConnector.java
@@ -148,6 +148,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
mCallbackHandler.sendMessage(mCallbackHandler.obtainMessage(
event.getCode(), event.getRawEvent()));
} else {
+ log("POST<- {" + rawEvent + "}");
mResponseQueue.add(event.getCmdNumber(), event);
}
} catch (IllegalArgumentException e) {
@@ -327,6 +328,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
loge("timed-out waiting for response to " + logCmd);
throw new NativeDaemonFailureException(logCmd, event);
}
+ log("RMV <- {" + event + "}");
events.add(event);
} while (event.isClassContinue());
@@ -337,6 +339,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
throw new NativeDaemonFailureException(logCmd, event);
}
+ log("RTN <- {" + logCmd + "}");
return events.toArray(new NativeDaemonEvent[events.size()]);
}
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 4536a6d..e2852b5 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -166,7 +166,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
mConnector = new NativeDaemonConnector(
- new NetdCallbackReceiver(), "netd", 10, NETD_TAG, 50);
+ new NetdCallbackReceiver(), "netd", 10, NETD_TAG, 80);
mThread = new Thread(mConnector, NETD_TAG);
// Add ourself to the Watchdog monitors.
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 8429086..78c0c12 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -489,7 +489,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub
synchronized (mNotifications) {
final StatusBarNotification n = mNotifications.remove(key);
if (n == null) {
- throw new IllegalArgumentException("removeNotification key not found: " + key);
+ Slog.e(TAG, "removeNotification key not found: " + key);
+ return;
}
if (mBar != null) {
try {
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index bb38cd9..b1558c7 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -562,6 +562,8 @@ public class WifiService extends IWifiManager.Stub {
*/
public synchronized boolean setWifiEnabled(boolean enable) {
enforceChangePermission();
+ Slog.d(TAG, "setWifiEnabled: " + enable + " pid=" + Binder.getCallingPid()
+ + ", uid=" + Binder.getCallingUid());
if (DBG) {
Slog.e(TAG, "Invoking mWifiStateMachine.setWifiEnabled\n");
}
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index 1937bad..f23b25e 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -35,6 +35,7 @@ import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
import android.database.ContentObserver;
import android.graphics.Rect;
import android.hardware.input.InputManager;
@@ -532,6 +533,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
for (int i = 0, count = installedServices.size(); i < count; i++) {
ResolveInfo resolveInfo = installedServices.get(i);
+ ServiceInfo serviceInfo = resolveInfo.serviceInfo;
+ // For now we are enforcing this if the target version is JellyBean or
+ // higher and in a later release we will enforce this for everyone.
+ if (serviceInfo.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.JELLY_BEAN
+ && !android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE.equals(
+ serviceInfo.permission)) {
+ Slog.w(LOG_TAG, "Skipping accessibilty service " + new ComponentName(
+ serviceInfo.packageName, serviceInfo.name).flattenToShortString()
+ + ": it does not require the permission "
+ + android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE);
+ continue;
+ }
AccessibilityServiceInfo accessibilityServiceInfo;
try {
accessibilityServiceInfo = new AccessibilityServiceInfo(resolveInfo, mContext);
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 54ef724..76016f4 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -3510,31 +3510,36 @@ public final class ActivityManagerService extends ActivityManagerNative
public void closeSystemDialogs(String reason) {
enforceNotIsolatedCaller("closeSystemDialogs");
+
+ final int uid = Binder.getCallingUid();
+ final long origId = Binder.clearCallingIdentity();
+ synchronized (this) {
+ closeSystemDialogsLocked(uid, reason);
+ }
+ Binder.restoreCallingIdentity(origId);
+ }
+
+ void closeSystemDialogsLocked(int callingUid, String reason) {
Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
if (reason != null) {
intent.putExtra("reason", reason);
}
+ mWindowManager.closeSystemDialogs(reason);
- final int uid = Binder.getCallingUid();
- final long origId = Binder.clearCallingIdentity();
- synchronized (this) {
- mWindowManager.closeSystemDialogs(reason);
-
- for (int i=mMainStack.mHistory.size()-1; i>=0; i--) {
- ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i);
- if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
- r.stack.finishActivityLocked(r, i,
- Activity.RESULT_CANCELED, null, "close-sys");
- }
+ for (int i=mMainStack.mHistory.size()-1; i>=0; i--) {
+ ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i);
+ if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
+ r.stack.finishActivityLocked(r, i,
+ Activity.RESULT_CANCELED, null, "close-sys");
}
-
- broadcastIntentLocked(null, null, intent, null,
- null, 0, null, null, null, false, false, -1, uid, 0 /* TODO: Verify */);
}
- Binder.restoreCallingIdentity(origId);
+
+ broadcastIntentLocked(null, null, intent, null,
+ null, 0, null, null, null, false, false, -1,
+ callingUid, 0 /* TODO: Verify */);
}
-
+
public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
throws RemoteException {
enforceNotIsolatedCaller("getProcessMemoryInfo");
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index e6f4d918..5b15e50 100755
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -52,6 +52,7 @@ import android.os.IBinder;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
+import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserId;
@@ -2532,6 +2533,10 @@ final class ActivityStack {
mDismissKeyguardOnNextActivity = false;
mService.mWindowManager.dismissKeyguard();
}
+ if (err >= ActivityManager.START_SUCCESS &&
+ (launchFlags&Intent.FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS) != 0) {
+ mService.closeSystemDialogsLocked(Process.myUid(), "launch");
+ }
return err;
}
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index cba92f3..5516dea 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -935,6 +935,59 @@ class WindowStateAnimator {
mDtDy = mWin.mGlobalScale;
}
+ void updateSurfaceWindowCrop(final boolean recoveringMemory) {
+ final WindowState w = mWin;
+
+ // Need to recompute a new system decor rect each time.
+ if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) {
+ // Currently can't do this cropping for scaled windows. We'll
+ // just keep the crop rect the same as the source surface.
+ w.mSystemDecorRect.set(0, 0, w.mRequestedWidth, w.mRequestedHeight);
+ } else if (w.mLayer >= mService.mSystemDecorLayer) {
+ // Above the decor layer is easy, just use the entire window.
+ w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(),
+ w.mCompatFrame.height());
+ } else {
+ final Rect decorRect = mService.mSystemDecorRect;
+ // Compute the offset of the window in relation to the decor rect.
+ final int offX = w.mXOffset + w.mFrame.left;
+ final int offY = w.mYOffset + w.mFrame.top;
+ // Initialize the decor rect to the entire frame.
+ w.mSystemDecorRect.set(0, 0, w.mFrame.width(), w.mFrame.height());
+ // Intersect with the decor rect, offsetted by window position.
+ w.mSystemDecorRect.intersect(decorRect.left-offX, decorRect.top-offY,
+ decorRect.right-offX, decorRect.bottom-offY);
+ // If size compatibility is being applied to the window, the
+ // surface is scaled relative to the screen. Also apply this
+ // scaling to the crop rect. We aren't using the standard rect
+ // scale function because we want to round things to make the crop
+ // always round to a larger rect to ensure we don't crop too
+ // much and hide part of the window that should be seen.
+ if (w.mEnforceSizeCompat && w.mInvGlobalScale != 1.0f) {
+ final float scale = w.mInvGlobalScale;
+ w.mSystemDecorRect.left = (int) (w.mSystemDecorRect.left * scale - 0.5f);
+ w.mSystemDecorRect.top = (int) (w.mSystemDecorRect.top * scale - 0.5f);
+ w.mSystemDecorRect.right = (int) ((w.mSystemDecorRect.right+1) * scale - 0.5f);
+ w.mSystemDecorRect.bottom = (int) ((w.mSystemDecorRect.bottom+1) * scale - 0.5f);
+ }
+ }
+
+ if (!w.mSystemDecorRect.equals(w.mLastSystemDecorRect)) {
+ w.mLastSystemDecorRect.set(w.mSystemDecorRect);
+ try {
+ if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
+ "CROP " + w.mSystemDecorRect.toShortString(), null);
+ mSurface.setWindowCrop(w.mSystemDecorRect);
+ } catch (RuntimeException e) {
+ Slog.w(TAG, "Error setting crop surface of " + w
+ + " crop=" + w.mSystemDecorRect.toShortString(), e);
+ if (!recoveringMemory) {
+ mService.reclaimSomeSurfaceMemoryLocked(this, "crop", true);
+ }
+ }
+ }
+ }
+
void setSurfaceBoundaries(final boolean recoveringMemory) {
final WindowState w = mWin;
int width, height;
@@ -1003,54 +1056,7 @@ class WindowStateAnimator {
}
}
- // Need to recompute a new system decor rect each time.
- if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) {
- // Currently can't do this cropping for scaled windows. We'll
- // just keep the crop rect the same as the source surface.
- w.mSystemDecorRect.set(0, 0, w.mRequestedWidth, w.mRequestedHeight);
- } else if (w.mLayer >= mService.mSystemDecorLayer) {
- // Above the decor layer is easy, just use the entire window.
- w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(),
- w.mCompatFrame.height());
- } else {
- final Rect decorRect = mService.mSystemDecorRect;
- // Compute the offset of the window in relation to the decor rect.
- final int offX = w.mXOffset + w.mFrame.left;
- final int offY = w.mYOffset + w.mFrame.top;
- // Initialize the decor rect to the entire frame.
- w.mSystemDecorRect.set(0, 0, w.mFrame.width(), w.mFrame.height());
- // Intersect with the decor rect, offsetted by window position.
- w.mSystemDecorRect.intersect(decorRect.left-offX, decorRect.top-offY,
- decorRect.right-offX, decorRect.bottom-offY);
- // If size compatibility is being applied to the window, the
- // surface is scaled relative to the screen. Also apply this
- // scaling to the crop rect. We aren't using the standard rect
- // scale function because we want to round things to make the crop
- // always round to a larger rect to ensure we don't crop too
- // much and hide part of the window that should be seen.
- if (w.mEnforceSizeCompat && w.mInvGlobalScale != 1.0f) {
- final float scale = w.mInvGlobalScale;
- w.mSystemDecorRect.left = (int) (w.mSystemDecorRect.left * scale - 0.5f);
- w.mSystemDecorRect.top = (int) (w.mSystemDecorRect.top * scale - 0.5f);
- w.mSystemDecorRect.right = (int) ((w.mSystemDecorRect.right+1) * scale - 0.5f);
- w.mSystemDecorRect.bottom = (int) ((w.mSystemDecorRect.bottom+1) * scale - 0.5f);
- }
- }
-
- if (!w.mSystemDecorRect.equals(w.mLastSystemDecorRect)) {
- w.mLastSystemDecorRect.set(w.mSystemDecorRect);
- try {
- if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
- "CROP " + w.mSystemDecorRect.toShortString(), null);
- mSurface.setWindowCrop(w.mSystemDecorRect);
- } catch (RuntimeException e) {
- Slog.w(TAG, "Error setting crop surface of " + w
- + " crop=" + w.mSystemDecorRect.toShortString(), e);
- if (!recoveringMemory) {
- mService.reclaimSomeSurfaceMemoryLocked(this, "crop", true);
- }
- }
- }
+ updateSurfaceWindowCrop(recoveringMemory);
}
public void prepareSurfaceLocked(final boolean recoveringMemory) {
@@ -1181,17 +1187,31 @@ class WindowStateAnimator {
}
void setWallpaperOffset(int left, int top) {
+ mSurfaceX = left;
+ mSurfaceY = top;
+ if (mAnimating) {
+ // If this window (or its app token) is animating, then the position
+ // of the surface will be re-computed on the next animation frame.
+ // We can't poke it directly here because it depends on whatever
+ // transformation is being applied by the animation.
+ return;
+ }
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
+ ">>> OPEN TRANSACTION setWallpaperOffset");
Surface.openTransaction();
try {
- mSurfaceX = left;
- mSurfaceY = top;
- mSurface.setPosition(left, top);
- mSurface.setWindowCrop(null);
+ if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin,
+ "POS " + left + ", " + top, null);
+ mSurface.setPosition(mWin.mFrame.left + left, mWin.mFrame.top + top);
+ updateSurfaceWindowCrop(false);
} catch (RuntimeException e) {
Slog.w(TAG, "Error positioning surface of " + mWin
+ " pos=(" + left + "," + top + ")", e);
+ } finally {
+ Surface.closeTransaction();
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
+ "<<< CLOSE TRANSACTION setWallpaperOffset");
}
- Surface.closeTransaction();
}
// This must be called while inside a transaction.