Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2011 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.layoutlib.bridge.android;
     18 
     19 import com.android.internal.view.IInputContext;
     20 import com.android.internal.view.IInputMethodClient;
     21 
     22 import android.content.res.CompatibilityInfo;
     23 import android.content.res.Configuration;
     24 import android.graphics.Bitmap;
     25 import android.graphics.Point;
     26 import android.os.IBinder;
     27 import android.os.IRemoteCallback;
     28 import android.os.RemoteException;
     29 import android.util.DisplayMetrics;
     30 import android.view.Display;
     31 import android.view.Display_Delegate;
     32 import android.view.Gravity;
     33 import android.view.IApplicationToken;
     34 import android.view.IOnKeyguardExitResult;
     35 import android.view.IRotationWatcher;
     36 import android.view.IWindowManager;
     37 import android.view.IWindowSession;
     38 import android.view.InputChannel;
     39 import android.view.InputDevice;
     40 import android.view.InputEvent;
     41 import android.view.KeyEvent;
     42 import android.view.MotionEvent;
     43 
     44 import java.util.List;
     45 
     46 /**
     47  * Basic implementation of {@link IWindowManager} so that {@link Display} (and
     48  * {@link Display_Delegate}) can return a valid instance.
     49  */
     50 public class BridgeWindowManager implements IWindowManager {
     51 
     52     private final Configuration mConfig;
     53     private final DisplayMetrics mMetrics;
     54     private final int mRotation;
     55 
     56     public BridgeWindowManager(Configuration config, DisplayMetrics metrics, int rotation) {
     57         mConfig = config;
     58         mMetrics = metrics;
     59         mRotation = rotation;
     60     }
     61 
     62     // custom API.
     63 
     64     public DisplayMetrics getMetrics() {
     65         return mMetrics;
     66     }
     67 
     68     // ---- implementation of IWindowManager that we care about ----
     69 
     70     @Override
     71     public int getRotation() throws RemoteException {
     72         return mRotation;
     73     }
     74 
     75     @Override
     76     public int getMaximumSizeDimension() throws RemoteException {
     77         return 0;
     78     }
     79 
     80     @Override
     81     public void getCurrentSizeRange(Point smallestSize, Point largestSize) {
     82     }
     83 
     84     @Override
     85     public void getDisplaySize(Point arg0) throws RemoteException {
     86     }
     87 
     88     @Override
     89     public void getRealDisplaySize(Point arg0) throws RemoteException {
     90     }
     91 
     92     // ---- unused implementation of IWindowManager ----
     93 
     94     @Override
     95     public boolean hasSystemNavBar() throws RemoteException {
     96         // TODO Auto-generated method stub
     97         return false;
     98     }
     99 
    100     @Override
    101     public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, boolean arg4)
    102             throws RemoteException {
    103         // TODO Auto-generated method stub
    104 
    105     }
    106 
    107     @Override
    108     public void addWindowToken(IBinder arg0, int arg1) throws RemoteException {
    109         // TODO Auto-generated method stub
    110 
    111     }
    112 
    113     @Override
    114     public void clearForcedDisplaySize() throws RemoteException {
    115         // TODO Auto-generated method stub
    116 
    117     }
    118 
    119     @Override
    120     public void closeSystemDialogs(String arg0) throws RemoteException {
    121         // TODO Auto-generated method stub
    122 
    123     }
    124 
    125     @Override
    126     public void disableKeyguard(IBinder arg0, String arg1) throws RemoteException {
    127         // TODO Auto-generated method stub
    128 
    129     }
    130 
    131     @Override
    132     public void executeAppTransition() throws RemoteException {
    133         // TODO Auto-generated method stub
    134 
    135     }
    136 
    137     @Override
    138     public void exitKeyguardSecurely(IOnKeyguardExitResult arg0) throws RemoteException {
    139         // TODO Auto-generated method stub
    140 
    141     }
    142 
    143     @Override
    144     public void freezeRotation(int arg0) throws RemoteException {
    145         // TODO Auto-generated method stub
    146 
    147     }
    148 
    149     @Override
    150     public float getAnimationScale(int arg0) throws RemoteException {
    151         // TODO Auto-generated method stub
    152         return 0;
    153     }
    154 
    155     @Override
    156     public float[] getAnimationScales() throws RemoteException {
    157         // TODO Auto-generated method stub
    158         return null;
    159     }
    160 
    161     @Override
    162     public int getAppOrientation(IApplicationToken arg0) throws RemoteException {
    163         // TODO Auto-generated method stub
    164         return 0;
    165     }
    166 
    167     @Override
    168     public int getPendingAppTransition() throws RemoteException {
    169         // TODO Auto-generated method stub
    170         return 0;
    171     }
    172 
    173     @Override
    174     public boolean inKeyguardRestrictedInputMode() throws RemoteException {
    175         // TODO Auto-generated method stub
    176         return false;
    177     }
    178 
    179     @Override
    180     public boolean inputMethodClientHasFocus(IInputMethodClient arg0) throws RemoteException {
    181         // TODO Auto-generated method stub
    182         return false;
    183     }
    184 
    185     @Override
    186     public boolean isKeyguardLocked() throws RemoteException {
    187         // TODO Auto-generated method stub
    188         return false;
    189     }
    190 
    191     @Override
    192     public boolean isKeyguardSecure() throws RemoteException {
    193         // TODO Auto-generated method stub
    194         return false;
    195     }
    196 
    197     @Override
    198     public boolean isViewServerRunning() throws RemoteException {
    199         // TODO Auto-generated method stub
    200         return false;
    201     }
    202 
    203     @Override
    204     public void moveAppToken(int arg0, IBinder arg1) throws RemoteException {
    205         // TODO Auto-generated method stub
    206 
    207     }
    208 
    209     @Override
    210     public void moveAppTokensToBottom(List<IBinder> arg0) throws RemoteException {
    211         // TODO Auto-generated method stub
    212 
    213     }
    214 
    215     @Override
    216     public void moveAppTokensToTop(List<IBinder> arg0) throws RemoteException {
    217         // TODO Auto-generated method stub
    218 
    219     }
    220 
    221     @Override
    222     public IWindowSession openSession(IInputMethodClient arg0, IInputContext arg1)
    223             throws RemoteException {
    224         // TODO Auto-generated method stub
    225         return null;
    226     }
    227 
    228     @Override
    229     public void overridePendingAppTransition(String arg0, int arg1, int arg2,
    230             IRemoteCallback startedCallback) throws RemoteException {
    231         // TODO Auto-generated method stub
    232 
    233     }
    234 
    235     @Override
    236     public void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
    237             int startHeight) throws RemoteException {
    238         // TODO Auto-generated method stub
    239     }
    240 
    241     @Override
    242     public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
    243             IRemoteCallback startedCallback, boolean delayed) throws RemoteException {
    244         // TODO Auto-generated method stub
    245     }
    246 
    247     @Override
    248     public void pauseKeyDispatching(IBinder arg0) throws RemoteException {
    249         // TODO Auto-generated method stub
    250 
    251     }
    252 
    253     @Override
    254     public void prepareAppTransition(int arg0, boolean arg1) throws RemoteException {
    255         // TODO Auto-generated method stub
    256 
    257     }
    258 
    259     @Override
    260     public void reenableKeyguard(IBinder arg0) throws RemoteException {
    261         // TODO Auto-generated method stub
    262 
    263     }
    264 
    265     @Override
    266     public void removeAppToken(IBinder arg0) throws RemoteException {
    267         // TODO Auto-generated method stub
    268 
    269     }
    270 
    271     @Override
    272     public void removeWindowToken(IBinder arg0) throws RemoteException {
    273         // TODO Auto-generated method stub
    274 
    275     }
    276 
    277     @Override
    278     public void resumeKeyDispatching(IBinder arg0) throws RemoteException {
    279         // TODO Auto-generated method stub
    280 
    281     }
    282 
    283     @Override
    284     public Bitmap screenshotApplications(IBinder arg0, int arg1, int arg2) throws RemoteException {
    285         // TODO Auto-generated method stub
    286         return null;
    287     }
    288 
    289     @Override
    290     public void setAnimationScale(int arg0, float arg1) throws RemoteException {
    291         // TODO Auto-generated method stub
    292 
    293     }
    294 
    295     @Override
    296     public void setAnimationScales(float[] arg0) throws RemoteException {
    297         // TODO Auto-generated method stub
    298 
    299     }
    300 
    301     @Override
    302     public void setAppGroupId(IBinder arg0, int arg1) throws RemoteException {
    303         // TODO Auto-generated method stub
    304 
    305     }
    306 
    307     @Override
    308     public void setAppOrientation(IApplicationToken arg0, int arg1) throws RemoteException {
    309         // TODO Auto-generated method stub
    310 
    311     }
    312 
    313     @Override
    314     public void setAppStartingWindow(IBinder arg0, String arg1, int arg2, CompatibilityInfo arg3,
    315             CharSequence arg4, int arg5, int arg6, int arg7, IBinder arg8, boolean arg9)
    316             throws RemoteException {
    317         // TODO Auto-generated method stub
    318 
    319     }
    320 
    321     @Override
    322     public void setAppVisibility(IBinder arg0, boolean arg1) throws RemoteException {
    323         // TODO Auto-generated method stub
    324 
    325     }
    326 
    327     @Override
    328     public void setAppWillBeHidden(IBinder arg0) throws RemoteException {
    329         // TODO Auto-generated method stub
    330 
    331     }
    332 
    333     @Override
    334     public void setEventDispatching(boolean arg0) throws RemoteException {
    335         // TODO Auto-generated method stub
    336 
    337     }
    338 
    339     @Override
    340     public void setFocusedApp(IBinder arg0, boolean arg1) throws RemoteException {
    341         // TODO Auto-generated method stub
    342 
    343     }
    344 
    345     @Override
    346     public void setForcedDisplaySize(int arg0, int arg1) throws RemoteException {
    347         // TODO Auto-generated method stub
    348 
    349     }
    350 
    351     @Override
    352     public void setInTouchMode(boolean arg0) throws RemoteException {
    353         // TODO Auto-generated method stub
    354 
    355     }
    356 
    357     @Override
    358     public void setNewConfiguration(Configuration arg0) throws RemoteException {
    359         // TODO Auto-generated method stub
    360 
    361     }
    362 
    363     @Override
    364     public void updateRotation(boolean arg0, boolean arg1) throws RemoteException {
    365         // TODO Auto-generated method stub
    366     }
    367 
    368     @Override
    369     public void setStrictModeVisualIndicatorPreference(String arg0) throws RemoteException {
    370         // TODO Auto-generated method stub
    371 
    372     }
    373 
    374     @Override
    375     public void showStrictModeViolation(boolean arg0) throws RemoteException {
    376         // TODO Auto-generated method stub
    377 
    378     }
    379 
    380     @Override
    381     public void startAppFreezingScreen(IBinder arg0, int arg1) throws RemoteException {
    382         // TODO Auto-generated method stub
    383 
    384     }
    385 
    386     @Override
    387     public boolean startViewServer(int arg0) throws RemoteException {
    388         // TODO Auto-generated method stub
    389         return false;
    390     }
    391 
    392     @Override
    393     public void statusBarVisibilityChanged(int arg0) throws RemoteException {
    394         // TODO Auto-generated method stub
    395 
    396     }
    397 
    398     @Override
    399     public void stopAppFreezingScreen(IBinder arg0, boolean arg1) throws RemoteException {
    400         // TODO Auto-generated method stub
    401 
    402     }
    403 
    404     @Override
    405     public boolean stopViewServer() throws RemoteException {
    406         // TODO Auto-generated method stub
    407         return false;
    408     }
    409 
    410     @Override
    411     public void thawRotation() throws RemoteException {
    412         // TODO Auto-generated method stub
    413 
    414     }
    415 
    416     @Override
    417     public Configuration updateOrientationFromAppTokens(Configuration arg0, IBinder arg1)
    418             throws RemoteException {
    419         // TODO Auto-generated method stub
    420         return null;
    421     }
    422 
    423     @Override
    424     public int watchRotation(IRotationWatcher arg0) throws RemoteException {
    425         // TODO Auto-generated method stub
    426         return 0;
    427     }
    428 
    429     @Override
    430     public void waitForWindowDrawn(IBinder token, IRemoteCallback callback) {
    431         // TODO Auto-generated method stub
    432     }
    433 
    434     @Override
    435     public IBinder asBinder() {
    436         // TODO Auto-generated method stub
    437         return null;
    438     }
    439 
    440     @Override
    441     public int getPreferredOptionsPanelGravity() throws RemoteException {
    442         return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    443     }
    444 
    445     @Override
    446     public void dismissKeyguard() {
    447     }
    448 
    449     @Override
    450     public boolean hasNavigationBar() {
    451         return false; // should this return something else?
    452     }
    453 
    454     @Override
    455     public void lockNow() {
    456         // TODO Auto-generated method stub
    457     }
    458 }
    459