From be4cbcc2267e3778776c68785b52f871f72c67f7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 29 Oct 2009 13:52:56 -0700 Subject: [PATCH] SDK Manager: fix NPE in AVD > Start when there's no skin name. Also log missing config.ini path. SDK BUG 2223760 Change-Id: I4517005e03e90c0b5a52bcb40b0d32eddd03c1f3 --- .../sdklib/internal/avd/AvdManager.java | 8 +++- .../internal/widgets/AvdStartDialog.java | 44 ++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java index 925f321a8..36b3b7fda 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java @@ -1044,7 +1044,13 @@ public final class AvdManager { } if (configIniFile != null) { - properties = SdkManager.parsePropertyFile(configIniFile, log); + if (!configIniFile.isFile()) { + if (log != null) { + log.warning("Missing file '%1$s'.", configIniFile.getPath()); + } + } else { + properties = SdkManager.parsePropertyFile(configIniFile, log); + } } // get name diff --git a/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java b/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java index 266a84833..b698b6406 100644 --- a/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java +++ b/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java @@ -120,7 +120,7 @@ final class AvdStartDialog extends GridDialog { l.setText("Skin:"); l = new Label(parent, SWT.NONE); - l.setText(mSkinDisplay); + l.setText(mSkinDisplay == null ? "None" : mSkinDisplay); l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); l = new Label(parent, SWT.NONE); @@ -417,27 +417,29 @@ final class AvdStartDialog extends GridDialog { Map prop = mAvd.getProperties(); String skinName = prop.get(AvdManager.AVD_INI_SKIN_NAME); - Matcher m = AvdManager.NUMERIC_SKIN_SIZE.matcher(skinName); - if (m.matches()) { - mSize1 = Integer.parseInt(m.group(1)); - mSize2 = Integer.parseInt(m.group(2)); - mSkinDisplay = skinName; - mEnableScaling = true; - } else { - // The resolution is inside the layout file of the skin. - mEnableScaling = false; // default to false for now. + if (skinName != null) { + Matcher m = AvdManager.NUMERIC_SKIN_SIZE.matcher(skinName); + if (m != null && m.matches()) { + mSize1 = Integer.parseInt(m.group(1)); + mSize2 = Integer.parseInt(m.group(2)); + mSkinDisplay = skinName; + mEnableScaling = true; + } + } - // path to the skin layout file. - File skinFolder = new File(mSdkLocation, prop.get(AvdManager.AVD_INI_SKIN_PATH)); - if (skinFolder.isDirectory()) { - File layoutFile = new File(skinFolder, "layout"); - if (layoutFile.isFile()) { - if (parseLayoutFile(layoutFile)) { - mSkinDisplay = String.format("%1$s (%2$dx%3$d)", skinName, mSize1, mSize2); - mEnableScaling = true; - } else { - mSkinDisplay = skinName; - } + // The resolution is inside the layout file of the skin. + mEnableScaling = false; // default to false for now. + + // path to the skin layout file. + File skinFolder = new File(mSdkLocation, prop.get(AvdManager.AVD_INI_SKIN_PATH)); + if (skinFolder.isDirectory()) { + File layoutFile = new File(skinFolder, "layout"); + if (layoutFile.isFile()) { + if (parseLayoutFile(layoutFile)) { + mSkinDisplay = String.format("%1$s (%2$dx%3$d)", skinName, mSize1, mSize2); + mEnableScaling = true; + } else { + mSkinDisplay = skinName; } } }