Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15ed2754 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix path for handling system window with app token.

It is wrong to turn the token into a null appWindowToken; we
need to create a new top-level token as if they had passed in null.

Change-Id: I870d8167c6ed456ea8fd58b149809ec9e0103bce
parent f52233df
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ public class WindowManagerService extends IWindowManager.Stub
    /**
     * Stores for each user whether screencapture is disabled
     * This array is essentially a cache for all userId for
     * {@link android.app.admin.DevicePolicyManager#getScreenCaptureDisabled(null, userId)}
     * {@link android.app.admin.DevicePolicyManager#getScreenCaptureDisabled}
     */
    SparseArray<Boolean> mScreenCaptureDisabled = new SparseArray<Boolean>();

@@ -2315,9 +2315,12 @@ public class WindowManagerService extends IWindowManager.Stub
                      return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
                }
            } else if (token.appWindowToken != null) {
                Slog.i(TAG, "Non-null appWindowToken for system window of type=" + type);
                // app token should be null for any other window types.
                token.appWindowToken = null;
                Slog.w(TAG, "Non-null appWindowToken for system window of type=" + type);
                // It is not valid to use an app token with other system types; we will
                // instead make a new token for it (as if null had been passed in for the token).
                attrs.token = null;
                token = new WindowToken(this, null, -1, false);
                addToken = true;
            }

            win = new WindowState(this, session, client, token,
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
    <uses-permission android:name="android.permission.MANAGE_USERS" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <application android:label="ActivityTest">
        <activity android:name="ActivityTestMain">
            <intent-filter>
+7 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.graphics.Bitmap;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -130,6 +131,12 @@ public class ActivityTestMain extends Activity {
                mSecondUser = ui.id;
            }
        }

        /*
        AlertDialog ad = new AlertDialog.Builder(this).setTitle("title").setMessage("message").create();
        ad.getWindow().getAttributes().type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
        ad.show();
        */
    }

    @Override