Loading core/java/android/app/ITransientNotification.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package android.app; /** @hide */ oneway interface ITransientNotification { void show(IBinder windowToken); void show(); void hide(); } core/java/android/view/SurfaceView.java +0 −1 Original line number Diff line number Diff line Loading @@ -233,7 +233,6 @@ public class SurfaceView extends View { mSession = getWindowSession(); mLayout.token = getWindowToken(); mLayout.setTitle("SurfaceView - " + getViewRootImpl().getTitle()); mLayout.packageName = mContext.getOpPackageName(); mViewVisibility = getVisibility() == VISIBLE; if (!mGlobalListenersAdded) { Loading core/java/android/view/WindowManager.java +6 −10 Original line number Diff line number Diff line Loading @@ -1734,18 +1734,14 @@ public interface WindowManager extends ViewManager { public CharSequence accessibilityTitle; /** * Sets a timeout in milliseconds before which the window will be hidden * Sets a timeout in milliseconds before which the window will be removed * by the window manager. Useful for transient notifications like toasts * so we don't have to rely on client cooperation to ensure the window * is hidden. Must be specified at window creation time. Note that apps * are not prepared to handle their windows being removed without their * explicit request and may try to interact with the removed window * resulting in undefined behavior and crashes. Therefore, we do hide * such windows to prevent them from overlaying other apps. * is removed. Must be specified at window creation time. * * @hide */ public long hideTimeoutMilliseconds = -1; public long removeTimeoutMilliseconds = -1; public LayoutParams() { super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); Loading Loading @@ -1881,7 +1877,7 @@ public interface WindowManager extends ViewManager { out.writeInt(needsMenuKey); out.writeInt(accessibilityIdOfAnchor); TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); out.writeLong(hideTimeoutMilliseconds); out.writeLong(removeTimeoutMilliseconds); } public static final Parcelable.Creator<LayoutParams> CREATOR Loading Loading @@ -1935,7 +1931,7 @@ public interface WindowManager extends ViewManager { needsMenuKey = in.readInt(); accessibilityIdOfAnchor = in.readInt(); accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); hideTimeoutMilliseconds = in.readLong(); removeTimeoutMilliseconds = in.readLong(); } @SuppressWarnings({"PointlessBitwiseExpression"}) Loading Loading @@ -2157,7 +2153,7 @@ public interface WindowManager extends ViewManager { } // This can't change, it's only set at window creation time. hideTimeoutMilliseconds = o.hideTimeoutMilliseconds; removeTimeoutMilliseconds = o.removeTimeoutMilliseconds; return changes; } Loading core/java/android/widget/Toast.java +12 −14 Original line number Diff line number Diff line Loading @@ -25,8 +25,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.PixelFormat; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; Loading Loading @@ -328,6 +326,13 @@ public class Toast { } 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() { Loading @@ -338,13 +343,7 @@ public class Toast { }; 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; Loading Loading @@ -380,9 +379,9 @@ public class Toast { * 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); } /** Loading @@ -394,7 +393,7 @@ public class Toast { 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) { Loading Loading @@ -423,9 +422,8 @@ public class Toast { mParams.verticalMargin = mVerticalMargin; mParams.horizontalMargin = mHorizontalMargin; mParams.packageName = packageName; mParams.hideTimeoutMilliseconds = mDuration == 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); Loading services/core/java/com/android/server/notification/NotificationManagerService.java +12 −23 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.app.Notification; 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; Loading Loading @@ -92,6 +93,7 @@ import android.os.IBinder; 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; Loading Loading @@ -120,8 +122,6 @@ import android.util.Log; 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; Loading @@ -138,7 +138,6 @@ import com.android.server.SystemService; import com.android.server.lights.Light; import com.android.server.lights.LightsManager; import com.android.server.notification.ManagedServices.ManagedServiceInfo; import com.android.server.policy.PhoneWindowManager; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.vr.VrManagerInternal; import com.android.server.notification.ManagedServices.UserProfiles; Loading Loading @@ -194,7 +193,7 @@ public class NotificationManagerService extends SystemService { private static final int MESSAGE_RECONSIDER_RANKING = 1000; private static final int MESSAGE_RANKING_SORT = 1001; static final int LONG_DELAY = PhoneWindowManager.TOAST_WINDOW_TIMEOUT; static final int LONG_DELAY = 3500; // 3.5 seconds static final int SHORT_DELAY = 2000; // 2 seconds static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250}; Loading Loading @@ -233,7 +232,6 @@ public class NotificationManagerService extends SystemService { @Nullable StatusBarManagerInternal mStatusBar; Vibrator mVibrator; private VrManagerInternal mVrManagerInternal; private WindowManagerInternal mWindowManagerInternal; final IBinder mForegroundToken = new Binder(); private Handler mHandler; Loading Loading @@ -454,15 +452,13 @@ public class NotificationManagerService extends SystemService { 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) { Loading Loading @@ -1129,7 +1125,6 @@ public class NotificationManagerService extends SystemService { 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 Loading Loading @@ -1330,13 +1325,10 @@ public class NotificationManagerService extends SystemService { } } 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. Loading Loading @@ -2995,7 +2987,7 @@ public class NotificationManagerService extends SystemService { 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) { Loading @@ -3006,7 +2998,7 @@ public class NotificationManagerService extends SystemService { if (index >= 0) { mToastQueue.remove(index); } keepProcessAliveIfNeededLocked(record.pid); keepProcessAliveLocked(record.pid); if (mToastQueue.size() > 0) { record = mToastQueue.get(0); } else { Loading @@ -3026,11 +3018,8 @@ public class NotificationManagerService extends SystemService { // 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 Loading Loading @@ -3074,7 +3063,7 @@ public class NotificationManagerService extends SystemService { } // lock on mToastQueue void keepProcessAliveIfNeededLocked(int pid) void keepProcessAliveLocked(int pid) { int toastCount = 0; // toasts from this pid ArrayList<ToastRecord> list = mToastQueue; Loading Loading
core/java/android/app/ITransientNotification.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package android.app; /** @hide */ oneway interface ITransientNotification { void show(IBinder windowToken); void show(); void hide(); }
core/java/android/view/SurfaceView.java +0 −1 Original line number Diff line number Diff line Loading @@ -233,7 +233,6 @@ public class SurfaceView extends View { mSession = getWindowSession(); mLayout.token = getWindowToken(); mLayout.setTitle("SurfaceView - " + getViewRootImpl().getTitle()); mLayout.packageName = mContext.getOpPackageName(); mViewVisibility = getVisibility() == VISIBLE; if (!mGlobalListenersAdded) { Loading
core/java/android/view/WindowManager.java +6 −10 Original line number Diff line number Diff line Loading @@ -1734,18 +1734,14 @@ public interface WindowManager extends ViewManager { public CharSequence accessibilityTitle; /** * Sets a timeout in milliseconds before which the window will be hidden * Sets a timeout in milliseconds before which the window will be removed * by the window manager. Useful for transient notifications like toasts * so we don't have to rely on client cooperation to ensure the window * is hidden. Must be specified at window creation time. Note that apps * are not prepared to handle their windows being removed without their * explicit request and may try to interact with the removed window * resulting in undefined behavior and crashes. Therefore, we do hide * such windows to prevent them from overlaying other apps. * is removed. Must be specified at window creation time. * * @hide */ public long hideTimeoutMilliseconds = -1; public long removeTimeoutMilliseconds = -1; public LayoutParams() { super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); Loading Loading @@ -1881,7 +1877,7 @@ public interface WindowManager extends ViewManager { out.writeInt(needsMenuKey); out.writeInt(accessibilityIdOfAnchor); TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); out.writeLong(hideTimeoutMilliseconds); out.writeLong(removeTimeoutMilliseconds); } public static final Parcelable.Creator<LayoutParams> CREATOR Loading Loading @@ -1935,7 +1931,7 @@ public interface WindowManager extends ViewManager { needsMenuKey = in.readInt(); accessibilityIdOfAnchor = in.readInt(); accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); hideTimeoutMilliseconds = in.readLong(); removeTimeoutMilliseconds = in.readLong(); } @SuppressWarnings({"PointlessBitwiseExpression"}) Loading Loading @@ -2157,7 +2153,7 @@ public interface WindowManager extends ViewManager { } // This can't change, it's only set at window creation time. hideTimeoutMilliseconds = o.hideTimeoutMilliseconds; removeTimeoutMilliseconds = o.removeTimeoutMilliseconds; return changes; } Loading
core/java/android/widget/Toast.java +12 −14 Original line number Diff line number Diff line Loading @@ -25,8 +25,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.PixelFormat; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; Loading Loading @@ -328,6 +326,13 @@ public class Toast { } 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() { Loading @@ -338,13 +343,7 @@ public class Toast { }; 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; Loading Loading @@ -380,9 +379,9 @@ public class Toast { * 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); } /** Loading @@ -394,7 +393,7 @@ public class Toast { 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) { Loading Loading @@ -423,9 +422,8 @@ public class Toast { mParams.verticalMargin = mVerticalMargin; mParams.horizontalMargin = mHorizontalMargin; mParams.packageName = packageName; mParams.hideTimeoutMilliseconds = mDuration == 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); Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +12 −23 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.app.Notification; 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; Loading Loading @@ -92,6 +93,7 @@ import android.os.IBinder; 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; Loading Loading @@ -120,8 +122,6 @@ import android.util.Log; 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; Loading @@ -138,7 +138,6 @@ import com.android.server.SystemService; import com.android.server.lights.Light; import com.android.server.lights.LightsManager; import com.android.server.notification.ManagedServices.ManagedServiceInfo; import com.android.server.policy.PhoneWindowManager; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.vr.VrManagerInternal; import com.android.server.notification.ManagedServices.UserProfiles; Loading Loading @@ -194,7 +193,7 @@ public class NotificationManagerService extends SystemService { private static final int MESSAGE_RECONSIDER_RANKING = 1000; private static final int MESSAGE_RANKING_SORT = 1001; static final int LONG_DELAY = PhoneWindowManager.TOAST_WINDOW_TIMEOUT; static final int LONG_DELAY = 3500; // 3.5 seconds static final int SHORT_DELAY = 2000; // 2 seconds static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250}; Loading Loading @@ -233,7 +232,6 @@ public class NotificationManagerService extends SystemService { @Nullable StatusBarManagerInternal mStatusBar; Vibrator mVibrator; private VrManagerInternal mVrManagerInternal; private WindowManagerInternal mWindowManagerInternal; final IBinder mForegroundToken = new Binder(); private Handler mHandler; Loading Loading @@ -454,15 +452,13 @@ public class NotificationManagerService extends SystemService { 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) { Loading Loading @@ -1129,7 +1125,6 @@ public class NotificationManagerService extends SystemService { 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 Loading Loading @@ -1330,13 +1325,10 @@ public class NotificationManagerService extends SystemService { } } 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. Loading Loading @@ -2995,7 +2987,7 @@ public class NotificationManagerService extends SystemService { 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) { Loading @@ -3006,7 +2998,7 @@ public class NotificationManagerService extends SystemService { if (index >= 0) { mToastQueue.remove(index); } keepProcessAliveIfNeededLocked(record.pid); keepProcessAliveLocked(record.pid); if (mToastQueue.size() > 0) { record = mToastQueue.get(0); } else { Loading @@ -3026,11 +3018,8 @@ public class NotificationManagerService extends SystemService { // 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 Loading Loading @@ -3074,7 +3063,7 @@ public class NotificationManagerService extends SystemService { } // lock on mToastQueue void keepProcessAliveIfNeededLocked(int pid) void keepProcessAliveLocked(int pid) { int toastCount = 0; // toasts from this pid ArrayList<ToastRecord> list = mToastQueue; Loading