There are two things going on here: (1) In secondary users, some times theme information such as whether the window is full screen opaque was not being retrieved, so the window manager didn't know that it could hide the windows behind the app. This would just be a performance problem, except that: (2) There appear to be a number of applications that declare that they are full screen opaque, when in fact they are not. Instead they are using window surfaces with an alpha channel, and setting some pixels in their window to a non-opaque alpha level. This will allow you to see whatever is behind the app. If the system happens to completely remove the windows behind the app, and somebody is filling the frame buffer with black, then you will see what the app intends -- those parts of its UI blended with black. If one of those cases doesn't hold (and though we have never guaranteed they would, in practice this is generally what happens), then you will see something else. At any rate, if nothing else than for performance reasons, we need to fix issue #1. It turns out what is happening here is that the AttributeCache used by the activity manager and window manager to retreive theme and other information about applications has not yet been updated for multi-user. One of the things we retrieve from this is the theme information telling the window manager whether an application's window should be treated as full screen opaque, allowing it to hide any windows behind it. In the current implementation, the AttributeCache always retrieves this information about the application as the primary user (user 0). So, if you have an application that is installed on a secondary user but not installed on the primary user, when the AttributeCache tries to retrieve the requested information for it, then from the perspective of the primary user it considers the application not installed, and is not able to retrieve that info. The change here makes AttributeCache multi-user aware, keeping all of its data separately per-user, and requiring that callers now provide the user they want to retrieve information for. Activity manager and window manager are updated to be able to pass in the user when needed. This required some fiddling of the window manager to have that information available -- in particular it needs to be associated with the AppWindowToken. Change-Id: I4b50b4b3a41bab9d4689e61f3584778e451343c8
288 lines
11 KiB
Java
288 lines
11 KiB
Java
/*
|
|
* Copyright (C) 2011 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.server.wm;
|
|
|
|
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
|
|
|
import com.android.server.input.InputApplicationHandle;
|
|
import com.android.server.wm.WindowManagerService.H;
|
|
|
|
import android.content.pm.ActivityInfo;
|
|
import android.os.Message;
|
|
import android.os.RemoteException;
|
|
import android.util.Slog;
|
|
import android.view.IApplicationToken;
|
|
import android.view.View;
|
|
import android.view.WindowManager;
|
|
|
|
import java.io.PrintWriter;
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
* Version of WindowToken that is specifically for a particular application (or
|
|
* really activity) that is displaying windows.
|
|
*/
|
|
class AppWindowToken extends WindowToken {
|
|
// The user who owns this app window token.
|
|
final int userId;
|
|
// Non-null only for application tokens.
|
|
final IApplicationToken appToken;
|
|
|
|
// All of the windows and child windows that are included in this
|
|
// application token. Note this list is NOT sorted!
|
|
final ArrayList<WindowState> allAppWindows = new ArrayList<WindowState>();
|
|
final AppWindowAnimator mAppAnimator;
|
|
|
|
final WindowAnimator mAnimator;
|
|
|
|
int groupId = -1;
|
|
boolean appFullscreen;
|
|
int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
|
boolean showWhenLocked;
|
|
|
|
// The input dispatching timeout for this application token in nanoseconds.
|
|
long inputDispatchingTimeoutNanos;
|
|
|
|
// These are used for determining when all windows associated with
|
|
// an activity have been drawn, so they can be made visible together
|
|
// at the same time.
|
|
// initialize so that it doesn't match mTransactionSequence which is an int.
|
|
long lastTransactionSequence = Long.MIN_VALUE;
|
|
int numInterestingWindows;
|
|
int numDrawnWindows;
|
|
boolean inPendingTransaction;
|
|
boolean allDrawn;
|
|
|
|
// Is this token going to be hidden in a little while? If so, it
|
|
// won't be taken into account for setting the screen orientation.
|
|
boolean willBeHidden;
|
|
|
|
// Is this window's surface needed? This is almost like hidden, except
|
|
// it will sometimes be true a little earlier: when the token has
|
|
// been shown, but is still waiting for its app transition to execute
|
|
// before making its windows shown.
|
|
boolean hiddenRequested;
|
|
|
|
// Have we told the window clients to hide themselves?
|
|
boolean clientHidden;
|
|
|
|
// Last visibility state we reported to the app token.
|
|
boolean reportedVisible;
|
|
|
|
// Last drawn state we reported to the app token.
|
|
boolean reportedDrawn;
|
|
|
|
// Set to true when the token has been removed from the window mgr.
|
|
boolean removed;
|
|
|
|
// Information about an application starting window if displayed.
|
|
StartingData startingData;
|
|
WindowState startingWindow;
|
|
View startingView;
|
|
boolean startingDisplayed;
|
|
boolean startingMoved;
|
|
boolean firstWindowDrawn;
|
|
|
|
// Input application handle used by the input dispatcher.
|
|
final InputApplicationHandle mInputApplicationHandle;
|
|
|
|
AppWindowToken(WindowManagerService _service, int _userId, IApplicationToken _token) {
|
|
super(_service, _token.asBinder(),
|
|
WindowManager.LayoutParams.TYPE_APPLICATION, true);
|
|
userId = _userId;
|
|
appWindowToken = this;
|
|
appToken = _token;
|
|
mInputApplicationHandle = new InputApplicationHandle(this);
|
|
mAnimator = service.mAnimator;
|
|
mAppAnimator = new AppWindowAnimator(this);
|
|
}
|
|
|
|
void sendAppVisibilityToClients() {
|
|
final int N = allAppWindows.size();
|
|
for (int i=0; i<N; i++) {
|
|
WindowState win = allAppWindows.get(i);
|
|
if (win == startingWindow && clientHidden) {
|
|
// Don't hide the starting window.
|
|
continue;
|
|
}
|
|
try {
|
|
if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
|
|
"Setting visibility of " + win + ": " + (!clientHidden));
|
|
win.mClient.dispatchAppVisibility(!clientHidden);
|
|
} catch (RemoteException e) {
|
|
}
|
|
}
|
|
}
|
|
|
|
void updateReportedVisibilityLocked() {
|
|
if (appToken == null) {
|
|
return;
|
|
}
|
|
|
|
int numInteresting = 0;
|
|
int numVisible = 0;
|
|
int numDrawn = 0;
|
|
boolean nowGone = true;
|
|
|
|
if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
|
|
"Update reported visibility: " + this);
|
|
final int N = allAppWindows.size();
|
|
for (int i=0; i<N; i++) {
|
|
WindowState win = allAppWindows.get(i);
|
|
if (win == startingWindow || win.mAppFreezing
|
|
|| win.mViewVisibility != View.VISIBLE
|
|
|| win.mAttrs.type == TYPE_APPLICATION_STARTING
|
|
|| win.mDestroying) {
|
|
continue;
|
|
}
|
|
if (WindowManagerService.DEBUG_VISIBILITY) {
|
|
Slog.v(WindowManagerService.TAG, "Win " + win + ": isDrawn="
|
|
+ win.isDrawnLw()
|
|
+ ", isAnimating=" + win.mWinAnimator.isAnimating());
|
|
if (!win.isDrawnLw()) {
|
|
Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mWinAnimator.mSurface
|
|
+ " pv=" + win.mPolicyVisibility
|
|
+ " mDrawState=" + win.mWinAnimator.mDrawState
|
|
+ " ah=" + win.mAttachedHidden
|
|
+ " th="
|
|
+ (win.mAppToken != null
|
|
? win.mAppToken.hiddenRequested : false)
|
|
+ " a=" + win.mWinAnimator.mAnimating);
|
|
}
|
|
}
|
|
numInteresting++;
|
|
if (win.isDrawnLw()) {
|
|
numDrawn++;
|
|
if (!win.mWinAnimator.isAnimating()) {
|
|
numVisible++;
|
|
}
|
|
nowGone = false;
|
|
} else if (win.mWinAnimator.isAnimating()) {
|
|
nowGone = false;
|
|
}
|
|
}
|
|
|
|
boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
|
|
boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
|
|
if (!nowGone) {
|
|
// If the app is not yet gone, then it can only become visible/drawn.
|
|
if (!nowDrawn) {
|
|
nowDrawn = reportedDrawn;
|
|
}
|
|
if (!nowVisible) {
|
|
nowVisible = reportedVisible;
|
|
}
|
|
}
|
|
if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "VIS " + this + ": interesting="
|
|
+ numInteresting + " visible=" + numVisible);
|
|
if (nowDrawn != reportedDrawn) {
|
|
if (nowDrawn) {
|
|
Message m = service.mH.obtainMessage(
|
|
H.REPORT_APPLICATION_TOKEN_DRAWN, this);
|
|
service.mH.sendMessage(m);
|
|
}
|
|
reportedDrawn = nowDrawn;
|
|
}
|
|
if (nowVisible != reportedVisible) {
|
|
if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(
|
|
WindowManagerService.TAG, "Visibility changed in " + this
|
|
+ ": vis=" + nowVisible);
|
|
reportedVisible = nowVisible;
|
|
Message m = service.mH.obtainMessage(
|
|
H.REPORT_APPLICATION_TOKEN_WINDOWS,
|
|
nowVisible ? 1 : 0,
|
|
nowGone ? 1 : 0,
|
|
this);
|
|
service.mH.sendMessage(m);
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
@Override
|
|
void dump(PrintWriter pw, String prefix) {
|
|
super.dump(pw, prefix);
|
|
if (appToken != null) {
|
|
pw.print(prefix); pw.print("app=true");
|
|
pw.print(" userId="); pw.println(userId);
|
|
}
|
|
if (allAppWindows.size() > 0) {
|
|
pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
|
|
}
|
|
pw.print(prefix); pw.print("groupId="); pw.print(groupId);
|
|
pw.print(" appFullscreen="); pw.print(appFullscreen);
|
|
pw.print(" requestedOrientation="); pw.println(requestedOrientation);
|
|
pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
|
|
pw.print(" clientHidden="); pw.print(clientHidden);
|
|
pw.print(" willBeHidden="); pw.print(willBeHidden);
|
|
pw.print(" reportedDrawn="); pw.print(reportedDrawn);
|
|
pw.print(" reportedVisible="); pw.println(reportedVisible);
|
|
if (paused) {
|
|
pw.print(prefix); pw.print("paused="); pw.println(paused);
|
|
}
|
|
if (numInterestingWindows != 0 || numDrawnWindows != 0
|
|
|| allDrawn || mAppAnimator.allDrawn) {
|
|
pw.print(prefix); pw.print("numInterestingWindows=");
|
|
pw.print(numInterestingWindows);
|
|
pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
|
|
pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
|
|
pw.print(" allDrawn="); pw.print(allDrawn);
|
|
pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
|
|
pw.println(")");
|
|
}
|
|
if (inPendingTransaction) {
|
|
pw.print(prefix); pw.print("inPendingTransaction=");
|
|
pw.println(inPendingTransaction);
|
|
}
|
|
if (startingData != null || removed || firstWindowDrawn) {
|
|
pw.print(prefix); pw.print("startingData="); pw.print(startingData);
|
|
pw.print(" removed="); pw.print(removed);
|
|
pw.print(" firstWindowDrawn="); pw.println(firstWindowDrawn);
|
|
}
|
|
if (startingWindow != null || startingView != null
|
|
|| startingDisplayed || startingMoved) {
|
|
pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
|
|
pw.print(" startingView="); pw.print(startingView);
|
|
pw.print(" startingDisplayed="); pw.print(startingDisplayed);
|
|
pw.print(" startingMoved"); pw.println(startingMoved);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
if (stringName == null) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("AppWindowToken{");
|
|
sb.append(Integer.toHexString(System.identityHashCode(this)));
|
|
sb.append(" token="); sb.append(token); sb.append('}');
|
|
stringName = sb.toString();
|
|
}
|
|
return stringName;
|
|
}
|
|
}
|