The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
| 17 | package android.content.pm; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import 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 Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 25 | * AndroidManifest.xml's <uses-configuration> and <uses-feature> tags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | */ |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 27 | public class ConfigurationInfo implements Parcelable { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | /** |
| 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 Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 73 | /** |
| 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | 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 Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 91 | reqGlEsVersion = orig.reqGlEsVersion; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | public String toString() { |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 95 | return "ConfigurationInfo{" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | + Integer.toHexString(System.identityHashCode(this)) |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 97 | + " touchscreen = " + reqTouchScreen |
| 98 | + " inputMethod = " + reqKeyboardType |
| 99 | + " navigation = " + reqNavigation |
| 100 | + " reqInputFeatures = " + reqInputFeatures |
| 101 | + " reqGlEsVersion = " + reqGlEsVersion + "}"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | } |
| 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 Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 113 | dest.writeInt(reqGlEsVersion); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | } |
| 115 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 116 | public static final @android.annotation.NonNull Creator<ConfigurationInfo> CREATOR = |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | 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 Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 131 | 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | } |
| 145 | } |