diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-09-10 10:54:46 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-09-10 12:08:50 -0700 |
commit | bcbcaa7edd32ba67c6290d79f7e7821c4b5b39ac (patch) | |
tree | 7840b8a005d8261f864b8404e5cf5941cf6caf80 /services | |
parent | e1fd02400d69c059db2cc6299c893eba4096cc1d (diff) | |
download | frameworks_base-bcbcaa7edd32ba67c6290d79f7e7821c4b5b39ac.zip frameworks_base-bcbcaa7edd32ba67c6290d79f7e7821c4b5b39ac.tar.gz frameworks_base-bcbcaa7edd32ba67c6290d79f7e7821c4b5b39ac.tar.bz2 |
Wallpapers, animations, pending intent.
Some more tweaks and fixes to wallpapers. Make sure wallpapers are
told they are not visible when the screen is off. Add some new animations
for transitions across tasks, and fiddle with many of the existing
animations. Clean up the relationship between translucent activities
and animations. Add new API to start a PendingIntent from an
activity.
Change-Id: Ie0bf45fe44081bb6982c75361257a55d9cd9d863
Diffstat (limited to 'services')
3 files changed, 114 insertions, 112 deletions
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index c8ff6cb..b0e4038 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -8022,6 +8022,19 @@ public class WindowManagerService extends IWindowManager.Stub } } + WindowState findMainWindow() { + int j = windows.size(); + while (j > 0) { + j--; + WindowState win = windows.get(j); + if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION + || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { + return win; + } + } + return null; + } + void dump(PrintWriter pw, String prefix) { super.dump(pw, prefix); if (appToken != null) { @@ -8088,71 +8101,6 @@ public class WindowManagerService extends IWindowManager.Stub } } - public static WindowManager.LayoutParams findAnimations( - ArrayList<AppWindowToken> order, - ArrayList<AppWindowToken> openingTokenList1, - ArrayList<AppWindowToken> closingTokenList2) { - // We need to figure out which animation to use... - - // First, check if there is a compatible window in opening/closing - // apps, and use it if exists. - WindowManager.LayoutParams animParams = null; - int animSrc = 0; - animParams = findCompatibleWindowParams(openingTokenList1); - if (animParams == null) { - animParams = findCompatibleWindowParams(closingTokenList2); - } - if (animParams != null) { - return animParams; - } - - //Log.i(TAG, "Looking for animations..."); - for (int i=order.size()-1; i>=0; i--) { - AppWindowToken wtoken = order.get(i); - //Log.i(TAG, "Token " + wtoken + " with " + wtoken.windows.size() + " windows"); - if (openingTokenList1.contains(wtoken) || closingTokenList2.contains(wtoken)) { - int j = wtoken.windows.size(); - while (j > 0) { - j--; - WindowState win = wtoken.windows.get(j); - //Log.i(TAG, "Window " + win + ": type=" + win.mAttrs.type); - if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION - || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { - //Log.i(TAG, "Found base or application window, done!"); - if (wtoken.appFullscreen) { - return win.mAttrs; - } - if (animSrc < 2) { - animParams = win.mAttrs; - animSrc = 2; - } - } else if (animSrc < 1 && win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION) { - //Log.i(TAG, "Found normal window, we may use this..."); - animParams = win.mAttrs; - animSrc = 1; - } - } - } - } - - return animParams; - } - - private static LayoutParams findCompatibleWindowParams(ArrayList<AppWindowToken> tokenList) { - for (int appCount = tokenList.size() - 1; appCount >= 0; appCount--) { - AppWindowToken wtoken = tokenList.get(appCount); - // Just checking one window is sufficient as all windows have the compatible flag - // if the application is in compatibility mode. - if (wtoken.windows.size() > 0) { - WindowManager.LayoutParams params = wtoken.windows.get(0).mAttrs; - if ((params.flags & FLAG_COMPATIBLE_WINDOW) != 0) { - return params; - } - } - } - return null; - } - // ------------------------------------------------------------- // DummyAnimation // ------------------------------------------------------------- @@ -9043,35 +8991,56 @@ public class WindowManagerService extends IWindowManager.Stub adjustWallpaperWindowsLocked(); wallpaperMayChange = false; + // The top-most window will supply the layout params, + // and we will determine it below. + LayoutParams animLp = null; + int bestAnimLayer = -1; + if (DEBUG_APP_TRANSITIONS) Log.v(TAG, "New wallpaper target=" + mWallpaperTarget + ", lower target=" + mLowerWallpaperTarget + ", upper target=" + mUpperWallpaperTarget); int foundWallpapers = 0; - if (mLowerWallpaperTarget != null) { - // Need to determine if both the closing and - // opening app token sets are wallpaper targets, - // in which case special animations are needed - // (since the wallpaper needs to stay static - // behind them). - NN = mClosingApps.size(); - for (i=0; i<NN; i++) { - AppWindowToken wtoken = mClosingApps.get(i); - if (mLowerWallpaperTarget.mAppToken == wtoken) { - foundWallpapers |= 1; - } - if (mUpperWallpaperTarget.mAppToken == wtoken) { - foundWallpapers |= 1; - } + // Do a first pass through the tokens for two + // things: + // (1) Determine if both the closing and opening + // app token sets are wallpaper targets, in which + // case special animations are needed + // (since the wallpaper needs to stay static + // behind them). + // (2) Find the layout params of the top-most + // application window in the tokens, which is + // what will control the animation theme. + final int NC = mClosingApps.size(); + NN = NC + mOpeningApps.size(); + for (i=0; i<NN; i++) { + AppWindowToken wtoken; + int mode; + if (i < NC) { + wtoken = mClosingApps.get(i); + mode = 1; + } else { + wtoken = mOpeningApps.get(i-NC); + mode = 2; } - NN = mOpeningApps.size(); - for (i=0; i<NN; i++) { - AppWindowToken wtoken = mOpeningApps.get(i); - if (mLowerWallpaperTarget.mAppToken == wtoken) { - foundWallpapers |= 2; + if (mLowerWallpaperTarget != null) { + if (mLowerWallpaperTarget.mAppToken == wtoken + || mUpperWallpaperTarget.mAppToken == wtoken) { + foundWallpapers |= mode; } - if (mUpperWallpaperTarget.mAppToken == wtoken) { - foundWallpapers |= 2; + } + if (wtoken.appFullscreen) { + WindowState ws = wtoken.findMainWindow(); + if (ws != null) { + // If this is a compatibility mode + // window, we will always use its anim. + if ((ws.mAttrs.flags&FLAG_COMPATIBLE_WINDOW) != 0) { + animLp = ws.mAttrs; + bestAnimLayer = Integer.MAX_VALUE; + } else if (ws.mLayer > bestAnimLayer) { + animLp = ws.mAttrs; + bestAnimLayer = ws.mLayer; + } } } } @@ -9107,10 +9076,6 @@ public class WindowManagerService extends IWindowManager.Stub "New transit into wallpaper: " + transit); } - // We need to figure out which animation to use... - WindowManager.LayoutParams lp = findAnimations(mAppTokens, - mOpeningApps, mClosingApps); - NN = mOpeningApps.size(); for (i=0; i<NN; i++) { AppWindowToken wtoken = mOpeningApps.get(i); @@ -9119,7 +9084,7 @@ public class WindowManagerService extends IWindowManager.Stub wtoken.reportedVisible = false; wtoken.inPendingTransaction = false; wtoken.animation = null; - setTokenVisibilityLocked(wtoken, lp, true, transit, false); + setTokenVisibilityLocked(wtoken, animLp, true, transit, false); wtoken.updateReportedVisibilityLocked(); wtoken.waitingToShow = false; wtoken.showAllWindowsLocked(); @@ -9131,7 +9096,7 @@ public class WindowManagerService extends IWindowManager.Stub "Now closing app" + wtoken); wtoken.inPendingTransaction = false; wtoken.animation = null; - setTokenVisibilityLocked(wtoken, lp, false, transit, false); + setTokenVisibilityLocked(wtoken, animLp, false, transit, false); wtoken.updateReportedVisibilityLocked(); wtoken.waitingToHide = false; // Force the allDrawn flag, because we want to start diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 0b86fc0..66ef557 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -33,6 +33,7 @@ import android.app.AlertDialog; import android.app.ApplicationErrorReport; import android.app.Dialog; import android.app.IActivityController; +import android.app.IActivityManager; import android.app.IActivityWatcher; import android.app.IApplicationThread; import android.app.IInstrumentationWatcher; @@ -3612,6 +3613,29 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } + public int startActivityPendingIntent(IApplicationThread caller, + PendingIntent intent, Intent fillInIntent, String resolvedType, + IBinder resultTo, String resultWho, int requestCode, + int flagsMask, int flagsValues) { + // Refuse possible leaked file descriptors + if (fillInIntent != null && fillInIntent.hasFileDescriptors()) { + throw new IllegalArgumentException("File descriptors passed in Intent"); + } + + IIntentSender sender = intent.getTarget(); + if (!(sender instanceof PendingIntentRecord)) { + throw new IllegalArgumentException("Bad PendingIntent object"); + } + + PendingIntentRecord pir = (PendingIntentRecord)sender; + if (pir.key.type != IActivityManager.INTENT_SENDER_ACTIVITY) { + return START_NOT_ACTIVITY; + } + + return pir.sendInner(0, fillInIntent, resolvedType, + null, resultTo, resultWho, requestCode, flagsMask, flagsValues); + } + public boolean startNextMatchingActivity(IBinder callingActivity, Intent intent) { // Refuse possible leaked file descriptors @@ -12918,15 +12942,6 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } if (app.services.size() != 0 && adj > FOREGROUND_APP_ADJ) { - // If this process has active services running in it, we would - // like to avoid killing it unless it would prevent the current - // application from running. By default we put the process in - // with the rest of the background processes; as we scan through - // its services we may bump it up from there. - if (adj > hiddenAdj) { - adj = hiddenAdj; - app.adjType = "bg-services"; - } final long now = SystemClock.uptimeMillis(); // This process is more important if the top activity is // bound to the service. @@ -12994,17 +13009,19 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } } + + // Finally, f this process has active services running in it, we + // would like to avoid killing it unless it would prevent the current + // application from running. By default we put the process in + // with the rest of the background processes; as we scan through + // its services we may bump it up from there. + if (adj > hiddenAdj) { + adj = hiddenAdj; + app.adjType = "bg-services"; + } } if (app.pubProviders.size() != 0 && adj > FOREGROUND_APP_ADJ) { - // If this process has published any content providers, then - // its adjustment makes it at least as important as any of the - // processes using those providers, and no less important than - // CONTENT_PROVIDER_ADJ, which is just shy of EMPTY. - if (adj > CONTENT_PROVIDER_ADJ) { - adj = CONTENT_PROVIDER_ADJ; - app.adjType = "pub-providers"; - } Iterator jt = app.pubProviders.values().iterator(); while (jt.hasNext() && adj > FOREGROUND_APP_ADJ) { ContentProviderRecord cpr = (ContentProviderRecord)jt.next(); @@ -13048,6 +13065,15 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } } + + // Finally, if this process has published any content providers, + // then its adjustment makes it at least as important as any of the + // processes using those providers, and no less important than + // CONTENT_PROVIDER_ADJ, which is just shy of EMPTY. + if (adj > CONTENT_PROVIDER_ADJ) { + adj = CONTENT_PROVIDER_ADJ; + app.adjType = "pub-providers"; + } } app.curRawAdj = adj; diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java index fa2a100..d994362 100644 --- a/services/java/com/android/server/am/PendingIntentRecord.java +++ b/services/java/com/android/server/am/PendingIntentRecord.java @@ -22,6 +22,7 @@ import android.content.IIntentReceiver; import android.app.PendingIntent; import android.content.Intent; import android.os.Binder; +import android.os.IBinder; import android.os.RemoteException; import android.util.Log; @@ -172,6 +173,14 @@ class PendingIntentRecord extends IIntentSender.Stub { public int send(int code, Intent intent, String resolvedType, IIntentReceiver finishedReceiver) { + return sendInner(code, intent, resolvedType, finishedReceiver, + null, null, 0, 0, 0); + } + + int sendInner(int code, Intent intent, String resolvedType, + IIntentReceiver finishedReceiver, + IBinder resultTo, String resultWho, int requestCode, + int flagsMask, int flagsValues) { synchronized(owner) { if (!canceled) { sent = true; @@ -189,6 +198,8 @@ class PendingIntentRecord extends IIntentSender.Stub { } else { resolvedType = key.requestResolvedType; } + flagsValues &= flagsMask; + finalIntent.setFlags((finalIntent.getFlags()&~flagsMask) | flagsValues); final long origId = Binder.clearCallingIdentity(); @@ -198,7 +209,7 @@ class PendingIntentRecord extends IIntentSender.Stub { try { owner.startActivityInPackage(uid, finalIntent, resolvedType, - null, null, 0, false); + resultTo, resultWho, requestCode, false); } catch (RuntimeException e) { Log.w(ActivityManagerService.TAG, "Unable to send startActivity intent", e); @@ -246,7 +257,7 @@ class PendingIntentRecord extends IIntentSender.Stub { return 0; } } - return -1; + return IActivityManager.START_CANCELED; } protected void finalize() throws Throwable { |