1/*
2 * Copyright (C) 2007-2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17package com.android.internal.view;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * Bundle of information returned by input method manager about a successful
24 * binding to an input method.
25 */
26public final class InputBindResult implements Parcelable {
27    static final String TAG = "InputBindResult";
28
29    /**
30     * The input method service.
31     */
32    public final IInputMethodSession method;
33
34    /**
35     * The ID for this input method, as found in InputMethodInfo; null if
36     * no input method will be bound.
37     */
38    public final String id;
39
40    /**
41     * Sequence number of this binding.
42     */
43    public final int sequence;
44
45    public InputBindResult(IInputMethodSession _method, String _id, int _sequence) {
46        method = _method;
47        id = _id;
48        sequence = _sequence;
49    }
50
51    InputBindResult(Parcel source) {
52        method = IInputMethodSession.Stub.asInterface(source.readStrongBinder());
53        id = source.readString();
54        sequence = source.readInt();
55    }
56
57    @Override
58    public String toString() {
59        return "InputBindResult{" + method + " " + id
60                + " #" + sequence + "}";
61    }
62
63    /**
64     * Used to package this object into a {@link Parcel}.
65     *
66     * @param dest The {@link Parcel} to be written.
67     * @param flags The flags used for parceling.
68     */
69    public void writeToParcel(Parcel dest, int flags) {
70        dest.writeStrongInterface(method);
71        dest.writeString(id);
72        dest.writeInt(sequence);
73    }
74
75    /**
76     * Used to make this class parcelable.
77     */
78    public static final Parcelable.Creator<InputBindResult> CREATOR = new Parcelable.Creator<InputBindResult>() {
79        public InputBindResult createFromParcel(Parcel source) {
80            return new InputBindResult(source);
81        }
82
83        public InputBindResult[] newArray(int size) {
84            return new InputBindResult[size];
85        }
86    };
87
88    public int describeContents() {
89        return 0;
90    }
91}
92