diff options
6 files changed, 169 insertions, 103 deletions
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java index 11d984d0695c..fb2608a33334 100644 --- a/core/java/android/content/SyncStorageEngine.java +++ b/core/java/android/content/SyncStorageEngine.java @@ -103,7 +103,7 @@ public class SyncStorageEngine extends Handler { public static final String MESG_SUCCESS = "success"; public static final String MESG_CANCELED = "canceled"; - public static final int MAX_HISTORY = 15; + public static final int MAX_HISTORY = 100; private static final int MSG_WRITE_STATUS = 1; private static final long WRITE_STATUS_DELAY = 1000*60*10; // 10 minutes diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 3e117d49a3b8..83e63b9c435e 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -986,6 +986,7 @@ public class PackageParser { } final int NP = PackageParser.NEW_PERMISSIONS.length; + StringBuilder implicitPerms = null; for (int ip=0; ip<NP; ip++) { final PackageParser.NewPermissionInfo npi = PackageParser.NEW_PERMISSIONS[ip]; @@ -993,11 +994,20 @@ public class PackageParser { break; } if (!pkg.requestedPermissions.contains(npi.name)) { - Log.i(TAG, "Impliciting adding " + npi.name + " to old pkg " - + pkg.packageName); + if (implicitPerms == null) { + implicitPerms = new StringBuilder(128); + implicitPerms.append(pkg.packageName); + implicitPerms.append(": compat added "); + } else { + implicitPerms.append(' '); + } + implicitPerms.append(npi.name); pkg.requestedPermissions.add(npi.name); } } + if (implicitPerms != null) { + Log.i(TAG, implicitPerms.toString()); + } if (supportsSmallScreens < 0 || (supportsSmallScreens > 0 && pkg.applicationInfo.targetSdkVersion @@ -1335,8 +1345,10 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestApplication_backupAgent); if (backupAgent != null) { ai.backupAgentName = buildClassName(pkgName, backupAgent, outError); - Log.v(TAG, "android:backupAgent = " + ai.backupAgentName - + " from " + pkgName + "+" + backupAgent); + if (false) { + Log.v(TAG, "android:backupAgent = " + ai.backupAgentName + + " from " + pkgName + "+" + backupAgent); + } if (sa.getBoolean( com.android.internal.R.styleable.AndroidManifestApplication_killAfterRestore, @@ -1526,8 +1538,9 @@ public class PackageParser { } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); - Log.w(TAG, "Unknown element under <application>: " + tagName); + Log.w(TAG, "Unknown element under <application>: " + tagName + + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { @@ -1572,25 +1585,6 @@ public class PackageParser { return true; } - private boolean parseComponentInfo(Package owner, int flags, - ComponentInfo outInfo, String[] outError, String tag, TypedArray sa, - int nameRes, int labelRes, int iconRes, int processRes, - int enabledRes) { - if (!parsePackageItemInfo(owner, outInfo, outError, tag, sa, - nameRes, labelRes, iconRes)) { - return false; - } - - if (processRes != 0) { - outInfo.processName = buildProcessName(owner.applicationInfo.packageName, - owner.applicationInfo.processName, sa.getNonResourceString(processRes), - flags, mSeparateProcesses, outError); - } - outInfo.enabled = sa.getBoolean(enabledRes, true); - - return outError[0] == null; - } - private Activity parseActivity(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError, boolean receiver) throws XmlPullParserException, IOException { @@ -1749,9 +1743,13 @@ public class PackageParser { if (!RIGID_PARSER) { Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); if (receiver) { - Log.w(TAG, "Unknown element under <receiver>: " + parser.getName()); + Log.w(TAG, "Unknown element under <receiver>: " + parser.getName() + + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); } else { - Log.w(TAG, "Unknown element under <activity>: " + parser.getName()); + Log.w(TAG, "Unknown element under <activity>: " + parser.getName() + + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); } XmlUtils.skipCurrentTag(parser); continue; @@ -1891,8 +1889,9 @@ public class PackageParser { } } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); - Log.w(TAG, "Unknown element under <activity-alias>: " + parser.getName()); + Log.w(TAG, "Unknown element under <activity-alias>: " + parser.getName() + + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -2055,8 +2054,9 @@ public class PackageParser { outInfo.info.grantUriPermissions = true; } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); - Log.w(TAG, "No path, pathPrefix, or pathPattern for <path-permission>"); + Log.w(TAG, "Unknown element under <path-permission>: " + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -2096,8 +2096,9 @@ public class PackageParser { if (!havePerm) { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); - Log.w(TAG, "No readPermission or writePermssion for <path-permission>"); + Log.w(TAG, "No readPermission or writePermssion for <path-permission>: " + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -2141,8 +2142,9 @@ public class PackageParser { } } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); - Log.w(TAG, "No path, pathPrefix, or pathPattern for <path-permission>"); + Log.w(TAG, "No path, pathPrefix, or pathPattern for <path-permission>: " + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -2153,9 +2155,9 @@ public class PackageParser { } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); Log.w(TAG, "Unknown element under <provider>: " - + parser.getName()); + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -2233,9 +2235,9 @@ public class PackageParser { } } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); Log.w(TAG, "Unknown element under <service>: " - + parser.getName()); + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -2272,9 +2274,9 @@ public class PackageParser { } } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); Log.w(TAG, "Unknown element under " + tag + ": " - + parser.getName()); + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -2330,8 +2332,9 @@ public class PackageParser { data.putFloat(name, v.getFloat()); } else { if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); - Log.w(TAG, "<meta-data> only supports string, integer, float, color, boolean, and resource reference types"); + Log.w(TAG, "<meta-data> only supports string, integer, float, color, boolean, and resource reference types: " + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); } else { outError[0] = "<meta-data> only supports string, integer, float, color, boolean, and resource reference types"; data = null; @@ -2365,6 +2368,7 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestIntentFilter_priority, 0); if (priority > 0 && isActivity && (flags&PARSE_IS_SYSTEM) == 0) { Log.w(TAG, "Activity with priority > 0, forcing to 0 at " + + mArchiveSourcePath + " " + parser.getPositionDescription()); priority = 0; } @@ -2462,8 +2466,9 @@ public class PackageParser { sa.recycle(); XmlUtils.skipCurrentTag(parser); } else if (!RIGID_PARSER) { - Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); - Log.w(TAG, "Unknown element under <intent-filter>: " + parser.getName()); + Log.w(TAG, "Unknown element under <intent-filter>: " + + parser.getName() + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); } else { outError[0] = "Bad element under <intent-filter>: " + parser.getName(); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index f27902db5a99..2ca17f6f43bd 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -464,7 +464,7 @@ public final class Settings { resolver.insert(uri, values); return true; } catch (SQLException e) { - Log.e(TAG, "Can't set key " + name + " in " + uri, e); + Log.w(TAG, "Can't set key " + name + " in " + uri, e); return false; } } @@ -501,7 +501,7 @@ public final class Settings { mValues.put(name, value); } catch (SQLException e) { // SQL error: return null, but don't cache it. - Log.e(TAG, "Can't get key " + name + " from " + mUri, e); + Log.w(TAG, "Can't get key " + name + " from " + mUri, e); } finally { if (c != null) c.close(); } @@ -3746,7 +3746,7 @@ public final class Settings { // The stored URL is bad... ignore it. } catch (IllegalArgumentException e) { // Column not found - Log.e(TAG, "Intent column not found", e); + Log.w(TAG, "Intent column not found", e); } } } finally { diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index 867f215cc97e..2f16b8491687 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -178,6 +178,7 @@ class PackageManagerService extends IPackageManager.Stub { final File mFrameworkDir; final File mSystemAppDir; final File mAppInstallDir; + final File mDalvikCacheDir; // Directory containing the private parts (e.g. code and non-resource assets) of forward-locked // apps. @@ -438,8 +439,11 @@ class PackageManagerService extends IPackageManager.Stub { final HashSet<String> libFiles = new HashSet<String>(); mFrameworkDir = new File(Environment.getRootDirectory(), "framework"); + mDalvikCacheDir = new File(dataDir, "dalvik-cache"); if (mInstaller != null) { + boolean didDexOpt = false; + /** * Out of paranoia, ensure that everything in the boot class * path has been dexed. @@ -452,6 +456,7 @@ class PackageManagerService extends IPackageManager.Stub { if (dalvik.system.DexFile.isDexOptNeeded(paths[i])) { libFiles.add(paths[i]); mInstaller.dexopt(paths[i], Process.SYSTEM_UID, true); + didDexOpt = true; } } catch (FileNotFoundException e) { Log.w(TAG, "Boot class path not found: " + paths[i]); @@ -474,6 +479,7 @@ class PackageManagerService extends IPackageManager.Stub { if (dalvik.system.DexFile.isDexOptNeeded(lib)) { libFiles.add(lib); mInstaller.dexopt(lib, Process.SYSTEM_UID, true); + didDexOpt = true; } } catch (FileNotFoundException e) { Log.w(TAG, "Library not found: " + lib); @@ -493,7 +499,7 @@ class PackageManagerService extends IPackageManager.Stub { * run from a non-root shell. */ String[] frameworkFiles = mFrameworkDir.list(); - if (frameworkFiles != null && mInstaller != null) { + if (frameworkFiles != null) { for (int i=0; i<frameworkFiles.length; i++) { File libPath = new File(mFrameworkDir, frameworkFiles[i]); String path = libPath.getPath(); @@ -508,6 +514,7 @@ class PackageManagerService extends IPackageManager.Stub { try { if (dalvik.system.DexFile.isDexOptNeeded(path)) { mInstaller.dexopt(path, Process.SYSTEM_UID, true); + didDexOpt = true; } } catch (FileNotFoundException e) { Log.w(TAG, "Jar not found: " + path); @@ -516,6 +523,25 @@ class PackageManagerService extends IPackageManager.Stub { } } } + + if (didDexOpt) { + // If we had to do a dexopt of one of the previous + // things, then something on the system has changed. + // Consider this significant, and wipe away all other + // existing dexopt files to ensure we don't leave any + // dangling around. + String[] files = mDalvikCacheDir.list(); + if (files != null) { + for (int i=0; i<files.length; i++) { + String fn = files[i]; + if (fn.startsWith("data@app@") + || fn.startsWith("data@app-private@")) { + Log.i(TAG, "Pruning dalvik file: " + fn); + (new File(mDalvikCacheDir, fn)).delete(); + } + } + } + } } mFrameworkInstallObserver = new AppDirObserver( @@ -641,6 +667,27 @@ class PackageManagerService extends IPackageManager.Stub { final File permFile = new File(Environment.getRootDirectory(), "etc/permissions/platform.xml"); readPermissionsFromXml(permFile); + + StringBuilder sb = new StringBuilder(128); + sb.append("Libs:"); + Iterator<String> it = mSharedLibraries.keySet().iterator(); + while (it.hasNext()) { + sb.append(' '); + String name = it.next(); + sb.append(name); + sb.append(':'); + sb.append(mSharedLibraries.get(name)); + } + Log.i(TAG, sb.toString()); + + sb.setLength(0); + sb.append("Features:"); + it = mAvailableFeatures.keySet().iterator(); + while (it.hasNext()) { + sb.append(' '); + sb.append(it.next()); + } + Log.i(TAG, sb.toString()); } private void readPermissionsFromXml(File permFile) { @@ -730,7 +777,7 @@ class PackageManagerService extends IPackageManager.Stub { Log.w(TAG, "<library> without file at " + parser.getPositionDescription()); } else { - Log.i(TAG, "Got library " + lname + " in " + lfile); + //Log.i(TAG, "Got library " + lname + " in " + lfile); mSharedLibraries.put(lname, lfile); } XmlUtils.skipCurrentTag(parser); @@ -742,7 +789,7 @@ class PackageManagerService extends IPackageManager.Stub { Log.w(TAG, "<feature> without name at " + parser.getPositionDescription()); } else { - Log.i(TAG, "Got feature " + fname); + //Log.i(TAG, "Got feature " + fname); FeatureInfo fi = new FeatureInfo(); fi.name = fname; mAvailableFeatures.put(fname, fi); @@ -1974,27 +2021,25 @@ class PackageManagerService extends IPackageManager.Stub { } if ((parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0) { // Check for updated system applications here - if (updatedPkg != null) { - if ((ps != null) && (!ps.codePath.getPath().equals(scanFile.getPath()))) { - if (pkg.mVersionCode <= ps.versionCode) { - // The system package has been updated and the code path does not match - // Ignore entry. Just return - Log.w(TAG, "Package:" + pkg.packageName + - " has been updated. Ignoring the one from path:"+scanFile); - mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE; - return null; - } else { - // Delete the older apk pointed to by ps - // At this point, its safely assumed that package installation for - // apps in system partition will go through. If not there won't be a working - // version of the app - synchronized (mPackages) { - // Just remove the loaded entries from package lists. - mPackages.remove(ps.name); - } - deletePackageResourcesLI(ps.name, ps.codePathString, ps.resourcePathString); - mSettings.enableSystemPackageLP(ps.name); + if ((ps != null) && (!ps.codePath.equals(scanFile))) { + if (pkg.mVersionCode < ps.versionCode) { + // The system package has been updated and the code path does not match + // Ignore entry. Just return + Log.w(TAG, "Package:" + pkg.packageName + + " has been updated. Ignoring the one from path:"+scanFile); + mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE; + return null; + } else { + // Delete the older apk pointed to by ps + // At this point, its safely assumed that package installation for + // apps in system partition will go through. If not there won't be a working + // version of the app + synchronized (mPackages) { + // Just remove the loaded entries from package lists. + mPackages.remove(ps.name); } + deletePackageResourcesLI(ps.name, ps.codePathString, ps.resourcePathString); + mSettings.enableSystemPackageLP(ps.name); } } } @@ -3814,14 +3859,13 @@ class PackageManagerService extends IPackageManager.Stub { final ApplicationInfo deletedPackageAppInfo = deletedPackage.applicationInfo; final ApplicationInfo installedPackageAppInfo = newPackage.applicationInfo; - if (!deletedPackageAppInfo.sourceDir - .equals(installedPackageAppInfo.sourceDir)) { - new File(deletedPackageAppInfo.sourceDir).delete(); - } - if (!deletedPackageAppInfo.publicSourceDir - .equals(installedPackageAppInfo.publicSourceDir)) { - new File(deletedPackageAppInfo.publicSourceDir).delete(); - } + deletePackageResourcesLI(pkgName, + !deletedPackageAppInfo.sourceDir + .equals(installedPackageAppInfo.sourceDir) + ? deletedPackageAppInfo.sourceDir : null, + !deletedPackageAppInfo.publicSourceDir + .equals(installedPackageAppInfo.publicSourceDir) + ? deletedPackageAppInfo.publicSourceDir : null); //update signature on the new package setting //this should always succeed, since we checked the //signature earlier. @@ -4504,22 +4548,30 @@ class PackageManagerService extends IPackageManager.Stub { private void deletePackageResourcesLI(String packageName, String sourceDir, String publicSourceDir) { - File sourceFile = new File(sourceDir); - if (!sourceFile.exists()) { - Log.w(TAG, "Package source " + sourceDir + " does not exist."); - } - // Delete application's code and resources - sourceFile.delete(); - final File publicSourceFile = new File(publicSourceDir); - if (publicSourceFile.exists()) { - publicSourceFile.delete(); + if (sourceDir != null) { + File sourceFile = new File(sourceDir); + if (!sourceFile.exists()) { + Log.w(TAG, "Package source " + sourceDir + " does not exist."); + } + // Delete application's code and resources + sourceFile.delete(); + if (mInstaller != null) { + int retCode = mInstaller.rmdex(sourceFile.toString()); + if (retCode < 0) { + Log.w(TAG, "Couldn't remove dex file for package: " + + packageName + " at location " + + sourceFile.toString() + ", retcode=" + retCode); + // we don't consider this to be a failure of the core package deletion + } + } } - if (mInstaller != null) { - int retCode = mInstaller.rmdex(sourceFile.toString()); - if (retCode < 0) { - Log.w(TAG, "Couldn't remove dex file for package: " - + packageName + " at location " + sourceFile.toString() + ", retcode=" + retCode); - // we don't consider this to be a failure of the core package deletion + if (publicSourceDir != null && !publicSourceDir.equals(sourceDir)) { + final File publicSourceFile = new File(publicSourceDir); + if (!publicSourceFile.exists()) { + Log.w(TAG, "Package public source " + publicSourceFile + " does not exist."); + } + if (publicSourceFile.exists()) { + publicSourceFile.delete(); } } } @@ -5725,7 +5777,7 @@ class PackageManagerService extends IPackageManager.Stub { } static class GrantedPermissions { - final int pkgFlags; + int pkgFlags; HashSet<String> grantedPermissions = new HashSet<String>(); int[] gids; @@ -6143,10 +6195,10 @@ class PackageManagerService extends IPackageManager.Stub { // Let the app continue with previous uid if code path changes. reportSettingsProblem(Log.WARN, "Package " + name + " codePath changed from " + p.codePath - + " to " + codePath + "; Retaining data and using new code from " + - codePath); + + " to " + codePath + "; Retaining data and using new"); } - } else if (p.sharedUser != sharedUser) { + } + if (p.sharedUser != sharedUser) { reportSettingsProblem(Log.WARN, "Package " + name + " shared user changed from " + (p.sharedUser != null ? p.sharedUser.name : "<nothing>") @@ -6154,6 +6206,13 @@ class PackageManagerService extends IPackageManager.Stub { + (sharedUser != null ? sharedUser.name : "<nothing>") + "; replacing with new"); p = null; + } else { + if ((pkgFlags&ApplicationInfo.FLAG_SYSTEM) != 0) { + // If what we are scanning is a system package, then + // make it so, regardless of whether it was previously + // installed only in the data partition. + p.pkgFlags |= ApplicationInfo.FLAG_SYSTEM; + } } } if (p == null) { @@ -6214,14 +6273,14 @@ class PackageManagerService extends IPackageManager.Stub { // Update code path if needed if (!codePath.toString().equalsIgnoreCase(p.codePathString)) { Log.w(TAG, "Code path for pkg : " + p.pkg.packageName + - " changing form " + p.codePathString + " to " + codePath); + " changing from " + p.codePathString + " to " + codePath); p.codePath = codePath; p.codePathString = codePath.toString(); } //Update resource path if needed if (!resourcePath.toString().equalsIgnoreCase(p.resourcePathString)) { Log.w(TAG, "Resource path for pkg : " + p.pkg.packageName + - " changing form " + p.resourcePathString + " to " + resourcePath); + " changing from " + p.resourcePathString + " to " + resourcePath); p.resourcePath = resourcePath; p.resourcePathString = resourcePath.toString(); } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 84ed3ed8bc9c..e5b6720b079f 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -233,8 +233,8 @@ public class WindowManagerService extends IWindowManager.Stub mPolicy.enableKeyguard(false); } public void released() { + mPolicy.enableKeyguard(true); synchronized (mKeyguardDisabled) { - mPolicy.enableKeyguard(true); mWaitingUntilKeyguardReenabled = false; mKeyguardDisabled.notifyAll(); } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 6858c75bce2c..09792a135d27 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -10340,9 +10340,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen try { if (DEBUG_SERVICE) Log.v(TAG, "Scheduling start service: " + r.name + " " + r.intent); + mStringBuilder.setLength(0); + r.intent.getIntent().toShortString(mStringBuilder, false, true); EventLog.writeEvent(LOG_AM_CREATE_SERVICE, System.identityHashCode(r), r.shortName, - r.intent.getIntent().toString(), r.app.pid); + mStringBuilder.toString(), r.app.pid); synchronized (r.stats.getBatteryStats()) { r.stats.startLaunchedLocked(); } |