Merge change 20200 into donut

* changes:
  Fix NPE that prevented any package w/o license to be installed.
This commit is contained in:
Android (Google) Code Review
2009-08-05 17:22:04 -07:00
4 changed files with 34 additions and 7 deletions

View File

@@ -126,8 +126,12 @@ public class AddonPackage extends Package {
super.saveProperties(props);
mVersion.saveProperties(props);
props.setProperty(PROP_NAME, mName);
props.setProperty(PROP_VENDOR, mVendor);
if (mName != null) {
props.setProperty(PROP_NAME, mName);
}
if (mVendor != null) {
props.setProperty(PROP_VENDOR, mVendor);
}
}
/**

View File

@@ -145,9 +145,15 @@ public abstract class Package implements IDescription {
*/
void saveProperties(Properties props) {
props.setProperty(PROP_REVISION, Integer.toString(mRevision));
props.setProperty(PROP_LICENSE, mLicense);
props.setProperty(PROP_DESC, mDescription);
props.setProperty(PROP_DESC_URL, mDescUrl);
if (mLicense != null) {
props.setProperty(PROP_LICENSE, mLicense);
}
if (mDescription != null) {
props.setProperty(PROP_DESC, mDescription);
}
if (mDescUrl != null) {
props.setProperty(PROP_DESC_URL, mDescUrl);
}
if (mSource != null) {
props.setProperty(PROP_SOURCE_URL, mSource.getUrl());

View File

@@ -87,7 +87,9 @@ public class PlatformPackage extends Package {
super.saveProperties(props);
mVersion.saveProperties(props);
props.setProperty(PROP_VERSION, mVersionName);
if (mVersionName != null) {
props.setProperty(PROP_VERSION, mVersionName);
}
}
/** Returns the version, a string, for platform packages. */

View File

@@ -36,6 +36,8 @@ import com.android.sdkuilib.repository.UpdaterWindow.ISdkListener;
import org.eclipse.swt.widgets.Shell;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -304,8 +306,21 @@ class UpdaterData {
} catch (Throwable t) {
// Display anything unexpected in the monitor.
monitor.setResult("Unexpected Error: %1$s", t.getMessage());
String msg = t.getMessage();
if (msg != null) {
monitor.setResult("Unexpected Error installing '%1%s: %2$s",
archive.getParentPackage().getShortDescription(), msg);
} else {
// no error info? get the stack call to display it
// At least that'll give us a better bug report.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
t.printStackTrace(new PrintStream(baos));
// and display it
monitor.setResult("Unexpected Error installing '%1$s\n%2$s",
archive.getParentPackage().getShortDescription(),
baos.toString());
}
} finally {
// Always move the progress bar to the desired position.