1 /** 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 * express or implied. See the License for the specific language governing permissions and 12 * limitations under the License. 13 */ 14 15 package android.app.uiautomation.cts; 16 17 import android.accessibilityservice.AccessibilityService; 18 import android.content.Intent; 19 import android.os.IBinder; 20 import android.util.Log; 21 import android.view.accessibility.AccessibilityEvent; 22 23 /** 24 * A stub accessibility service to install for testing UiAutomation's effect on accessibility 25 * services 26 */ 27 public class UiAutomationTestA11yService extends AccessibilityService { 28 private static String LOG_TAG = "UiAutomationTest"; 29 public static Object sWaitObjectForConnectOrUnbind = new Object(); 30 31 public static UiAutomationTestA11yService sConnectedInstance; 32 33 @Override 34 public boolean onUnbind(Intent intent) { 35 synchronized (sWaitObjectForConnectOrUnbind) { 36 sConnectedInstance = null; 37 sWaitObjectForConnectOrUnbind.notifyAll(); 38 } 39 Log.v(LOG_TAG, "onUnbind [" + this + "]"); 40 return false; 41 } 42 43 @Override 44 public void onDestroy() { 45 Log.v(LOG_TAG, "onDestroy [" + this + "]"); 46 } 47 48 @Override 49 public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) { 50 } 51 52 @Override 53 public void onInterrupt() { 54 55 } 56 57 @Override 58 protected void onServiceConnected() { 59 synchronized (sWaitObjectForConnectOrUnbind) { 60 sConnectedInstance = this; 61 sWaitObjectForConnectOrUnbind.notifyAll(); 62 } 63 Log.v(LOG_TAG, "onServiceConnected [" + this + "]"); 64 } 65 66 public boolean isConnected() { 67 try { 68 if (getServiceInfo() == null) { 69 return false; 70 } 71 return true; 72 } catch (Exception e) { 73 return false; 74 } 75 } 76 } 77