Merge "SDK doc change: Misc small fixes." into eclair
diff --git a/docs/html/sdk/adding-components.jd b/docs/html/sdk/adding-components.jd
index bc82170..d7c886e 100644
--- a/docs/html/sdk/adding-components.jd
+++ b/docs/html/sdk/adding-components.jd
@@ -122,6 +122,21 @@
 <p>Any SDK components available from the site will now be listed under
 <strong>Available Components</strong>.</p>
 
+<h3 id="troubleshooting">Troubleshooting</h3>
+
+<p><strong>Problems connecting to the SDK repository</strong></p>
+
+<p>If you are using the SDK and AVD Manager to download components and are encountering
+connection problems, try connecting over http, rather than https. To switch the
+protocol used by the SDK and AVD Manager, follow these steps: </p>
+
+<ol>
+  <li>With the Android SDK and AVD Manager window open, select "Settings" in the
+  left pane. </li>
+  <li>On the right, in the "Misc" section, check the checkbox labeled "Force
+  https://... sources to be fetched using http://..." </li>
+  <li>Click <strong>Save &amp; Apply</strong>.</li>
+</ol>
 
 <h2 id="dependencies">SDK Component Dependencies</h2>
 
@@ -138,7 +153,3 @@
 
 <p>Additionally, the development tools will notify you with debug warnings
 if there is dependency that you need to address. </p>
-
-
-
-
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 9382146..86504a0 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -573,7 +573,7 @@
                 mAppInstallDir.mkdirs(); // scanDirLI() assumes this dir exists
             }
             //look for any incomplete package installations
-            ArrayList<String> deletePkgsList = mSettings.getListOfIncompleteInstallPackages();
+            ArrayList<PackageSetting> deletePkgsList = mSettings.getListOfIncompleteInstallPackages();
             //clean up list
             for(int i = 0; i < deletePkgsList.size(); i++) {
                 //clean up here
@@ -628,20 +628,31 @@
         }
     }
 
-    void cleanupInstallFailedPackage(String packageName) {
+    void cleanupInstallFailedPackage(PackageSetting ps) {
+        Log.i(TAG, "Cleaning up incompletely installed app: " + ps.name);
         if (mInstaller != null) {
-            int retCode = mInstaller.remove(packageName);
+            int retCode = mInstaller.remove(ps.name);
             if (retCode < 0) {
                 Log.w(TAG, "Couldn't remove app data directory for package: "
-                           + packageName + ", retcode=" + retCode);
+                           + ps.name + ", retcode=" + retCode);
             }
         } else {
             //for emulator
-            PackageParser.Package pkg = mPackages.get(packageName);
+            PackageParser.Package pkg = mPackages.get(ps.name);
             File dataDir = new File(pkg.applicationInfo.dataDir);
             dataDir.delete();
         }
-        mSettings.removePackageLP(packageName);
+        if (ps.codePath != null) {
+            if (!ps.codePath.delete()) {
+                Log.w(TAG, "Unable to remove old code file: " + ps.codePath);
+            }
+        }
+        if (ps.resourcePath != null) {
+            if (!ps.resourcePath.delete() && !ps.resourcePath.equals(ps.codePath)) {
+                Log.w(TAG, "Unable to remove old code file: " + ps.resourcePath);
+            }
+        }
+        mSettings.removePackageLP(ps.name);
     }
 
     void readPermissions() {
@@ -6732,15 +6743,15 @@
             return mReadMessages.toString();
         }
 
-        ArrayList<String> getListOfIncompleteInstallPackages() {
+        ArrayList<PackageSetting> getListOfIncompleteInstallPackages() {
             HashSet<String> kList = new HashSet<String>(mPackages.keySet());
             Iterator<String> its = kList.iterator();
-            ArrayList<String> ret = new ArrayList<String>();
+            ArrayList<PackageSetting> ret = new ArrayList<PackageSetting>();
             while(its.hasNext()) {
                 String key = its.next();
                 PackageSetting ps = mPackages.get(key);
                 if(ps.getInstallStatus() == PKG_INSTALL_INCOMPLETE) {
-                    ret.add(key);
+                    ret.add(ps);
                 }
             }
             return ret;