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     public int getRotation() throws RemoteException {
     71         return mRotation;
     72     }
     73 
     74     public int getMaximumSizeDimension() throws RemoteException {
     75         return 0;
     76     }
     77 
     78     public void getDisplaySize(Point arg0) throws RemoteException {
     79     }
     80 
     81     public void getRealDisplaySize(Point arg0) throws RemoteException {
     82     }
     83 
     84     // ---- unused implementation of IWindowManager ----
     85 
     86     public boolean canStatusBarHide() throws RemoteException {
     87         // TODO Auto-generated method stub
     88         return false;
     89     }
     90 
     91     public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, boolean arg4)
     92             throws RemoteException {
     93         // TODO Auto-generated method stub
     94 
     95     }
     96 
     97     public void addWindowToken(IBinder arg0, int arg1) throws RemoteException {
     98         // TODO Auto-generated method stub
     99 
    100     }
    101 
    102     public void clearForcedDisplaySize() throws RemoteException {
    103         // TODO Auto-generated method stub
    104 
    105     }
    106 
    107     public void closeSystemDialogs(String arg0) throws RemoteException {
    108         // TODO Auto-generated method stub
    109 
    110     }
    111 
    112     public void disableKeyguard(IBinder arg0, String arg1) throws RemoteException {
    113         // TODO Auto-generated method stub
    114 
    115     }
    116 
    117     public void executeAppTransition() throws RemoteException {
    118         // TODO Auto-generated method stub
    119 
    120     }
    121 
    122     public void exitKeyguardSecurely(IOnKeyguardExitResult arg0) throws RemoteException {
    123         // TODO Auto-generated method stub
    124 
    125     }
    126 
    127     public void freezeRotation(int arg0) throws RemoteException {
    128         // TODO Auto-generated method stub
    129 
    130     }
    131 
    132     public float getAnimationScale(int arg0) throws RemoteException {
    133         // TODO Auto-generated method stub
    134         return 0;
    135     }
    136 
    137     public float[] getAnimationScales() throws RemoteException {
    138         // TODO Auto-generated method stub
    139         return null;
    140     }
    141 
    142     public int getAppOrientation(IApplicationToken arg0) throws RemoteException {
    143         // TODO Auto-generated method stub
    144         return 0;
    145     }
    146 
    147     public int getDPadKeycodeState(int arg0) throws RemoteException {
    148         // TODO Auto-generated method stub
    149         return 0;
    150     }
    151 
    152     public int getDPadScancodeState(int arg0) throws RemoteException {
    153         // TODO Auto-generated method stub
    154         return 0;
    155     }
    156 
    157 
    158     public InputDevice getInputDevice(int arg0) throws RemoteException {
    159         // TODO Auto-generated method stub
    160         return null;
    161     }
    162 
    163     public int[] getInputDeviceIds() throws RemoteException {
    164         // TODO Auto-generated method stub
    165         return null;
    166     }
    167 
    168     public int getKeycodeState(int arg0) throws RemoteException {
    169         // TODO Auto-generated method stub
    170         return 0;
    171     }
    172 
    173     public int getKeycodeStateForDevice(int arg0, int arg1) throws RemoteException {
    174         // TODO Auto-generated method stub
    175         return 0;
    176     }
    177 
    178 
    179     public int getPendingAppTransition() throws RemoteException {
    180         // TODO Auto-generated method stub
    181         return 0;
    182     }
    183 
    184 
    185     public int getScancodeState(int arg0) throws RemoteException {
    186         // TODO Auto-generated method stub
    187         return 0;
    188     }
    189 
    190     public int getScancodeStateForDevice(int arg0, int arg1) throws RemoteException {
    191         // TODO Auto-generated method stub
    192         return 0;
    193     }
    194 
    195     public int getSwitchState(int arg0) throws RemoteException {
    196         // TODO Auto-generated method stub
    197         return 0;
    198     }
    199 
    200     public int getSwitchStateForDevice(int arg0, int arg1) throws RemoteException {
    201         // TODO Auto-generated method stub
    202         return 0;
    203     }
    204 
    205     public int getTrackballKeycodeState(int arg0) throws RemoteException {
    206         // TODO Auto-generated method stub
    207         return 0;
    208     }
    209 
    210     public int getTrackballScancodeState(int arg0) throws RemoteException {
    211         // TODO Auto-generated method stub
    212         return 0;
    213     }
    214 
    215     public boolean hasKeys(int[] arg0, boolean[] arg1) throws RemoteException {
    216         // TODO Auto-generated method stub
    217         return false;
    218     }
    219 
    220     public boolean inKeyguardRestrictedInputMode() throws RemoteException {
    221         // TODO Auto-generated method stub
    222         return false;
    223     }
    224 
    225     public boolean injectInputEventNoWait(InputEvent arg0) throws RemoteException {
    226         // TODO Auto-generated method stub
    227         return false;
    228     }
    229 
    230     public boolean injectKeyEvent(KeyEvent arg0, boolean arg1) throws RemoteException {
    231         // TODO Auto-generated method stub
    232         return false;
    233     }
    234 
    235     public boolean injectPointerEvent(MotionEvent arg0, boolean arg1) throws RemoteException {
    236         // TODO Auto-generated method stub
    237         return false;
    238     }
    239 
    240     public boolean injectTrackballEvent(MotionEvent arg0, boolean arg1) throws RemoteException {
    241         // TODO Auto-generated method stub
    242         return false;
    243     }
    244 
    245     public boolean inputMethodClientHasFocus(IInputMethodClient arg0) throws RemoteException {
    246         // TODO Auto-generated method stub
    247         return false;
    248     }
    249 
    250     public boolean isKeyguardLocked() throws RemoteException {
    251         // TODO Auto-generated method stub
    252         return false;
    253     }
    254 
    255     public boolean isKeyguardSecure() throws RemoteException {
    256         // TODO Auto-generated method stub
    257         return false;
    258     }
    259 
    260     public boolean isViewServerRunning() throws RemoteException {
    261         // TODO Auto-generated method stub
    262         return false;
    263     }
    264 
    265     public InputChannel monitorInput(String arg0) throws RemoteException {
    266         // TODO Auto-generated method stub
    267         return null;
    268     }
    269 
    270     public void moveAppToken(int arg0, IBinder arg1) throws RemoteException {
    271         // TODO Auto-generated method stub
    272 
    273     }
    274 
    275     public void moveAppTokensToBottom(List<IBinder> arg0) throws RemoteException {
    276         // TODO Auto-generated method stub
    277 
    278     }
    279 
    280     public void moveAppTokensToTop(List<IBinder> arg0) throws RemoteException {
    281         // TODO Auto-generated method stub
    282 
    283     }
    284 
    285     public IWindowSession openSession(IInputMethodClient arg0, IInputContext arg1)
    286             throws RemoteException {
    287         // TODO Auto-generated method stub
    288         return null;
    289     }
    290 
    291     public void overridePendingAppTransition(String arg0, int arg1, int arg2)
    292             throws RemoteException {
    293         // TODO Auto-generated method stub
    294 
    295     }
    296 
    297     public void pauseKeyDispatching(IBinder arg0) throws RemoteException {
    298         // TODO Auto-generated method stub
    299 
    300     }
    301 
    302     public void prepareAppTransition(int arg0, boolean arg1) throws RemoteException {
    303         // TODO Auto-generated method stub
    304 
    305     }
    306 
    307     public void reenableKeyguard(IBinder arg0) throws RemoteException {
    308         // TODO Auto-generated method stub
    309 
    310     }
    311 
    312     public void removeAppToken(IBinder arg0) throws RemoteException {
    313         // TODO Auto-generated method stub
    314 
    315     }
    316 
    317     public void removeWindowToken(IBinder arg0) throws RemoteException {
    318         // TODO Auto-generated method stub
    319 
    320     }
    321 
    322     public void resumeKeyDispatching(IBinder arg0) throws RemoteException {
    323         // TODO Auto-generated method stub
    324 
    325     }
    326 
    327     public Bitmap screenshotApplications(IBinder arg0, int arg1, int arg2) throws RemoteException {
    328         // TODO Auto-generated method stub
    329         return null;
    330     }
    331 
    332     public void setAnimationScale(int arg0, float arg1) throws RemoteException {
    333         // TODO Auto-generated method stub
    334 
    335     }
    336 
    337     public void setAnimationScales(float[] arg0) throws RemoteException {
    338         // TODO Auto-generated method stub
    339 
    340     }
    341 
    342     public void setAppGroupId(IBinder arg0, int arg1) throws RemoteException {
    343         // TODO Auto-generated method stub
    344 
    345     }
    346 
    347     public void setAppOrientation(IApplicationToken arg0, int arg1) throws RemoteException {
    348         // TODO Auto-generated method stub
    349 
    350     }
    351 
    352     public void setAppStartingWindow(IBinder arg0, String arg1, int arg2, CompatibilityInfo arg3,
    353             CharSequence arg4, int arg5, int arg6, int arg7, IBinder arg8, boolean arg9)
    354             throws RemoteException {
    355         // TODO Auto-generated method stub
    356 
    357     }
    358 
    359     public void setAppVisibility(IBinder arg0, boolean arg1) throws RemoteException {
    360         // TODO Auto-generated method stub
    361 
    362     }
    363 
    364     public void setAppWillBeHidden(IBinder arg0) throws RemoteException {
    365         // TODO Auto-generated method stub
    366 
    367     }
    368 
    369     public void setEventDispatching(boolean arg0) throws RemoteException {
    370         // TODO Auto-generated method stub
    371 
    372     }
    373 
    374     public void setFocusedApp(IBinder arg0, boolean arg1) throws RemoteException {
    375         // TODO Auto-generated method stub
    376 
    377     }
    378 
    379     public void setForcedDisplaySize(int arg0, int arg1) throws RemoteException {
    380         // TODO Auto-generated method stub
    381 
    382     }
    383 
    384     public void setInTouchMode(boolean arg0) throws RemoteException {
    385         // TODO Auto-generated method stub
    386 
    387     }
    388 
    389     public void setNewConfiguration(Configuration arg0) throws RemoteException {
    390         // TODO Auto-generated method stub
    391 
    392     }
    393 
    394     public void setPointerSpeed(int arg0) throws RemoteException {
    395         // TODO Auto-generated method stub
    396 
    397     }
    398 
    399     public void updateRotation(boolean arg0) throws RemoteException {
    400         // TODO Auto-generated method stub
    401 
    402     }
    403 
    404     public void setStrictModeVisualIndicatorPreference(String arg0) throws RemoteException {
    405         // TODO Auto-generated method stub
    406 
    407     }
    408 
    409     public void showStrictModeViolation(boolean arg0) throws RemoteException {
    410         // TODO Auto-generated method stub
    411 
    412     }
    413 
    414     public void startAppFreezingScreen(IBinder arg0, int arg1) throws RemoteException {
    415         // TODO Auto-generated method stub
    416 
    417     }
    418 
    419     public boolean startViewServer(int arg0) throws RemoteException {
    420         // TODO Auto-generated method stub
    421         return false;
    422     }
    423 
    424     public void statusBarVisibilityChanged(int arg0) throws RemoteException {
    425         // TODO Auto-generated method stub
    426 
    427     }
    428 
    429     public void stopAppFreezingScreen(IBinder arg0, boolean arg1) throws RemoteException {
    430         // TODO Auto-generated method stub
    431 
    432     }
    433 
    434     public boolean stopViewServer() throws RemoteException {
    435         // TODO Auto-generated method stub
    436         return false;
    437     }
    438 
    439     public void thawRotation() throws RemoteException {
    440         // TODO Auto-generated method stub
    441 
    442     }
    443 
    444     public Configuration updateOrientationFromAppTokens(Configuration arg0, IBinder arg1)
    445             throws RemoteException {
    446         // TODO Auto-generated method stub
    447         return null;
    448     }
    449 
    450     public int watchRotation(IRotationWatcher arg0) throws RemoteException {
    451         // TODO Auto-generated method stub
    452         return 0;
    453     }
    454 
    455     public void waitForWindowDrawn(IBinder token, IRemoteCallback callback) {
    456         // TODO Auto-generated method stub
    457     }
    458 
    459     public IBinder asBinder() {
    460         // TODO Auto-generated method stub
    461         return null;
    462     }
    463 
    464     public int getPreferredOptionsPanelGravity() throws RemoteException {
    465         return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    466     }
    467 
    468     public void dismissKeyguard() {
    469     }
    470 
    471     public boolean hasNavigationBar() {
    472         return false; // should this return something else?
    473     }
    474 
    475     public void lockNow() {
    476         // TODO Auto-generated method stub
    477     }
    478 }
    479