本文整理汇总了Java中org.jetbrains.android.sdk.AndroidSdkUtils类的典型用法代码示例。如果您正苦于以下问题:Java AndroidSdkUtils类的具体用法?Java AndroidSdkUtils怎么用?Java AndroidSdkUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndroidSdkUtils类属于org.jetbrains.android.sdk包,在下文中一共展示了AndroidSdkUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectedDevices
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
@NotNull
public IDevice[] getSelectedDevices() {
int[] rows = mySelectedRows != null ? mySelectedRows : myDeviceTable.getSelectedRows();
List<IDevice> result = new ArrayList<IDevice>();
for (int row : rows) {
if (row >= 0) {
Object serial = myDeviceTable.getValueAt(row, SERIAL_COLUMN_INDEX);
final AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject());
if (bridge == null) {
return EMPTY_DEVICE_ARRAY;
}
IDevice[] devices = getFilteredDevices(bridge);
for (IDevice device : devices) {
if (device.getSerialNumber().equals(serial.toString())) {
result.add(device);
break;
}
}
}
}
return result.toArray(new IDevice[result.size()]);
}
示例2: chooseDevice
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
private IDevice chooseDevice() {
AndroidDebugBridge adb = AndroidSdkUtils.getDebugBridge(project);
if (adb == null) {
showErrorNotification("ADB connection error");
return null;
}
List<IDevice> devices = Arrays.asList(adb.getDevices());
if (devices.isEmpty()) {
showErrorNotification("Can't find any devices");
return null;
}
if (devices.size() == 1) {
return devices.get(0);
}
return new ChooseDialog<IDevice>(project, "Choose Device", devices) {
@Override
protected String getItemName(IDevice d) {
return d.getProperty(IDevice.PROP_DEVICE_MANUFACTURER) + " " + d.getProperty(IDevice.PROP_DEVICE_MODEL)
+ " [" + d.getSerialNumber() + "]";
}
}
.showAndGetResult();
}
示例3: computeDownloadSize
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
private long computeDownloadSize(List<IPkgDesc> packages) {
AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk();
SdkState state = SdkState.getInstance(data);
// Should already be loaded at this point--just reload to be sure.
state.loadSynchronously(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, false);
Map<String, UpdatablePkgInfo> sdkPackages = state.getPackages().getConsolidatedPkgs();
long size = 0;
boolean preview =
SdkComponentSource.PREVIEW_CHANNEL.equals(UpdateSettings.getInstance().getExternalUpdateChannels().get(SdkComponentSource.NAME));
for (IPkgDesc pkg : packages) {
String iid = pkg.getInstallId();
UpdatablePkgInfo updatablePkgInfo = sdkPackages.get(iid);
if (updatablePkgInfo == null && iid.endsWith(PkgDesc.PREVIEW_SUFFIX)) {
iid = iid.substring(0, iid.indexOf(PkgDesc.PREVIEW_SUFFIX));
updatablePkgInfo = sdkPackages.get(iid);
}
size += updatablePkgInfo.getRemote(preview).getDownloadSize();
}
return size;
}
示例4: fetchPackages
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
@NotNull
private static Multimap<PkgType, RemotePkgInfo> fetchPackages() {
ConnectionState connectionState = checkInternetConnection();
switch (connectionState) {
case OK:
break;
case NO_CONNECTION:
return ImmutableMultimap.of();
default:
throw new IllegalArgumentException(connectionState.name());
}
SdkState state = SdkState.getInstance(AndroidSdkUtils.tryToChooseAndroidSdk());
state.loadSynchronously(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, true);
return state.getPackages().getRemotePkgInfos();
}
示例5: getSdkDownloadUrl
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
/**
* @return Android SDK download URL
*/
@NotNull
public static String getSdkDownloadUrl() {
String url = System.getProperty("android.sdkurl");
if (!StringUtil.isEmptyOrSpaces(url)) {
File file = new File(url);
if (file.isFile()) {
// Can't use any path => URL utilities as they don't add two slashes
// after the protocol as required by IJ downloader
return LocalFileSystem.PROTOCOL_PREFIX + PathUtil.toSystemIndependentName(file.getAbsolutePath());
}
else {
System.err.println("File " + file.getAbsolutePath() + " does not exist.");
}
}
String downloadUrl = AndroidSdkUtils.getSdkDownloadUrl();
if (downloadUrl == null) {
throw new IllegalStateException("Unsupported OS");
}
return downloadUrl;
}
示例6: getInitialSdkLocation
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
/**
* Returns initial SDK location. That will be the SDK location from the installer
* handoff file in the handoff case, sdk location location from the preference if set
* or platform-dependant default path.
*/
@NotNull
public static File getInitialSdkLocation(@NotNull FirstRunWizardMode mode) {
File dest = mode.getSdkLocation();
if (dest != null) {
return dest;
}
else {
List<Sdk> sdks = AndroidSdkUtils.getAllAndroidSdks();
Sdk sdk = Iterables.getFirst(sdks, null);
if (sdk != null) {
VirtualFile homeDirectory = sdk.getHomeDirectory();
if (homeDirectory != null) {
return VfsUtilCore.virtualToIoFile(homeDirectory);
}
}
return getDefaultSdkLocation();
}
}
示例7: getLabel
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
@NotNull
private static String getLabel(@NotNull IAndroidTarget target) {
if (target.isPlatform()
&& target.getVersion().getApiLevel() <= SdkVersionInfo.HIGHEST_KNOWN_API) {
if (target.getVersion().isPreview()) {
return target.getVersion().getApiString() + ": " + target.getName();
}
String name = SdkVersionInfo.getAndroidName(target.getVersion().getApiLevel());
if (name == null) {
return "API " + Integer.toString(target.getVersion().getApiLevel());
} else {
return name;
}
} else {
return AndroidSdkUtils.getTargetLabel(target);
}
}
示例8: putSdkDependentParams
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
/**
* Populate the given state with a set of variables that depend on the user's installed SDK. This method should
* be called early in the initialization of a wizard or path.
* Variables:
* Build Tools Version: Used to populate the project level build.gradle with the correct Gradle plugin version number
* If the required build tools version is not installed, a request is added for installation
* SDK Home: The location of the installed SDK
* @param state the state store to populate with the values stored in the SDK
*/
public static void putSdkDependentParams(@NotNull ScopedStateStore state) {
final AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
BuildToolInfo buildTool = sdkData != null ? sdkData.getLatestBuildTool() : null;
FullRevision minimumRequiredBuildToolVersion = FullRevision.parseRevision(SdkConstants.MIN_BUILD_TOOLS_VERSION);
if (buildTool != null && buildTool.getRevision().compareTo(minimumRequiredBuildToolVersion) >= 0) {
state.put(WizardConstants.BUILD_TOOLS_VERSION_KEY, buildTool.getRevision().toString());
} else {
// We need to install a new build tools version
state.listPush(WizardConstants.INSTALL_REQUESTS_KEY, PkgDesc.Builder.newBuildTool(minimumRequiredBuildToolVersion).create());
state.put(WizardConstants.BUILD_TOOLS_VERSION_KEY, minimumRequiredBuildToolVersion.toString());
}
if (sdkData != null) {
// Gradle expects a platform-neutral path
state.put(WizardConstants.SDK_HOME_KEY, FileUtil.toSystemIndependentName(sdkData.getPath()));
}
}
示例9: actionPerformed
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
Notifications.Bus.notify(new Notification("Android", "ADB", "ADB requested.", NotificationType.INFORMATION));
Project project = getEventProject(e);
File adb = project == null ? null : AndroidSdkUtils.getAdb(project);
if (adb == null) {
return;
}
ListenableFuture<AndroidDebugBridge> bridge = AdbService.getInstance().getDebugBridge(adb);
Futures.addCallback(bridge, new FutureCallback<AndroidDebugBridge>() {
@Override
public void onSuccess(AndroidDebugBridge result) {
Notifications.Bus.notify(new Notification("Android", "ADB", "ADB obtained", NotificationType.INFORMATION));
}
@Override
public void onFailure(Throwable t) {
Notifications.Bus.notify(new Notification("Android", "ADB", "ADB error: " + t.toString(), NotificationType.INFORMATION));
}
});
}
示例10: findProblemPackages
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
/**
* Find packages that might not be able to be installed while studio is running.
* Currently this means packages that are upgrades on windows systems, since windows locks files that are in use.
* @return
*/
private Set<IPkgDesc> findProblemPackages() {
Set<IPkgDesc> result = Sets.newHashSet();
if (!SystemInfo.isWindows) {
return result;
}
SdkState state = SdkState.getInstance(AndroidSdkUtils.tryToChooseAndroidSdk());
state.loadSynchronously(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, false);
Set<String> available = Sets.newHashSet();
for (UpdatablePkgInfo update : state.getPackages().getUpdatedPkgs()) {
if (update.hasRemote(false)) {
available.add(update.getRemote(false).getPkgDesc().getInstallId());
}
if (update.hasPreview()) {
available.add(update.getRemote(true).getPkgDesc().getInstallId());
}
}
for (IPkgDesc request : myRequestedPackages) {
if (available.contains(request.getInstallId())) {
// This is an update
result.add(request);
}
}
return result;
}
示例11: performFinishingActions
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
@Override
public void performFinishingActions() {
List<IPkgDesc> skipped = myState.get(SKIPPED_INSTALL_REQUESTS_KEY);
if (skipped != null && !skipped.isEmpty()) {
StringBuilder warningBuilder = new StringBuilder("The following packages were not installed.\n\n Would you like to exit ");
warningBuilder.append(ApplicationNamesInfo.getInstance().getFullProductName());
warningBuilder.append(" and install the following packages using the standalone SDK manager?");
for (IPkgDesc problemPkg : skipped) {
warningBuilder.append("\n");
warningBuilder.append(problemPkg.getListDescription());
}
String restartOption = String.format("Exit %s and launch SDK Manager", ApplicationNamesInfo.getInstance().getProductName());
int result = Messages.showDialog(getProject(), warningBuilder.toString(), "Warning", new String[]{restartOption, "Skip installation"},
0, AllIcons.General.Warning);
if (result == 0) {
startSdkManagerAndExit();
}
}
// We've already installed things, so clearly there's an SDK.
AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk();
SdkState.getInstance(data).loadAsync(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, true);
}
示例12: getRemoteArchives
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
private List<ArchiveInfo> getRemoteArchives(boolean includeAll) {
SdkState state = SdkState.getInstance(AndroidSdkUtils.tryToChooseAndroidSdk());
state.loadSynchronously(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, false);
List<ArchiveInfo> result = Lists.newArrayList();
for (UpdatablePkgInfo update : state.getPackages().getConsolidatedPkgs().values()) {
for (RemotePkgInfo remote : update.getAllRemotes()) {
if (includeAll || !remote.isObsolete()) {
for (Archive archive : remote.getArchives()) {
if (archive.isCompatible()) {
result.add(new ArchiveInfo(archive, update.getLocalInfo(), null));
}
}
}
}
}
return result;
}
示例13: testGradlePlus
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
public void testGradlePlus() throws Exception {
// Needs a valid SDK; can't use the mock one in the test data.
AndroidSdkData prevSdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (prevSdkData == null) {
String recentSdkPath = AndroidTestBase.getRecentSdkPath();
String platformDir = AndroidTestBase.getRecentPlatformDir();
if (recentSdkPath == null || platformDir == null) {
System.out.println("Not running " + this.getClass() + "#" + getName() + ": Needs SDK with Support Repo installed");
return;
}
Sdk androidSdk = createAndroidSdk(recentSdkPath, platformDir);
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(androidSdk);
assertNotNull(androidPlatform);
// Put default platforms in the list before non-default ones so they'll be looked at first.
AndroidSdkUtils.setSdkData(androidPlatform.getSdkData());
}
// NOTE: The android support repository must be installed in the SDK used by the test!
doTestWithFix(new AndroidLintInspectionToolProvider.AndroidLintGradleDynamicVersionInspection(),
"Replace with specific version", "build.gradle", "gradle");
AndroidSdkUtils.setSdkData(prevSdkData);
}
示例14: testJdk7
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
public void testJdk7() throws Exception {
if (DISABLED) {
return;
}
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
assertNotNull(sdkData);
if (ConfigureAndroidModuleStep.isJdk7Supported(sdkData)) {
IAndroidTarget[] targets = sdkData.getTargets();
IAndroidTarget target = targets[targets.length - 1];
Map<String,Object> overrides = Maps.newHashMap();
overrides.put(ATTR_JAVA_VERSION, "1.7");
NewProjectWizardState state = createNewProjectState(true, sdkData);
// TODO: Allow null activity state!
File activity = findTemplate("activities", "BlankActivity");
TemplateWizardState activityState = state.getActivityTemplateState();
assertNotNull(activity);
activityState.setTemplateLocation(activity);
checkApiTarget(19, 19, target, state, "Test17", null, overrides);
} else {
System.out.println("JDK 7 not supported by current SDK manager: not testing");
}
}
示例15: testJdk5
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入依赖的package包/类
public void testJdk5() throws Exception {
if (DISABLED) {
return;
}
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
assertNotNull(sdkData);
IAndroidTarget[] targets = sdkData.getTargets();
IAndroidTarget target = targets[targets.length - 1];
Map<String,Object> overrides = Maps.newHashMap();
overrides.put(ATTR_JAVA_VERSION, "1.5");
NewProjectWizardState state = createNewProjectState(true, sdkData);
// TODO: Allow null activity state!
File activity = findTemplate("activities", "BlankActivity");
TemplateWizardState activityState = state.getActivityTemplateState();
assertNotNull(activity);
activityState.setTemplateLocation(activity);
checkApiTarget(8, 18, target, state, "Test15", null, overrides);
}