diff options
author | Raphael <raphael@google.com> | 2011-09-23 22:17:19 -0700 |
---|---|---|
committer | Raphael Moll <raphael@google.com> | 2011-09-24 21:44:05 -0700 |
commit | a2fc0466f6d784ab31306e4572a8af14fa5b2734 (patch) | |
tree | 9ec3f84e5dc1fd6218a8f65d07694aaa6f92195d /sdkmanager | |
parent | 84cbb7dfc89081b1c3429ed8c3568977cc354cd1 (diff) | |
download | sdk-a2fc0466f6d784ab31306e4572a8af14fa5b2734.zip sdk-a2fc0466f6d784ab31306e4572a8af14fa5b2734.tar.gz sdk-a2fc0466f6d784ab31306e4572a8af14fa5b2734.tar.bz2 |
Prevent new install of tools from displaying update msg. Do not merge.
(cherry picked from commit 2a94ac98f9079e083ca88037b38244b5b5a46d7f)
Change-Id: Iee30e19c591cb375104fbcbeb3474c52a47df465
Diffstat (limited to 'sdkmanager')
10 files changed, 97 insertions, 30 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java index 0b494a7..ac292c3 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java @@ -74,6 +74,11 @@ import java.util.Set; * Data shared between {@link SdkUpdaterWindowImpl1} and its pages.
*/
public class UpdaterData implements IUpdaterData {
+
+ public static final int NO_TOOLS_MSG = 0;
+ public static final int TOOLS_MSG_UPDATED_FROM_ADT = 1;
+ public static final int TOOLS_MSG_UPDATED_FROM_SDKMAN = 2;
+
private String mOsSdkRoot;
private final ISdkLog mSdkLog;
@@ -390,10 +395,11 @@ public class UpdaterData implements IUpdaterData { * packages in the remote page and then clicking "install selected".
*
* @param archives The archives to install. Incompatible ones will be skipped.
+ * @param flags Optional flags for the installer, such as {@link #NO_TOOLS_MSG}.
* @return A list of archives that have been installed. Can be empty but not null.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
- protected List<Archive> installArchives(final List<ArchiveInfo> archives) {
+ protected List<Archive> installArchives(final List<ArchiveInfo> archives, final int flags) {
if (mTaskFactory == null) {
throw new IllegalArgumentException("Task Factory is null");
}
@@ -548,7 +554,7 @@ public class UpdaterData implements IUpdaterData { }
if (installedTools) {
- notifyToolsNeedsToBeRestarted();
+ notifyToolsNeedsToBeRestarted(flags);
}
if (numInstalled == 0) {
@@ -649,20 +655,33 @@ public class UpdaterData implements IUpdaterData { }
}
- private void notifyToolsNeedsToBeRestarted() {
- // We don't need to print anything if this is a standalone console update with no shell.
+ private void notifyToolsNeedsToBeRestarted(int flags) {
+
+ String msg = null;
+ if ((flags & TOOLS_MSG_UPDATED_FROM_ADT) != 0) {
+ msg =
+ "The Android SDK and AVD Manager that you are currently using has been updated. " +
+ "Please also run Eclipse > Help > Check for Updates to see if the Android " +
+ "plug-in needs to be updated.";
+
+ } else if ((flags & TOOLS_MSG_UPDATED_FROM_SDKMAN) != 0) {
+ msg =
+ "The Android SDK and AVD Manager that you are currently using has been updated. " +
+ "It is recommended that you now close the manager window and re-open it. " +
+ "If you use Eclipse, please run Help > Check for Updates to see if the Android " +
+ "plug-in needs to be updated.";
+ }
+
+ final String msg2 = msg;
final Shell shell = getWindowShell();
- if (shell != null && !shell.isDisposed()) {
+ if (msg2 != null && shell != null && !shell.isDisposed()) {
shell.getDisplay().syncExec(new Runnable() {
public void run() {
if (!shell.isDisposed()) {
- MessageDialog.openInformation(getWindowShell(),
+ MessageDialog.openInformation(shell,
"Android Tools Updated",
- "The Android SDK and AVD Manager that you are currently using has been updated. " +
- "It is recommended that you now close the manager window and re-open it. " +
- "If you started this window from Eclipse, please check if the Android " +
- "plug-in needs to be updated.");
+ msg2);
}
}
});
@@ -686,11 +705,15 @@ public class UpdaterData implements IUpdaterData { * @param selectedArchives The list of remote archives to consider for the update.
* This can be null, in which case a list of remote archive is fetched from all
* available sources.
+ * @param includeObsoletes True if obsolete packages should be used when resolving what
+ * to update.
+ * @param flags Optional flags for the installer, such as {@link #NO_TOOLS_MSG}.
* @return A list of archives that have been installed. Can be null if nothing was done.
*/
public List<Archive> updateOrInstallAll_WithGUI(
Collection<Archive> selectedArchives,
- boolean includeObsoletes) {
+ boolean includeObsoletes,
+ int flags) {
// Note: we no longer call refreshSources(true) here. This will be done
// automatically by computeUpdates() iif it needs to access sources to
@@ -723,7 +746,7 @@ public class UpdaterData implements IUpdaterData { ArrayList<ArchiveInfo> result = dialog.getResult();
if (result != null && result.size() > 0) {
- return installArchives(result);
+ return installArchives(result, flags);
}
return null;
}
@@ -922,7 +945,7 @@ public class UpdaterData implements IUpdaterData { }
mSdkLog.printf("\nDry mode is on so nothing is actually being installed.\n");
} else {
- return installArchives(archives);
+ return installArchives(archives, NO_TOOLS_MSG);
}
} else {
mSdkLog.printf("There is nothing to install or update.\n");
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/LocalPackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/LocalPackagesPage.java index b12cd39..4858f9a 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/LocalPackagesPage.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/LocalPackagesPage.java @@ -232,7 +232,8 @@ public class LocalPackagesPage extends UpdaterPage implements ISdkChangeListener private void onUpdateSelected() {
mUpdaterData.updateOrInstallAll_WithGUI(
null /*selectedArchives*/,
- false /* includeObsoletes */);
+ false /* includeObsoletes */,
+ 0 /* flags */);
}
private void onDeleteSelected() {
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/RemotePackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/RemotePackagesPage.java index 541424a..9e157cb 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/RemotePackagesPage.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/RemotePackagesPage.java @@ -342,7 +342,8 @@ public class RemotePackagesPage extends UpdaterPage implements ISdkChangeListene if (mUpdaterData != null) { mUpdaterData.updateOrInstallAll_WithGUI( archives, - mUpdateOnlyCheckBox.getSelection() /* includeObsoletes */); + mUpdateOnlyCheckBox.getSelection() /* includeObsoletes */, + 0 /* flags */); } } diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/SdkUpdaterWindowImpl1.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/SdkUpdaterWindowImpl1.java index 844a630..37f849c 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/SdkUpdaterWindowImpl1.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman1/SdkUpdaterWindowImpl1.java @@ -321,7 +321,8 @@ public class SdkUpdaterWindowImpl1 implements ISdkUpdaterWindow { if (mRequestAutoUpdate) {
mUpdaterData.updateOrInstallAll_WithGUI(
null /*selectedArchives*/,
- false /* includeObsoletes */);
+ false /* includeObsoletes */,
+ 0 /* flags */);
}
return true;
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java index 069102e..6e7c611 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java @@ -226,7 +226,9 @@ public class AdtUpdateDialog extends SwtBaseDialog { @Override
protected void eventLoop() {
- mPackageMananger.loadPackagesWithInstallTask(new IAutoInstallTask() {
+ mPackageMananger.loadPackagesWithInstallTask(
+ mPackageFilter.installFlags(),
+ new IAutoInstallTask() {
public Package[] filterLoadedSource(SdkSource source, Package[] packages) {
for (Package pkg : packages) {
mPackageFilter.visit(pkg);
@@ -282,6 +284,9 @@ public class AdtUpdateDialog extends SwtBaseDialog { // ----
private static abstract class PackageFilter {
+ /** Returns the installer flags for the corresponding mode. */
+ abstract int installFlags();
+
/** Visit a new package definition, in case we need to adjust the filter dynamically. */
abstract void visit(Package pkg);
@@ -310,6 +315,11 @@ public class AdtUpdateDialog extends SwtBaseDialog { void visit(Package pkg) {
// nop
}
+
+ @Override
+ int installFlags() {
+ return UpdaterData.TOOLS_MSG_UPDATED_FROM_ADT;
+ }
};
}
@@ -344,6 +354,11 @@ public class AdtUpdateDialog extends SwtBaseDialog { }
}
}
+
+ @Override
+ int installFlags() {
+ return UpdaterData.TOOLS_MSG_UPDATED_FROM_ADT;
+ }
};
}
@@ -398,6 +413,11 @@ public class AdtUpdateDialog extends SwtBaseDialog { }
}
}
+
+ @Override
+ int installFlags() {
+ return UpdaterData.NO_TOOLS_MSG;
+ }
};
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java index 12ddf6e..63224bd 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java @@ -336,7 +336,10 @@ public class AvdManagerWindowImpl1 { if (mRequestAutoUpdate) {
mUpdaterData.updateOrInstallAll_WithGUI(
null /*selectedArchives*/,
- false /* includeObsoletes */);
+ false /* includeObsoletes */,
+ mContext == AvdInvocationContext.IDE ?
+ UpdaterData.TOOLS_MSG_UPDATED_FROM_ADT :
+ UpdaterData.TOOLS_MSG_UPDATED_FROM_SDKMAN);
}
return true;
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackageLoader.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackageLoader.java index f296cb0..fdef221 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackageLoader.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackageLoader.java @@ -82,9 +82,9 @@ class PackageLoader { /** * Interface describing the task of installing a specific package. * For details on the operation, - * see {@link PackageLoader#loadPackagesWithInstallTask(IAutoInstallTask)}. + * see {@link PackageLoader#loadPackagesWithInstallTask(int, IAutoInstallTask)}. * - * @see PackageLoader#loadPackagesWithInstallTask(IAutoInstallTask) + * @see PackageLoader#loadPackagesWithInstallTask(int, IAutoInstallTask) */ public interface IAutoInstallTask { /** @@ -227,9 +227,13 @@ class PackageLoader { * The call is blocking. Although the name says "Task", this is not an {@link ITask} * running in its own thread but merely a synchronous call. * + * @param installFlags Flags for installation such as + * {@link UpdaterData#TOOLS_MSG_UPDATED_FROM_ADT}. * @param installTask The task to perform. */ - public void loadPackagesWithInstallTask(final IAutoInstallTask installTask) { + public void loadPackagesWithInstallTask( + final int installFlags, + final IAutoInstallTask installTask) { loadPackages(new ISourceLoadedCallback() { List<Archive> mArchivesToInstall = new ArrayList<Archive>(); @@ -306,7 +310,8 @@ class PackageLoader { List<Archive> archives = mUpdaterData.updateOrInstallAll_WithGUI( archivesToInstall, - true /* includeObsoletes */); + true /* includeObsoletes */, + installFlags); if (archives != null) { installedArchives.addAll(archives); 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 0967fc8..bb72745 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 @@ -29,6 +29,7 @@ import com.android.sdkuilib.internal.repository.icons.ImageFactory; import com.android.sdkuilib.internal.repository.sdkman2.PackageLoader.ISourceLoadedCallback; import com.android.sdkuilib.internal.repository.sdkman2.PkgItem.PkgState; import com.android.sdkuilib.repository.ISdkChangeListener; +import com.android.sdkuilib.repository.SdkUpdaterWindow.SdkInvocationContext; import com.android.sdkuilib.ui.GridDataBuilder; import com.android.sdkuilib.ui.GridLayoutBuilder; @@ -127,8 +128,11 @@ public class PackagesPage extends UpdaterPage private final Map<MenuAction, MenuItem> mMenuActions = new HashMap<MenuAction, MenuItem>(); + private final SdkInvocationContext mContext; + private final UpdaterData mUpdaterData; private final PackagesDiffLogic mDiffLogic; private boolean mDisplayArchives = false; + private boolean mOperationPending; private Text mTextSdkOsPath; private Button mCheckSortSource; @@ -149,12 +153,15 @@ public class PackagesPage extends UpdaterPage private TreeViewerColumn mColumnStatus; private Font mTreeFontItalic; private TreeColumn mTreeColumnName; - private boolean mOperationPending; - private final UpdaterData mUpdaterData; - public PackagesPage(Composite parent, int swtStyle, UpdaterData updaterData) { + public PackagesPage( + Composite parent, + int swtStyle, + UpdaterData updaterData, + SdkInvocationContext context) { super(parent, swtStyle); mUpdaterData = updaterData; + mContext = context; mDiffLogic = new PackagesDiffLogic(updaterData); @@ -1091,7 +1098,10 @@ public class PackagesPage extends UpdaterPage List<Archive> installed = mUpdaterData.updateOrInstallAll_WithGUI( archives, - mCheckFilterObsolete.getSelection() /* includeObsoletes */); + mCheckFilterObsolete.getSelection() /* includeObsoletes */, + mContext == SdkInvocationContext.IDE ? + UpdaterData.TOOLS_MSG_UPDATED_FROM_ADT : + UpdaterData.TOOLS_MSG_UPDATED_FROM_SDKMAN); needsRefresh = installed != null && !installed.isEmpty(); } finally { endOperationPending(); diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java index 1d0c484..89754e0 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java @@ -189,7 +189,7 @@ public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow { private void createContents() {
- mPkgPage = new PackagesPage(mShell, SWT.NONE, mUpdaterData);
+ mPkgPage = new PackagesPage(mShell, SWT.NONE, mUpdaterData, mContext);
mPkgPage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
Composite composite1 = new Composite(mShell, SWT.NONE);
@@ -512,7 +512,10 @@ public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow { if (mRequestAutoUpdate) {
mUpdaterData.updateOrInstallAll_WithGUI(
null /*selectedArchives*/,
- false /* includeObsoletes */);
+ false /* includeObsoletes */,
+ mContext == SdkInvocationContext.IDE ?
+ UpdaterData.TOOLS_MSG_UPDATED_FROM_ADT :
+ UpdaterData.TOOLS_MSG_UPDATED_FROM_SDKMAN);
}
// Tell the one page its the selected one
diff --git a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/MockUpdaterData.java b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/MockUpdaterData.java index 215c2cf..897e012 100755 --- a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/MockUpdaterData.java +++ b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/MockUpdaterData.java @@ -47,9 +47,9 @@ public class MockUpdaterData extends UpdaterData { setImageFactory(new NullImageFactory()); } - /** Gives access to the internal {@link #installArchives(List)}. */ + /** Gives access to the internal {@link #installArchives(List, int)}. */ public void _installArchives(List<ArchiveInfo> result) { - installArchives(result); + installArchives(result, 0/*flags*/); } public ArchiveReplacement[] getInstalled() { |