The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.content.ComponentName; |
| 20 | import android.content.Intent; |
| 21 | import android.content.IntentFilter; |
| 22 | import android.content.res.AssetManager; |
| 23 | import android.content.res.Configuration; |
| 24 | import android.content.res.Resources; |
| 25 | import android.content.res.TypedArray; |
| 26 | import android.content.res.XmlResourceParser; |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 27 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.os.Bundle; |
| 29 | import android.os.PatternMatcher; |
| 30 | import android.util.AttributeSet; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.util.DisplayMetrics; |
| 32 | import android.util.Log; |
| 33 | import android.util.TypedValue; |
Jason parks | a3cdaa5 | 2011-01-13 14:15:43 -0600 | [diff] [blame] | 34 | import com.android.internal.util.XmlUtils; |
| 35 | import org.xmlpull.v1.XmlPullParser; |
| 36 | import org.xmlpull.v1.XmlPullParserException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
Kenny Root | d63f7db | 2010-09-27 08:07:48 -0700 | [diff] [blame] | 38 | import java.io.BufferedInputStream; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import java.io.File; |
| 40 | import java.io.IOException; |
| 41 | import java.io.InputStream; |
| 42 | import java.lang.ref.WeakReference; |
| 43 | import java.security.cert.Certificate; |
| 44 | import java.security.cert.CertificateEncodingException; |
| 45 | import java.util.ArrayList; |
| 46 | import java.util.Enumeration; |
| 47 | import java.util.Iterator; |
| 48 | import java.util.jar.JarEntry; |
| 49 | import java.util.jar.JarFile; |
| 50 | |
| 51 | /** |
| 52 | * Package archive parsing |
| 53 | * |
| 54 | * {@hide} |
| 55 | */ |
| 56 | public class PackageParser { |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 57 | /** @hide */ |
| 58 | public static class NewPermissionInfo { |
| 59 | public final String name; |
| 60 | public final int sdkVersion; |
| 61 | public final int fileVersion; |
| 62 | |
| 63 | public NewPermissionInfo(String name, int sdkVersion, int fileVersion) { |
| 64 | this.name = name; |
| 65 | this.sdkVersion = sdkVersion; |
| 66 | this.fileVersion = fileVersion; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * List of new permissions that have been added since 1.0. |
| 72 | * NOTE: These must be declared in SDK version order, with permissions |
| 73 | * added to older SDKs appearing before those added to newer SDKs. |
| 74 | * @hide |
| 75 | */ |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 76 | public static final PackageParser.NewPermissionInfo NEW_PERMISSIONS[] = |
| 77 | new PackageParser.NewPermissionInfo[] { |
San Mehat | 5a3a77d | 2009-06-01 09:25:28 -0700 | [diff] [blame] | 78 | new PackageParser.NewPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 79 | android.os.Build.VERSION_CODES.DONUT, 0), |
| 80 | new PackageParser.NewPermissionInfo(android.Manifest.permission.READ_PHONE_STATE, |
| 81 | android.os.Build.VERSION_CODES.DONUT, 0) |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 82 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | |
| 84 | private String mArchiveSourcePath; |
| 85 | private String[] mSeparateProcesses; |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 86 | private static final int SDK_VERSION = Build.VERSION.SDK_INT; |
| 87 | private static final String SDK_CODENAME = "REL".equals(Build.VERSION.CODENAME) |
| 88 | ? null : Build.VERSION.CODENAME; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | |
| 90 | private int mParseError = PackageManager.INSTALL_SUCCEEDED; |
| 91 | |
| 92 | private static final Object mSync = new Object(); |
| 93 | private static WeakReference<byte[]> mReadBuffer; |
| 94 | |
Suchi Amalapurapu | 90d8ee6 | 2010-03-18 11:38:35 -0700 | [diff] [blame] | 95 | private static boolean sCompatibilityModeEnabled = true; |
| 96 | private static final int PARSE_DEFAULT_INSTALL_LOCATION = PackageInfo.INSTALL_LOCATION_UNSPECIFIED; |
Mitsuru Oshima | 69fff4a | 2009-07-21 09:51:05 -0700 | [diff] [blame] | 97 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 98 | static class ParsePackageItemArgs { |
| 99 | final Package owner; |
| 100 | final String[] outError; |
| 101 | final int nameRes; |
| 102 | final int labelRes; |
| 103 | final int iconRes; |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 104 | final int logoRes; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 105 | |
| 106 | String tag; |
| 107 | TypedArray sa; |
| 108 | |
| 109 | ParsePackageItemArgs(Package _owner, String[] _outError, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 110 | int _nameRes, int _labelRes, int _iconRes, int _logoRes) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 111 | owner = _owner; |
| 112 | outError = _outError; |
| 113 | nameRes = _nameRes; |
| 114 | labelRes = _labelRes; |
| 115 | iconRes = _iconRes; |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 116 | logoRes = _logoRes; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
| 120 | static class ParseComponentArgs extends ParsePackageItemArgs { |
| 121 | final String[] sepProcesses; |
| 122 | final int processRes; |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 123 | final int descriptionRes; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 124 | final int enabledRes; |
| 125 | int flags; |
| 126 | |
| 127 | ParseComponentArgs(Package _owner, String[] _outError, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 128 | int _nameRes, int _labelRes, int _iconRes, int _logoRes, |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 129 | String[] _sepProcesses, int _processRes, |
| 130 | int _descriptionRes, int _enabledRes) { |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 131 | super(_owner, _outError, _nameRes, _labelRes, _iconRes, _logoRes); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 132 | sepProcesses = _sepProcesses; |
| 133 | processRes = _processRes; |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 134 | descriptionRes = _descriptionRes; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 135 | enabledRes = _enabledRes; |
| 136 | } |
| 137 | } |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 138 | |
| 139 | /* Light weight package info. |
| 140 | * @hide |
| 141 | */ |
| 142 | public static class PackageLite { |
| 143 | public String packageName; |
| 144 | public int installLocation; |
| 145 | public String mScanPath; |
| 146 | public PackageLite(String packageName, int installLocation) { |
| 147 | this.packageName = packageName; |
| 148 | this.installLocation = installLocation; |
| 149 | } |
| 150 | } |
| 151 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 152 | private ParsePackageItemArgs mParseInstrumentationArgs; |
| 153 | private ParseComponentArgs mParseActivityArgs; |
| 154 | private ParseComponentArgs mParseActivityAliasArgs; |
| 155 | private ParseComponentArgs mParseServiceArgs; |
| 156 | private ParseComponentArgs mParseProviderArgs; |
| 157 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | /** If set to true, we will only allow package files that exactly match |
| 159 | * the DTD. Otherwise, we try to get as much from the package as we |
| 160 | * can without failing. This should normally be set to false, to |
| 161 | * support extensions to the DTD in future versions. */ |
| 162 | private static final boolean RIGID_PARSER = false; |
| 163 | |
| 164 | private static final String TAG = "PackageParser"; |
| 165 | |
| 166 | public PackageParser(String archiveSourcePath) { |
| 167 | mArchiveSourcePath = archiveSourcePath; |
| 168 | } |
| 169 | |
| 170 | public void setSeparateProcesses(String[] procs) { |
| 171 | mSeparateProcesses = procs; |
| 172 | } |
| 173 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | private static final boolean isPackageFilename(String name) { |
| 175 | return name.endsWith(".apk"); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Generate and return the {@link PackageInfo} for a parsed package. |
| 180 | * |
| 181 | * @param p the parsed package. |
| 182 | * @param flags indicating which optional information is included. |
| 183 | */ |
| 184 | public static PackageInfo generatePackageInfo(PackageParser.Package p, |
Dianne Hackborn | 78d6883 | 2010-10-07 01:12:46 -0700 | [diff] [blame] | 185 | int gids[], int flags, long firstInstallTime, long lastUpdateTime) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 186 | |
| 187 | PackageInfo pi = new PackageInfo(); |
| 188 | pi.packageName = p.packageName; |
| 189 | pi.versionCode = p.mVersionCode; |
| 190 | pi.versionName = p.mVersionName; |
| 191 | pi.sharedUserId = p.mSharedUserId; |
| 192 | pi.sharedUserLabel = p.mSharedUserLabel; |
Dianne Hackborn | e4a5951 | 2010-12-07 11:08:07 -0800 | [diff] [blame] | 193 | pi.applicationInfo = generateApplicationInfo(p, flags); |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 194 | pi.installLocation = p.installLocation; |
Dianne Hackborn | 78d6883 | 2010-10-07 01:12:46 -0700 | [diff] [blame] | 195 | pi.firstInstallTime = firstInstallTime; |
| 196 | pi.lastUpdateTime = lastUpdateTime; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 197 | if ((flags&PackageManager.GET_GIDS) != 0) { |
| 198 | pi.gids = gids; |
| 199 | } |
| 200 | if ((flags&PackageManager.GET_CONFIGURATIONS) != 0) { |
| 201 | int N = p.configPreferences.size(); |
| 202 | if (N > 0) { |
| 203 | pi.configPreferences = new ConfigurationInfo[N]; |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 204 | p.configPreferences.toArray(pi.configPreferences); |
| 205 | } |
| 206 | N = p.reqFeatures != null ? p.reqFeatures.size() : 0; |
| 207 | if (N > 0) { |
| 208 | pi.reqFeatures = new FeatureInfo[N]; |
| 209 | p.reqFeatures.toArray(pi.reqFeatures); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | if ((flags&PackageManager.GET_ACTIVITIES) != 0) { |
| 213 | int N = p.activities.size(); |
| 214 | if (N > 0) { |
Dianne Hackborn | 7eca687 | 2009-09-28 23:57:05 -0700 | [diff] [blame] | 215 | if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
| 216 | pi.activities = new ActivityInfo[N]; |
| 217 | } else { |
| 218 | int num = 0; |
| 219 | for (int i=0; i<N; i++) { |
| 220 | if (p.activities.get(i).info.enabled) num++; |
| 221 | } |
| 222 | pi.activities = new ActivityInfo[num]; |
| 223 | } |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 224 | for (int i=0, j=0; i<N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | final Activity activity = p.activities.get(i); |
| 226 | if (activity.info.enabled |
| 227 | || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 228 | pi.activities[j++] = generateActivityInfo(p.activities.get(i), flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | if ((flags&PackageManager.GET_RECEIVERS) != 0) { |
| 234 | int N = p.receivers.size(); |
| 235 | if (N > 0) { |
Dianne Hackborn | 7eca687 | 2009-09-28 23:57:05 -0700 | [diff] [blame] | 236 | if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
| 237 | pi.receivers = new ActivityInfo[N]; |
| 238 | } else { |
| 239 | int num = 0; |
| 240 | for (int i=0; i<N; i++) { |
| 241 | if (p.receivers.get(i).info.enabled) num++; |
| 242 | } |
| 243 | pi.receivers = new ActivityInfo[num]; |
| 244 | } |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 245 | for (int i=0, j=0; i<N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | final Activity activity = p.receivers.get(i); |
| 247 | if (activity.info.enabled |
| 248 | || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 249 | pi.receivers[j++] = generateActivityInfo(p.receivers.get(i), flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | if ((flags&PackageManager.GET_SERVICES) != 0) { |
| 255 | int N = p.services.size(); |
| 256 | if (N > 0) { |
Dianne Hackborn | 7eca687 | 2009-09-28 23:57:05 -0700 | [diff] [blame] | 257 | if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
| 258 | pi.services = new ServiceInfo[N]; |
| 259 | } else { |
| 260 | int num = 0; |
| 261 | for (int i=0; i<N; i++) { |
| 262 | if (p.services.get(i).info.enabled) num++; |
| 263 | } |
| 264 | pi.services = new ServiceInfo[num]; |
| 265 | } |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 266 | for (int i=0, j=0; i<N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 267 | final Service service = p.services.get(i); |
| 268 | if (service.info.enabled |
| 269 | || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 270 | pi.services[j++] = generateServiceInfo(p.services.get(i), flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | if ((flags&PackageManager.GET_PROVIDERS) != 0) { |
| 276 | int N = p.providers.size(); |
| 277 | if (N > 0) { |
Dianne Hackborn | 7eca687 | 2009-09-28 23:57:05 -0700 | [diff] [blame] | 278 | if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
| 279 | pi.providers = new ProviderInfo[N]; |
| 280 | } else { |
| 281 | int num = 0; |
| 282 | for (int i=0; i<N; i++) { |
| 283 | if (p.providers.get(i).info.enabled) num++; |
| 284 | } |
| 285 | pi.providers = new ProviderInfo[num]; |
| 286 | } |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 287 | for (int i=0, j=0; i<N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 288 | final Provider provider = p.providers.get(i); |
| 289 | if (provider.info.enabled |
| 290 | || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) { |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 291 | pi.providers[j++] = generateProviderInfo(p.providers.get(i), flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | if ((flags&PackageManager.GET_INSTRUMENTATION) != 0) { |
| 297 | int N = p.instrumentation.size(); |
| 298 | if (N > 0) { |
| 299 | pi.instrumentation = new InstrumentationInfo[N]; |
| 300 | for (int i=0; i<N; i++) { |
| 301 | pi.instrumentation[i] = generateInstrumentationInfo( |
| 302 | p.instrumentation.get(i), flags); |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | if ((flags&PackageManager.GET_PERMISSIONS) != 0) { |
| 307 | int N = p.permissions.size(); |
| 308 | if (N > 0) { |
| 309 | pi.permissions = new PermissionInfo[N]; |
| 310 | for (int i=0; i<N; i++) { |
| 311 | pi.permissions[i] = generatePermissionInfo(p.permissions.get(i), flags); |
| 312 | } |
| 313 | } |
| 314 | N = p.requestedPermissions.size(); |
| 315 | if (N > 0) { |
| 316 | pi.requestedPermissions = new String[N]; |
| 317 | for (int i=0; i<N; i++) { |
| 318 | pi.requestedPermissions[i] = p.requestedPermissions.get(i); |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | if ((flags&PackageManager.GET_SIGNATURES) != 0) { |
Suchi Amalapurapu | d83006c | 2009-10-28 23:39:46 -0700 | [diff] [blame] | 323 | int N = (p.mSignatures != null) ? p.mSignatures.length : 0; |
| 324 | if (N > 0) { |
| 325 | pi.signatures = new Signature[N]; |
| 326 | System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 327 | } |
| 328 | } |
| 329 | return pi; |
| 330 | } |
| 331 | |
| 332 | private Certificate[] loadCertificates(JarFile jarFile, JarEntry je, |
| 333 | byte[] readBuffer) { |
| 334 | try { |
| 335 | // We must read the stream for the JarEntry to retrieve |
| 336 | // its certificates. |
Kenny Root | d63f7db | 2010-09-27 08:07:48 -0700 | [diff] [blame] | 337 | InputStream is = new BufferedInputStream(jarFile.getInputStream(je)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 338 | while (is.read(readBuffer, 0, readBuffer.length) != -1) { |
| 339 | // not using |
| 340 | } |
| 341 | is.close(); |
| 342 | return je != null ? je.getCertificates() : null; |
| 343 | } catch (IOException e) { |
| 344 | Log.w(TAG, "Exception reading " + je.getName() + " in " |
| 345 | + jarFile.getName(), e); |
Dianne Hackborn | 6e52b5d | 2010-04-05 14:33:01 -0700 | [diff] [blame] | 346 | } catch (RuntimeException e) { |
| 347 | Log.w(TAG, "Exception reading " + je.getName() + " in " |
| 348 | + jarFile.getName(), e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 349 | } |
| 350 | return null; |
| 351 | } |
| 352 | |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 353 | public final static int PARSE_IS_SYSTEM = 1<<0; |
| 354 | public final static int PARSE_CHATTY = 1<<1; |
| 355 | public final static int PARSE_MUST_BE_APK = 1<<2; |
| 356 | public final static int PARSE_IGNORE_PROCESSES = 1<<3; |
| 357 | public final static int PARSE_FORWARD_LOCK = 1<<4; |
| 358 | public final static int PARSE_ON_SDCARD = 1<<5; |
Dianne Hackborn | 806da1d | 2010-03-18 16:50:07 -0700 | [diff] [blame] | 359 | public final static int PARSE_IS_SYSTEM_DIR = 1<<6; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 360 | |
| 361 | public int getParseError() { |
| 362 | return mParseError; |
| 363 | } |
| 364 | |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 365 | public Package parsePackage(File sourceFile, String destCodePath, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 366 | DisplayMetrics metrics, int flags) { |
| 367 | mParseError = PackageManager.INSTALL_SUCCEEDED; |
| 368 | |
| 369 | mArchiveSourcePath = sourceFile.getPath(); |
| 370 | if (!sourceFile.isFile()) { |
| 371 | Log.w(TAG, "Skipping dir: " + mArchiveSourcePath); |
| 372 | mParseError = PackageManager.INSTALL_PARSE_FAILED_NOT_APK; |
| 373 | return null; |
| 374 | } |
| 375 | if (!isPackageFilename(sourceFile.getName()) |
| 376 | && (flags&PARSE_MUST_BE_APK) != 0) { |
| 377 | if ((flags&PARSE_IS_SYSTEM) == 0) { |
| 378 | // We expect to have non-.apk files in the system dir, |
| 379 | // so don't warn about them. |
| 380 | Log.w(TAG, "Skipping non-package file: " + mArchiveSourcePath); |
| 381 | } |
| 382 | mParseError = PackageManager.INSTALL_PARSE_FAILED_NOT_APK; |
| 383 | return null; |
| 384 | } |
| 385 | |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 386 | if ((flags&PARSE_CHATTY) != 0 && false) Log.d( |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 387 | TAG, "Scanning package: " + mArchiveSourcePath); |
| 388 | |
| 389 | XmlResourceParser parser = null; |
| 390 | AssetManager assmgr = null; |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 391 | Resources res = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 392 | boolean assetError = true; |
| 393 | try { |
| 394 | assmgr = new AssetManager(); |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 395 | int cookie = assmgr.addAssetPath(mArchiveSourcePath); |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 396 | if (cookie != 0) { |
| 397 | res = new Resources(assmgr, metrics, null); |
Dianne Hackborn | 3fc982f | 2011-03-30 16:20:26 -0700 | [diff] [blame] | 398 | assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 399 | Build.VERSION.RESOURCES_SDK_INT); |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 400 | parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | assetError = false; |
| 402 | } else { |
| 403 | Log.w(TAG, "Failed adding asset path:"+mArchiveSourcePath); |
| 404 | } |
| 405 | } catch (Exception e) { |
| 406 | Log.w(TAG, "Unable to read AndroidManifest.xml of " |
| 407 | + mArchiveSourcePath, e); |
| 408 | } |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 409 | if (assetError) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 410 | if (assmgr != null) assmgr.close(); |
| 411 | mParseError = PackageManager.INSTALL_PARSE_FAILED_BAD_MANIFEST; |
| 412 | return null; |
| 413 | } |
| 414 | String[] errorText = new String[1]; |
| 415 | Package pkg = null; |
| 416 | Exception errorException = null; |
| 417 | try { |
| 418 | // XXXX todo: need to figure out correct configuration. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 419 | pkg = parsePackage(res, parser, flags, errorText); |
| 420 | } catch (Exception e) { |
| 421 | errorException = e; |
| 422 | mParseError = PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION; |
| 423 | } |
| 424 | |
| 425 | |
| 426 | if (pkg == null) { |
| 427 | if (errorException != null) { |
| 428 | Log.w(TAG, mArchiveSourcePath, errorException); |
| 429 | } else { |
| 430 | Log.w(TAG, mArchiveSourcePath + " (at " |
| 431 | + parser.getPositionDescription() |
| 432 | + "): " + errorText[0]); |
| 433 | } |
| 434 | parser.close(); |
| 435 | assmgr.close(); |
| 436 | if (mParseError == PackageManager.INSTALL_SUCCEEDED) { |
| 437 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 438 | } |
| 439 | return null; |
| 440 | } |
| 441 | |
| 442 | parser.close(); |
| 443 | assmgr.close(); |
| 444 | |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 445 | // Set code and resource paths |
| 446 | pkg.mPath = destCodePath; |
| 447 | pkg.mScanPath = mArchiveSourcePath; |
| 448 | //pkg.applicationInfo.sourceDir = destCodePath; |
| 449 | //pkg.applicationInfo.publicSourceDir = destRes; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 450 | pkg.mSignatures = null; |
| 451 | |
| 452 | return pkg; |
| 453 | } |
| 454 | |
| 455 | public boolean collectCertificates(Package pkg, int flags) { |
| 456 | pkg.mSignatures = null; |
| 457 | |
| 458 | WeakReference<byte[]> readBufferRef; |
| 459 | byte[] readBuffer = null; |
| 460 | synchronized (mSync) { |
| 461 | readBufferRef = mReadBuffer; |
| 462 | if (readBufferRef != null) { |
| 463 | mReadBuffer = null; |
| 464 | readBuffer = readBufferRef.get(); |
| 465 | } |
| 466 | if (readBuffer == null) { |
| 467 | readBuffer = new byte[8192]; |
| 468 | readBufferRef = new WeakReference<byte[]>(readBuffer); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | try { |
| 473 | JarFile jarFile = new JarFile(mArchiveSourcePath); |
| 474 | |
| 475 | Certificate[] certs = null; |
| 476 | |
| 477 | if ((flags&PARSE_IS_SYSTEM) != 0) { |
| 478 | // If this package comes from the system image, then we |
| 479 | // can trust it... we'll just use the AndroidManifest.xml |
| 480 | // to retrieve its signatures, not validating all of the |
| 481 | // files. |
| 482 | JarEntry jarEntry = jarFile.getJarEntry("AndroidManifest.xml"); |
| 483 | certs = loadCertificates(jarFile, jarEntry, readBuffer); |
| 484 | if (certs == null) { |
| 485 | Log.e(TAG, "Package " + pkg.packageName |
| 486 | + " has no certificates at entry " |
| 487 | + jarEntry.getName() + "; ignoring!"); |
| 488 | jarFile.close(); |
| 489 | mParseError = PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES; |
| 490 | return false; |
| 491 | } |
| 492 | if (false) { |
| 493 | Log.i(TAG, "File " + mArchiveSourcePath + ": entry=" + jarEntry |
| 494 | + " certs=" + (certs != null ? certs.length : 0)); |
| 495 | if (certs != null) { |
| 496 | final int N = certs.length; |
| 497 | for (int i=0; i<N; i++) { |
| 498 | Log.i(TAG, " Public key: " |
| 499 | + certs[i].getPublicKey().getEncoded() |
| 500 | + " " + certs[i].getPublicKey()); |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | } else { |
| 506 | Enumeration entries = jarFile.entries(); |
| 507 | while (entries.hasMoreElements()) { |
| 508 | JarEntry je = (JarEntry)entries.nextElement(); |
| 509 | if (je.isDirectory()) continue; |
| 510 | if (je.getName().startsWith("META-INF/")) continue; |
| 511 | Certificate[] localCerts = loadCertificates(jarFile, je, |
| 512 | readBuffer); |
| 513 | if (false) { |
| 514 | Log.i(TAG, "File " + mArchiveSourcePath + " entry " + je.getName() |
| 515 | + ": certs=" + certs + " (" |
| 516 | + (certs != null ? certs.length : 0) + ")"); |
| 517 | } |
| 518 | if (localCerts == null) { |
| 519 | Log.e(TAG, "Package " + pkg.packageName |
| 520 | + " has no certificates at entry " |
| 521 | + je.getName() + "; ignoring!"); |
| 522 | jarFile.close(); |
| 523 | mParseError = PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES; |
| 524 | return false; |
| 525 | } else if (certs == null) { |
| 526 | certs = localCerts; |
| 527 | } else { |
| 528 | // Ensure all certificates match. |
| 529 | for (int i=0; i<certs.length; i++) { |
| 530 | boolean found = false; |
| 531 | for (int j=0; j<localCerts.length; j++) { |
| 532 | if (certs[i] != null && |
| 533 | certs[i].equals(localCerts[j])) { |
| 534 | found = true; |
| 535 | break; |
| 536 | } |
| 537 | } |
| 538 | if (!found || certs.length != localCerts.length) { |
| 539 | Log.e(TAG, "Package " + pkg.packageName |
| 540 | + " has mismatched certificates at entry " |
| 541 | + je.getName() + "; ignoring!"); |
| 542 | jarFile.close(); |
| 543 | mParseError = PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES; |
| 544 | return false; |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | jarFile.close(); |
| 551 | |
| 552 | synchronized (mSync) { |
| 553 | mReadBuffer = readBufferRef; |
| 554 | } |
| 555 | |
| 556 | if (certs != null && certs.length > 0) { |
| 557 | final int N = certs.length; |
| 558 | pkg.mSignatures = new Signature[certs.length]; |
| 559 | for (int i=0; i<N; i++) { |
| 560 | pkg.mSignatures[i] = new Signature( |
| 561 | certs[i].getEncoded()); |
| 562 | } |
| 563 | } else { |
| 564 | Log.e(TAG, "Package " + pkg.packageName |
| 565 | + " has no certificates; ignoring!"); |
| 566 | mParseError = PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES; |
| 567 | return false; |
| 568 | } |
| 569 | } catch (CertificateEncodingException e) { |
| 570 | Log.w(TAG, "Exception reading " + mArchiveSourcePath, e); |
| 571 | mParseError = PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING; |
| 572 | return false; |
| 573 | } catch (IOException e) { |
| 574 | Log.w(TAG, "Exception reading " + mArchiveSourcePath, e); |
| 575 | mParseError = PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING; |
| 576 | return false; |
| 577 | } catch (RuntimeException e) { |
| 578 | Log.w(TAG, "Exception reading " + mArchiveSourcePath, e); |
| 579 | mParseError = PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION; |
| 580 | return false; |
| 581 | } |
| 582 | |
| 583 | return true; |
| 584 | } |
| 585 | |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 586 | /* |
| 587 | * Utility method that retrieves just the package name and install |
| 588 | * location from the apk location at the given file path. |
| 589 | * @param packageFilePath file location of the apk |
| 590 | * @param flags Special parse flags |
Kenny Root | 930d3af | 2010-07-30 16:52:29 -0700 | [diff] [blame] | 591 | * @return PackageLite object with package information or null on failure. |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 592 | */ |
| 593 | public static PackageLite parsePackageLite(String packageFilePath, int flags) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 594 | XmlResourceParser parser = null; |
| 595 | AssetManager assmgr = null; |
| 596 | try { |
| 597 | assmgr = new AssetManager(); |
Dianne Hackborn | 3fc982f | 2011-03-30 16:20:26 -0700 | [diff] [blame] | 598 | assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 599 | Build.VERSION.RESOURCES_SDK_INT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 600 | int cookie = assmgr.addAssetPath(packageFilePath); |
| 601 | parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml"); |
| 602 | } catch (Exception e) { |
| 603 | if (assmgr != null) assmgr.close(); |
| 604 | Log.w(TAG, "Unable to read AndroidManifest.xml of " |
| 605 | + packageFilePath, e); |
| 606 | return null; |
| 607 | } |
| 608 | AttributeSet attrs = parser; |
| 609 | String errors[] = new String[1]; |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 610 | PackageLite packageLite = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 611 | try { |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 612 | packageLite = parsePackageLite(parser, attrs, flags, errors); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 613 | } catch (IOException e) { |
| 614 | Log.w(TAG, packageFilePath, e); |
| 615 | } catch (XmlPullParserException e) { |
| 616 | Log.w(TAG, packageFilePath, e); |
| 617 | } finally { |
| 618 | if (parser != null) parser.close(); |
| 619 | if (assmgr != null) assmgr.close(); |
| 620 | } |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 621 | if (packageLite == null) { |
| 622 | Log.e(TAG, "parsePackageLite error: " + errors[0]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | return null; |
| 624 | } |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 625 | return packageLite; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | private static String validateName(String name, boolean requiresSeparator) { |
| 629 | final int N = name.length(); |
| 630 | boolean hasSep = false; |
| 631 | boolean front = true; |
| 632 | for (int i=0; i<N; i++) { |
| 633 | final char c = name.charAt(i); |
| 634 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { |
| 635 | front = false; |
| 636 | continue; |
| 637 | } |
| 638 | if (!front) { |
| 639 | if ((c >= '0' && c <= '9') || c == '_') { |
| 640 | continue; |
| 641 | } |
| 642 | } |
| 643 | if (c == '.') { |
| 644 | hasSep = true; |
| 645 | front = true; |
| 646 | continue; |
| 647 | } |
| 648 | return "bad character '" + c + "'"; |
| 649 | } |
| 650 | return hasSep || !requiresSeparator |
| 651 | ? null : "must have at least one '.' separator"; |
| 652 | } |
| 653 | |
| 654 | private static String parsePackageName(XmlPullParser parser, |
| 655 | AttributeSet attrs, int flags, String[] outError) |
| 656 | throws IOException, XmlPullParserException { |
| 657 | |
| 658 | int type; |
| 659 | while ((type=parser.next()) != parser.START_TAG |
| 660 | && type != parser.END_DOCUMENT) { |
| 661 | ; |
| 662 | } |
| 663 | |
| 664 | if (type != parser.START_TAG) { |
| 665 | outError[0] = "No start tag found"; |
| 666 | return null; |
| 667 | } |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 668 | if ((flags&PARSE_CHATTY) != 0 && false) Log.v( |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 669 | TAG, "Root element name: '" + parser.getName() + "'"); |
| 670 | if (!parser.getName().equals("manifest")) { |
| 671 | outError[0] = "No <manifest> tag"; |
| 672 | return null; |
| 673 | } |
| 674 | String pkgName = attrs.getAttributeValue(null, "package"); |
| 675 | if (pkgName == null || pkgName.length() == 0) { |
| 676 | outError[0] = "<manifest> does not specify package"; |
| 677 | return null; |
| 678 | } |
| 679 | String nameError = validateName(pkgName, true); |
| 680 | if (nameError != null && !"android".equals(pkgName)) { |
| 681 | outError[0] = "<manifest> specifies bad package name \"" |
| 682 | + pkgName + "\": " + nameError; |
| 683 | return null; |
| 684 | } |
| 685 | |
| 686 | return pkgName.intern(); |
| 687 | } |
| 688 | |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 689 | private static PackageLite parsePackageLite(XmlPullParser parser, |
| 690 | AttributeSet attrs, int flags, String[] outError) |
| 691 | throws IOException, XmlPullParserException { |
| 692 | |
| 693 | int type; |
| 694 | while ((type=parser.next()) != parser.START_TAG |
| 695 | && type != parser.END_DOCUMENT) { |
| 696 | ; |
| 697 | } |
| 698 | |
| 699 | if (type != parser.START_TAG) { |
| 700 | outError[0] = "No start tag found"; |
| 701 | return null; |
| 702 | } |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 703 | if ((flags&PARSE_CHATTY) != 0 && false) Log.v( |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 704 | TAG, "Root element name: '" + parser.getName() + "'"); |
| 705 | if (!parser.getName().equals("manifest")) { |
| 706 | outError[0] = "No <manifest> tag"; |
| 707 | return null; |
| 708 | } |
| 709 | String pkgName = attrs.getAttributeValue(null, "package"); |
| 710 | if (pkgName == null || pkgName.length() == 0) { |
| 711 | outError[0] = "<manifest> does not specify package"; |
| 712 | return null; |
| 713 | } |
| 714 | String nameError = validateName(pkgName, true); |
| 715 | if (nameError != null && !"android".equals(pkgName)) { |
| 716 | outError[0] = "<manifest> specifies bad package name \"" |
| 717 | + pkgName + "\": " + nameError; |
| 718 | return null; |
| 719 | } |
Suchi Amalapurapu | 90d8ee6 | 2010-03-18 11:38:35 -0700 | [diff] [blame] | 720 | int installLocation = PARSE_DEFAULT_INSTALL_LOCATION; |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 721 | for (int i = 0; i < attrs.getAttributeCount(); i++) { |
| 722 | String attr = attrs.getAttributeName(i); |
| 723 | if (attr.equals("installLocation")) { |
| 724 | installLocation = attrs.getAttributeIntValue(i, |
Suchi Amalapurapu | 90d8ee6 | 2010-03-18 11:38:35 -0700 | [diff] [blame] | 725 | PARSE_DEFAULT_INSTALL_LOCATION); |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 726 | break; |
| 727 | } |
| 728 | } |
| 729 | return new PackageLite(pkgName.intern(), installLocation); |
| 730 | } |
| 731 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | /** |
| 733 | * Temporary. |
| 734 | */ |
| 735 | static public Signature stringToSignature(String str) { |
| 736 | final int N = str.length(); |
| 737 | byte[] sig = new byte[N]; |
| 738 | for (int i=0; i<N; i++) { |
| 739 | sig[i] = (byte)str.charAt(i); |
| 740 | } |
| 741 | return new Signature(sig); |
| 742 | } |
| 743 | |
| 744 | private Package parsePackage( |
| 745 | Resources res, XmlResourceParser parser, int flags, String[] outError) |
| 746 | throws XmlPullParserException, IOException { |
| 747 | AttributeSet attrs = parser; |
| 748 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 749 | mParseInstrumentationArgs = null; |
| 750 | mParseActivityArgs = null; |
| 751 | mParseServiceArgs = null; |
| 752 | mParseProviderArgs = null; |
| 753 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 754 | String pkgName = parsePackageName(parser, attrs, flags, outError); |
| 755 | if (pkgName == null) { |
| 756 | mParseError = PackageManager.INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME; |
| 757 | return null; |
| 758 | } |
| 759 | int type; |
| 760 | |
| 761 | final Package pkg = new Package(pkgName); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 762 | boolean foundApp = false; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 763 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 764 | TypedArray sa = res.obtainAttributes(attrs, |
| 765 | com.android.internal.R.styleable.AndroidManifest); |
| 766 | pkg.mVersionCode = sa.getInteger( |
| 767 | com.android.internal.R.styleable.AndroidManifest_versionCode, 0); |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 768 | pkg.mVersionName = sa.getNonConfigurationString( |
| 769 | com.android.internal.R.styleable.AndroidManifest_versionName, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 770 | if (pkg.mVersionName != null) { |
| 771 | pkg.mVersionName = pkg.mVersionName.intern(); |
| 772 | } |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 773 | String str = sa.getNonConfigurationString( |
| 774 | com.android.internal.R.styleable.AndroidManifest_sharedUserId, 0); |
| 775 | if (str != null && str.length() > 0) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 776 | String nameError = validateName(str, true); |
| 777 | if (nameError != null && !"android".equals(pkgName)) { |
| 778 | outError[0] = "<manifest> specifies bad sharedUserId name \"" |
| 779 | + str + "\": " + nameError; |
| 780 | mParseError = PackageManager.INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID; |
| 781 | return null; |
| 782 | } |
| 783 | pkg.mSharedUserId = str.intern(); |
| 784 | pkg.mSharedUserLabel = sa.getResourceId( |
| 785 | com.android.internal.R.styleable.AndroidManifest_sharedUserLabel, 0); |
| 786 | } |
| 787 | sa.recycle(); |
Suchi Amalapurapu | aaec779 | 2010-02-25 11:49:43 -0800 | [diff] [blame] | 788 | |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 789 | pkg.installLocation = sa.getInteger( |
| 790 | com.android.internal.R.styleable.AndroidManifest_installLocation, |
Suchi Amalapurapu | 90d8ee6 | 2010-03-18 11:38:35 -0700 | [diff] [blame] | 791 | PARSE_DEFAULT_INSTALL_LOCATION); |
Dianne Hackborn | 54e570f | 2010-10-04 18:32:32 -0700 | [diff] [blame] | 792 | pkg.applicationInfo.installLocation = pkg.installLocation; |
| 793 | |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 794 | // Resource boolean are -1, so 1 means we don't know the value. |
| 795 | int supportsSmallScreens = 1; |
| 796 | int supportsNormalScreens = 1; |
| 797 | int supportsLargeScreens = 1; |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 798 | int supportsXLargeScreens = 1; |
Dianne Hackborn | c4db95c | 2009-07-21 17:46:02 -0700 | [diff] [blame] | 799 | int resizeable = 1; |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 800 | int anyDensity = 1; |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 801 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 802 | int outerDepth = parser.getDepth(); |
| 803 | while ((type=parser.next()) != parser.END_DOCUMENT |
| 804 | && (type != parser.END_TAG || parser.getDepth() > outerDepth)) { |
| 805 | if (type == parser.END_TAG || type == parser.TEXT) { |
| 806 | continue; |
| 807 | } |
| 808 | |
| 809 | String tagName = parser.getName(); |
| 810 | if (tagName.equals("application")) { |
| 811 | if (foundApp) { |
| 812 | if (RIGID_PARSER) { |
| 813 | outError[0] = "<manifest> has more than one <application>"; |
| 814 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 815 | return null; |
| 816 | } else { |
| 817 | Log.w(TAG, "<manifest> has more than one <application>"); |
| 818 | XmlUtils.skipCurrentTag(parser); |
| 819 | continue; |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | foundApp = true; |
| 824 | if (!parseApplication(pkg, res, parser, attrs, flags, outError)) { |
| 825 | return null; |
| 826 | } |
| 827 | } else if (tagName.equals("permission-group")) { |
| 828 | if (parsePermissionGroup(pkg, res, parser, attrs, outError) == null) { |
| 829 | return null; |
| 830 | } |
| 831 | } else if (tagName.equals("permission")) { |
| 832 | if (parsePermission(pkg, res, parser, attrs, outError) == null) { |
| 833 | return null; |
| 834 | } |
| 835 | } else if (tagName.equals("permission-tree")) { |
| 836 | if (parsePermissionTree(pkg, res, parser, attrs, outError) == null) { |
| 837 | return null; |
| 838 | } |
| 839 | } else if (tagName.equals("uses-permission")) { |
| 840 | sa = res.obtainAttributes(attrs, |
| 841 | com.android.internal.R.styleable.AndroidManifestUsesPermission); |
| 842 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 843 | // Note: don't allow this value to be a reference to a resource |
| 844 | // that may change. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 845 | String name = sa.getNonResourceString( |
| 846 | com.android.internal.R.styleable.AndroidManifestUsesPermission_name); |
| 847 | |
| 848 | sa.recycle(); |
| 849 | |
| 850 | if (name != null && !pkg.requestedPermissions.contains(name)) { |
Dianne Hackborn | 854060a | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 851 | pkg.requestedPermissions.add(name.intern()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 852 | } |
| 853 | |
| 854 | XmlUtils.skipCurrentTag(parser); |
| 855 | |
| 856 | } else if (tagName.equals("uses-configuration")) { |
| 857 | ConfigurationInfo cPref = new ConfigurationInfo(); |
| 858 | sa = res.obtainAttributes(attrs, |
| 859 | com.android.internal.R.styleable.AndroidManifestUsesConfiguration); |
| 860 | cPref.reqTouchScreen = sa.getInt( |
| 861 | com.android.internal.R.styleable.AndroidManifestUsesConfiguration_reqTouchScreen, |
| 862 | Configuration.TOUCHSCREEN_UNDEFINED); |
| 863 | cPref.reqKeyboardType = sa.getInt( |
| 864 | com.android.internal.R.styleable.AndroidManifestUsesConfiguration_reqKeyboardType, |
| 865 | Configuration.KEYBOARD_UNDEFINED); |
| 866 | if (sa.getBoolean( |
| 867 | com.android.internal.R.styleable.AndroidManifestUsesConfiguration_reqHardKeyboard, |
| 868 | false)) { |
| 869 | cPref.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD; |
| 870 | } |
| 871 | cPref.reqNavigation = sa.getInt( |
| 872 | com.android.internal.R.styleable.AndroidManifestUsesConfiguration_reqNavigation, |
| 873 | Configuration.NAVIGATION_UNDEFINED); |
| 874 | if (sa.getBoolean( |
| 875 | com.android.internal.R.styleable.AndroidManifestUsesConfiguration_reqFiveWayNav, |
| 876 | false)) { |
| 877 | cPref.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV; |
| 878 | } |
| 879 | sa.recycle(); |
| 880 | pkg.configPreferences.add(cPref); |
| 881 | |
| 882 | XmlUtils.skipCurrentTag(parser); |
| 883 | |
Suchi Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 884 | } else if (tagName.equals("uses-feature")) { |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 885 | FeatureInfo fi = new FeatureInfo(); |
Suchi Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 886 | sa = res.obtainAttributes(attrs, |
| 887 | com.android.internal.R.styleable.AndroidManifestUsesFeature); |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 888 | // Note: don't allow this value to be a reference to a resource |
| 889 | // that may change. |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 890 | fi.name = sa.getNonResourceString( |
| 891 | com.android.internal.R.styleable.AndroidManifestUsesFeature_name); |
| 892 | if (fi.name == null) { |
| 893 | fi.reqGlEsVersion = sa.getInt( |
| 894 | com.android.internal.R.styleable.AndroidManifestUsesFeature_glEsVersion, |
| 895 | FeatureInfo.GL_ES_VERSION_UNDEFINED); |
| 896 | } |
| 897 | if (sa.getBoolean( |
| 898 | com.android.internal.R.styleable.AndroidManifestUsesFeature_required, |
| 899 | true)) { |
| 900 | fi.flags |= FeatureInfo.FLAG_REQUIRED; |
| 901 | } |
Suchi Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 902 | sa.recycle(); |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 903 | if (pkg.reqFeatures == null) { |
| 904 | pkg.reqFeatures = new ArrayList<FeatureInfo>(); |
| 905 | } |
| 906 | pkg.reqFeatures.add(fi); |
| 907 | |
| 908 | if (fi.name == null) { |
| 909 | ConfigurationInfo cPref = new ConfigurationInfo(); |
| 910 | cPref.reqGlEsVersion = fi.reqGlEsVersion; |
| 911 | pkg.configPreferences.add(cPref); |
| 912 | } |
Suchi Amalapurapu | d299b81 | 2009-06-05 10:26:19 -0700 | [diff] [blame] | 913 | |
| 914 | XmlUtils.skipCurrentTag(parser); |
| 915 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 916 | } else if (tagName.equals("uses-sdk")) { |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 917 | if (SDK_VERSION > 0) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 918 | sa = res.obtainAttributes(attrs, |
| 919 | com.android.internal.R.styleable.AndroidManifestUsesSdk); |
| 920 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 921 | int minVers = 0; |
| 922 | String minCode = null; |
| 923 | int targetVers = 0; |
| 924 | String targetCode = null; |
| 925 | |
| 926 | TypedValue val = sa.peekValue( |
| 927 | com.android.internal.R.styleable.AndroidManifestUsesSdk_minSdkVersion); |
| 928 | if (val != null) { |
| 929 | if (val.type == TypedValue.TYPE_STRING && val.string != null) { |
| 930 | targetCode = minCode = val.string.toString(); |
| 931 | } else { |
| 932 | // If it's not a string, it's an integer. |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 933 | targetVers = minVers = val.data; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 934 | } |
| 935 | } |
| 936 | |
| 937 | val = sa.peekValue( |
| 938 | com.android.internal.R.styleable.AndroidManifestUsesSdk_targetSdkVersion); |
| 939 | if (val != null) { |
| 940 | if (val.type == TypedValue.TYPE_STRING && val.string != null) { |
| 941 | targetCode = minCode = val.string.toString(); |
| 942 | } else { |
| 943 | // If it's not a string, it's an integer. |
| 944 | targetVers = val.data; |
| 945 | } |
| 946 | } |
| 947 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 948 | sa.recycle(); |
| 949 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 950 | if (minCode != null) { |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 951 | if (!minCode.equals(SDK_CODENAME)) { |
| 952 | if (SDK_CODENAME != null) { |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 953 | outError[0] = "Requires development platform " + minCode |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 954 | + " (current platform is " + SDK_CODENAME + ")"; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 955 | } else { |
| 956 | outError[0] = "Requires development platform " + minCode |
| 957 | + " but this is a release platform."; |
| 958 | } |
| 959 | mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK; |
| 960 | return null; |
| 961 | } |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 962 | } else if (minVers > SDK_VERSION) { |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 963 | outError[0] = "Requires newer sdk version #" + minVers |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 964 | + " (current version is #" + SDK_VERSION + ")"; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 965 | mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK; |
| 966 | return null; |
| 967 | } |
| 968 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 969 | if (targetCode != null) { |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 970 | if (!targetCode.equals(SDK_CODENAME)) { |
| 971 | if (SDK_CODENAME != null) { |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 972 | outError[0] = "Requires development platform " + targetCode |
Suchi Amalapurapu | 8d5ae98 | 2009-10-06 09:26:09 -0700 | [diff] [blame] | 973 | + " (current platform is " + SDK_CODENAME + ")"; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 974 | } else { |
| 975 | outError[0] = "Requires development platform " + targetCode |
| 976 | + " but this is a release platform."; |
| 977 | } |
| 978 | mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK; |
| 979 | return null; |
| 980 | } |
| 981 | // If the code matches, it definitely targets this SDK. |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 982 | pkg.applicationInfo.targetSdkVersion |
| 983 | = android.os.Build.VERSION_CODES.CUR_DEVELOPMENT; |
| 984 | } else { |
| 985 | pkg.applicationInfo.targetSdkVersion = targetVers; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 986 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | XmlUtils.skipCurrentTag(parser); |
| 990 | |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 991 | } else if (tagName.equals("supports-screens")) { |
| 992 | sa = res.obtainAttributes(attrs, |
| 993 | com.android.internal.R.styleable.AndroidManifestSupportsScreens); |
| 994 | |
| 995 | // This is a trick to get a boolean and still able to detect |
| 996 | // if a value was actually set. |
| 997 | supportsSmallScreens = sa.getInteger( |
| 998 | com.android.internal.R.styleable.AndroidManifestSupportsScreens_smallScreens, |
| 999 | supportsSmallScreens); |
| 1000 | supportsNormalScreens = sa.getInteger( |
| 1001 | com.android.internal.R.styleable.AndroidManifestSupportsScreens_normalScreens, |
| 1002 | supportsNormalScreens); |
| 1003 | supportsLargeScreens = sa.getInteger( |
| 1004 | com.android.internal.R.styleable.AndroidManifestSupportsScreens_largeScreens, |
| 1005 | supportsLargeScreens); |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 1006 | supportsXLargeScreens = sa.getInteger( |
| 1007 | com.android.internal.R.styleable.AndroidManifestSupportsScreens_xlargeScreens, |
| 1008 | supportsXLargeScreens); |
Dianne Hackborn | c4db95c | 2009-07-21 17:46:02 -0700 | [diff] [blame] | 1009 | resizeable = sa.getInteger( |
| 1010 | com.android.internal.R.styleable.AndroidManifestSupportsScreens_resizeable, |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 1011 | resizeable); |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 1012 | anyDensity = sa.getInteger( |
| 1013 | com.android.internal.R.styleable.AndroidManifestSupportsScreens_anyDensity, |
| 1014 | anyDensity); |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 1015 | |
| 1016 | sa.recycle(); |
| 1017 | |
Mitsuru Oshima | 9189cab | 2009-06-03 11:19:12 -0700 | [diff] [blame] | 1018 | XmlUtils.skipCurrentTag(parser); |
Dianne Hackborn | 854060a | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1019 | |
| 1020 | } else if (tagName.equals("protected-broadcast")) { |
| 1021 | sa = res.obtainAttributes(attrs, |
| 1022 | com.android.internal.R.styleable.AndroidManifestProtectedBroadcast); |
| 1023 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1024 | // Note: don't allow this value to be a reference to a resource |
| 1025 | // that may change. |
Dianne Hackborn | 854060a | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1026 | String name = sa.getNonResourceString( |
| 1027 | com.android.internal.R.styleable.AndroidManifestProtectedBroadcast_name); |
| 1028 | |
| 1029 | sa.recycle(); |
| 1030 | |
| 1031 | if (name != null && (flags&PARSE_IS_SYSTEM) != 0) { |
| 1032 | if (pkg.protectedBroadcasts == null) { |
| 1033 | pkg.protectedBroadcasts = new ArrayList<String>(); |
| 1034 | } |
| 1035 | if (!pkg.protectedBroadcasts.contains(name)) { |
| 1036 | pkg.protectedBroadcasts.add(name.intern()); |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | XmlUtils.skipCurrentTag(parser); |
| 1041 | |
| 1042 | } else if (tagName.equals("instrumentation")) { |
| 1043 | if (parseInstrumentation(pkg, res, parser, attrs, outError) == null) { |
| 1044 | return null; |
| 1045 | } |
| 1046 | |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 1047 | } else if (tagName.equals("original-package")) { |
| 1048 | sa = res.obtainAttributes(attrs, |
| 1049 | com.android.internal.R.styleable.AndroidManifestOriginalPackage); |
| 1050 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1051 | String orig =sa.getNonConfigurationString( |
| 1052 | com.android.internal.R.styleable.AndroidManifestOriginalPackage_name, 0); |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 1053 | if (!pkg.packageName.equals(orig)) { |
Dianne Hackborn | c155239 | 2010-03-03 16:19:01 -0800 | [diff] [blame] | 1054 | if (pkg.mOriginalPackages == null) { |
| 1055 | pkg.mOriginalPackages = new ArrayList<String>(); |
| 1056 | pkg.mRealPackage = pkg.packageName; |
| 1057 | } |
| 1058 | pkg.mOriginalPackages.add(orig); |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 1059 | } |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 1060 | |
| 1061 | sa.recycle(); |
| 1062 | |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 1063 | XmlUtils.skipCurrentTag(parser); |
| 1064 | |
| 1065 | } else if (tagName.equals("adopt-permissions")) { |
| 1066 | sa = res.obtainAttributes(attrs, |
| 1067 | com.android.internal.R.styleable.AndroidManifestOriginalPackage); |
| 1068 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1069 | String name = sa.getNonConfigurationString( |
| 1070 | com.android.internal.R.styleable.AndroidManifestOriginalPackage_name, 0); |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 1071 | |
| 1072 | sa.recycle(); |
| 1073 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 1074 | if (name != null) { |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 1075 | if (pkg.mAdoptPermissions == null) { |
| 1076 | pkg.mAdoptPermissions = new ArrayList<String>(); |
| 1077 | } |
| 1078 | pkg.mAdoptPermissions.add(name); |
| 1079 | } |
| 1080 | |
| 1081 | XmlUtils.skipCurrentTag(parser); |
| 1082 | |
Dianne Hackborn | a0b46c9 | 2010-10-21 15:32:06 -0700 | [diff] [blame] | 1083 | } else if (tagName.equals("uses-gl-texture")) { |
| 1084 | // Just skip this tag |
| 1085 | XmlUtils.skipCurrentTag(parser); |
| 1086 | continue; |
| 1087 | |
| 1088 | } else if (tagName.equals("compatible-screens")) { |
| 1089 | // Just skip this tag |
| 1090 | XmlUtils.skipCurrentTag(parser); |
| 1091 | continue; |
| 1092 | |
Dianne Hackborn | 854060a | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1093 | } else if (tagName.equals("eat-comment")) { |
| 1094 | // Just skip this tag |
| 1095 | XmlUtils.skipCurrentTag(parser); |
| 1096 | continue; |
| 1097 | |
| 1098 | } else if (RIGID_PARSER) { |
| 1099 | outError[0] = "Bad element under <manifest>: " |
| 1100 | + parser.getName(); |
| 1101 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1102 | return null; |
| 1103 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1104 | } else { |
Dianne Hackborn | bd0a81f | 2009-10-04 13:30:50 -0700 | [diff] [blame] | 1105 | Log.w(TAG, "Unknown element under <manifest>: " + parser.getName() |
| 1106 | + " at " + mArchiveSourcePath + " " |
| 1107 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1108 | XmlUtils.skipCurrentTag(parser); |
| 1109 | continue; |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | if (!foundApp && pkg.instrumentation.size() == 0) { |
| 1114 | outError[0] = "<manifest> does not contain an <application> or <instrumentation>"; |
| 1115 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_EMPTY; |
| 1116 | } |
| 1117 | |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 1118 | final int NP = PackageParser.NEW_PERMISSIONS.length; |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 1119 | StringBuilder implicitPerms = null; |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 1120 | for (int ip=0; ip<NP; ip++) { |
| 1121 | final PackageParser.NewPermissionInfo npi |
| 1122 | = PackageParser.NEW_PERMISSIONS[ip]; |
| 1123 | if (pkg.applicationInfo.targetSdkVersion >= npi.sdkVersion) { |
| 1124 | break; |
| 1125 | } |
| 1126 | if (!pkg.requestedPermissions.contains(npi.name)) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 1127 | if (implicitPerms == null) { |
| 1128 | implicitPerms = new StringBuilder(128); |
| 1129 | implicitPerms.append(pkg.packageName); |
| 1130 | implicitPerms.append(": compat added "); |
| 1131 | } else { |
| 1132 | implicitPerms.append(' '); |
| 1133 | } |
| 1134 | implicitPerms.append(npi.name); |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 1135 | pkg.requestedPermissions.add(npi.name); |
| 1136 | } |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 1137 | } |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 1138 | if (implicitPerms != null) { |
| 1139 | Log.i(TAG, implicitPerms.toString()); |
| 1140 | } |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 1141 | |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 1142 | if (supportsSmallScreens < 0 || (supportsSmallScreens > 0 |
| 1143 | && pkg.applicationInfo.targetSdkVersion |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 1144 | >= android.os.Build.VERSION_CODES.DONUT)) { |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 1145 | pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS; |
| 1146 | } |
| 1147 | if (supportsNormalScreens != 0) { |
| 1148 | pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS; |
| 1149 | } |
| 1150 | if (supportsLargeScreens < 0 || (supportsLargeScreens > 0 |
| 1151 | && pkg.applicationInfo.targetSdkVersion |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 1152 | >= android.os.Build.VERSION_CODES.DONUT)) { |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 1153 | pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS; |
| 1154 | } |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 1155 | if (supportsXLargeScreens < 0 || (supportsXLargeScreens > 0 |
| 1156 | && pkg.applicationInfo.targetSdkVersion |
| 1157 | >= android.os.Build.VERSION_CODES.GINGERBREAD)) { |
| 1158 | pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS; |
| 1159 | } |
Dianne Hackborn | c4db95c | 2009-07-21 17:46:02 -0700 | [diff] [blame] | 1160 | if (resizeable < 0 || (resizeable > 0 |
| 1161 | && pkg.applicationInfo.targetSdkVersion |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 1162 | >= android.os.Build.VERSION_CODES.DONUT)) { |
Dianne Hackborn | c4db95c | 2009-07-21 17:46:02 -0700 | [diff] [blame] | 1163 | pkg.applicationInfo.flags |= ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS; |
| 1164 | } |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 1165 | if (anyDensity < 0 || (anyDensity > 0 |
| 1166 | && pkg.applicationInfo.targetSdkVersion |
| 1167 | >= android.os.Build.VERSION_CODES.DONUT)) { |
| 1168 | pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES; |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 1169 | } |
Mitsuru Oshima | 1ecf5d2 | 2009-07-06 17:20:38 -0700 | [diff] [blame] | 1170 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1171 | return pkg; |
| 1172 | } |
| 1173 | |
| 1174 | private static String buildClassName(String pkg, CharSequence clsSeq, |
| 1175 | String[] outError) { |
| 1176 | if (clsSeq == null || clsSeq.length() <= 0) { |
| 1177 | outError[0] = "Empty class name in package " + pkg; |
| 1178 | return null; |
| 1179 | } |
| 1180 | String cls = clsSeq.toString(); |
| 1181 | char c = cls.charAt(0); |
| 1182 | if (c == '.') { |
| 1183 | return (pkg + cls).intern(); |
| 1184 | } |
| 1185 | if (cls.indexOf('.') < 0) { |
| 1186 | StringBuilder b = new StringBuilder(pkg); |
| 1187 | b.append('.'); |
| 1188 | b.append(cls); |
| 1189 | return b.toString().intern(); |
| 1190 | } |
| 1191 | if (c >= 'a' && c <= 'z') { |
| 1192 | return cls.intern(); |
| 1193 | } |
| 1194 | outError[0] = "Bad class name " + cls + " in package " + pkg; |
| 1195 | return null; |
| 1196 | } |
| 1197 | |
| 1198 | private static String buildCompoundName(String pkg, |
| 1199 | CharSequence procSeq, String type, String[] outError) { |
| 1200 | String proc = procSeq.toString(); |
| 1201 | char c = proc.charAt(0); |
| 1202 | if (pkg != null && c == ':') { |
| 1203 | if (proc.length() < 2) { |
| 1204 | outError[0] = "Bad " + type + " name " + proc + " in package " + pkg |
| 1205 | + ": must be at least two characters"; |
| 1206 | return null; |
| 1207 | } |
| 1208 | String subName = proc.substring(1); |
| 1209 | String nameError = validateName(subName, false); |
| 1210 | if (nameError != null) { |
| 1211 | outError[0] = "Invalid " + type + " name " + proc + " in package " |
| 1212 | + pkg + ": " + nameError; |
| 1213 | return null; |
| 1214 | } |
| 1215 | return (pkg + proc).intern(); |
| 1216 | } |
| 1217 | String nameError = validateName(proc, true); |
| 1218 | if (nameError != null && !"system".equals(proc)) { |
| 1219 | outError[0] = "Invalid " + type + " name " + proc + " in package " |
| 1220 | + pkg + ": " + nameError; |
| 1221 | return null; |
| 1222 | } |
| 1223 | return proc.intern(); |
| 1224 | } |
| 1225 | |
| 1226 | private static String buildProcessName(String pkg, String defProc, |
| 1227 | CharSequence procSeq, int flags, String[] separateProcesses, |
| 1228 | String[] outError) { |
| 1229 | if ((flags&PARSE_IGNORE_PROCESSES) != 0 && !"system".equals(procSeq)) { |
| 1230 | return defProc != null ? defProc : pkg; |
| 1231 | } |
| 1232 | if (separateProcesses != null) { |
| 1233 | for (int i=separateProcesses.length-1; i>=0; i--) { |
| 1234 | String sp = separateProcesses[i]; |
| 1235 | if (sp.equals(pkg) || sp.equals(defProc) || sp.equals(procSeq)) { |
| 1236 | return pkg; |
| 1237 | } |
| 1238 | } |
| 1239 | } |
| 1240 | if (procSeq == null || procSeq.length() <= 0) { |
| 1241 | return defProc; |
| 1242 | } |
Dianne Hackborn | d1cff1b | 2010-04-02 16:51:26 -0700 | [diff] [blame] | 1243 | return buildCompoundName(pkg, procSeq, "process", outError); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1244 | } |
| 1245 | |
| 1246 | private static String buildTaskAffinityName(String pkg, String defProc, |
| 1247 | CharSequence procSeq, String[] outError) { |
| 1248 | if (procSeq == null) { |
| 1249 | return defProc; |
| 1250 | } |
| 1251 | if (procSeq.length() <= 0) { |
| 1252 | return null; |
| 1253 | } |
| 1254 | return buildCompoundName(pkg, procSeq, "taskAffinity", outError); |
| 1255 | } |
| 1256 | |
| 1257 | private PermissionGroup parsePermissionGroup(Package owner, Resources res, |
| 1258 | XmlPullParser parser, AttributeSet attrs, String[] outError) |
| 1259 | throws XmlPullParserException, IOException { |
| 1260 | PermissionGroup perm = new PermissionGroup(owner); |
| 1261 | |
| 1262 | TypedArray sa = res.obtainAttributes(attrs, |
| 1263 | com.android.internal.R.styleable.AndroidManifestPermissionGroup); |
| 1264 | |
| 1265 | if (!parsePackageItemInfo(owner, perm.info, outError, |
| 1266 | "<permission-group>", sa, |
| 1267 | com.android.internal.R.styleable.AndroidManifestPermissionGroup_name, |
| 1268 | com.android.internal.R.styleable.AndroidManifestPermissionGroup_label, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1269 | com.android.internal.R.styleable.AndroidManifestPermissionGroup_icon, |
| 1270 | com.android.internal.R.styleable.AndroidManifestPermissionGroup_logo)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1271 | sa.recycle(); |
| 1272 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1273 | return null; |
| 1274 | } |
| 1275 | |
| 1276 | perm.info.descriptionRes = sa.getResourceId( |
| 1277 | com.android.internal.R.styleable.AndroidManifestPermissionGroup_description, |
| 1278 | 0); |
| 1279 | |
| 1280 | sa.recycle(); |
| 1281 | |
| 1282 | if (!parseAllMetaData(res, parser, attrs, "<permission-group>", perm, |
| 1283 | outError)) { |
| 1284 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1285 | return null; |
| 1286 | } |
| 1287 | |
| 1288 | owner.permissionGroups.add(perm); |
| 1289 | |
| 1290 | return perm; |
| 1291 | } |
| 1292 | |
| 1293 | private Permission parsePermission(Package owner, Resources res, |
| 1294 | XmlPullParser parser, AttributeSet attrs, String[] outError) |
| 1295 | throws XmlPullParserException, IOException { |
| 1296 | Permission perm = new Permission(owner); |
| 1297 | |
| 1298 | TypedArray sa = res.obtainAttributes(attrs, |
| 1299 | com.android.internal.R.styleable.AndroidManifestPermission); |
| 1300 | |
| 1301 | if (!parsePackageItemInfo(owner, perm.info, outError, |
| 1302 | "<permission>", sa, |
| 1303 | com.android.internal.R.styleable.AndroidManifestPermission_name, |
| 1304 | com.android.internal.R.styleable.AndroidManifestPermission_label, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1305 | com.android.internal.R.styleable.AndroidManifestPermission_icon, |
| 1306 | com.android.internal.R.styleable.AndroidManifestPermission_logo)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1307 | sa.recycle(); |
| 1308 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1309 | return null; |
| 1310 | } |
| 1311 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1312 | // Note: don't allow this value to be a reference to a resource |
| 1313 | // that may change. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1314 | perm.info.group = sa.getNonResourceString( |
| 1315 | com.android.internal.R.styleable.AndroidManifestPermission_permissionGroup); |
| 1316 | if (perm.info.group != null) { |
| 1317 | perm.info.group = perm.info.group.intern(); |
| 1318 | } |
| 1319 | |
| 1320 | perm.info.descriptionRes = sa.getResourceId( |
| 1321 | com.android.internal.R.styleable.AndroidManifestPermission_description, |
| 1322 | 0); |
| 1323 | |
| 1324 | perm.info.protectionLevel = sa.getInt( |
| 1325 | com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel, |
| 1326 | PermissionInfo.PROTECTION_NORMAL); |
| 1327 | |
| 1328 | sa.recycle(); |
| 1329 | |
| 1330 | if (perm.info.protectionLevel == -1) { |
| 1331 | outError[0] = "<permission> does not specify protectionLevel"; |
| 1332 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1333 | return null; |
| 1334 | } |
| 1335 | |
| 1336 | if (!parseAllMetaData(res, parser, attrs, "<permission>", perm, |
| 1337 | outError)) { |
| 1338 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1339 | return null; |
| 1340 | } |
| 1341 | |
| 1342 | owner.permissions.add(perm); |
| 1343 | |
| 1344 | return perm; |
| 1345 | } |
| 1346 | |
| 1347 | private Permission parsePermissionTree(Package owner, Resources res, |
| 1348 | XmlPullParser parser, AttributeSet attrs, String[] outError) |
| 1349 | throws XmlPullParserException, IOException { |
| 1350 | Permission perm = new Permission(owner); |
| 1351 | |
| 1352 | TypedArray sa = res.obtainAttributes(attrs, |
| 1353 | com.android.internal.R.styleable.AndroidManifestPermissionTree); |
| 1354 | |
| 1355 | if (!parsePackageItemInfo(owner, perm.info, outError, |
| 1356 | "<permission-tree>", sa, |
| 1357 | com.android.internal.R.styleable.AndroidManifestPermissionTree_name, |
| 1358 | com.android.internal.R.styleable.AndroidManifestPermissionTree_label, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1359 | com.android.internal.R.styleable.AndroidManifestPermissionTree_icon, |
| 1360 | com.android.internal.R.styleable.AndroidManifestPermissionTree_logo)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1361 | sa.recycle(); |
| 1362 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1363 | return null; |
| 1364 | } |
| 1365 | |
| 1366 | sa.recycle(); |
| 1367 | |
| 1368 | int index = perm.info.name.indexOf('.'); |
| 1369 | if (index > 0) { |
| 1370 | index = perm.info.name.indexOf('.', index+1); |
| 1371 | } |
| 1372 | if (index < 0) { |
| 1373 | outError[0] = "<permission-tree> name has less than three segments: " |
| 1374 | + perm.info.name; |
| 1375 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1376 | return null; |
| 1377 | } |
| 1378 | |
| 1379 | perm.info.descriptionRes = 0; |
| 1380 | perm.info.protectionLevel = PermissionInfo.PROTECTION_NORMAL; |
| 1381 | perm.tree = true; |
| 1382 | |
| 1383 | if (!parseAllMetaData(res, parser, attrs, "<permission-tree>", perm, |
| 1384 | outError)) { |
| 1385 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1386 | return null; |
| 1387 | } |
| 1388 | |
| 1389 | owner.permissions.add(perm); |
| 1390 | |
| 1391 | return perm; |
| 1392 | } |
| 1393 | |
| 1394 | private Instrumentation parseInstrumentation(Package owner, Resources res, |
| 1395 | XmlPullParser parser, AttributeSet attrs, String[] outError) |
| 1396 | throws XmlPullParserException, IOException { |
| 1397 | TypedArray sa = res.obtainAttributes(attrs, |
| 1398 | com.android.internal.R.styleable.AndroidManifestInstrumentation); |
| 1399 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1400 | if (mParseInstrumentationArgs == null) { |
| 1401 | mParseInstrumentationArgs = new ParsePackageItemArgs(owner, outError, |
| 1402 | com.android.internal.R.styleable.AndroidManifestInstrumentation_name, |
| 1403 | com.android.internal.R.styleable.AndroidManifestInstrumentation_label, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1404 | com.android.internal.R.styleable.AndroidManifestInstrumentation_icon, |
| 1405 | com.android.internal.R.styleable.AndroidManifestInstrumentation_logo); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1406 | mParseInstrumentationArgs.tag = "<instrumentation>"; |
| 1407 | } |
| 1408 | |
| 1409 | mParseInstrumentationArgs.sa = sa; |
| 1410 | |
| 1411 | Instrumentation a = new Instrumentation(mParseInstrumentationArgs, |
| 1412 | new InstrumentationInfo()); |
| 1413 | if (outError[0] != null) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1414 | sa.recycle(); |
| 1415 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1416 | return null; |
| 1417 | } |
| 1418 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1419 | String str; |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1420 | // Note: don't allow this value to be a reference to a resource |
| 1421 | // that may change. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1422 | str = sa.getNonResourceString( |
| 1423 | com.android.internal.R.styleable.AndroidManifestInstrumentation_targetPackage); |
| 1424 | a.info.targetPackage = str != null ? str.intern() : null; |
| 1425 | |
| 1426 | a.info.handleProfiling = sa.getBoolean( |
| 1427 | com.android.internal.R.styleable.AndroidManifestInstrumentation_handleProfiling, |
| 1428 | false); |
| 1429 | |
| 1430 | a.info.functionalTest = sa.getBoolean( |
| 1431 | com.android.internal.R.styleable.AndroidManifestInstrumentation_functionalTest, |
| 1432 | false); |
| 1433 | |
| 1434 | sa.recycle(); |
| 1435 | |
| 1436 | if (a.info.targetPackage == null) { |
| 1437 | outError[0] = "<instrumentation> does not specify targetPackage"; |
| 1438 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1439 | return null; |
| 1440 | } |
| 1441 | |
| 1442 | if (!parseAllMetaData(res, parser, attrs, "<instrumentation>", a, |
| 1443 | outError)) { |
| 1444 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1445 | return null; |
| 1446 | } |
| 1447 | |
| 1448 | owner.instrumentation.add(a); |
| 1449 | |
| 1450 | return a; |
| 1451 | } |
| 1452 | |
| 1453 | private boolean parseApplication(Package owner, Resources res, |
| 1454 | XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) |
| 1455 | throws XmlPullParserException, IOException { |
| 1456 | final ApplicationInfo ai = owner.applicationInfo; |
| 1457 | final String pkgName = owner.applicationInfo.packageName; |
| 1458 | |
| 1459 | TypedArray sa = res.obtainAttributes(attrs, |
| 1460 | com.android.internal.R.styleable.AndroidManifestApplication); |
| 1461 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1462 | String name = sa.getNonConfigurationString( |
| 1463 | com.android.internal.R.styleable.AndroidManifestApplication_name, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1464 | if (name != null) { |
| 1465 | ai.className = buildClassName(pkgName, name, outError); |
| 1466 | if (ai.className == null) { |
| 1467 | sa.recycle(); |
| 1468 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1469 | return false; |
| 1470 | } |
| 1471 | } |
| 1472 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1473 | String manageSpaceActivity = sa.getNonConfigurationString( |
| 1474 | com.android.internal.R.styleable.AndroidManifestApplication_manageSpaceActivity, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1475 | if (manageSpaceActivity != null) { |
| 1476 | ai.manageSpaceActivityName = buildClassName(pkgName, manageSpaceActivity, |
| 1477 | outError); |
| 1478 | } |
| 1479 | |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 1480 | boolean allowBackup = sa.getBoolean( |
| 1481 | com.android.internal.R.styleable.AndroidManifestApplication_allowBackup, true); |
| 1482 | if (allowBackup) { |
| 1483 | ai.flags |= ApplicationInfo.FLAG_ALLOW_BACKUP; |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 1484 | |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 1485 | // backupAgent, killAfterRestore, and restoreAnyVersion are only relevant |
| 1486 | // if backup is possible for the given application. |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1487 | String backupAgent = sa.getNonConfigurationString( |
| 1488 | com.android.internal.R.styleable.AndroidManifestApplication_backupAgent, 0); |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 1489 | if (backupAgent != null) { |
| 1490 | ai.backupAgentName = buildClassName(pkgName, backupAgent, outError); |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 1491 | if (false) { |
| 1492 | Log.v(TAG, "android:backupAgent = " + ai.backupAgentName |
| 1493 | + " from " + pkgName + "+" + backupAgent); |
| 1494 | } |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 1495 | |
| 1496 | if (sa.getBoolean( |
| 1497 | com.android.internal.R.styleable.AndroidManifestApplication_killAfterRestore, |
| 1498 | true)) { |
| 1499 | ai.flags |= ApplicationInfo.FLAG_KILL_AFTER_RESTORE; |
| 1500 | } |
| 1501 | if (sa.getBoolean( |
Christopher Tate | 3dda518 | 2010-02-24 16:06:18 -0800 | [diff] [blame] | 1502 | com.android.internal.R.styleable.AndroidManifestApplication_restoreAnyVersion, |
| 1503 | false)) { |
| 1504 | ai.flags |= ApplicationInfo.FLAG_RESTORE_ANY_VERSION; |
| 1505 | } |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 1506 | } |
| 1507 | } |
| 1508 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1509 | TypedValue v = sa.peekValue( |
| 1510 | com.android.internal.R.styleable.AndroidManifestApplication_label); |
| 1511 | if (v != null && (ai.labelRes=v.resourceId) == 0) { |
| 1512 | ai.nonLocalizedLabel = v.coerceToString(); |
| 1513 | } |
| 1514 | |
| 1515 | ai.icon = sa.getResourceId( |
| 1516 | com.android.internal.R.styleable.AndroidManifestApplication_icon, 0); |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1517 | ai.logo = sa.getResourceId( |
| 1518 | com.android.internal.R.styleable.AndroidManifestApplication_logo, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1519 | ai.theme = sa.getResourceId( |
Dianne Hackborn | b35cd54 | 2011-01-04 21:30:53 -0800 | [diff] [blame] | 1520 | com.android.internal.R.styleable.AndroidManifestApplication_theme, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1521 | ai.descriptionRes = sa.getResourceId( |
| 1522 | com.android.internal.R.styleable.AndroidManifestApplication_description, 0); |
| 1523 | |
| 1524 | if ((flags&PARSE_IS_SYSTEM) != 0) { |
| 1525 | if (sa.getBoolean( |
| 1526 | com.android.internal.R.styleable.AndroidManifestApplication_persistent, |
| 1527 | false)) { |
| 1528 | ai.flags |= ApplicationInfo.FLAG_PERSISTENT; |
| 1529 | } |
| 1530 | } |
| 1531 | |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 1532 | if ((flags & PARSE_FORWARD_LOCK) != 0) { |
| 1533 | ai.flags |= ApplicationInfo.FLAG_FORWARD_LOCK; |
| 1534 | } |
| 1535 | |
| 1536 | if ((flags & PARSE_ON_SDCARD) != 0) { |
Suchi Amalapurapu | 6069beb | 2010-03-10 09:46:49 -0800 | [diff] [blame] | 1537 | ai.flags |= ApplicationInfo.FLAG_EXTERNAL_STORAGE; |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 1538 | } |
| 1539 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1540 | if (sa.getBoolean( |
| 1541 | com.android.internal.R.styleable.AndroidManifestApplication_debuggable, |
| 1542 | false)) { |
| 1543 | ai.flags |= ApplicationInfo.FLAG_DEBUGGABLE; |
| 1544 | } |
| 1545 | |
| 1546 | if (sa.getBoolean( |
Ben Cheng | ef3f5dd | 2010-03-29 15:47:26 -0700 | [diff] [blame] | 1547 | com.android.internal.R.styleable.AndroidManifestApplication_vmSafeMode, |
Ben Cheng | 23085b7 | 2010-02-08 16:06:32 -0800 | [diff] [blame] | 1548 | false)) { |
| 1549 | ai.flags |= ApplicationInfo.FLAG_VM_SAFE_MODE; |
| 1550 | } |
| 1551 | |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1552 | boolean hardwareAccelerated = sa.getBoolean( |
Romain Guy | 812ccbe | 2010-06-01 14:07:24 -0700 | [diff] [blame] | 1553 | com.android.internal.R.styleable.AndroidManifestApplication_hardwareAccelerated, |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1554 | false); |
Romain Guy | 812ccbe | 2010-06-01 14:07:24 -0700 | [diff] [blame] | 1555 | |
| 1556 | if (sa.getBoolean( |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1557 | com.android.internal.R.styleable.AndroidManifestApplication_hasCode, |
| 1558 | true)) { |
| 1559 | ai.flags |= ApplicationInfo.FLAG_HAS_CODE; |
| 1560 | } |
| 1561 | |
| 1562 | if (sa.getBoolean( |
| 1563 | com.android.internal.R.styleable.AndroidManifestApplication_allowTaskReparenting, |
| 1564 | false)) { |
| 1565 | ai.flags |= ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING; |
| 1566 | } |
| 1567 | |
| 1568 | if (sa.getBoolean( |
| 1569 | com.android.internal.R.styleable.AndroidManifestApplication_allowClearUserData, |
| 1570 | true)) { |
| 1571 | ai.flags |= ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA; |
| 1572 | } |
| 1573 | |
Dianne Hackborn | ade3eca | 2009-05-11 18:54:45 -0700 | [diff] [blame] | 1574 | if (sa.getBoolean( |
| 1575 | com.android.internal.R.styleable.AndroidManifestApplication_testOnly, |
Dianne Hackborn | e7fe35b | 2009-05-13 10:53:41 -0700 | [diff] [blame] | 1576 | false)) { |
Dianne Hackborn | ade3eca | 2009-05-11 18:54:45 -0700 | [diff] [blame] | 1577 | ai.flags |= ApplicationInfo.FLAG_TEST_ONLY; |
| 1578 | } |
| 1579 | |
Jason parks | a3cdaa5 | 2011-01-13 14:15:43 -0600 | [diff] [blame] | 1580 | if (sa.getBoolean( |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 1581 | com.android.internal.R.styleable.AndroidManifestApplication_largeHeap, |
Jason parks | a3cdaa5 | 2011-01-13 14:15:43 -0600 | [diff] [blame] | 1582 | false)) { |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 1583 | ai.flags |= ApplicationInfo.FLAG_LARGE_HEAP; |
Jason parks | a3cdaa5 | 2011-01-13 14:15:43 -0600 | [diff] [blame] | 1584 | } |
| 1585 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1586 | String str; |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1587 | str = sa.getNonConfigurationString( |
| 1588 | com.android.internal.R.styleable.AndroidManifestApplication_permission, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1589 | ai.permission = (str != null && str.length() > 0) ? str.intern() : null; |
| 1590 | |
Dianne Hackborn | d1cff1b | 2010-04-02 16:51:26 -0700 | [diff] [blame] | 1591 | if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { |
| 1592 | str = sa.getNonConfigurationString( |
| 1593 | com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity, 0); |
| 1594 | } else { |
| 1595 | // Some older apps have been seen to use a resource reference |
| 1596 | // here that on older builds was ignored (with a warning). We |
| 1597 | // need to continue to do this for them so they don't break. |
| 1598 | str = sa.getNonResourceString( |
| 1599 | com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity); |
| 1600 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1601 | ai.taskAffinity = buildTaskAffinityName(ai.packageName, ai.packageName, |
| 1602 | str, outError); |
| 1603 | |
| 1604 | if (outError[0] == null) { |
Dianne Hackborn | d1cff1b | 2010-04-02 16:51:26 -0700 | [diff] [blame] | 1605 | CharSequence pname; |
| 1606 | if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { |
| 1607 | pname = sa.getNonConfigurationString( |
| 1608 | com.android.internal.R.styleable.AndroidManifestApplication_process, 0); |
| 1609 | } else { |
| 1610 | // Some older apps have been seen to use a resource reference |
| 1611 | // here that on older builds was ignored (with a warning). We |
| 1612 | // need to continue to do this for them so they don't break. |
| 1613 | pname = sa.getNonResourceString( |
| 1614 | com.android.internal.R.styleable.AndroidManifestApplication_process); |
| 1615 | } |
| 1616 | ai.processName = buildProcessName(ai.packageName, null, pname, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1617 | flags, mSeparateProcesses, outError); |
| 1618 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1619 | ai.enabled = sa.getBoolean( |
| 1620 | com.android.internal.R.styleable.AndroidManifestApplication_enabled, true); |
Dianne Hackborn | 860755f | 2010-06-03 18:47:52 -0700 | [diff] [blame] | 1621 | |
Dianne Hackborn | 02486b1 | 2010-08-26 14:18:37 -0700 | [diff] [blame] | 1622 | if (false) { |
| 1623 | if (sa.getBoolean( |
| 1624 | com.android.internal.R.styleable.AndroidManifestApplication_cantSaveState, |
| 1625 | false)) { |
Dianne Hackborn | 54e570f | 2010-10-04 18:32:32 -0700 | [diff] [blame] | 1626 | ai.flags |= ApplicationInfo.FLAG_CANT_SAVE_STATE; |
Dianne Hackborn | 02486b1 | 2010-08-26 14:18:37 -0700 | [diff] [blame] | 1627 | |
| 1628 | // A heavy-weight application can not be in a custom process. |
| 1629 | // We can do direct compare because we intern all strings. |
| 1630 | if (ai.processName != null && ai.processName != ai.packageName) { |
| 1631 | outError[0] = "cantSaveState applications can not use custom processes"; |
| 1632 | } |
Dianne Hackborn | 860755f | 2010-06-03 18:47:52 -0700 | [diff] [blame] | 1633 | } |
| 1634 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1635 | } |
| 1636 | |
| 1637 | sa.recycle(); |
| 1638 | |
| 1639 | if (outError[0] != null) { |
| 1640 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1641 | return false; |
| 1642 | } |
| 1643 | |
| 1644 | final int innerDepth = parser.getDepth(); |
| 1645 | |
| 1646 | int type; |
| 1647 | while ((type=parser.next()) != parser.END_DOCUMENT |
| 1648 | && (type != parser.END_TAG || parser.getDepth() > innerDepth)) { |
| 1649 | if (type == parser.END_TAG || type == parser.TEXT) { |
| 1650 | continue; |
| 1651 | } |
| 1652 | |
| 1653 | String tagName = parser.getName(); |
| 1654 | if (tagName.equals("activity")) { |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1655 | Activity a = parseActivity(owner, res, parser, attrs, flags, outError, false, |
| 1656 | hardwareAccelerated); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1657 | if (a == null) { |
| 1658 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1659 | return false; |
| 1660 | } |
| 1661 | |
| 1662 | owner.activities.add(a); |
| 1663 | |
| 1664 | } else if (tagName.equals("receiver")) { |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1665 | Activity a = parseActivity(owner, res, parser, attrs, flags, outError, true, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1666 | if (a == null) { |
| 1667 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1668 | return false; |
| 1669 | } |
| 1670 | |
| 1671 | owner.receivers.add(a); |
| 1672 | |
| 1673 | } else if (tagName.equals("service")) { |
| 1674 | Service s = parseService(owner, res, parser, attrs, flags, outError); |
| 1675 | if (s == null) { |
| 1676 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1677 | return false; |
| 1678 | } |
| 1679 | |
| 1680 | owner.services.add(s); |
| 1681 | |
| 1682 | } else if (tagName.equals("provider")) { |
| 1683 | Provider p = parseProvider(owner, res, parser, attrs, flags, outError); |
| 1684 | if (p == null) { |
| 1685 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1686 | return false; |
| 1687 | } |
| 1688 | |
| 1689 | owner.providers.add(p); |
| 1690 | |
| 1691 | } else if (tagName.equals("activity-alias")) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1692 | Activity a = parseActivityAlias(owner, res, parser, attrs, flags, outError); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1693 | if (a == null) { |
| 1694 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1695 | return false; |
| 1696 | } |
| 1697 | |
| 1698 | owner.activities.add(a); |
| 1699 | |
| 1700 | } else if (parser.getName().equals("meta-data")) { |
| 1701 | // note: application meta-data is stored off to the side, so it can |
| 1702 | // remain null in the primary copy (we like to avoid extra copies because |
| 1703 | // it can be large) |
| 1704 | if ((owner.mAppMetaData = parseMetaData(res, parser, attrs, owner.mAppMetaData, |
| 1705 | outError)) == null) { |
| 1706 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1707 | return false; |
| 1708 | } |
| 1709 | |
| 1710 | } else if (tagName.equals("uses-library")) { |
| 1711 | sa = res.obtainAttributes(attrs, |
| 1712 | com.android.internal.R.styleable.AndroidManifestUsesLibrary); |
| 1713 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1714 | // Note: don't allow this value to be a reference to a resource |
| 1715 | // that may change. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1716 | String lname = sa.getNonResourceString( |
| 1717 | com.android.internal.R.styleable.AndroidManifestUsesLibrary_name); |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 1718 | boolean req = sa.getBoolean( |
| 1719 | com.android.internal.R.styleable.AndroidManifestUsesLibrary_required, |
| 1720 | true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1721 | |
| 1722 | sa.recycle(); |
| 1723 | |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 1724 | if (lname != null) { |
| 1725 | if (req) { |
| 1726 | if (owner.usesLibraries == null) { |
| 1727 | owner.usesLibraries = new ArrayList<String>(); |
| 1728 | } |
| 1729 | if (!owner.usesLibraries.contains(lname)) { |
| 1730 | owner.usesLibraries.add(lname.intern()); |
| 1731 | } |
| 1732 | } else { |
| 1733 | if (owner.usesOptionalLibraries == null) { |
| 1734 | owner.usesOptionalLibraries = new ArrayList<String>(); |
| 1735 | } |
| 1736 | if (!owner.usesOptionalLibraries.contains(lname)) { |
| 1737 | owner.usesOptionalLibraries.add(lname.intern()); |
| 1738 | } |
| 1739 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1740 | } |
| 1741 | |
| 1742 | XmlUtils.skipCurrentTag(parser); |
| 1743 | |
Dianne Hackborn | cef65ee | 2010-09-30 18:27:22 -0700 | [diff] [blame] | 1744 | } else if (tagName.equals("uses-package")) { |
| 1745 | // Dependencies for app installers; we don't currently try to |
| 1746 | // enforce this. |
| 1747 | XmlUtils.skipCurrentTag(parser); |
| 1748 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1749 | } else { |
| 1750 | if (!RIGID_PARSER) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 1751 | Log.w(TAG, "Unknown element under <application>: " + tagName |
| 1752 | + " at " + mArchiveSourcePath + " " |
| 1753 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1754 | XmlUtils.skipCurrentTag(parser); |
| 1755 | continue; |
| 1756 | } else { |
| 1757 | outError[0] = "Bad element under <application>: " + tagName; |
| 1758 | mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; |
| 1759 | return false; |
| 1760 | } |
| 1761 | } |
| 1762 | } |
| 1763 | |
| 1764 | return true; |
| 1765 | } |
| 1766 | |
| 1767 | private boolean parsePackageItemInfo(Package owner, PackageItemInfo outInfo, |
| 1768 | String[] outError, String tag, TypedArray sa, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1769 | int nameRes, int labelRes, int iconRes, int logoRes) { |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1770 | String name = sa.getNonConfigurationString(nameRes, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1771 | if (name == null) { |
| 1772 | outError[0] = tag + " does not specify android:name"; |
| 1773 | return false; |
| 1774 | } |
| 1775 | |
| 1776 | outInfo.name |
| 1777 | = buildClassName(owner.applicationInfo.packageName, name, outError); |
| 1778 | if (outInfo.name == null) { |
| 1779 | return false; |
| 1780 | } |
| 1781 | |
| 1782 | int iconVal = sa.getResourceId(iconRes, 0); |
| 1783 | if (iconVal != 0) { |
| 1784 | outInfo.icon = iconVal; |
| 1785 | outInfo.nonLocalizedLabel = null; |
| 1786 | } |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1787 | |
| 1788 | int logoVal = sa.getResourceId(logoRes, 0); |
| 1789 | if (logoVal != 0) { |
| 1790 | outInfo.logo = logoVal; |
| 1791 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1792 | |
| 1793 | TypedValue v = sa.peekValue(labelRes); |
| 1794 | if (v != null && (outInfo.labelRes=v.resourceId) == 0) { |
| 1795 | outInfo.nonLocalizedLabel = v.coerceToString(); |
| 1796 | } |
| 1797 | |
| 1798 | outInfo.packageName = owner.packageName; |
| 1799 | |
| 1800 | return true; |
| 1801 | } |
| 1802 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1803 | private Activity parseActivity(Package owner, Resources res, |
| 1804 | XmlPullParser parser, AttributeSet attrs, int flags, String[] outError, |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1805 | boolean receiver, boolean hardwareAccelerated) |
| 1806 | throws XmlPullParserException, IOException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1807 | TypedArray sa = res.obtainAttributes(attrs, |
| 1808 | com.android.internal.R.styleable.AndroidManifestActivity); |
| 1809 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1810 | if (mParseActivityArgs == null) { |
| 1811 | mParseActivityArgs = new ParseComponentArgs(owner, outError, |
| 1812 | com.android.internal.R.styleable.AndroidManifestActivity_name, |
| 1813 | com.android.internal.R.styleable.AndroidManifestActivity_label, |
| 1814 | com.android.internal.R.styleable.AndroidManifestActivity_icon, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 1815 | com.android.internal.R.styleable.AndroidManifestActivity_logo, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1816 | mSeparateProcesses, |
| 1817 | com.android.internal.R.styleable.AndroidManifestActivity_process, |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 1818 | com.android.internal.R.styleable.AndroidManifestActivity_description, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1819 | com.android.internal.R.styleable.AndroidManifestActivity_enabled); |
| 1820 | } |
| 1821 | |
| 1822 | mParseActivityArgs.tag = receiver ? "<receiver>" : "<activity>"; |
| 1823 | mParseActivityArgs.sa = sa; |
| 1824 | mParseActivityArgs.flags = flags; |
| 1825 | |
| 1826 | Activity a = new Activity(mParseActivityArgs, new ActivityInfo()); |
| 1827 | if (outError[0] != null) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1828 | sa.recycle(); |
| 1829 | return null; |
| 1830 | } |
| 1831 | |
| 1832 | final boolean setExported = sa.hasValue( |
| 1833 | com.android.internal.R.styleable.AndroidManifestActivity_exported); |
| 1834 | if (setExported) { |
| 1835 | a.info.exported = sa.getBoolean( |
| 1836 | com.android.internal.R.styleable.AndroidManifestActivity_exported, false); |
| 1837 | } |
| 1838 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1839 | a.info.theme = sa.getResourceId( |
| 1840 | com.android.internal.R.styleable.AndroidManifestActivity_theme, 0); |
| 1841 | |
| 1842 | String str; |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1843 | str = sa.getNonConfigurationString( |
| 1844 | com.android.internal.R.styleable.AndroidManifestActivity_permission, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1845 | if (str == null) { |
| 1846 | a.info.permission = owner.applicationInfo.permission; |
| 1847 | } else { |
| 1848 | a.info.permission = str.length() > 0 ? str.toString().intern() : null; |
| 1849 | } |
| 1850 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 1851 | str = sa.getNonConfigurationString( |
| 1852 | com.android.internal.R.styleable.AndroidManifestActivity_taskAffinity, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1853 | a.info.taskAffinity = buildTaskAffinityName(owner.applicationInfo.packageName, |
| 1854 | owner.applicationInfo.taskAffinity, str, outError); |
| 1855 | |
| 1856 | a.info.flags = 0; |
| 1857 | if (sa.getBoolean( |
| 1858 | com.android.internal.R.styleable.AndroidManifestActivity_multiprocess, |
| 1859 | false)) { |
| 1860 | a.info.flags |= ActivityInfo.FLAG_MULTIPROCESS; |
| 1861 | } |
| 1862 | |
| 1863 | if (sa.getBoolean( |
| 1864 | com.android.internal.R.styleable.AndroidManifestActivity_finishOnTaskLaunch, |
| 1865 | false)) { |
| 1866 | a.info.flags |= ActivityInfo.FLAG_FINISH_ON_TASK_LAUNCH; |
| 1867 | } |
| 1868 | |
| 1869 | if (sa.getBoolean( |
| 1870 | com.android.internal.R.styleable.AndroidManifestActivity_clearTaskOnLaunch, |
| 1871 | false)) { |
| 1872 | a.info.flags |= ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH; |
| 1873 | } |
| 1874 | |
| 1875 | if (sa.getBoolean( |
| 1876 | com.android.internal.R.styleable.AndroidManifestActivity_noHistory, |
| 1877 | false)) { |
| 1878 | a.info.flags |= ActivityInfo.FLAG_NO_HISTORY; |
| 1879 | } |
| 1880 | |
| 1881 | if (sa.getBoolean( |
| 1882 | com.android.internal.R.styleable.AndroidManifestActivity_alwaysRetainTaskState, |
| 1883 | false)) { |
| 1884 | a.info.flags |= ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE; |
| 1885 | } |
| 1886 | |
| 1887 | if (sa.getBoolean( |
| 1888 | com.android.internal.R.styleable.AndroidManifestActivity_stateNotNeeded, |
| 1889 | false)) { |
| 1890 | a.info.flags |= ActivityInfo.FLAG_STATE_NOT_NEEDED; |
| 1891 | } |
| 1892 | |
| 1893 | if (sa.getBoolean( |
| 1894 | com.android.internal.R.styleable.AndroidManifestActivity_excludeFromRecents, |
| 1895 | false)) { |
| 1896 | a.info.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS; |
| 1897 | } |
| 1898 | |
| 1899 | if (sa.getBoolean( |
| 1900 | com.android.internal.R.styleable.AndroidManifestActivity_allowTaskReparenting, |
| 1901 | (owner.applicationInfo.flags&ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING) != 0)) { |
| 1902 | a.info.flags |= ActivityInfo.FLAG_ALLOW_TASK_REPARENTING; |
| 1903 | } |
| 1904 | |
Dianne Hackborn | ffa4248 | 2009-09-23 22:20:11 -0700 | [diff] [blame] | 1905 | if (sa.getBoolean( |
| 1906 | com.android.internal.R.styleable.AndroidManifestActivity_finishOnCloseSystemDialogs, |
| 1907 | false)) { |
| 1908 | a.info.flags |= ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS; |
| 1909 | } |
| 1910 | |
Daniel Sandler | 613dde4 | 2010-06-21 13:46:39 -0400 | [diff] [blame] | 1911 | if (sa.getBoolean( |
| 1912 | com.android.internal.R.styleable.AndroidManifestActivity_immersive, |
| 1913 | false)) { |
| 1914 | a.info.flags |= ActivityInfo.FLAG_IMMERSIVE; |
| 1915 | } |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1916 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1917 | if (!receiver) { |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1918 | if (sa.getBoolean( |
| 1919 | com.android.internal.R.styleable.AndroidManifestActivity_hardwareAccelerated, |
| 1920 | hardwareAccelerated)) { |
| 1921 | a.info.flags |= ActivityInfo.FLAG_HARDWARE_ACCELERATED; |
| 1922 | } |
| 1923 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1924 | a.info.launchMode = sa.getInt( |
| 1925 | com.android.internal.R.styleable.AndroidManifestActivity_launchMode, |
| 1926 | ActivityInfo.LAUNCH_MULTIPLE); |
| 1927 | a.info.screenOrientation = sa.getInt( |
| 1928 | com.android.internal.R.styleable.AndroidManifestActivity_screenOrientation, |
| 1929 | ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); |
| 1930 | a.info.configChanges = sa.getInt( |
| 1931 | com.android.internal.R.styleable.AndroidManifestActivity_configChanges, |
| 1932 | 0); |
Dianne Hackborn | 3fc982f | 2011-03-30 16:20:26 -0700 | [diff] [blame] | 1933 | if (owner.applicationInfo.targetSdkVersion |
| 1934 | < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { |
| 1935 | a.info.configChanges |= ActivityInfo.CONFIG_SCREEN_SIZE; |
| 1936 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1937 | a.info.softInputMode = sa.getInt( |
| 1938 | com.android.internal.R.styleable.AndroidManifestActivity_windowSoftInputMode, |
| 1939 | 0); |
| 1940 | } else { |
| 1941 | a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE; |
| 1942 | a.info.configChanges = 0; |
| 1943 | } |
| 1944 | |
| 1945 | sa.recycle(); |
| 1946 | |
Dianne Hackborn | 54e570f | 2010-10-04 18:32:32 -0700 | [diff] [blame] | 1947 | if (receiver && (owner.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) { |
Dianne Hackborn | 860755f | 2010-06-03 18:47:52 -0700 | [diff] [blame] | 1948 | // A heavy-weight application can not have receives in its main process |
| 1949 | // We can do direct compare because we intern all strings. |
| 1950 | if (a.info.processName == owner.packageName) { |
| 1951 | outError[0] = "Heavy-weight applications can not have receivers in main process"; |
| 1952 | } |
| 1953 | } |
| 1954 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1955 | if (outError[0] != null) { |
| 1956 | return null; |
| 1957 | } |
| 1958 | |
| 1959 | int outerDepth = parser.getDepth(); |
| 1960 | int type; |
| 1961 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 1962 | && (type != XmlPullParser.END_TAG |
| 1963 | || parser.getDepth() > outerDepth)) { |
| 1964 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 1965 | continue; |
| 1966 | } |
| 1967 | |
| 1968 | if (parser.getName().equals("intent-filter")) { |
| 1969 | ActivityIntentInfo intent = new ActivityIntentInfo(a); |
| 1970 | if (!parseIntent(res, parser, attrs, flags, intent, outError, !receiver)) { |
| 1971 | return null; |
| 1972 | } |
| 1973 | if (intent.countActions() == 0) { |
Dianne Hackborn | bd0a81f | 2009-10-04 13:30:50 -0700 | [diff] [blame] | 1974 | Log.w(TAG, "No actions in intent filter at " |
| 1975 | + mArchiveSourcePath + " " |
| 1976 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1977 | } else { |
| 1978 | a.intents.add(intent); |
| 1979 | } |
| 1980 | } else if (parser.getName().equals("meta-data")) { |
| 1981 | if ((a.metaData=parseMetaData(res, parser, attrs, a.metaData, |
| 1982 | outError)) == null) { |
| 1983 | return null; |
| 1984 | } |
| 1985 | } else { |
| 1986 | if (!RIGID_PARSER) { |
| 1987 | Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); |
| 1988 | if (receiver) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 1989 | Log.w(TAG, "Unknown element under <receiver>: " + parser.getName() |
| 1990 | + " at " + mArchiveSourcePath + " " |
| 1991 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1992 | } else { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 1993 | Log.w(TAG, "Unknown element under <activity>: " + parser.getName() |
| 1994 | + " at " + mArchiveSourcePath + " " |
| 1995 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1996 | } |
| 1997 | XmlUtils.skipCurrentTag(parser); |
| 1998 | continue; |
| 1999 | } |
| 2000 | if (receiver) { |
| 2001 | outError[0] = "Bad element under <receiver>: " + parser.getName(); |
| 2002 | } else { |
| 2003 | outError[0] = "Bad element under <activity>: " + parser.getName(); |
| 2004 | } |
| 2005 | return null; |
| 2006 | } |
| 2007 | } |
| 2008 | |
| 2009 | if (!setExported) { |
| 2010 | a.info.exported = a.intents.size() > 0; |
| 2011 | } |
| 2012 | |
| 2013 | return a; |
| 2014 | } |
| 2015 | |
| 2016 | private Activity parseActivityAlias(Package owner, Resources res, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2017 | XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) |
| 2018 | throws XmlPullParserException, IOException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2019 | TypedArray sa = res.obtainAttributes(attrs, |
| 2020 | com.android.internal.R.styleable.AndroidManifestActivityAlias); |
| 2021 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2022 | String targetActivity = sa.getNonConfigurationString( |
| 2023 | com.android.internal.R.styleable.AndroidManifestActivityAlias_targetActivity, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2024 | if (targetActivity == null) { |
| 2025 | outError[0] = "<activity-alias> does not specify android:targetActivity"; |
| 2026 | sa.recycle(); |
| 2027 | return null; |
| 2028 | } |
| 2029 | |
| 2030 | targetActivity = buildClassName(owner.applicationInfo.packageName, |
| 2031 | targetActivity, outError); |
| 2032 | if (targetActivity == null) { |
| 2033 | sa.recycle(); |
| 2034 | return null; |
| 2035 | } |
| 2036 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2037 | if (mParseActivityAliasArgs == null) { |
| 2038 | mParseActivityAliasArgs = new ParseComponentArgs(owner, outError, |
| 2039 | com.android.internal.R.styleable.AndroidManifestActivityAlias_name, |
| 2040 | com.android.internal.R.styleable.AndroidManifestActivityAlias_label, |
| 2041 | com.android.internal.R.styleable.AndroidManifestActivityAlias_icon, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 2042 | com.android.internal.R.styleable.AndroidManifestActivityAlias_logo, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2043 | mSeparateProcesses, |
| 2044 | 0, |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 2045 | com.android.internal.R.styleable.AndroidManifestActivityAlias_description, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2046 | com.android.internal.R.styleable.AndroidManifestActivityAlias_enabled); |
| 2047 | mParseActivityAliasArgs.tag = "<activity-alias>"; |
| 2048 | } |
| 2049 | |
| 2050 | mParseActivityAliasArgs.sa = sa; |
| 2051 | mParseActivityAliasArgs.flags = flags; |
| 2052 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2053 | Activity target = null; |
| 2054 | |
| 2055 | final int NA = owner.activities.size(); |
| 2056 | for (int i=0; i<NA; i++) { |
| 2057 | Activity t = owner.activities.get(i); |
| 2058 | if (targetActivity.equals(t.info.name)) { |
| 2059 | target = t; |
| 2060 | break; |
| 2061 | } |
| 2062 | } |
| 2063 | |
| 2064 | if (target == null) { |
| 2065 | outError[0] = "<activity-alias> target activity " + targetActivity |
| 2066 | + " not found in manifest"; |
| 2067 | sa.recycle(); |
| 2068 | return null; |
| 2069 | } |
| 2070 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2071 | ActivityInfo info = new ActivityInfo(); |
| 2072 | info.targetActivity = targetActivity; |
| 2073 | info.configChanges = target.info.configChanges; |
| 2074 | info.flags = target.info.flags; |
| 2075 | info.icon = target.info.icon; |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 2076 | info.logo = target.info.logo; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2077 | info.labelRes = target.info.labelRes; |
| 2078 | info.nonLocalizedLabel = target.info.nonLocalizedLabel; |
| 2079 | info.launchMode = target.info.launchMode; |
| 2080 | info.processName = target.info.processName; |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 2081 | if (info.descriptionRes == 0) { |
| 2082 | info.descriptionRes = target.info.descriptionRes; |
| 2083 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2084 | info.screenOrientation = target.info.screenOrientation; |
| 2085 | info.taskAffinity = target.info.taskAffinity; |
| 2086 | info.theme = target.info.theme; |
| 2087 | |
| 2088 | Activity a = new Activity(mParseActivityAliasArgs, info); |
| 2089 | if (outError[0] != null) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2090 | sa.recycle(); |
| 2091 | return null; |
| 2092 | } |
| 2093 | |
| 2094 | final boolean setExported = sa.hasValue( |
| 2095 | com.android.internal.R.styleable.AndroidManifestActivityAlias_exported); |
| 2096 | if (setExported) { |
| 2097 | a.info.exported = sa.getBoolean( |
| 2098 | com.android.internal.R.styleable.AndroidManifestActivityAlias_exported, false); |
| 2099 | } |
| 2100 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2101 | String str; |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2102 | str = sa.getNonConfigurationString( |
| 2103 | com.android.internal.R.styleable.AndroidManifestActivityAlias_permission, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2104 | if (str != null) { |
| 2105 | a.info.permission = str.length() > 0 ? str.toString().intern() : null; |
| 2106 | } |
| 2107 | |
| 2108 | sa.recycle(); |
| 2109 | |
| 2110 | if (outError[0] != null) { |
| 2111 | return null; |
| 2112 | } |
| 2113 | |
| 2114 | int outerDepth = parser.getDepth(); |
| 2115 | int type; |
| 2116 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 2117 | && (type != XmlPullParser.END_TAG |
| 2118 | || parser.getDepth() > outerDepth)) { |
| 2119 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 2120 | continue; |
| 2121 | } |
| 2122 | |
| 2123 | if (parser.getName().equals("intent-filter")) { |
| 2124 | ActivityIntentInfo intent = new ActivityIntentInfo(a); |
| 2125 | if (!parseIntent(res, parser, attrs, flags, intent, outError, true)) { |
| 2126 | return null; |
| 2127 | } |
| 2128 | if (intent.countActions() == 0) { |
Dianne Hackborn | bd0a81f | 2009-10-04 13:30:50 -0700 | [diff] [blame] | 2129 | Log.w(TAG, "No actions in intent filter at " |
| 2130 | + mArchiveSourcePath + " " |
| 2131 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2132 | } else { |
| 2133 | a.intents.add(intent); |
| 2134 | } |
| 2135 | } else if (parser.getName().equals("meta-data")) { |
| 2136 | if ((a.metaData=parseMetaData(res, parser, attrs, a.metaData, |
| 2137 | outError)) == null) { |
| 2138 | return null; |
| 2139 | } |
| 2140 | } else { |
| 2141 | if (!RIGID_PARSER) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2142 | Log.w(TAG, "Unknown element under <activity-alias>: " + parser.getName() |
| 2143 | + " at " + mArchiveSourcePath + " " |
| 2144 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2145 | XmlUtils.skipCurrentTag(parser); |
| 2146 | continue; |
| 2147 | } |
| 2148 | outError[0] = "Bad element under <activity-alias>: " + parser.getName(); |
| 2149 | return null; |
| 2150 | } |
| 2151 | } |
| 2152 | |
| 2153 | if (!setExported) { |
| 2154 | a.info.exported = a.intents.size() > 0; |
| 2155 | } |
| 2156 | |
| 2157 | return a; |
| 2158 | } |
| 2159 | |
| 2160 | private Provider parseProvider(Package owner, Resources res, |
| 2161 | XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) |
| 2162 | throws XmlPullParserException, IOException { |
| 2163 | TypedArray sa = res.obtainAttributes(attrs, |
| 2164 | com.android.internal.R.styleable.AndroidManifestProvider); |
| 2165 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2166 | if (mParseProviderArgs == null) { |
| 2167 | mParseProviderArgs = new ParseComponentArgs(owner, outError, |
| 2168 | com.android.internal.R.styleable.AndroidManifestProvider_name, |
| 2169 | com.android.internal.R.styleable.AndroidManifestProvider_label, |
| 2170 | com.android.internal.R.styleable.AndroidManifestProvider_icon, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 2171 | com.android.internal.R.styleable.AndroidManifestProvider_logo, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2172 | mSeparateProcesses, |
| 2173 | com.android.internal.R.styleable.AndroidManifestProvider_process, |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 2174 | com.android.internal.R.styleable.AndroidManifestProvider_description, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2175 | com.android.internal.R.styleable.AndroidManifestProvider_enabled); |
| 2176 | mParseProviderArgs.tag = "<provider>"; |
| 2177 | } |
| 2178 | |
| 2179 | mParseProviderArgs.sa = sa; |
| 2180 | mParseProviderArgs.flags = flags; |
| 2181 | |
| 2182 | Provider p = new Provider(mParseProviderArgs, new ProviderInfo()); |
| 2183 | if (outError[0] != null) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2184 | sa.recycle(); |
| 2185 | return null; |
| 2186 | } |
| 2187 | |
| 2188 | p.info.exported = sa.getBoolean( |
| 2189 | com.android.internal.R.styleable.AndroidManifestProvider_exported, true); |
| 2190 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2191 | String cpname = sa.getNonConfigurationString( |
| 2192 | com.android.internal.R.styleable.AndroidManifestProvider_authorities, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2193 | |
| 2194 | p.info.isSyncable = sa.getBoolean( |
| 2195 | com.android.internal.R.styleable.AndroidManifestProvider_syncable, |
| 2196 | false); |
| 2197 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2198 | String permission = sa.getNonConfigurationString( |
| 2199 | com.android.internal.R.styleable.AndroidManifestProvider_permission, 0); |
| 2200 | String str = sa.getNonConfigurationString( |
| 2201 | com.android.internal.R.styleable.AndroidManifestProvider_readPermission, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2202 | if (str == null) { |
| 2203 | str = permission; |
| 2204 | } |
| 2205 | if (str == null) { |
| 2206 | p.info.readPermission = owner.applicationInfo.permission; |
| 2207 | } else { |
| 2208 | p.info.readPermission = |
| 2209 | str.length() > 0 ? str.toString().intern() : null; |
| 2210 | } |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2211 | str = sa.getNonConfigurationString( |
| 2212 | com.android.internal.R.styleable.AndroidManifestProvider_writePermission, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2213 | if (str == null) { |
| 2214 | str = permission; |
| 2215 | } |
| 2216 | if (str == null) { |
| 2217 | p.info.writePermission = owner.applicationInfo.permission; |
| 2218 | } else { |
| 2219 | p.info.writePermission = |
| 2220 | str.length() > 0 ? str.toString().intern() : null; |
| 2221 | } |
| 2222 | |
| 2223 | p.info.grantUriPermissions = sa.getBoolean( |
| 2224 | com.android.internal.R.styleable.AndroidManifestProvider_grantUriPermissions, |
| 2225 | false); |
| 2226 | |
| 2227 | p.info.multiprocess = sa.getBoolean( |
| 2228 | com.android.internal.R.styleable.AndroidManifestProvider_multiprocess, |
| 2229 | false); |
| 2230 | |
| 2231 | p.info.initOrder = sa.getInt( |
| 2232 | com.android.internal.R.styleable.AndroidManifestProvider_initOrder, |
| 2233 | 0); |
| 2234 | |
| 2235 | sa.recycle(); |
| 2236 | |
Dianne Hackborn | 54e570f | 2010-10-04 18:32:32 -0700 | [diff] [blame] | 2237 | if ((owner.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) { |
Dianne Hackborn | 860755f | 2010-06-03 18:47:52 -0700 | [diff] [blame] | 2238 | // A heavy-weight application can not have providers in its main process |
| 2239 | // We can do direct compare because we intern all strings. |
| 2240 | if (p.info.processName == owner.packageName) { |
| 2241 | outError[0] = "Heavy-weight applications can not have providers in main process"; |
| 2242 | return null; |
| 2243 | } |
| 2244 | } |
| 2245 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2246 | if (cpname == null) { |
| 2247 | outError[0] = "<provider> does not incude authorities attribute"; |
| 2248 | return null; |
| 2249 | } |
| 2250 | p.info.authority = cpname.intern(); |
| 2251 | |
| 2252 | if (!parseProviderTags(res, parser, attrs, p, outError)) { |
| 2253 | return null; |
| 2254 | } |
| 2255 | |
| 2256 | return p; |
| 2257 | } |
| 2258 | |
| 2259 | private boolean parseProviderTags(Resources res, |
| 2260 | XmlPullParser parser, AttributeSet attrs, |
| 2261 | Provider outInfo, String[] outError) |
| 2262 | throws XmlPullParserException, IOException { |
| 2263 | int outerDepth = parser.getDepth(); |
| 2264 | int type; |
| 2265 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 2266 | && (type != XmlPullParser.END_TAG |
| 2267 | || parser.getDepth() > outerDepth)) { |
| 2268 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 2269 | continue; |
| 2270 | } |
| 2271 | |
| 2272 | if (parser.getName().equals("meta-data")) { |
| 2273 | if ((outInfo.metaData=parseMetaData(res, parser, attrs, |
| 2274 | outInfo.metaData, outError)) == null) { |
| 2275 | return false; |
| 2276 | } |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2277 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2278 | } else if (parser.getName().equals("grant-uri-permission")) { |
| 2279 | TypedArray sa = res.obtainAttributes(attrs, |
| 2280 | com.android.internal.R.styleable.AndroidManifestGrantUriPermission); |
| 2281 | |
| 2282 | PatternMatcher pa = null; |
| 2283 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2284 | String str = sa.getNonConfigurationString( |
| 2285 | com.android.internal.R.styleable.AndroidManifestGrantUriPermission_path, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2286 | if (str != null) { |
| 2287 | pa = new PatternMatcher(str, PatternMatcher.PATTERN_LITERAL); |
| 2288 | } |
| 2289 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2290 | str = sa.getNonConfigurationString( |
| 2291 | com.android.internal.R.styleable.AndroidManifestGrantUriPermission_pathPrefix, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2292 | if (str != null) { |
| 2293 | pa = new PatternMatcher(str, PatternMatcher.PATTERN_PREFIX); |
| 2294 | } |
| 2295 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2296 | str = sa.getNonConfigurationString( |
| 2297 | com.android.internal.R.styleable.AndroidManifestGrantUriPermission_pathPattern, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2298 | if (str != null) { |
| 2299 | pa = new PatternMatcher(str, PatternMatcher.PATTERN_SIMPLE_GLOB); |
| 2300 | } |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2301 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2302 | sa.recycle(); |
| 2303 | |
| 2304 | if (pa != null) { |
| 2305 | if (outInfo.info.uriPermissionPatterns == null) { |
| 2306 | outInfo.info.uriPermissionPatterns = new PatternMatcher[1]; |
| 2307 | outInfo.info.uriPermissionPatterns[0] = pa; |
| 2308 | } else { |
| 2309 | final int N = outInfo.info.uriPermissionPatterns.length; |
| 2310 | PatternMatcher[] newp = new PatternMatcher[N+1]; |
| 2311 | System.arraycopy(outInfo.info.uriPermissionPatterns, 0, newp, 0, N); |
| 2312 | newp[N] = pa; |
| 2313 | outInfo.info.uriPermissionPatterns = newp; |
| 2314 | } |
| 2315 | outInfo.info.grantUriPermissions = true; |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2316 | } else { |
| 2317 | if (!RIGID_PARSER) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2318 | Log.w(TAG, "Unknown element under <path-permission>: " |
| 2319 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2320 | + parser.getPositionDescription()); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2321 | XmlUtils.skipCurrentTag(parser); |
| 2322 | continue; |
| 2323 | } |
| 2324 | outError[0] = "No path, pathPrefix, or pathPattern for <path-permission>"; |
| 2325 | return false; |
| 2326 | } |
| 2327 | XmlUtils.skipCurrentTag(parser); |
| 2328 | |
| 2329 | } else if (parser.getName().equals("path-permission")) { |
| 2330 | TypedArray sa = res.obtainAttributes(attrs, |
| 2331 | com.android.internal.R.styleable.AndroidManifestPathPermission); |
| 2332 | |
| 2333 | PathPermission pa = null; |
| 2334 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2335 | String permission = sa.getNonConfigurationString( |
| 2336 | com.android.internal.R.styleable.AndroidManifestPathPermission_permission, 0); |
| 2337 | String readPermission = sa.getNonConfigurationString( |
| 2338 | com.android.internal.R.styleable.AndroidManifestPathPermission_readPermission, 0); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2339 | if (readPermission == null) { |
| 2340 | readPermission = permission; |
| 2341 | } |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2342 | String writePermission = sa.getNonConfigurationString( |
| 2343 | com.android.internal.R.styleable.AndroidManifestPathPermission_writePermission, 0); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2344 | if (writePermission == null) { |
| 2345 | writePermission = permission; |
| 2346 | } |
| 2347 | |
| 2348 | boolean havePerm = false; |
| 2349 | if (readPermission != null) { |
| 2350 | readPermission = readPermission.intern(); |
| 2351 | havePerm = true; |
| 2352 | } |
| 2353 | if (writePermission != null) { |
Bjorn Bringert | e04b1ad | 2010-02-09 13:56:08 +0000 | [diff] [blame] | 2354 | writePermission = writePermission.intern(); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2355 | havePerm = true; |
| 2356 | } |
| 2357 | |
| 2358 | if (!havePerm) { |
| 2359 | if (!RIGID_PARSER) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2360 | Log.w(TAG, "No readPermission or writePermssion for <path-permission>: " |
| 2361 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2362 | + parser.getPositionDescription()); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2363 | XmlUtils.skipCurrentTag(parser); |
| 2364 | continue; |
| 2365 | } |
| 2366 | outError[0] = "No readPermission or writePermssion for <path-permission>"; |
| 2367 | return false; |
| 2368 | } |
| 2369 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2370 | String path = sa.getNonConfigurationString( |
| 2371 | com.android.internal.R.styleable.AndroidManifestPathPermission_path, 0); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2372 | if (path != null) { |
| 2373 | pa = new PathPermission(path, |
| 2374 | PatternMatcher.PATTERN_LITERAL, readPermission, writePermission); |
| 2375 | } |
| 2376 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2377 | path = sa.getNonConfigurationString( |
| 2378 | com.android.internal.R.styleable.AndroidManifestPathPermission_pathPrefix, 0); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2379 | if (path != null) { |
| 2380 | pa = new PathPermission(path, |
| 2381 | PatternMatcher.PATTERN_PREFIX, readPermission, writePermission); |
| 2382 | } |
| 2383 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2384 | path = sa.getNonConfigurationString( |
| 2385 | com.android.internal.R.styleable.AndroidManifestPathPermission_pathPattern, 0); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2386 | if (path != null) { |
| 2387 | pa = new PathPermission(path, |
| 2388 | PatternMatcher.PATTERN_SIMPLE_GLOB, readPermission, writePermission); |
| 2389 | } |
| 2390 | |
| 2391 | sa.recycle(); |
| 2392 | |
| 2393 | if (pa != null) { |
| 2394 | if (outInfo.info.pathPermissions == null) { |
| 2395 | outInfo.info.pathPermissions = new PathPermission[1]; |
| 2396 | outInfo.info.pathPermissions[0] = pa; |
| 2397 | } else { |
| 2398 | final int N = outInfo.info.pathPermissions.length; |
| 2399 | PathPermission[] newp = new PathPermission[N+1]; |
| 2400 | System.arraycopy(outInfo.info.pathPermissions, 0, newp, 0, N); |
| 2401 | newp[N] = pa; |
| 2402 | outInfo.info.pathPermissions = newp; |
| 2403 | } |
| 2404 | } else { |
| 2405 | if (!RIGID_PARSER) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2406 | Log.w(TAG, "No path, pathPrefix, or pathPattern for <path-permission>: " |
| 2407 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2408 | + parser.getPositionDescription()); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 2409 | XmlUtils.skipCurrentTag(parser); |
| 2410 | continue; |
| 2411 | } |
| 2412 | outError[0] = "No path, pathPrefix, or pathPattern for <path-permission>"; |
| 2413 | return false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2414 | } |
| 2415 | XmlUtils.skipCurrentTag(parser); |
| 2416 | |
| 2417 | } else { |
| 2418 | if (!RIGID_PARSER) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2419 | Log.w(TAG, "Unknown element under <provider>: " |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2420 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2421 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2422 | XmlUtils.skipCurrentTag(parser); |
| 2423 | continue; |
| 2424 | } |
| 2425 | outError[0] = "Bad element under <provider>: " |
| 2426 | + parser.getName(); |
| 2427 | return false; |
| 2428 | } |
| 2429 | } |
| 2430 | return true; |
| 2431 | } |
| 2432 | |
| 2433 | private Service parseService(Package owner, Resources res, |
| 2434 | XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) |
| 2435 | throws XmlPullParserException, IOException { |
| 2436 | TypedArray sa = res.obtainAttributes(attrs, |
| 2437 | com.android.internal.R.styleable.AndroidManifestService); |
| 2438 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2439 | if (mParseServiceArgs == null) { |
| 2440 | mParseServiceArgs = new ParseComponentArgs(owner, outError, |
| 2441 | com.android.internal.R.styleable.AndroidManifestService_name, |
| 2442 | com.android.internal.R.styleable.AndroidManifestService_label, |
| 2443 | com.android.internal.R.styleable.AndroidManifestService_icon, |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 2444 | com.android.internal.R.styleable.AndroidManifestService_logo, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2445 | mSeparateProcesses, |
| 2446 | com.android.internal.R.styleable.AndroidManifestService_process, |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 2447 | com.android.internal.R.styleable.AndroidManifestService_description, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2448 | com.android.internal.R.styleable.AndroidManifestService_enabled); |
| 2449 | mParseServiceArgs.tag = "<service>"; |
| 2450 | } |
| 2451 | |
| 2452 | mParseServiceArgs.sa = sa; |
| 2453 | mParseServiceArgs.flags = flags; |
| 2454 | |
| 2455 | Service s = new Service(mParseServiceArgs, new ServiceInfo()); |
| 2456 | if (outError[0] != null) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2457 | sa.recycle(); |
| 2458 | return null; |
| 2459 | } |
| 2460 | |
| 2461 | final boolean setExported = sa.hasValue( |
| 2462 | com.android.internal.R.styleable.AndroidManifestService_exported); |
| 2463 | if (setExported) { |
| 2464 | s.info.exported = sa.getBoolean( |
| 2465 | com.android.internal.R.styleable.AndroidManifestService_exported, false); |
| 2466 | } |
| 2467 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2468 | String str = sa.getNonConfigurationString( |
| 2469 | com.android.internal.R.styleable.AndroidManifestService_permission, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2470 | if (str == null) { |
| 2471 | s.info.permission = owner.applicationInfo.permission; |
| 2472 | } else { |
| 2473 | s.info.permission = str.length() > 0 ? str.toString().intern() : null; |
| 2474 | } |
| 2475 | |
Dianne Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame^] | 2476 | s.info.flags = 0; |
| 2477 | if (sa.getBoolean( |
| 2478 | com.android.internal.R.styleable.AndroidManifestService_stopWithTask, |
| 2479 | false)) { |
| 2480 | s.info.flags |= ServiceInfo.FLAG_STOP_WITH_TASK; |
| 2481 | } |
| 2482 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2483 | sa.recycle(); |
| 2484 | |
Dianne Hackborn | 54e570f | 2010-10-04 18:32:32 -0700 | [diff] [blame] | 2485 | if ((owner.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) { |
Dianne Hackborn | 860755f | 2010-06-03 18:47:52 -0700 | [diff] [blame] | 2486 | // A heavy-weight application can not have services in its main process |
| 2487 | // We can do direct compare because we intern all strings. |
| 2488 | if (s.info.processName == owner.packageName) { |
| 2489 | outError[0] = "Heavy-weight applications can not have services in main process"; |
| 2490 | return null; |
| 2491 | } |
| 2492 | } |
| 2493 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2494 | int outerDepth = parser.getDepth(); |
| 2495 | int type; |
| 2496 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 2497 | && (type != XmlPullParser.END_TAG |
| 2498 | || parser.getDepth() > outerDepth)) { |
| 2499 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 2500 | continue; |
| 2501 | } |
| 2502 | |
| 2503 | if (parser.getName().equals("intent-filter")) { |
| 2504 | ServiceIntentInfo intent = new ServiceIntentInfo(s); |
| 2505 | if (!parseIntent(res, parser, attrs, flags, intent, outError, false)) { |
| 2506 | return null; |
| 2507 | } |
| 2508 | |
| 2509 | s.intents.add(intent); |
| 2510 | } else if (parser.getName().equals("meta-data")) { |
| 2511 | if ((s.metaData=parseMetaData(res, parser, attrs, s.metaData, |
| 2512 | outError)) == null) { |
| 2513 | return null; |
| 2514 | } |
| 2515 | } else { |
| 2516 | if (!RIGID_PARSER) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2517 | Log.w(TAG, "Unknown element under <service>: " |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2518 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2519 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2520 | XmlUtils.skipCurrentTag(parser); |
| 2521 | continue; |
| 2522 | } |
| 2523 | outError[0] = "Bad element under <service>: " |
| 2524 | + parser.getName(); |
| 2525 | return null; |
| 2526 | } |
| 2527 | } |
| 2528 | |
| 2529 | if (!setExported) { |
| 2530 | s.info.exported = s.intents.size() > 0; |
| 2531 | } |
| 2532 | |
| 2533 | return s; |
| 2534 | } |
| 2535 | |
| 2536 | private boolean parseAllMetaData(Resources res, |
| 2537 | XmlPullParser parser, AttributeSet attrs, String tag, |
| 2538 | Component outInfo, String[] outError) |
| 2539 | throws XmlPullParserException, IOException { |
| 2540 | int outerDepth = parser.getDepth(); |
| 2541 | int type; |
| 2542 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 2543 | && (type != XmlPullParser.END_TAG |
| 2544 | || parser.getDepth() > outerDepth)) { |
| 2545 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 2546 | continue; |
| 2547 | } |
| 2548 | |
| 2549 | if (parser.getName().equals("meta-data")) { |
| 2550 | if ((outInfo.metaData=parseMetaData(res, parser, attrs, |
| 2551 | outInfo.metaData, outError)) == null) { |
| 2552 | return false; |
| 2553 | } |
| 2554 | } else { |
| 2555 | if (!RIGID_PARSER) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2556 | Log.w(TAG, "Unknown element under " + tag + ": " |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2557 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2558 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2559 | XmlUtils.skipCurrentTag(parser); |
| 2560 | continue; |
| 2561 | } |
| 2562 | outError[0] = "Bad element under " + tag + ": " |
| 2563 | + parser.getName(); |
| 2564 | return false; |
| 2565 | } |
| 2566 | } |
| 2567 | return true; |
| 2568 | } |
| 2569 | |
| 2570 | private Bundle parseMetaData(Resources res, |
| 2571 | XmlPullParser parser, AttributeSet attrs, |
| 2572 | Bundle data, String[] outError) |
| 2573 | throws XmlPullParserException, IOException { |
| 2574 | |
| 2575 | TypedArray sa = res.obtainAttributes(attrs, |
| 2576 | com.android.internal.R.styleable.AndroidManifestMetaData); |
| 2577 | |
| 2578 | if (data == null) { |
| 2579 | data = new Bundle(); |
| 2580 | } |
| 2581 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2582 | String name = sa.getNonConfigurationString( |
| 2583 | com.android.internal.R.styleable.AndroidManifestMetaData_name, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2584 | if (name == null) { |
| 2585 | outError[0] = "<meta-data> requires an android:name attribute"; |
| 2586 | sa.recycle(); |
| 2587 | return null; |
| 2588 | } |
| 2589 | |
Dianne Hackborn | 854060a | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2590 | name = name.intern(); |
| 2591 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2592 | TypedValue v = sa.peekValue( |
| 2593 | com.android.internal.R.styleable.AndroidManifestMetaData_resource); |
| 2594 | if (v != null && v.resourceId != 0) { |
| 2595 | //Log.i(TAG, "Meta data ref " + name + ": " + v); |
| 2596 | data.putInt(name, v.resourceId); |
| 2597 | } else { |
| 2598 | v = sa.peekValue( |
| 2599 | com.android.internal.R.styleable.AndroidManifestMetaData_value); |
| 2600 | //Log.i(TAG, "Meta data " + name + ": " + v); |
| 2601 | if (v != null) { |
| 2602 | if (v.type == TypedValue.TYPE_STRING) { |
| 2603 | CharSequence cs = v.coerceToString(); |
Dianne Hackborn | 854060a | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2604 | data.putString(name, cs != null ? cs.toString().intern() : null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2605 | } else if (v.type == TypedValue.TYPE_INT_BOOLEAN) { |
| 2606 | data.putBoolean(name, v.data != 0); |
| 2607 | } else if (v.type >= TypedValue.TYPE_FIRST_INT |
| 2608 | && v.type <= TypedValue.TYPE_LAST_INT) { |
| 2609 | data.putInt(name, v.data); |
| 2610 | } else if (v.type == TypedValue.TYPE_FLOAT) { |
| 2611 | data.putFloat(name, v.getFloat()); |
| 2612 | } else { |
| 2613 | if (!RIGID_PARSER) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2614 | Log.w(TAG, "<meta-data> only supports string, integer, float, color, boolean, and resource reference types: " |
| 2615 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2616 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2617 | } else { |
| 2618 | outError[0] = "<meta-data> only supports string, integer, float, color, boolean, and resource reference types"; |
| 2619 | data = null; |
| 2620 | } |
| 2621 | } |
| 2622 | } else { |
| 2623 | outError[0] = "<meta-data> requires an android:value or android:resource attribute"; |
| 2624 | data = null; |
| 2625 | } |
| 2626 | } |
| 2627 | |
| 2628 | sa.recycle(); |
| 2629 | |
| 2630 | XmlUtils.skipCurrentTag(parser); |
| 2631 | |
| 2632 | return data; |
| 2633 | } |
| 2634 | |
| 2635 | private static final String ANDROID_RESOURCES |
| 2636 | = "http://schemas.android.com/apk/res/android"; |
| 2637 | |
| 2638 | private boolean parseIntent(Resources res, |
| 2639 | XmlPullParser parser, AttributeSet attrs, int flags, |
| 2640 | IntentInfo outInfo, String[] outError, boolean isActivity) |
| 2641 | throws XmlPullParserException, IOException { |
| 2642 | |
| 2643 | TypedArray sa = res.obtainAttributes(attrs, |
| 2644 | com.android.internal.R.styleable.AndroidManifestIntentFilter); |
| 2645 | |
| 2646 | int priority = sa.getInt( |
| 2647 | com.android.internal.R.styleable.AndroidManifestIntentFilter_priority, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2648 | outInfo.setPriority(priority); |
Kenny Root | 502e9a4 | 2011-01-10 13:48:15 -0800 | [diff] [blame] | 2649 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2650 | TypedValue v = sa.peekValue( |
| 2651 | com.android.internal.R.styleable.AndroidManifestIntentFilter_label); |
| 2652 | if (v != null && (outInfo.labelRes=v.resourceId) == 0) { |
| 2653 | outInfo.nonLocalizedLabel = v.coerceToString(); |
| 2654 | } |
| 2655 | |
| 2656 | outInfo.icon = sa.getResourceId( |
| 2657 | com.android.internal.R.styleable.AndroidManifestIntentFilter_icon, 0); |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 2658 | |
| 2659 | outInfo.logo = sa.getResourceId( |
| 2660 | com.android.internal.R.styleable.AndroidManifestIntentFilter_logo, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2661 | |
| 2662 | sa.recycle(); |
| 2663 | |
| 2664 | int outerDepth = parser.getDepth(); |
| 2665 | int type; |
| 2666 | while ((type=parser.next()) != parser.END_DOCUMENT |
| 2667 | && (type != parser.END_TAG || parser.getDepth() > outerDepth)) { |
| 2668 | if (type == parser.END_TAG || type == parser.TEXT) { |
| 2669 | continue; |
| 2670 | } |
| 2671 | |
| 2672 | String nodeName = parser.getName(); |
| 2673 | if (nodeName.equals("action")) { |
| 2674 | String value = attrs.getAttributeValue( |
| 2675 | ANDROID_RESOURCES, "name"); |
| 2676 | if (value == null || value == "") { |
| 2677 | outError[0] = "No value supplied for <android:name>"; |
| 2678 | return false; |
| 2679 | } |
| 2680 | XmlUtils.skipCurrentTag(parser); |
| 2681 | |
| 2682 | outInfo.addAction(value); |
| 2683 | } else if (nodeName.equals("category")) { |
| 2684 | String value = attrs.getAttributeValue( |
| 2685 | ANDROID_RESOURCES, "name"); |
| 2686 | if (value == null || value == "") { |
| 2687 | outError[0] = "No value supplied for <android:name>"; |
| 2688 | return false; |
| 2689 | } |
| 2690 | XmlUtils.skipCurrentTag(parser); |
| 2691 | |
| 2692 | outInfo.addCategory(value); |
| 2693 | |
| 2694 | } else if (nodeName.equals("data")) { |
| 2695 | sa = res.obtainAttributes(attrs, |
| 2696 | com.android.internal.R.styleable.AndroidManifestData); |
| 2697 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2698 | String str = sa.getNonConfigurationString( |
| 2699 | com.android.internal.R.styleable.AndroidManifestData_mimeType, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2700 | if (str != null) { |
| 2701 | try { |
| 2702 | outInfo.addDataType(str); |
| 2703 | } catch (IntentFilter.MalformedMimeTypeException e) { |
| 2704 | outError[0] = e.toString(); |
| 2705 | sa.recycle(); |
| 2706 | return false; |
| 2707 | } |
| 2708 | } |
| 2709 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2710 | str = sa.getNonConfigurationString( |
| 2711 | com.android.internal.R.styleable.AndroidManifestData_scheme, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2712 | if (str != null) { |
| 2713 | outInfo.addDataScheme(str); |
| 2714 | } |
| 2715 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2716 | String host = sa.getNonConfigurationString( |
| 2717 | com.android.internal.R.styleable.AndroidManifestData_host, 0); |
| 2718 | String port = sa.getNonConfigurationString( |
| 2719 | com.android.internal.R.styleable.AndroidManifestData_port, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2720 | if (host != null) { |
| 2721 | outInfo.addDataAuthority(host, port); |
| 2722 | } |
| 2723 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2724 | str = sa.getNonConfigurationString( |
| 2725 | com.android.internal.R.styleable.AndroidManifestData_path, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2726 | if (str != null) { |
| 2727 | outInfo.addDataPath(str, PatternMatcher.PATTERN_LITERAL); |
| 2728 | } |
| 2729 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2730 | str = sa.getNonConfigurationString( |
| 2731 | com.android.internal.R.styleable.AndroidManifestData_pathPrefix, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2732 | if (str != null) { |
| 2733 | outInfo.addDataPath(str, PatternMatcher.PATTERN_PREFIX); |
| 2734 | } |
| 2735 | |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2736 | str = sa.getNonConfigurationString( |
| 2737 | com.android.internal.R.styleable.AndroidManifestData_pathPattern, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2738 | if (str != null) { |
| 2739 | outInfo.addDataPath(str, PatternMatcher.PATTERN_SIMPLE_GLOB); |
| 2740 | } |
| 2741 | |
| 2742 | sa.recycle(); |
| 2743 | XmlUtils.skipCurrentTag(parser); |
| 2744 | } else if (!RIGID_PARSER) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 2745 | Log.w(TAG, "Unknown element under <intent-filter>: " |
| 2746 | + parser.getName() + " at " + mArchiveSourcePath + " " |
| 2747 | + parser.getPositionDescription()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2748 | XmlUtils.skipCurrentTag(parser); |
| 2749 | } else { |
| 2750 | outError[0] = "Bad element under <intent-filter>: " + parser.getName(); |
| 2751 | return false; |
| 2752 | } |
| 2753 | } |
| 2754 | |
| 2755 | outInfo.hasDefault = outInfo.hasCategory(Intent.CATEGORY_DEFAULT); |
| 2756 | if (false) { |
| 2757 | String cats = ""; |
| 2758 | Iterator<String> it = outInfo.categoriesIterator(); |
| 2759 | while (it != null && it.hasNext()) { |
| 2760 | cats += " " + it.next(); |
| 2761 | } |
| 2762 | System.out.println("Intent d=" + |
| 2763 | outInfo.hasDefault + ", cat=" + cats); |
| 2764 | } |
| 2765 | |
| 2766 | return true; |
| 2767 | } |
| 2768 | |
| 2769 | public final static class Package { |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2770 | public String packageName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2771 | |
| 2772 | // For now we only support one application per package. |
| 2773 | public final ApplicationInfo applicationInfo = new ApplicationInfo(); |
| 2774 | |
| 2775 | public final ArrayList<Permission> permissions = new ArrayList<Permission>(0); |
| 2776 | public final ArrayList<PermissionGroup> permissionGroups = new ArrayList<PermissionGroup>(0); |
| 2777 | public final ArrayList<Activity> activities = new ArrayList<Activity>(0); |
| 2778 | public final ArrayList<Activity> receivers = new ArrayList<Activity>(0); |
| 2779 | public final ArrayList<Provider> providers = new ArrayList<Provider>(0); |
| 2780 | public final ArrayList<Service> services = new ArrayList<Service>(0); |
| 2781 | public final ArrayList<Instrumentation> instrumentation = new ArrayList<Instrumentation>(0); |
| 2782 | |
| 2783 | public final ArrayList<String> requestedPermissions = new ArrayList<String>(); |
| 2784 | |
Dianne Hackborn | 854060a | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2785 | public ArrayList<String> protectedBroadcasts; |
| 2786 | |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 2787 | public ArrayList<String> usesLibraries = null; |
| 2788 | public ArrayList<String> usesOptionalLibraries = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2789 | public String[] usesLibraryFiles = null; |
| 2790 | |
Dianne Hackborn | c155239 | 2010-03-03 16:19:01 -0800 | [diff] [blame] | 2791 | public ArrayList<String> mOriginalPackages = null; |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2792 | public String mRealPackage = null; |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 2793 | public ArrayList<String> mAdoptPermissions = null; |
| 2794 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2795 | // We store the application meta-data independently to avoid multiple unwanted references |
| 2796 | public Bundle mAppMetaData = null; |
| 2797 | |
| 2798 | // If this is a 3rd party app, this is the path of the zip file. |
| 2799 | public String mPath; |
| 2800 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2801 | // The version code declared for this package. |
| 2802 | public int mVersionCode; |
| 2803 | |
| 2804 | // The version name declared for this package. |
| 2805 | public String mVersionName; |
| 2806 | |
| 2807 | // The shared user id that this package wants to use. |
| 2808 | public String mSharedUserId; |
| 2809 | |
| 2810 | // The shared user label that this package wants to use. |
| 2811 | public int mSharedUserLabel; |
| 2812 | |
| 2813 | // Signatures that were read from the package. |
| 2814 | public Signature mSignatures[]; |
| 2815 | |
| 2816 | // For use by package manager service for quick lookup of |
| 2817 | // preferred up order. |
| 2818 | public int mPreferredOrder = 0; |
| 2819 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 2820 | // For use by the package manager to keep track of the path to the |
| 2821 | // file an app came from. |
| 2822 | public String mScanPath; |
| 2823 | |
| 2824 | // For use by package manager to keep track of where it has done dexopt. |
| 2825 | public boolean mDidDexOpt; |
| 2826 | |
Dianne Hackborn | 46730fc | 2010-07-24 16:32:42 -0700 | [diff] [blame] | 2827 | // User set enabled state. |
| 2828 | public int mSetEnabled = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; |
| 2829 | |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 2830 | // Whether the package has been stopped. |
| 2831 | public boolean mSetStopped = false; |
| 2832 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2833 | // Additional data supplied by callers. |
| 2834 | public Object mExtras; |
Kenny Root | deb1126 | 2010-08-02 11:36:21 -0700 | [diff] [blame] | 2835 | |
| 2836 | // Whether an operation is currently pending on this package |
| 2837 | public boolean mOperationPending; |
| 2838 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2839 | /* |
| 2840 | * Applications hardware preferences |
| 2841 | */ |
| 2842 | public final ArrayList<ConfigurationInfo> configPreferences = |
| 2843 | new ArrayList<ConfigurationInfo>(); |
| 2844 | |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 2845 | /* |
| 2846 | * Applications requested features |
| 2847 | */ |
| 2848 | public ArrayList<FeatureInfo> reqFeatures = null; |
| 2849 | |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 2850 | public int installLocation; |
| 2851 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2852 | public Package(String _name) { |
| 2853 | packageName = _name; |
| 2854 | applicationInfo.packageName = _name; |
| 2855 | applicationInfo.uid = -1; |
| 2856 | } |
| 2857 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2858 | public void setPackageName(String newName) { |
| 2859 | packageName = newName; |
| 2860 | applicationInfo.packageName = newName; |
| 2861 | for (int i=permissions.size()-1; i>=0; i--) { |
| 2862 | permissions.get(i).setPackageName(newName); |
| 2863 | } |
| 2864 | for (int i=permissionGroups.size()-1; i>=0; i--) { |
| 2865 | permissionGroups.get(i).setPackageName(newName); |
| 2866 | } |
| 2867 | for (int i=activities.size()-1; i>=0; i--) { |
| 2868 | activities.get(i).setPackageName(newName); |
| 2869 | } |
| 2870 | for (int i=receivers.size()-1; i>=0; i--) { |
| 2871 | receivers.get(i).setPackageName(newName); |
| 2872 | } |
| 2873 | for (int i=providers.size()-1; i>=0; i--) { |
| 2874 | providers.get(i).setPackageName(newName); |
| 2875 | } |
| 2876 | for (int i=services.size()-1; i>=0; i--) { |
| 2877 | services.get(i).setPackageName(newName); |
| 2878 | } |
| 2879 | for (int i=instrumentation.size()-1; i>=0; i--) { |
| 2880 | instrumentation.get(i).setPackageName(newName); |
| 2881 | } |
| 2882 | } |
| 2883 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2884 | public String toString() { |
| 2885 | return "Package{" |
| 2886 | + Integer.toHexString(System.identityHashCode(this)) |
| 2887 | + " " + packageName + "}"; |
| 2888 | } |
| 2889 | } |
| 2890 | |
| 2891 | public static class Component<II extends IntentInfo> { |
| 2892 | public final Package owner; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2893 | public final ArrayList<II> intents; |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2894 | public final String className; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2895 | public Bundle metaData; |
| 2896 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2897 | ComponentName componentName; |
| 2898 | String componentShortName; |
| 2899 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2900 | public Component(Package _owner) { |
| 2901 | owner = _owner; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2902 | intents = null; |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2903 | className = null; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2904 | } |
| 2905 | |
| 2906 | public Component(final ParsePackageItemArgs args, final PackageItemInfo outInfo) { |
| 2907 | owner = args.owner; |
| 2908 | intents = new ArrayList<II>(0); |
Dianne Hackborn | cf244ad | 2010-03-09 15:00:30 -0800 | [diff] [blame] | 2909 | String name = args.sa.getNonConfigurationString(args.nameRes, 0); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2910 | if (name == null) { |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2911 | className = null; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2912 | args.outError[0] = args.tag + " does not specify android:name"; |
| 2913 | return; |
| 2914 | } |
| 2915 | |
| 2916 | outInfo.name |
| 2917 | = buildClassName(owner.applicationInfo.packageName, name, args.outError); |
| 2918 | if (outInfo.name == null) { |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2919 | className = null; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2920 | args.outError[0] = args.tag + " does not have valid android:name"; |
| 2921 | return; |
| 2922 | } |
| 2923 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2924 | className = outInfo.name; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2925 | |
| 2926 | int iconVal = args.sa.getResourceId(args.iconRes, 0); |
| 2927 | if (iconVal != 0) { |
| 2928 | outInfo.icon = iconVal; |
| 2929 | outInfo.nonLocalizedLabel = null; |
| 2930 | } |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 2931 | |
| 2932 | int logoVal = args.sa.getResourceId(args.logoRes, 0); |
| 2933 | if (logoVal != 0) { |
| 2934 | outInfo.logo = logoVal; |
| 2935 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2936 | |
| 2937 | TypedValue v = args.sa.peekValue(args.labelRes); |
| 2938 | if (v != null && (outInfo.labelRes=v.resourceId) == 0) { |
| 2939 | outInfo.nonLocalizedLabel = v.coerceToString(); |
| 2940 | } |
| 2941 | |
| 2942 | outInfo.packageName = owner.packageName; |
| 2943 | } |
| 2944 | |
| 2945 | public Component(final ParseComponentArgs args, final ComponentInfo outInfo) { |
| 2946 | this(args, (PackageItemInfo)outInfo); |
| 2947 | if (args.outError[0] != null) { |
| 2948 | return; |
| 2949 | } |
| 2950 | |
| 2951 | if (args.processRes != 0) { |
Dianne Hackborn | d1cff1b | 2010-04-02 16:51:26 -0700 | [diff] [blame] | 2952 | CharSequence pname; |
| 2953 | if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { |
| 2954 | pname = args.sa.getNonConfigurationString(args.processRes, 0); |
| 2955 | } else { |
| 2956 | // Some older apps have been seen to use a resource reference |
| 2957 | // here that on older builds was ignored (with a warning). We |
| 2958 | // need to continue to do this for them so they don't break. |
| 2959 | pname = args.sa.getNonResourceString(args.processRes); |
| 2960 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2961 | outInfo.processName = buildProcessName(owner.applicationInfo.packageName, |
Dianne Hackborn | d1cff1b | 2010-04-02 16:51:26 -0700 | [diff] [blame] | 2962 | owner.applicationInfo.processName, pname, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2963 | args.flags, args.sepProcesses, args.outError); |
| 2964 | } |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 2965 | |
| 2966 | if (args.descriptionRes != 0) { |
| 2967 | outInfo.descriptionRes = args.sa.getResourceId(args.descriptionRes, 0); |
| 2968 | } |
| 2969 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2970 | outInfo.enabled = args.sa.getBoolean(args.enabledRes, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2971 | } |
| 2972 | |
| 2973 | public Component(Component<II> clone) { |
| 2974 | owner = clone.owner; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2975 | intents = clone.intents; |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2976 | className = clone.className; |
| 2977 | componentName = clone.componentName; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2978 | componentShortName = clone.componentShortName; |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 2979 | } |
| 2980 | |
| 2981 | public ComponentName getComponentName() { |
| 2982 | if (componentName != null) { |
| 2983 | return componentName; |
| 2984 | } |
| 2985 | if (className != null) { |
| 2986 | componentName = new ComponentName(owner.applicationInfo.packageName, |
| 2987 | className); |
| 2988 | } |
| 2989 | return componentName; |
| 2990 | } |
| 2991 | |
| 2992 | public String getComponentShortName() { |
| 2993 | if (componentShortName != null) { |
| 2994 | return componentShortName; |
| 2995 | } |
| 2996 | ComponentName component = getComponentName(); |
| 2997 | if (component != null) { |
| 2998 | componentShortName = component.flattenToShortString(); |
| 2999 | } |
| 3000 | return componentShortName; |
| 3001 | } |
| 3002 | |
| 3003 | public void setPackageName(String packageName) { |
| 3004 | componentName = null; |
| 3005 | componentShortName = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3006 | } |
| 3007 | } |
| 3008 | |
| 3009 | public final static class Permission extends Component<IntentInfo> { |
| 3010 | public final PermissionInfo info; |
| 3011 | public boolean tree; |
| 3012 | public PermissionGroup group; |
| 3013 | |
| 3014 | public Permission(Package _owner) { |
| 3015 | super(_owner); |
| 3016 | info = new PermissionInfo(); |
| 3017 | } |
| 3018 | |
| 3019 | public Permission(Package _owner, PermissionInfo _info) { |
| 3020 | super(_owner); |
| 3021 | info = _info; |
| 3022 | } |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3023 | |
| 3024 | public void setPackageName(String packageName) { |
| 3025 | super.setPackageName(packageName); |
| 3026 | info.packageName = packageName; |
| 3027 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3028 | |
| 3029 | public String toString() { |
| 3030 | return "Permission{" |
| 3031 | + Integer.toHexString(System.identityHashCode(this)) |
| 3032 | + " " + info.name + "}"; |
| 3033 | } |
| 3034 | } |
| 3035 | |
| 3036 | public final static class PermissionGroup extends Component<IntentInfo> { |
| 3037 | public final PermissionGroupInfo info; |
| 3038 | |
| 3039 | public PermissionGroup(Package _owner) { |
| 3040 | super(_owner); |
| 3041 | info = new PermissionGroupInfo(); |
| 3042 | } |
| 3043 | |
| 3044 | public PermissionGroup(Package _owner, PermissionGroupInfo _info) { |
| 3045 | super(_owner); |
| 3046 | info = _info; |
| 3047 | } |
| 3048 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3049 | public void setPackageName(String packageName) { |
| 3050 | super.setPackageName(packageName); |
| 3051 | info.packageName = packageName; |
| 3052 | } |
| 3053 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3054 | public String toString() { |
| 3055 | return "PermissionGroup{" |
| 3056 | + Integer.toHexString(System.identityHashCode(this)) |
| 3057 | + " " + info.name + "}"; |
| 3058 | } |
| 3059 | } |
| 3060 | |
| 3061 | private static boolean copyNeeded(int flags, Package p, Bundle metaData) { |
Dianne Hackborn | 46730fc | 2010-07-24 16:32:42 -0700 | [diff] [blame] | 3062 | if (p.mSetEnabled != PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { |
| 3063 | boolean enabled = p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; |
| 3064 | if (p.applicationInfo.enabled != enabled) { |
| 3065 | return true; |
| 3066 | } |
| 3067 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3068 | if ((flags & PackageManager.GET_META_DATA) != 0 |
| 3069 | && (metaData != null || p.mAppMetaData != null)) { |
| 3070 | return true; |
| 3071 | } |
| 3072 | if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0 |
| 3073 | && p.usesLibraryFiles != null) { |
| 3074 | return true; |
| 3075 | } |
| 3076 | return false; |
| 3077 | } |
| 3078 | |
| 3079 | public static ApplicationInfo generateApplicationInfo(Package p, int flags) { |
| 3080 | if (p == null) return null; |
| 3081 | if (!copyNeeded(flags, p, null)) { |
Mitsuru Oshima | 69fff4a | 2009-07-21 09:51:05 -0700 | [diff] [blame] | 3082 | // CompatibilityMode is global state. It's safe to modify the instance |
| 3083 | // of the package. |
| 3084 | if (!sCompatibilityModeEnabled) { |
| 3085 | p.applicationInfo.disableCompatibilityMode(); |
| 3086 | } |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 3087 | if (p.mSetStopped) { |
| 3088 | p.applicationInfo.flags |= ApplicationInfo.FLAG_STOPPED; |
| 3089 | } else { |
| 3090 | p.applicationInfo.flags &= ~ApplicationInfo.FLAG_STOPPED; |
| 3091 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3092 | return p.applicationInfo; |
| 3093 | } |
| 3094 | |
| 3095 | // Make shallow copy so we can store the metadata/libraries safely |
| 3096 | ApplicationInfo ai = new ApplicationInfo(p.applicationInfo); |
| 3097 | if ((flags & PackageManager.GET_META_DATA) != 0) { |
| 3098 | ai.metaData = p.mAppMetaData; |
| 3099 | } |
| 3100 | if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0) { |
| 3101 | ai.sharedLibraryFiles = p.usesLibraryFiles; |
| 3102 | } |
Mitsuru Oshima | 69fff4a | 2009-07-21 09:51:05 -0700 | [diff] [blame] | 3103 | if (!sCompatibilityModeEnabled) { |
| 3104 | ai.disableCompatibilityMode(); |
| 3105 | } |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 3106 | if (p.mSetStopped) { |
| 3107 | p.applicationInfo.flags |= ApplicationInfo.FLAG_STOPPED; |
| 3108 | } else { |
| 3109 | p.applicationInfo.flags &= ~ApplicationInfo.FLAG_STOPPED; |
| 3110 | } |
John Reck | 4b7b7cc | 2011-02-02 11:57:44 -0800 | [diff] [blame] | 3111 | if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { |
| 3112 | ai.enabled = true; |
| 3113 | } else if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { |
| 3114 | ai.enabled = false; |
| 3115 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3116 | return ai; |
| 3117 | } |
| 3118 | |
| 3119 | public static final PermissionInfo generatePermissionInfo( |
| 3120 | Permission p, int flags) { |
| 3121 | if (p == null) return null; |
| 3122 | if ((flags&PackageManager.GET_META_DATA) == 0) { |
| 3123 | return p.info; |
| 3124 | } |
| 3125 | PermissionInfo pi = new PermissionInfo(p.info); |
| 3126 | pi.metaData = p.metaData; |
| 3127 | return pi; |
| 3128 | } |
| 3129 | |
| 3130 | public static final PermissionGroupInfo generatePermissionGroupInfo( |
| 3131 | PermissionGroup pg, int flags) { |
| 3132 | if (pg == null) return null; |
| 3133 | if ((flags&PackageManager.GET_META_DATA) == 0) { |
| 3134 | return pg.info; |
| 3135 | } |
| 3136 | PermissionGroupInfo pgi = new PermissionGroupInfo(pg.info); |
| 3137 | pgi.metaData = pg.metaData; |
| 3138 | return pgi; |
| 3139 | } |
| 3140 | |
| 3141 | public final static class Activity extends Component<ActivityIntentInfo> { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3142 | public final ActivityInfo info; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3143 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3144 | public Activity(final ParseComponentArgs args, final ActivityInfo _info) { |
| 3145 | super(args, _info); |
| 3146 | info = _info; |
| 3147 | info.applicationInfo = args.owner.applicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3148 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3149 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3150 | public void setPackageName(String packageName) { |
| 3151 | super.setPackageName(packageName); |
| 3152 | info.packageName = packageName; |
| 3153 | } |
| 3154 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3155 | public String toString() { |
| 3156 | return "Activity{" |
| 3157 | + Integer.toHexString(System.identityHashCode(this)) |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3158 | + " " + getComponentShortName() + "}"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3159 | } |
| 3160 | } |
| 3161 | |
| 3162 | public static final ActivityInfo generateActivityInfo(Activity a, |
| 3163 | int flags) { |
| 3164 | if (a == null) return null; |
| 3165 | if (!copyNeeded(flags, a.owner, a.metaData)) { |
| 3166 | return a.info; |
| 3167 | } |
| 3168 | // Make shallow copies so we can store the metadata safely |
| 3169 | ActivityInfo ai = new ActivityInfo(a.info); |
| 3170 | ai.metaData = a.metaData; |
| 3171 | ai.applicationInfo = generateApplicationInfo(a.owner, flags); |
| 3172 | return ai; |
| 3173 | } |
| 3174 | |
| 3175 | public final static class Service extends Component<ServiceIntentInfo> { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3176 | public final ServiceInfo info; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3177 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3178 | public Service(final ParseComponentArgs args, final ServiceInfo _info) { |
| 3179 | super(args, _info); |
| 3180 | info = _info; |
| 3181 | info.applicationInfo = args.owner.applicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3182 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3183 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3184 | public void setPackageName(String packageName) { |
| 3185 | super.setPackageName(packageName); |
| 3186 | info.packageName = packageName; |
| 3187 | } |
| 3188 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3189 | public String toString() { |
| 3190 | return "Service{" |
| 3191 | + Integer.toHexString(System.identityHashCode(this)) |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3192 | + " " + getComponentShortName() + "}"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3193 | } |
| 3194 | } |
| 3195 | |
| 3196 | public static final ServiceInfo generateServiceInfo(Service s, int flags) { |
| 3197 | if (s == null) return null; |
| 3198 | if (!copyNeeded(flags, s.owner, s.metaData)) { |
| 3199 | return s.info; |
| 3200 | } |
| 3201 | // Make shallow copies so we can store the metadata safely |
| 3202 | ServiceInfo si = new ServiceInfo(s.info); |
| 3203 | si.metaData = s.metaData; |
| 3204 | si.applicationInfo = generateApplicationInfo(s.owner, flags); |
| 3205 | return si; |
| 3206 | } |
| 3207 | |
| 3208 | public final static class Provider extends Component { |
| 3209 | public final ProviderInfo info; |
| 3210 | public boolean syncable; |
| 3211 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3212 | public Provider(final ParseComponentArgs args, final ProviderInfo _info) { |
| 3213 | super(args, _info); |
| 3214 | info = _info; |
| 3215 | info.applicationInfo = args.owner.applicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3216 | syncable = false; |
| 3217 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3218 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3219 | public Provider(Provider existingProvider) { |
| 3220 | super(existingProvider); |
| 3221 | this.info = existingProvider.info; |
| 3222 | this.syncable = existingProvider.syncable; |
| 3223 | } |
| 3224 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3225 | public void setPackageName(String packageName) { |
| 3226 | super.setPackageName(packageName); |
| 3227 | info.packageName = packageName; |
| 3228 | } |
| 3229 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3230 | public String toString() { |
| 3231 | return "Provider{" |
| 3232 | + Integer.toHexString(System.identityHashCode(this)) |
| 3233 | + " " + info.name + "}"; |
| 3234 | } |
| 3235 | } |
| 3236 | |
| 3237 | public static final ProviderInfo generateProviderInfo(Provider p, |
| 3238 | int flags) { |
| 3239 | if (p == null) return null; |
| 3240 | if (!copyNeeded(flags, p.owner, p.metaData) |
| 3241 | && ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) != 0 |
| 3242 | || p.info.uriPermissionPatterns == null)) { |
| 3243 | return p.info; |
| 3244 | } |
| 3245 | // Make shallow copies so we can store the metadata safely |
| 3246 | ProviderInfo pi = new ProviderInfo(p.info); |
| 3247 | pi.metaData = p.metaData; |
| 3248 | if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) { |
| 3249 | pi.uriPermissionPatterns = null; |
| 3250 | } |
| 3251 | pi.applicationInfo = generateApplicationInfo(p.owner, flags); |
| 3252 | return pi; |
| 3253 | } |
| 3254 | |
| 3255 | public final static class Instrumentation extends Component { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3256 | public final InstrumentationInfo info; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3257 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3258 | public Instrumentation(final ParsePackageItemArgs args, final InstrumentationInfo _info) { |
| 3259 | super(args, _info); |
| 3260 | info = _info; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3261 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 3262 | |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3263 | public void setPackageName(String packageName) { |
| 3264 | super.setPackageName(packageName); |
| 3265 | info.packageName = packageName; |
| 3266 | } |
| 3267 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3268 | public String toString() { |
| 3269 | return "Instrumentation{" |
| 3270 | + Integer.toHexString(System.identityHashCode(this)) |
Dianne Hackborn | 6dee18c | 2010-02-09 23:59:16 -0800 | [diff] [blame] | 3271 | + " " + getComponentShortName() + "}"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3272 | } |
| 3273 | } |
| 3274 | |
| 3275 | public static final InstrumentationInfo generateInstrumentationInfo( |
| 3276 | Instrumentation i, int flags) { |
| 3277 | if (i == null) return null; |
| 3278 | if ((flags&PackageManager.GET_META_DATA) == 0) { |
| 3279 | return i.info; |
| 3280 | } |
| 3281 | InstrumentationInfo ii = new InstrumentationInfo(i.info); |
| 3282 | ii.metaData = i.metaData; |
| 3283 | return ii; |
| 3284 | } |
| 3285 | |
| 3286 | public static class IntentInfo extends IntentFilter { |
| 3287 | public boolean hasDefault; |
| 3288 | public int labelRes; |
| 3289 | public CharSequence nonLocalizedLabel; |
| 3290 | public int icon; |
Adam Powell | 81cd2e9 | 2010-04-21 16:35:18 -0700 | [diff] [blame] | 3291 | public int logo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3292 | } |
| 3293 | |
| 3294 | public final static class ActivityIntentInfo extends IntentInfo { |
| 3295 | public final Activity activity; |
| 3296 | |
| 3297 | public ActivityIntentInfo(Activity _activity) { |
| 3298 | activity = _activity; |
| 3299 | } |
| 3300 | |
| 3301 | public String toString() { |
| 3302 | return "ActivityIntentInfo{" |
| 3303 | + Integer.toHexString(System.identityHashCode(this)) |
| 3304 | + " " + activity.info.name + "}"; |
| 3305 | } |
| 3306 | } |
| 3307 | |
| 3308 | public final static class ServiceIntentInfo extends IntentInfo { |
| 3309 | public final Service service; |
| 3310 | |
| 3311 | public ServiceIntentInfo(Service _service) { |
| 3312 | service = _service; |
| 3313 | } |
| 3314 | |
| 3315 | public String toString() { |
| 3316 | return "ServiceIntentInfo{" |
| 3317 | + Integer.toHexString(System.identityHashCode(this)) |
| 3318 | + " " + service.info.name + "}"; |
| 3319 | } |
| 3320 | } |
Mitsuru Oshima | 69fff4a | 2009-07-21 09:51:05 -0700 | [diff] [blame] | 3321 | |
| 3322 | /** |
| 3323 | * @hide |
| 3324 | */ |
| 3325 | public static void setCompatibilityModeEnabled(boolean compatibilityModeEnabled) { |
| 3326 | sCompatibilityModeEnabled = compatibilityModeEnabled; |
| 3327 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3328 | } |