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

Commit fb32c6e9 authored by Craig Mautner's avatar Craig Mautner
Browse files

Refactor setAppOpVisibility implementation.

- Convert double iteration over DisplayContents and WindowLists to
single iteration over AllWindowsIterator.

- Use existing change check in show() and hide() to trigger animation
scheduling rather than propagate change state up through calling tree.

Change-Id: Ic703a9fddebacbd0785bd5a186e95f9d0b128c42
parent f9d2c2e6
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -2452,22 +2452,15 @@ public class WindowManagerService extends IWindowManager.Stub

    public void updateAppOpsState() {
        synchronized(mWindowMap) {
            boolean changed = false;
            for (int i=0; i<mDisplayContents.size(); i++) {
                DisplayContent display = mDisplayContents.valueAt(i);
                WindowList windows = display.getWindowList();
                for (int j=0; j<windows.size(); j++) {
                    final WindowState win = windows.get(j);
            AllWindowsIterator iterator = new AllWindowsIterator();
            while (iterator.hasNext()) {
                final WindowState win = iterator.next();
                if (win.mAppOp != AppOpsManager.OP_NONE) {
                        changed |= win.setAppOpVisibilityLw(mAppOps.checkOpNoThrow(win.mAppOp,
                                win.getOwningUid(),
                                win.getOwningPackage()) == AppOpsManager.MODE_ALLOWED);
                    }
                    final int mode = mAppOps.checkOpNoThrow(win.mAppOp, win.getOwningUid(),
                            win.getOwningPackage());
                    win.setAppOpVisibilityLw(mode == AppOpsManager.MODE_ALLOWED);
                }
            }
            if (changed) {
                scheduleAnimationLocked();
            }
        }
    }

+3 −5
Original line number Diff line number Diff line
@@ -1058,7 +1058,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        return true;
    }

    public boolean setAppOpVisibilityLw(boolean state) {
    public void setAppOpVisibilityLw(boolean state) {
        if (mAppOpVisibility != state) {
            mAppOpVisibility = state;
            if (state) {
@@ -1068,13 +1068,11 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                // ops modifies they should only be hidden by policy due to the
                // lock screen, and the user won't be changing this if locked.
                // Plus it will quickly be fixed the next time we do a layout.
                showLw(true, false);
                showLw(true, true);
            } else {
                hideLw(true, false);
                hideLw(true, true);
            }
            return true;
        }
        return false;
    }

    @Override