Merge \\"Revert \\"Prevent apps to overlay other apps via toast windows\\"\\" into nyc-mr1-dev am: 78fa7a1b3f
am: d6c4cf03e3
Change-Id: Iebc613fbecb372dbb39a9110c1b3123150b6ce5d
diff --git a/core/java/android/app/ITransientNotification.aidl b/core/java/android/app/ITransientNotification.aidl
index d5b3ed0..35b53a4 100644
--- a/core/java/android/app/ITransientNotification.aidl
+++ b/core/java/android/app/ITransientNotification.aidl
@@ -19,7 +19,7 @@
/** @hide */
oneway interface ITransientNotification {
- void show(IBinder windowToken);
+ void show();
void hide();
}
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index 4074166..7762675 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -24,10 +24,7 @@
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
-import android.os.Binder;
import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
@@ -329,6 +326,13 @@
}
private static class TN extends ITransientNotification.Stub {
+ final Runnable mShow = new Runnable() {
+ @Override
+ public void run() {
+ handleShow();
+ }
+ };
+
final Runnable mHide = new Runnable() {
@Override
public void run() {
@@ -339,13 +343,7 @@
};
private final WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();
- final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- IBinder token = (IBinder) msg.obj;
- handleShow(token);
- }
- };
+ final Handler mHandler = new Handler();
int mGravity;
int mX, mY;
@@ -381,9 +379,9 @@
* schedule handleShow into the right thread
*/
@Override
- public void show(IBinder windowToken) {
+ public void show() {
if (localLOGV) Log.v(TAG, "SHOW: " + this);
- mHandler.obtainMessage(0, windowToken).sendToTarget();
+ mHandler.post(mShow);
}
/**
@@ -395,7 +393,7 @@
mHandler.post(mHide);
}
- public void handleShow(IBinder windowToken) {
+ public void handleShow() {
if (localLOGV) Log.v(TAG, "HANDLE SHOW: " + this + " mView=" + mView
+ " mNextView=" + mNextView);
if (mView != mNextView) {
@@ -426,7 +424,6 @@
mParams.packageName = packageName;
mParams.removeTimeoutMilliseconds = mDuration ==
Toast.LENGTH_LONG ? LONG_DURATION_TIMEOUT : SHORT_DURATION_TIMEOUT;
- mParams.token = windowToken;
if (mView.getParent() != null) {
if (localLOGV) Log.v(TAG, "REMOVE! " + mView + " in " + this);
mWM.removeView(mView);
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index add8b90..d32dc14 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -58,6 +58,7 @@
import android.app.NotificationManager;
import android.app.NotificationManager.Policy;
import android.app.PendingIntent;
+import android.app.RemoteInput;
import android.app.StatusBarManager;
import android.app.backup.BackupManager;
import android.app.usage.UsageEvents;
@@ -92,6 +93,7 @@
import android.os.IInterface;
import android.os.Looper;
import android.os.Message;
+import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -120,8 +122,6 @@
import android.util.Slog;
import android.util.SparseArray;
import android.util.Xml;
-import android.view.WindowManager;
-import android.view.WindowManagerInternal;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.widget.Toast;
@@ -232,7 +232,6 @@
@Nullable StatusBarManagerInternal mStatusBar;
Vibrator mVibrator;
private VrManagerInternal mVrManagerInternal;
- private WindowManagerInternal mWindowManagerInternal;
final IBinder mForegroundToken = new Binder();
private Handler mHandler;
@@ -453,15 +452,13 @@
final String pkg;
final ITransientNotification callback;
int duration;
- Binder token;
- ToastRecord(int pid, String pkg, ITransientNotification callback, int duration,
- Binder token) {
+ ToastRecord(int pid, String pkg, ITransientNotification callback, int duration)
+ {
this.pid = pid;
this.pkg = pkg;
this.callback = callback;
this.duration = duration;
- this.token = token;
}
void update(int duration) {
@@ -1128,7 +1125,6 @@
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mAudioManagerInternal = getLocalService(AudioManagerInternal.class);
mVrManagerInternal = getLocalService(VrManagerInternal.class);
- mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
mZenModeHelper.onSystemReady();
} else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
// This observer will force an update when observe is called, causing us to
@@ -1329,13 +1325,10 @@
}
}
- Binder token = new Binder();
- mWindowManagerInternal.addWindowToken(token,
- WindowManager.LayoutParams.TYPE_TOAST);
- record = new ToastRecord(callingPid, pkg, callback, duration, token);
+ record = new ToastRecord(callingPid, pkg, callback, duration);
mToastQueue.add(record);
index = mToastQueue.size() - 1;
- keepProcessAliveIfNeededLocked(callingPid);
+ keepProcessAliveLocked(callingPid);
}
// If it's at index 0, it's the current toast. It doesn't matter if it's
// new or just been updated. Call back and tell it to show itself.
@@ -2994,7 +2987,7 @@
while (record != null) {
if (DBG) Slog.d(TAG, "Show pkg=" + record.pkg + " callback=" + record.callback);
try {
- record.callback.show(record.token);
+ record.callback.show();
scheduleTimeoutLocked(record);
return;
} catch (RemoteException e) {
@@ -3005,7 +2998,7 @@
if (index >= 0) {
mToastQueue.remove(index);
}
- keepProcessAliveIfNeededLocked(record.pid);
+ keepProcessAliveLocked(record.pid);
if (mToastQueue.size() > 0) {
record = mToastQueue.get(0);
} else {
@@ -3025,11 +3018,8 @@
// don't worry about this, we're about to remove it from
// the list anyway
}
-
- ToastRecord lastToast = mToastQueue.remove(index);
- mWindowManagerInternal.removeWindowToken(lastToast.token, true);
-
- keepProcessAliveIfNeededLocked(record.pid);
+ mToastQueue.remove(index);
+ keepProcessAliveLocked(record.pid);
if (mToastQueue.size() > 0) {
// Show the next one. If the callback fails, this will remove
// it from the list, so don't assume that the list hasn't changed
@@ -3073,7 +3063,7 @@
}
// lock on mToastQueue
- void keepProcessAliveIfNeededLocked(int pid)
+ void keepProcessAliveLocked(int pid)
{
int toastCount = 0; // toasts from this pid
ArrayList<ToastRecord> list = mToastQueue;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 76189be..45eb907 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -200,7 +200,6 @@
import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
-import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY;
@@ -1925,11 +1924,6 @@
+ attrs.token + ". Aborting.");
return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
- if (type == TYPE_TOAST) {
- Slog.w(TAG_WM, "Attempted to add a toast window with unknown token "
- + attrs.token + ". Aborting.");
- return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
- }
token = new WindowToken(this, attrs.token, -1, false);
addToken = true;
} else if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
@@ -1979,12 +1973,6 @@
+ attrs.token + ". Aborting.");
return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
- } else if (type == TYPE_TOAST) {
- if (token.windowType != TYPE_TOAST) {
- Slog.w(TAG_WM, "Attempted to add a toast window with bad token "
- + attrs.token + ". Aborting.");
- return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
- }
} else if (type == TYPE_QS_DIALOG) {
if (token.windowType != TYPE_QS_DIALOG) {
Slog.w(TAG_WM, "Attempted to add QS dialog window with bad token "