Home | History | Annotate | Download | only in policy
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.server.policy;
     18 
     19 import android.annotation.Nullable;
     20 import android.graphics.Point;
     21 import android.graphics.Rect;
     22 import android.util.proto.ProtoOutputStream;
     23 import android.view.Display;
     24 import android.view.DisplayCutout;
     25 import android.view.IApplicationToken;
     26 import android.view.WindowManager;
     27 
     28 import com.android.server.wm.utils.WmDisplayCutout;
     29 
     30 public class FakeWindowState implements WindowManagerPolicy.WindowState {
     31 
     32     public final Rect parentFrame = new Rect();
     33     public final Rect displayFrame = new Rect();
     34     public final Rect overscanFrame = new Rect();
     35     public final Rect contentFrame = new Rect();
     36     public final Rect visibleFrame = new Rect();
     37     public final Rect decorFrame = new Rect();
     38     public final Rect stableFrame = new Rect();
     39     public Rect outsetFrame = new Rect();
     40 
     41     public WmDisplayCutout displayCutout;
     42 
     43     public WindowManager.LayoutParams attrs;
     44     public int displayId;
     45     public boolean isVoiceInteraction;
     46     public boolean inMultiWindowMode;
     47     public boolean visible = true;
     48     public int surfaceLayer = 1;
     49     public boolean isDimming = false;
     50 
     51     public boolean policyVisible = true;
     52 
     53     @Override
     54     public int getOwningUid() {
     55         throw new UnsupportedOperationException("not implemented");
     56     }
     57 
     58     @Override
     59     public String getOwningPackage() {
     60         throw new UnsupportedOperationException("not implemented");
     61     }
     62 
     63     @Override
     64     public void computeFrameLw(Rect parentFrame, Rect displayFrame, Rect overlayFrame,
     65             Rect contentFrame, Rect visibleFrame, Rect decorFrame, Rect stableFrame,
     66             @Nullable Rect outsetFrame, WmDisplayCutout displayCutout,
     67             boolean parentFrameWasClippedByDisplayCutout) {
     68         this.parentFrame.set(parentFrame);
     69         this.displayFrame.set(displayFrame);
     70         this.overscanFrame.set(overlayFrame);
     71         this.contentFrame.set(contentFrame);
     72         this.visibleFrame.set(visibleFrame);
     73         this.decorFrame.set(decorFrame);
     74         this.stableFrame.set(stableFrame);
     75         this.outsetFrame = outsetFrame == null ? null : new Rect(outsetFrame);
     76         this.displayCutout = displayCutout;
     77     }
     78 
     79     @Override
     80     public Rect getFrameLw() {
     81         return parentFrame;
     82     }
     83 
     84     @Override
     85     public Rect getDisplayFrameLw() {
     86         return displayFrame;
     87     }
     88 
     89     @Override
     90     public Rect getOverscanFrameLw() {
     91         return overscanFrame;
     92     }
     93 
     94     @Override
     95     public Rect getContentFrameLw() {
     96         return contentFrame;
     97     }
     98 
     99     @Override
    100     public Rect getVisibleFrameLw() {
    101         return visibleFrame;
    102     }
    103 
    104     @Override
    105     public boolean getGivenInsetsPendingLw() {
    106         throw new UnsupportedOperationException("not implemented");
    107     }
    108 
    109     @Override
    110     public Rect getGivenContentInsetsLw() {
    111         throw new UnsupportedOperationException("not implemented");
    112     }
    113 
    114     @Override
    115     public Rect getGivenVisibleInsetsLw() {
    116         throw new UnsupportedOperationException("not implemented");
    117     }
    118 
    119     @Override
    120     public WindowManager.LayoutParams getAttrs() {
    121         return attrs;
    122     }
    123 
    124     @Override
    125     public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) {
    126         throw new UnsupportedOperationException("not implemented");
    127     }
    128 
    129     @Override
    130     public int getSystemUiVisibility() {
    131         return attrs.systemUiVisibility | attrs.subtreeSystemUiVisibility;
    132     }
    133 
    134     @Override
    135     public int getSurfaceLayer() {
    136         return surfaceLayer;
    137     }
    138 
    139     @Override
    140     public int getBaseType() {
    141         throw new UnsupportedOperationException("not implemented");
    142     }
    143 
    144     @Override
    145     public IApplicationToken getAppToken() {
    146         throw new UnsupportedOperationException("not implemented");
    147     }
    148 
    149     @Override
    150     public boolean isVoiceInteraction() {
    151         return isVoiceInteraction;
    152     }
    153 
    154     @Override
    155     public boolean hasAppShownWindows() {
    156         throw new UnsupportedOperationException("not implemented");
    157     }
    158 
    159     @Override
    160     public boolean isVisibleLw() {
    161         return visible && policyVisible;
    162     }
    163 
    164     @Override
    165     public boolean isDisplayedLw() {
    166         return isVisibleLw();
    167     }
    168 
    169     @Override
    170     public boolean isAnimatingLw() {
    171         return false;
    172     }
    173 
    174     @Override
    175     public boolean canAffectSystemUiFlags() {
    176         throw new UnsupportedOperationException("not implemented");
    177     }
    178 
    179     @Override
    180     public boolean isGoneForLayoutLw() {
    181         throw new UnsupportedOperationException("not implemented");
    182     }
    183 
    184     @Override
    185     public boolean isDrawnLw() {
    186         return true;
    187     }
    188 
    189     @Override
    190     public boolean hasDrawnLw() {
    191         return true;
    192     }
    193 
    194     @Override
    195     public boolean hideLw(boolean doAnimation) {
    196         if (!policyVisible) {
    197             return false;
    198         }
    199         policyVisible = false;
    200         return true;
    201     }
    202 
    203     @Override
    204     public boolean showLw(boolean doAnimation) {
    205         if (policyVisible) {
    206             return false;
    207         }
    208         policyVisible = true;
    209         return true;
    210     }
    211 
    212     @Override
    213     public boolean isAlive() {
    214         return true;
    215     }
    216 
    217     @Override
    218     public boolean isDefaultDisplay() {
    219         return displayId == Display.DEFAULT_DISPLAY;
    220     }
    221 
    222     @Override
    223     public boolean isDimming() {
    224         return isDimming;
    225     }
    226 
    227     @Override
    228     public int getWindowingMode() {
    229         throw new UnsupportedOperationException("not implemented");
    230     }
    231 
    232     @Override
    233     public boolean isInMultiWindowMode() {
    234         return inMultiWindowMode;
    235     }
    236 
    237     @Override
    238     public int getRotationAnimationHint() {
    239         throw new UnsupportedOperationException("not implemented");
    240     }
    241 
    242     @Override
    243     public boolean isInputMethodWindow() {
    244         throw new UnsupportedOperationException("not implemented");
    245     }
    246 
    247     @Override
    248     public int getDisplayId() {
    249         return displayId;
    250     }
    251 
    252     @Override
    253     public boolean canAcquireSleepToken() {
    254         throw new UnsupportedOperationException("not implemented");
    255     }
    256 
    257     @Override
    258     public void writeIdentifierToProto(ProtoOutputStream proto, long fieldId){
    259         throw new UnsupportedOperationException("not implemented");
    260     }
    261 
    262     @Override
    263     public boolean isInputMethodTarget() {
    264         return false;
    265     }
    266 }
    267