blob: 20494e91acce420af873dc99e24df0dfab8caf3b [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * Information you can retrieve about hardware configuration preferences
24 * declared by an application. This corresponds to information collected from the
Dianne Hackborn49237342009-08-27 20:08:01 -070025 * AndroidManifest.xml's <uses-configuration> and <uses-feature> tags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026 */
Dianne Hackborn49237342009-08-27 20:08:01 -070027public class ConfigurationInfo implements Parcelable {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028 /**
29 * The kind of touch screen attached to the device.
30 * One of: {@link android.content.res.Configuration#TOUCHSCREEN_NOTOUCH},
31 * {@link android.content.res.Configuration#TOUCHSCREEN_STYLUS},
32 * {@link android.content.res.Configuration#TOUCHSCREEN_FINGER}.
33 */
34 public int reqTouchScreen;
35
36 /**
37 * Application's input method preference.
38 * One of: {@link android.content.res.Configuration#KEYBOARD_UNDEFINED},
39 * {@link android.content.res.Configuration#KEYBOARD_NOKEYS},
40 * {@link android.content.res.Configuration#KEYBOARD_QWERTY},
41 * {@link android.content.res.Configuration#KEYBOARD_12KEY}
42 */
43 public int reqKeyboardType;
44
45 /**
46 * A flag indicating whether any keyboard is available.
47 * one of: {@link android.content.res.Configuration#NAVIGATION_UNDEFINED},
48 * {@link android.content.res.Configuration#NAVIGATION_DPAD},
49 * {@link android.content.res.Configuration#NAVIGATION_TRACKBALL},
50 * {@link android.content.res.Configuration#NAVIGATION_WHEEL}
51 */
52 public int reqNavigation;
53
54 /**
55 * Value for {@link #reqInputFeatures}: if set, indicates that the application
56 * requires a hard keyboard
57 */
58 public static final int INPUT_FEATURE_HARD_KEYBOARD = 0x00000001;
59
60 /**
61 * Value for {@link #reqInputFeatures}: if set, indicates that the application
62 * requires a five way navigation device
63 */
64 public static final int INPUT_FEATURE_FIVE_WAY_NAV = 0x00000002;
65
66 /**
67 * Flags associated with the input features. Any combination of
68 * {@link #INPUT_FEATURE_HARD_KEYBOARD},
69 * {@link #INPUT_FEATURE_FIVE_WAY_NAV}
70 */
71 public int reqInputFeatures = 0;
72
Suchi Amalapurapud299b812009-06-05 10:26:19 -070073 /**
74 * Default value for {@link #reqGlEsVersion};
75 */
76 public static final int GL_ES_VERSION_UNDEFINED = 0;
77 /**
78 * The GLES version used by an application. The upper order 16 bits represent the
79 * major version and the lower order 16 bits the minor version.
80 */
81 public int reqGlEsVersion;
82
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 public ConfigurationInfo() {
84 }
85
86 public ConfigurationInfo(ConfigurationInfo orig) {
87 reqTouchScreen = orig.reqTouchScreen;
88 reqKeyboardType = orig.reqKeyboardType;
89 reqNavigation = orig.reqNavigation;
90 reqInputFeatures = orig.reqInputFeatures;
Suchi Amalapurapud299b812009-06-05 10:26:19 -070091 reqGlEsVersion = orig.reqGlEsVersion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 }
93
94 public String toString() {
Dianne Hackborn49237342009-08-27 20:08:01 -070095 return "ConfigurationInfo{"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 + Integer.toHexString(System.identityHashCode(this))
Dianne Hackborn49237342009-08-27 20:08:01 -070097 + " touchscreen = " + reqTouchScreen
98 + " inputMethod = " + reqKeyboardType
99 + " navigation = " + reqNavigation
100 + " reqInputFeatures = " + reqInputFeatures
101 + " reqGlEsVersion = " + reqGlEsVersion + "}";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 }
103
104 public int describeContents() {
105 return 0;
106 }
107
108 public void writeToParcel(Parcel dest, int parcelableFlags) {
109 dest.writeInt(reqTouchScreen);
110 dest.writeInt(reqKeyboardType);
111 dest.writeInt(reqNavigation);
112 dest.writeInt(reqInputFeatures);
Suchi Amalapurapud299b812009-06-05 10:26:19 -0700113 dest.writeInt(reqGlEsVersion);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800114 }
115
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700116 public static final @android.annotation.NonNull Creator<ConfigurationInfo> CREATOR =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 new Creator<ConfigurationInfo>() {
118 public ConfigurationInfo createFromParcel(Parcel source) {
119 return new ConfigurationInfo(source);
120 }
121 public ConfigurationInfo[] newArray(int size) {
122 return new ConfigurationInfo[size];
123 }
124 };
125
126 private ConfigurationInfo(Parcel source) {
127 reqTouchScreen = source.readInt();
128 reqKeyboardType = source.readInt();
129 reqNavigation = source.readInt();
130 reqInputFeatures = source.readInt();
Suchi Amalapurapud299b812009-06-05 10:26:19 -0700131 reqGlEsVersion = source.readInt();
132 }
133
134 /**
135 * This method extracts the major and minor version of reqGLEsVersion attribute
136 * and returns it as a string. Say reqGlEsVersion value of 0x00010002 is returned
137 * as 1.2
138 * @return String representation of the reqGlEsVersion attribute
139 */
140 public String getGlEsVersion() {
141 int major = ((reqGlEsVersion & 0xffff0000) >> 16);
142 int minor = reqGlEsVersion & 0x0000ffff;
143 return String.valueOf(major)+"."+String.valueOf(minor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800144 }
145}