summaryrefslogtreecommitdiffstats
path: root/services/java/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android')
-rw-r--r--services/java/com/android/server/AppWidgetService.java34
-rw-r--r--services/java/com/android/server/AppWidgetServiceImpl.java5
-rw-r--r--services/java/com/android/server/WallpaperManagerService.java23
-rw-r--r--services/java/com/android/server/accessibility/ScreenMagnifier.java29
-rw-r--r--services/java/com/android/server/pm/UserManagerService.java9
-rw-r--r--services/java/com/android/server/wm/WindowState.java22
6 files changed, 93 insertions, 29 deletions
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java
index e7e4f87..06d37dc 100644
--- a/services/java/com/android/server/AppWidgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -98,21 +98,19 @@ class AppWidgetService extends IAppWidgetService.Stub
IntentFilter userFilter = new IntentFilter();
userFilter.addAction(Intent.ACTION_USER_REMOVED);
+ userFilter.addAction(Intent.ACTION_USER_STOPPING);
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- onUserRemoved(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1));
+ if (Intent.ACTION_USER_REMOVED.equals(intent.getAction())) {
+ onUserRemoved(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
+ UserHandle.USER_NULL));
+ } else if (Intent.ACTION_USER_STOPPING.equals(intent.getAction())) {
+ onUserStopping(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
+ UserHandle.USER_NULL));
+ }
}
}, userFilter);
-
- IntentFilter userStopFilter = new IntentFilter();
- userStopFilter.addAction(Intent.ACTION_USER_STOPPED);
- mContext.registerReceiverAsUser(new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- onUserStopped(getSendingUserId());
- }
- }, UserHandle.ALL, userFilter, null, null);
}
/**
@@ -203,7 +201,7 @@ class AppWidgetService extends IAppWidgetService.Stub
synchronized (mAppWidgetServices) {
AppWidgetServiceImpl impl = mAppWidgetServices.get(userId);
mAppWidgetServices.remove(userId);
-
+
if (impl == null) {
AppWidgetServiceImpl.getSettingsFile(userId).delete();
} else {
@@ -212,7 +210,15 @@ class AppWidgetService extends IAppWidgetService.Stub
}
}
- public void onUserStopped(int userId) {
+ public void onUserStopping(int userId) {
+ if (userId < 1) return;
+ synchronized (mAppWidgetServices) {
+ AppWidgetServiceImpl impl = mAppWidgetServices.get(userId);
+ if (impl != null) {
+ mAppWidgetServices.remove(userId);
+ impl.onUserStopping();
+ }
+ }
}
private AppWidgetServiceImpl getImplForUser(int userId) {
@@ -324,11 +330,11 @@ class AppWidgetService extends IAppWidgetService.Stub
String action = intent.getAction();
// Slog.d(TAG, "received " + action);
if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
- int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
+ int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
if (userId >= 0) {
getImplForUser(userId).sendInitialBroadcasts();
} else {
- Slog.w(TAG, "Not user handle supplied in " + intent);
+ Slog.w(TAG, "Incorrect user handle supplied in " + intent);
}
} else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
for (int i = 0; i < mAppWidgetServices.size(); i++) {
diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/AppWidgetServiceImpl.java
index 9fea6f3..6a313a0 100644
--- a/services/java/com/android/server/AppWidgetServiceImpl.java
+++ b/services/java/com/android/server/AppWidgetServiceImpl.java
@@ -1778,13 +1778,16 @@ class AppWidgetServiceImpl {
return new AtomicFile(settingsFile);
}
- void onUserRemoved() {
+ void onUserStopping() {
// prune the ones we don't want to keep
int N = mInstalledProviders.size();
for (int i = N - 1; i >= 0; i--) {
Provider p = mInstalledProviders.get(i);
cancelBroadcasts(p);
}
+ }
+
+ void onUserRemoved() {
getSettingsFile(mUserId).delete();
}
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index e0f3814..a02fc8d 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -458,15 +458,21 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
IntentFilter userFilter = new IntentFilter();
userFilter.addAction(Intent.ACTION_USER_REMOVED);
+ userFilter.addAction(Intent.ACTION_USER_STOPPING);
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_USER_REMOVED.equals(action)) {
- removeUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
+ onRemoveUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
+ UserHandle.USER_NULL));
+ } else if (Intent.ACTION_USER_STOPPING.equals(action)) {
+ onStoppingUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
+ UserHandle.USER_NULL));
}
}
}, userFilter);
+
try {
ActivityManagerNative.getDefault().registerUserSwitchObserver(
new IUserSwitchObserver.Stub() {
@@ -491,13 +497,24 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
}
}
- void removeUser(int userId) {
+ void onStoppingUser(int userId) {
+ if (userId < 1) return;
synchronized (mLock) {
WallpaperData wallpaper = mWallpaperMap.get(userId);
if (wallpaper != null) {
- wallpaper.wallpaperObserver.stopWatching();
+ if (wallpaper.wallpaperObserver != null) {
+ wallpaper.wallpaperObserver.stopWatching();
+ wallpaper.wallpaperObserver = null;
+ }
mWallpaperMap.remove(userId);
}
+ }
+ }
+
+ void onRemoveUser(int userId) {
+ if (userId < 1) return;
+ synchronized (mLock) {
+ onStoppingUser(userId);
File wallpaperFile = new File(getWallpaperDir(userId), WALLPAPER);
wallpaperFile.delete();
File wallpaperInfoFile = new File(getWallpaperDir(userId), WALLPAPER_INFO);
diff --git a/services/java/com/android/server/accessibility/ScreenMagnifier.java b/services/java/com/android/server/accessibility/ScreenMagnifier.java
index d5a8537..caf37b7 100644
--- a/services/java/com/android/server/accessibility/ScreenMagnifier.java
+++ b/services/java/com/android/server/accessibility/ScreenMagnifier.java
@@ -38,6 +38,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemClock;
import android.provider.Settings;
import android.util.Property;
import android.util.Slog;
@@ -662,12 +663,33 @@ public final class ScreenMagnifier implements EventStreamTransformation {
while (mDelayedEventQueue != null) {
MotionEventInfo info = mDelayedEventQueue;
mDelayedEventQueue = info.mNext;
- ScreenMagnifier.this.onMotionEvent(info.mEvent, info.mRawEvent,
- info.mPolicyFlags);
+ final long offset = SystemClock.uptimeMillis() - info.mCachedTimeMillis;
+ MotionEvent event = obtainEventWithOffsetTimeAndDownTime(info.mEvent, offset);
+ MotionEvent rawEvent = obtainEventWithOffsetTimeAndDownTime(info.mRawEvent, offset);
+ ScreenMagnifier.this.onMotionEvent(event, rawEvent, info.mPolicyFlags);
+ event.recycle();
+ rawEvent.recycle();
info.recycle();
}
}
+ private MotionEvent obtainEventWithOffsetTimeAndDownTime(MotionEvent event, long offset) {
+ final int pointerCount = event.getPointerCount();
+ PointerCoords[] coords = getTempPointerCoordsWithMinSize(pointerCount);
+ PointerProperties[] properties = getTempPointerPropertiesWithMinSize(pointerCount);
+ for (int i = 0; i < pointerCount; i++) {
+ event.getPointerCoords(i, coords[i]);
+ event.getPointerProperties(i, properties[i]);
+ }
+ final long downTime = event.getDownTime() + offset;
+ final long eventTime = event.getEventTime() + offset;
+ return MotionEvent.obtain(downTime, eventTime,
+ event.getAction(), pointerCount, properties, coords,
+ event.getMetaState(), event.getButtonState(),
+ 1.0f, 1.0f, event.getDeviceId(), event.getEdgeFlags(),
+ event.getSource(), event.getFlags());
+ }
+
private void clearDelayedMotionEvents() {
while (mDelayedEventQueue != null) {
MotionEventInfo info = mDelayedEventQueue;
@@ -746,6 +768,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
public MotionEvent mEvent;
public MotionEvent mRawEvent;
public int mPolicyFlags;
+ public long mCachedTimeMillis;
public static MotionEventInfo obtain(MotionEvent event, MotionEvent rawEvent,
int policyFlags) {
@@ -770,6 +793,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
mEvent = MotionEvent.obtain(event);
mRawEvent = MotionEvent.obtain(rawEvent);
mPolicyFlags = policyFlags;
+ mCachedTimeMillis = SystemClock.uptimeMillis();
}
public void recycle() {
@@ -793,6 +817,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
mRawEvent.recycle();
mRawEvent = null;
mPolicyFlags = 0;
+ mCachedTimeMillis = 0;
}
}
diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java
index 4f9375a..77e6c03 100644
--- a/services/java/com/android/server/pm/UserManagerService.java
+++ b/services/java/com/android/server/pm/UserManagerService.java
@@ -149,7 +149,7 @@ public class UserManagerService extends IUserManager.Stub {
-1, -1);
mUserListFile = new File(mUsersDir, USER_LIST_FILENAME);
readUserListLocked();
- // Prune out any partially created users.
+ // Prune out any partially created/partially removed users.
ArrayList<UserInfo> partials = new ArrayList<UserInfo>();
for (int i = 0; i < mUsers.size(); i++) {
UserInfo ui = mUsers.valueAt(i);
@@ -459,7 +459,7 @@ public class UserManagerService extends IUserManager.Stub {
private void fallbackToSingleUserLocked() {
// Create the primary user
UserInfo primary = new UserInfo(0, "Primary", null,
- UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY);
+ UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY | UserInfo.FLAG_INITIALIZED);
mUsers.put(0, primary);
mNextSerialNumber = MIN_USER_ID;
updateUserIdsLocked();
@@ -703,6 +703,11 @@ public class UserManagerService extends IUserManager.Stub {
return false;
}
mRemovingUserIds.add(userHandle);
+ // Set this to a partially created user, so that the user will be purged
+ // on next startup, in case the runtime stops now before stopping and
+ // removing the user completely.
+ user.partial = true;
+ writeUserLocked(user);
}
int res;
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index feb29b1..c195f45 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -1038,18 +1038,26 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
boolean isHiddenFromUserLocked() {
- // Save some cycles by not calling getDisplayInfo unless it is an application
- // window intended for all users.
- if (mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
- && mAppToken != null && mAppToken.showWhenLocked) {
- final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
- if (isFullscreen(displayInfo.appWidth, displayInfo.appHeight)) {
+ // Attached windows are evaluated based on the window that they are attached to.
+ WindowState win = this;
+ while (win.mAttachedWindow != null) {
+ win = win.mAttachedWindow;
+ }
+ if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
+ && win.mAppToken != null && win.mAppToken.showWhenLocked) {
+ // Save some cycles by not calling getDisplayInfo unless it is an application
+ // window intended for all users.
+ final DisplayInfo displayInfo = win.mDisplayContent.getDisplayInfo();
+ if (win.mFrame.left <= 0 && win.mFrame.top <= 0
+ && win.mFrame.right >= displayInfo.appWidth
+ && win.mFrame.bottom >= displayInfo.appHeight) {
// Is a fullscreen window, like the clock alarm. Show to everyone.
return false;
}
}
- return mShowToOwnerOnly && UserHandle.getUserId(mOwnerUid) != mService.mCurrentUserId;
+ return win.mShowToOwnerOnly
+ && UserHandle.getUserId(win.mOwnerUid) != mService.mCurrentUserId;
}
private static void applyInsets(Region outRegion, Rect frame, Rect inset) {