aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdkuilib
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2011-08-12 15:06:00 -0700
committerRaphael Moll <ralf@android.com>2011-08-12 15:06:00 -0700
commit911525008c905990c445962d59b8898d9cfc09a5 (patch)
tree99bb18cf0498c95b339905a0e4b592e3ea13a365 /sdkmanager/libs/sdkuilib
parent4ce1938fae83a4009d11241ecd2afbdcb1cdb440 (diff)
downloadsdk-911525008c905990c445962d59b8898d9cfc09a5.zip
sdk-911525008c905990c445962d59b8898d9cfc09a5.tar.gz
sdk-911525008c905990c445962d59b8898d9cfc09a5.tar.bz2
SDK Man2: fix bug when deleting a local package.
When deleting a local package, the model was still retaining the info of the previously installed package and was thus not offering it again for install. Also fixes a case where selecting something for install and then cancelling would trigger an unecessary list refresh. Change-Id: I0889e2c19c721325f921d8681a429210f76b490b
Diffstat (limited to 'sdkmanager/libs/sdkuilib')
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java4
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java12
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java2
-rwxr-xr-xsdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java4
4 files changed, 12 insertions, 10 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
index 4d81651..842f9d2 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
@@ -348,7 +348,7 @@ class PackagesDiffLogic {
}
}
- // Downgrade INSTALLED items to NEW if their package isn't listed anymore in locals
+ // Remove INSTALLED items if their package isn't listed anymore in locals
for (PkgCategory cat : op.getCategories()) {
List<PkgItem> items = cat.getItems();
for (int i = 0; i < items.size(); i++) {
@@ -357,7 +357,7 @@ class PackagesDiffLogic {
if (item.getState() == PkgState.INSTALLED) {
Package newPkg = setContainsLocalPackage(newPackages, item.getMainPackage());
if (newPkg == null) {
- replace(items, i, new PkgItem(item.getMainPackage(), PkgState.NEW));
+ items.remove(i--);
hasChanged = true;
}
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java
index ff6914f..6c7bcd3 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java
@@ -1008,18 +1008,22 @@ public class PackagesPage extends UpdaterPage
}
if (mUpdaterData != null) {
+ boolean needsRefresh = false;
try {
beginOperationPending();
- mUpdaterData.updateOrInstallAll_WithGUI(
+ List<Archive> installed = mUpdaterData.updateOrInstallAll_WithGUI(
archives,
mCheckFilterObsolete.getSelection() /* includeObsoletes */);
+ needsRefresh = installed != null && !installed.isEmpty();
} finally {
endOperationPending();
- // The local package list has changed, make sure to refresh it
- mUpdaterData.getLocalSdkParser().clearPackages();
- loadPackages();
+ if (needsRefresh) {
+ // The local package list has changed, make sure to refresh it
+ mUpdaterData.getLocalSdkParser().clearPackages();
+ loadPackages();
+ }
}
}
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java
index f3dff37..7609199 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java
@@ -102,8 +102,6 @@ class TaskMonitorImpl implements ITaskMonitor {
* Weird things will happen if setProgressMax is called multiple times
* *after* {@link #incProgress(int)}: we don't try to adjust it on the
* fly.
- *
- * @see ProgressBar#setMaximum(int)
*/
public void setProgressMax(int max) {
assert max > 0;
diff --git a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java
index ff46e6d..86011d4 100755
--- a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java
+++ b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java
@@ -285,7 +285,7 @@ public class PackagesDiffLogicTest extends TestCase {
m.updateStart();
// No local packages
assertTrue(m.updateSourcePackages(true /*sortByApi*/, null /*locals*/, new Package[0]));
- assertFalse(m.updateSourcePackages(true /*sortByApi*/, src1, new Package[] {
+ assertTrue(m.updateSourcePackages(true /*sortByApi*/, src1, new Package[] {
new MockEmptyPackage(src1, "type1", 1)
}));
@@ -658,7 +658,7 @@ public class PackagesDiffLogicTest extends TestCase {
m.updateStart();
// no local package
assertTrue(m.updateSourcePackages(false /*sortByApi*/, null /*locals*/, new Package[0]));
- assertFalse(m.updateSourcePackages(false /*sortByApi*/, src1, new Package[] {
+ assertTrue(m.updateSourcePackages(false /*sortByApi*/, src1, new Package[] {
new MockEmptyPackage(src1, "type1", 1),
}));
assertTrue(m.updateEnd(false /*sortByApi*/));