Home | History | Annotate | Download | only in accessibilityservice
      1 /*
      2  * Copyright (C) 2009 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 android.accessibilityservice;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 /**
     23  * This class describes an {@link AccessibilityService}. The system
     24  * notifies an {@link AccessibilityService} for
     25  * {@link android.view.accessibility.AccessibilityEvent}s
     26  * according to the information encapsulated in this class.
     27  *
     28  * @see AccessibilityService
     29  * @see android.view.accessibility.AccessibilityEvent
     30  */
     31 public class AccessibilityServiceInfo implements Parcelable {
     32 
     33     /**
     34      * Denotes spoken feedback.
     35      */
     36     public static final int FEEDBACK_SPOKEN = 0x0000001;
     37 
     38     /**
     39      * Denotes haptic feedback.
     40      */
     41     public static final int FEEDBACK_HAPTIC =  0x0000002;
     42 
     43     /**
     44      * Denotes audible (not spoken) feedback.
     45      */
     46     public static final int FEEDBACK_AUDIBLE = 0x0000004;
     47 
     48     /**
     49      * Denotes visual feedback.
     50      */
     51     public static final int FEEDBACK_VISUAL = 0x0000008;
     52 
     53     /**
     54      * Denotes generic feedback.
     55      */
     56     public static final int FEEDBACK_GENERIC = 0x0000010;
     57 
     58     /**
     59      * If an {@link AccessibilityService} is the default for a given type.
     60      * Default service is invoked only if no package specific one exists. In case of
     61      * more than one package specific service only the earlier registered is notified.
     62      */
     63     public static final int DEFAULT = 0x0000001;
     64 
     65     /**
     66      * The event types an {@link AccessibilityService} is interested in.
     67      *
     68      * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CLICKED
     69      * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_LONG_CLICKED
     70      * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_FOCUSED
     71      * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SELECTED
     72      * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED
     73      * @see android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
     74      * @see android.view.accessibility.AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED
     75      */
     76     public int eventTypes;
     77 
     78     /**
     79      * The package names an {@link AccessibilityService} is interested in. Setting
     80      * to null is equivalent to all packages.
     81      */
     82     public String[] packageNames;
     83 
     84     /**
     85      * The feedback type an {@link AccessibilityService} provides.
     86      *
     87      * @see #FEEDBACK_AUDIBLE
     88      * @see #FEEDBACK_GENERIC
     89      * @see #FEEDBACK_HAPTIC
     90      * @see #FEEDBACK_SPOKEN
     91      * @see #FEEDBACK_VISUAL
     92      */
     93     public int feedbackType;
     94 
     95     /**
     96      * The timeout after the most recent event of a given type before an
     97      * {@link AccessibilityService} is notified.
     98      * <p>
     99      * Note: The event notification timeout is useful to avoid propagating events to the client
    100      *       too frequently since this is accomplished via an expensive interprocess call.
    101      *       One can think of the timeout as a criteria to determine when event generation has
    102      *       settled down
    103      */
    104     public long notificationTimeout;
    105 
    106     /**
    107      * This field represents a set of flags used for configuring an
    108      * {@link AccessibilityService}.
    109      *
    110      * @see #DEFAULT
    111      */
    112     public int flags;
    113 
    114     public int describeContents() {
    115         return 0;
    116     }
    117 
    118     public void writeToParcel(Parcel parcel, int flagz) {
    119         parcel.writeInt(eventTypes);
    120         parcel.writeStringArray(packageNames);
    121         parcel.writeInt(feedbackType);
    122         parcel.writeLong(notificationTimeout);
    123         parcel.writeInt(flags);
    124     }
    125 
    126     /**
    127      * @see Parcelable.Creator
    128      */
    129     public static final Parcelable.Creator<AccessibilityServiceInfo> CREATOR =
    130             new Parcelable.Creator<AccessibilityServiceInfo>() {
    131         public AccessibilityServiceInfo createFromParcel(Parcel parcel) {
    132             AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    133             info.eventTypes = parcel.readInt();
    134             info.packageNames = parcel.readStringArray();
    135             info.feedbackType = parcel.readInt();
    136             info.notificationTimeout = parcel.readLong();
    137             info.flags = parcel.readInt();
    138             return info;
    139         }
    140 
    141         public AccessibilityServiceInfo[] newArray(int size) {
    142             return new AccessibilityServiceInfo[size];
    143         }
    144     };
    145 }
    146