189f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov/* 223296fc6448cd265fbb45c1fd9041976ae0da274Guang Zhu * Copyright (C) 2013 The Android Open Source Project 389f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * 489f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * Licensed under the Apache License, Version 2.0 (the "License"); 589f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * you may not use this file except in compliance with the License. 689f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * You may obtain a copy of the License at 789f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * 889f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * http://www.apache.org/licenses/LICENSE-2.0 989f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * 1089f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * Unless required by applicable law or agreed to in writing, software 1189f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * distributed under the License is distributed on an "AS IS" BASIS, 1289f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1389f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * See the License for the specific language governing permissions and 1489f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov * limitations under the License. 1589f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov */ 1689f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov 1789f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganovpackage com.android.uiautomator.core; 1889f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov 1989f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganovimport android.app.Service; 2089f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganovimport android.app.UiAutomation; 2189f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganovimport android.content.Context; 22cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhuimport android.os.PowerManager; 2389f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganovimport android.view.Display; 2489f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganovimport android.view.ViewConfiguration; 2589f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganovimport android.view.WindowManager; 2689f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov 27cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu/** 28cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu * @hide 29cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu */ 3023296fc6448cd265fbb45c1fd9041976ae0da274Guang Zhupublic class InstrumentationUiAutomatorBridge extends UiAutomatorBridge { 3189f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov 3289f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov private final Context mContext; 3389f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov 3423296fc6448cd265fbb45c1fd9041976ae0da274Guang Zhu public InstrumentationUiAutomatorBridge(Context context, UiAutomation uiAutomation) { 3589f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov super(uiAutomation); 3689f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov mContext = context; 3789f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov } 3889f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov 3989f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov public Display getDefaultDisplay() { 4089f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov WindowManager windowManager = (WindowManager) 4189f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov mContext.getSystemService(Service.WINDOW_SERVICE); 4289f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov return windowManager.getDefaultDisplay(); 4389f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov } 4489f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov 45cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu @Override 46cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu public int getRotation() { 47cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu return getDefaultDisplay().getRotation(); 48cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu } 49cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu 50cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu @Override 51cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu public boolean isScreenOn() { 52cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu PowerManager pm = (PowerManager) 53cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu mContext.getSystemService(Service.POWER_SERVICE); 54cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu return pm.isScreenOn(); 55cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu } 56cd08ab4b0d19e68cc1cf18396cb9076e828c1a63Guang Zhu 5789f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov public long getSystemLongPressTime() { 5889f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov return ViewConfiguration.getLongPressTimeout(); 5989f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov } 6089f6117cb1fbeab3770106cf54e05af1f597be81Svetoslav Ganov} 61