ConfigurationInfo.java revision f013e1afd1e68af5e3b868c26a653bbfb39538f8
1/*
2 * Copyright (C) 2008 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
17package android.content.pm;
18
19import android.content.res.Configuration;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
24 * Information you can retrieve about hardware configuration preferences
25 * declared by an application. This corresponds to information collected from the
26 * AndroidManifest.xml's <uses-configuration> tags.
27 */
28public class ConfigurationInfo implements Parcelable {
29    /**
30     * The kind of touch screen attached to the device.
31     * One of: {@link android.content.res.Configuration#TOUCHSCREEN_NOTOUCH},
32     * {@link android.content.res.Configuration#TOUCHSCREEN_STYLUS},
33     * {@link android.content.res.Configuration#TOUCHSCREEN_FINGER}.
34     */
35    public int reqTouchScreen;
36
37    /**
38     * Application's input method preference.
39     * One of: {@link android.content.res.Configuration#KEYBOARD_UNDEFINED},
40     * {@link android.content.res.Configuration#KEYBOARD_NOKEYS},
41     * {@link android.content.res.Configuration#KEYBOARD_QWERTY},
42     * {@link android.content.res.Configuration#KEYBOARD_12KEY}
43     */
44    public int reqKeyboardType;
45
46    /**
47     * A flag indicating whether any keyboard is available.
48     * one of: {@link android.content.res.Configuration#NAVIGATION_UNDEFINED},
49     * {@link android.content.res.Configuration#NAVIGATION_DPAD},
50     * {@link android.content.res.Configuration#NAVIGATION_TRACKBALL},
51     * {@link android.content.res.Configuration#NAVIGATION_WHEEL}
52     */
53    public int reqNavigation;
54
55    /**
56     * Value for {@link #reqInputFeatures}: if set, indicates that the application
57     * requires a hard keyboard
58     */
59    public static final int INPUT_FEATURE_HARD_KEYBOARD = 0x00000001;
60
61    /**
62     * Value for {@link #reqInputFeatures}: if set, indicates that the application
63     * requires a hard keyboard
64     */
65    public static final int INPUT_FEATURE_FIVE_WAY_NAV = 0x00000002;
66
67    /**
68     * Flags associated with the application.  Any combination of
69     * {@link #INPUT_FEATURE_HARD_KEYBOARD},
70     * {@link #INPUT_FEATURE_FIVE_WAY_NAV}
71     */
72    public int reqInputFeatures = 0;
73
74    public ConfigurationInfo() {
75    }
76
77    public ConfigurationInfo(ConfigurationInfo orig) {
78        reqTouchScreen = orig.reqTouchScreen;
79        reqKeyboardType = orig.reqKeyboardType;
80        reqNavigation = orig.reqNavigation;
81        reqInputFeatures = orig.reqInputFeatures;
82    }
83
84    public String toString() {
85        return "ApplicationHardwarePreferences{"
86            + Integer.toHexString(System.identityHashCode(this))
87            + ", touchscreen = " + reqTouchScreen + "}"
88            + ", inputMethod = " + reqKeyboardType + "}"
89            + ", navigation = " + reqNavigation + "}"
90            + ", reqInputFeatures = " + reqInputFeatures + "}";
91    }
92
93    public int describeContents() {
94        return 0;
95    }
96
97    public void writeToParcel(Parcel dest, int parcelableFlags) {
98        dest.writeInt(reqTouchScreen);
99        dest.writeInt(reqKeyboardType);
100        dest.writeInt(reqNavigation);
101        dest.writeInt(reqInputFeatures);
102    }
103
104    public static final Creator<ConfigurationInfo> CREATOR =
105        new Creator<ConfigurationInfo>() {
106        public ConfigurationInfo createFromParcel(Parcel source) {
107            return new ConfigurationInfo(source);
108        }
109        public ConfigurationInfo[] newArray(int size) {
110            return new ConfigurationInfo[size];
111        }
112    };
113
114    private ConfigurationInfo(Parcel source) {
115        reqTouchScreen = source.readInt();
116        reqKeyboardType = source.readInt();
117        reqNavigation = source.readInt();
118        reqInputFeatures = source.readInt();
119    }
120}
121