Search in sources :

Example 1 with IdDisplay

use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.

the class FormFactorUtils method getTag.

/**
   * Return the tag for the specified repository package.
   * We are only interested in 2 package types.
   */
@Nullable
static IdDisplay getTag(@NotNull RepoPackage repoPackage) {
    TypeDetails details = repoPackage.getTypeDetails();
    IdDisplay tag = NO_MATCH;
    if (details instanceof DetailsTypes.AddonDetailsType) {
        tag = ((DetailsTypes.AddonDetailsType) details).getTag();
    }
    if (details instanceof DetailsTypes.SysImgDetailsType) {
        DetailsTypes.SysImgDetailsType imgDetailsType = (DetailsTypes.SysImgDetailsType) details;
        if (imgDetailsType.getAbi().equals(SdkConstants.CPU_ARCH_INTEL_ATOM)) {
            tag = imgDetailsType.getTag();
        }
    }
    return tag;
}
Also used : TypeDetails(com.android.repository.impl.meta.TypeDetails) IdDisplay(com.android.sdklib.repository.IdDisplay) DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with IdDisplay

use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.

the class AvdDeviceData method updateValuesFromDevice.

public void updateValuesFromDevice(@NotNull Device device, @Nullable SystemImageDescription systemImage) {
    myName.set(device.getDisplayName());
    String tagId = device.getTagId();
    if (myTagId.get().isEmpty()) {
        myTagId.set(SystemImage.DEFAULT_TAG.getId());
        myDeviceType.setValue(SystemImage.DEFAULT_TAG);
    } else {
        for (IdDisplay tag : AvdWizardUtils.ALL_DEVICE_TAGS) {
            if (tag.getId().equals(tagId)) {
                myDeviceType.setValue(tag);
                break;
            }
        }
    }
    Hardware defaultHardware = device.getDefaultHardware();
    Screen screen = defaultHardware.getScreen();
    myDiagonalScreenSize.set(screen.getDiagonalLength());
    myScreenResolutionWidth.set(screen.getXDimension());
    myScreenResolutionHeight.set(screen.getYDimension());
    /**
     * This is maxed out at {@link AvdWizardUtils.MAX_RAM_MB}, for more information read
     * {@link AvdWizardUtils#getDefaultRam(Hardware)}
     */
    myRamStorage.set(AvdWizardUtils.getDefaultRam(defaultHardware));
    myHasHardwareButtons.set(defaultHardware.getButtonType() == ButtonType.HARD);
    myHasHardwareKeyboard.set(defaultHardware.getKeyboard() != Keyboard.NOKEY);
    myNavigation.setValue(defaultHardware.getNav());
    myDensity.set(defaultHardware.getScreen().getPixelDensity());
    List<State> states = device.getAllStates();
    mySupportsPortrait.set(false);
    mySupportsLandscape.set(false);
    for (State state : states) {
        if (state.isDefaultState()) {
            myDefaultState = state;
        }
        if (state.getOrientation().equals(ScreenOrientation.PORTRAIT)) {
            mySupportsPortrait.set(true);
        }
        if (state.getOrientation().equals(ScreenOrientation.LANDSCAPE)) {
            mySupportsLandscape.set(true);
        }
        if (state.getHardware().getScreen().getRatio().equals(ScreenRatio.NOTLONG)) {
            myNotLong.set(true);
        }
    }
    myHasFrontCamera.set(defaultHardware.getCamera(CameraLocation.FRONT) != null);
    myHasBackCamera.set(defaultHardware.getCamera(CameraLocation.BACK) != null);
    myHasAccelerometer.set(defaultHardware.getSensors().contains(Sensor.ACCELEROMETER));
    myHasGyroscope.set(defaultHardware.getSensors().contains(Sensor.GYROSCOPE));
    myHasGps.set(defaultHardware.getSensors().contains(Sensor.GPS));
    myHasProximitySensor.set(defaultHardware.getSensors().contains(Sensor.PROXIMITY_SENSOR));
    myIsTv.set(HardwareConfigHelper.isTv(device));
    myIsWear.set(HardwareConfigHelper.isWear(device));
    myIsScreenRound.set(device.isScreenRound());
    myScreenChinSize.set(device.getChinSize());
    updateSkinFromDeviceAndSystemImage(device, systemImage);
}
Also used : IdDisplay(com.android.sdklib.repository.IdDisplay)

Example 3 with IdDisplay

use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.

the class ChooseSystemImagePanel method systemImageMatchesDevice.

public static boolean systemImageMatchesDevice(@Nullable SystemImageDescription image, @Nullable Device device) {
    if (device == null || image == null) {
        return false;
    }
    String deviceTagId = device.getTagId();
    IdDisplay imageTag = image.getTag();
    // Unknown/generic device?
    if (deviceTagId == null || deviceTagId.equals(SystemImage.DEFAULT_TAG.getId())) {
        // system images (see issue #78947), we instead deliberately skip the other form factor images
        return imageTag.equals(SystemImage.DEFAULT_TAG) || !imageTag.equals(SystemImage.TV_TAG) && !imageTag.equals(SystemImage.WEAR_TAG);
    }
    return deviceTagId.equals(imageTag.getId());
}
Also used : IdDisplay(com.android.sdklib.repository.IdDisplay)

Example 4 with IdDisplay

use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.

the class EmulatorTargetConfigurable method getAvdCompatibilityWarning.

@Nullable
private String getAvdCompatibilityWarning() {
    IdDisplay selectedItem = (IdDisplay) myAvdCombo.getComboBox().getSelectedItem();
    if (selectedItem != null) {
        final String selectedAvdName = selectedItem.getId();
        final Module module = myContext.getModule();
        if (module == null) {
            return null;
        }
        final AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet == null) {
            return null;
        }
        final AvdManager avdManager = facet.getAvdManagerSilently();
        if (avdManager == null) {
            return null;
        }
        final AvdInfo avd = avdManager.getAvd(selectedAvdName, false);
        if (avd == null || avd.getSystemImage() == null) {
            return null;
        }
        AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
        if (platform == null) {
            return null;
        }
        AndroidVersion minSdk = AndroidModuleInfo.get(facet).getRuntimeMinSdkVersion();
        LaunchCompatibility compatibility = LaunchCompatibility.canRunOnAvd(minSdk, platform.getTarget(), avd.getSystemImage());
        if (compatibility.isCompatible() == ThreeState.NO) {
            // todo: provide info about current module configuration
            return String.format("'%1$s' may be incompatible with your configuration (%2$s)", selectedAvdName, StringUtil.notNullize(compatibility.getReason()));
        }
    }
    return null;
}
Also used : IdDisplay(com.android.sdklib.repository.IdDisplay) LaunchCompatibility(com.android.tools.idea.run.LaunchCompatibility) AvdManager(com.android.sdklib.internal.avd.AvdManager) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) Module(com.intellij.openapi.module.Module) AndroidVersion(com.android.sdklib.AndroidVersion) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with IdDisplay

use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.

the class EmulatorTargetConfigurable method applyTo.

@Override
public void applyTo(@NotNull EmulatorTargetProvider.State state, int uniqueID) {
    state.PREFERRED_AVD = "";
    JComboBox combo = myAvdCombo.getComboBox();
    IdDisplay preferredAvd = (IdDisplay) combo.getSelectedItem();
    if (preferredAvd == null) {
        state.PREFERRED_AVD = myIncorrectPreferredAvd != null ? myIncorrectPreferredAvd : "";
    } else {
        state.PREFERRED_AVD = preferredAvd.getId();
    }
}
Also used : IdDisplay(com.android.sdklib.repository.IdDisplay)

Aggregations

IdDisplay (com.android.sdklib.repository.IdDisplay)13 Module (com.intellij.openapi.module.Module)3 Nullable (org.jetbrains.annotations.Nullable)3 TypeDetails (com.android.repository.impl.meta.TypeDetails)2 AndroidVersion (com.android.sdklib.AndroidVersion)2 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)2 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)2 TextProperty (com.android.tools.idea.ui.properties.swing.TextProperty)2 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)2 AndroidDebugBridge (com.android.ddmlib.AndroidDebugBridge)1 IDevice (com.android.ddmlib.IDevice)1 State (com.android.sdklib.devices.State)1 AvdManager (com.android.sdklib.internal.avd.AvdManager)1 AvdComboBox (com.android.tools.idea.run.AvdComboBox)1 LaunchCompatibility (com.android.tools.idea.run.LaunchCompatibility)1 StringToDoubleAdapterProperty (com.android.tools.idea.ui.properties.adapters.StringToDoubleAdapterProperty)1 StringToIntAdapterProperty (com.android.tools.idea.ui.properties.adapters.StringToIntAdapterProperty)1 SelectedItemProperty (com.android.tools.idea.ui.properties.swing.SelectedItemProperty)1 SelectedProperty (com.android.tools.idea.ui.properties.swing.SelectedProperty)1 Result (com.android.tools.idea.ui.validation.Validator.Result)1