com.android.sdklib.devices.Device Java Examples

The following examples show how to use com.android.sdklib.devices.Device. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AvdManager.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
String getResolution(AvdInfo info) {
    Device device = deviceManager.getDevice(info.getDeviceName(), info.getDeviceManufacturer());
    Dimension res = null;
    Density density = null;
    if (device != null) {
        res = device.getScreenSize(device.getDefaultState().getOrientation());
        density = device.getDefaultHardware().getScreen().getPixelDensity();
    }
    String resolution;
    String densityString = density == null ? "Unknown Density" : density.getResourceValue();
    if (res != null) {
        resolution = String.format(Locale.getDefault(), "%1$d \u00D7 %2$d: %3$s", res.width, res.height, densityString);
    } else {
        resolution = "Unknown Resolution";
    }
    return resolution;
}
 
Example #2
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a user-displayable description of the given generic device
 * @param device the device to check
 * @return the label
 * @see #isGeneric(Device)
 */
@NonNull
public static String getGenericLabel(@NonNull Device device) {
    // * Use the same precision for all devices (all but one specify decimals)
    // * Add some leading space such that the dot ends up roughly in the
    //   same space
    // * Add in screen resolution and density
    String name = device.getDisplayName();
    Matcher matcher = GENERIC_PATTERN.matcher(name);
    if (matcher.matches()) {
        String size = matcher.group(1);
        String n = matcher.group(2);
        int dot = size.indexOf('.');
        if (dot == -1) {
            size += ".0";
            dot = size.length() - 2;
        }
        for (int i = 0; i < 2 - dot; i++) {
            size = ' ' + size;
        }
        name = size + "\" " + n;
    }

    return String.format(Locale.US, "%1$s (%2$s)", name,
            getResolutionString(device));
}
 
Example #3
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Device device = devices.get(rowIndex);
    switch (columnIndex) {
        case 0:
            return device.getDisplayName();
        case 1:
            if (device.hasPlayStore()) {
                return new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/android/avd/manager/device-play-store.png"));
            }
            return null;
        case 2:
            return getDiagonalSize(device);
        case 3:
            return getDimensionString(device);
        case 4:
            return getDensityString(device);
        default:
            return "Err";
    }
}
 
Example #4
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private Device buildDevice() {
    builder.setPlayStore(playstore.isSelected());
    builder.addAllState(generateStates(buildHardware()));
    builder.setName(deviceName.getText());
    if (edit) {
        builder.setId(deviceName.getText());
    }else{
        builder.setId(getUniqueId(deviceName.getText()));
    }
    builder.setManufacturer("User");
    DeviceType dt = (DeviceType) deviceType.getSelectedItem();
    switch (dt) {
        default:
            builder.setTagId(null);
            break;
        case TV:
            builder.setTagId(DeviceType.TV.id);
            break;
        case WEAR:
            builder.setTagId(DeviceType.WEAR.id);
            break;

    }
    Software software = new Software();
    software.setLiveWallpaperSupport(true);
    software.setPlayStoreEnabled(playstore.isSelected());
    software.setGlVersion("2.0");
    builder.addSoftware(software);
    return builder.build();
}
 
Example #5
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void importProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importProfileButtonActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder builder = new FileChooserBuilder("android-devices");
    builder.setFilesOnly(true);
    builder.setFileFilter(new FileNameExtensionFilter("Android devide definition", "xml", "XML"));
    File[] files = builder.showMultiOpenDialog();
    if (files != null) {
        for (File file : files) {
            try {
                Table<String, String, Device> devices = DeviceParser.parse(file);
                Map<String, Map<String, Device>> rowMap = devices.rowMap();
                rowMap.values().stream().forEach((t) -> {
                    t.values().stream().forEach((d) -> {
                        Device device = AvdHwProfile.showDeviceProfiler(d, deviceManager, false);
                        if (device != null) {
                            deviceManager.addUserDevice(d);
                        }
                    });
                });
            } catch (Exception ex) {
                NotifyDescriptor nd = new NotifyDescriptor.Message("Error while parsing Android device definition!", NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notifyLater(nd);
            }
        }
        deviceManager.saveUserDevices();
        refreshDevices();
    }
}
 
Example #6
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void cloneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cloneButtonActionPerformed
    // TODO add your handling code here:
    if (selectedDevice != null) {
        Device device = AvdHwProfile.showDeviceProfiler(selectedDevice, deviceManager, false);
        if (device != null) {
            deviceManager.addUserDevice(device);
            deviceManager.saveUserDevices();
            refreshDevices();
        }

    }
}
 
Example #7
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static Device showDeviceProfiler(Device device, DeviceManager deviceManager,boolean edit) {
    final AvdHwProfile hwProfile = new AvdHwProfile(device, deviceManager,edit);
    DialogDescriptor dd = new DialogDescriptor(hwProfile, "Device profile editor", true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.CANCEL_OPTION, null);
    Object notify = DialogDisplayer.getDefault().notify(dd);
    if (DialogDescriptor.OK_OPTION.equals(notify)) {
        Device buildDevice = hwProfile.buildDevice();
        NbPreferences.forModule(CreateAvdVisualPanel1.class).putBoolean(buildDevice.getId(), buildDevice.hasPlayStore());
        return buildDevice;
    }
    return null;
}
 
Example #8
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void createProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createProfileButtonActionPerformed
    // TODO add your handling code here:
    Device device = AvdHwProfile.showDeviceProfiler(null, deviceManager, false);
    if (device != null) {
        deviceManager.addUserDevice(device);
        deviceManager.saveUserDevices();
        refreshDevices();
    }
}
 
Example #9
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public String getUniqueId( String id) {
    String baseId = id == null ? "New Device" : id;
    Collection<Device> devices = deviceManager.getDevices(DeviceManager.DeviceFilter.USER);
    String candidate = baseId;
    int i = 0;
    while (anyIdMatches(candidate, devices)) {
        candidate = String.format(Locale.getDefault(), "%s %d", baseId, ++i);
    }
    return candidate;
}
 
Example #10
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sorts the given list of Nexus devices according to rank
 * @param list the list to sort
 */
public static void sortNexusList(@NonNull List<Device> list) {
    Collections.sort(list, new Comparator<Device>() {
        @Override
        public int compare(Device device1, Device device2) {
            // Descending order of age
            return nexusRank(device2) - nexusRank(device1);
        }
    });
}
 
Example #11
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the rank of the given nexus device. This can be used to order
 * the devices chronologically.
 *
 * @param device the device to look up the rank for
 * @return the rank of the device
 */
public static int nexusRank(Device device) {
    String id = device.getId();
    if (id.equals("Nexus One")) {      //$NON-NLS-1$
        return 1;
    }
    if (id.equals("Nexus S")) {        //$NON-NLS-1$
        return 2;
    }
    if (id.equals("Galaxy Nexus")) {   //$NON-NLS-1$
        return 3;
    }
    if (id.equals("Nexus 7")) {        //$NON-NLS-1$
        return 4; // 2012 version
    }
    if (id.equals("Nexus 10")) {       //$NON-NLS-1$
        return 5;
    }
    if (id.equals("Nexus 4")) {        //$NON-NLS-1$
        return 6;
    }
    if (id.equals("Nexus 7 2013")) {   //$NON-NLS-1$
        return 7;
    }
    if (id.equals("Nexus 5")) {        //$NON-NLS-1$
      return 8;
    }
    if (id.equals("Nexus 9")) {        //$NON-NLS-1$
        return 9;
    }
    if (id.equals("Nexus 6")) {        //$NON-NLS-1$
        return 10;
    }

    return 100; // devices released in the future?
}
 
Example #12
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private static boolean anyIdMatches( String id,  Collection<Device> devices) {
    for (Device d : devices) {
        if (id.equalsIgnoreCase(d.getId())) {
            return true;
        }
    }
    return false;
}
 
Example #13
Source File: AvdManager.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the device-specific part of an AVD ini.
 * @param avd the AVD to update.
 * @param log the log object to receive action logs. Cannot be null.
 * @return The new AVD on success.
 * @throws IOException
 */
public AvdInfo updateDeviceChanged(AvdInfo avd, ILogger log) throws IOException {

    // Overwrite the properties derived from the device and nothing else
    Map<String, String> properties = new HashMap<String, String>(avd.getProperties());

    DeviceManager devMan = DeviceManager.createInstance(myLocalSdk.getLocation(), log);
    Collection<Device> devices = devMan.getDevices(DeviceManager.ALL_DEVICES);
    String name = properties.get(AvdManager.AVD_INI_DEVICE_NAME);
    String manufacturer = properties.get(AvdManager.AVD_INI_DEVICE_MANUFACTURER);

    if (properties != null && devices != null && name != null && manufacturer != null) {
        for (Device d : devices) {
            if (d.getId().equals(name) && d.getManufacturer().equals(manufacturer)) {
                properties.putAll(DeviceManager.getHardwareProperties(d));
                try {
                    return updateAvd(avd, properties, AvdStatus.OK, log);
                } catch (IOException e) {
                    log.error(e, null);
                }
            }
        }
    } else {
        log.error(null, "Base device information incomplete or missing.");
    }
    return null;
}
 
Example #14
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a user displayable screen resolution string for the given device
 * @param device the device to look up the string for
 * @return a user displayable string
 */
@NonNull
public static String getResolutionString(@NonNull Device device) {
    Screen screen = device.getDefaultHardware().getScreen();
    return String.format(Locale.US,
            "%1$d \u00D7 %2$d: %3$s", // U+00D7: Unicode multiplication sign
            screen.getXDimension(),
            screen.getYDimension(),
            screen.getPixelDensity().getResourceValue());
}
 
Example #15
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a user-displayable description of the given Nexus device
 * @param device the device to check
 * @return the label
 * @see #isNexus(com.android.sdklib.devices.Device)
 */
@NonNull
public static String getNexusLabel(@NonNull Device device) {
    String name = device.getDisplayName();
    Screen screen = device.getDefaultHardware().getScreen();
    float length = (float) screen.getDiagonalLength();
    // Round dimensions to the nearest tenth
    length = Math.round(10 * length) / 10.0f;
    return String.format(Locale.US, "%1$s (%3$s\", %2$s)",
            name, getResolutionString(device), Float.toString(length));
}
 
Example #16
Source File: CreateAvdVisualPanel3.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
void readSettings() {
    defaultSdk = (AndroidSdk) wiz.getProperty(ANDROID_SDK);
    avdManager = (AvdManager) wiz.getProperty(AVD_MANAGER);
    selectedDevice = (Device) wiz.getProperty(DEVICE_SELECTED);
    selectedImage = (SystemImageDescription) wiz.getProperty(SYSTEM_IMAGE);
    initAvdName();
    updateAvdId();
    defaultSkinPath = defaultSdk.getSdkPath() + File.separator + "skins";
    File skinFile = selectedDevice.getDefaultHardware().getSkinFile();
    String skinPath = defaultSdk.getSdkPath() + File.separator + "skins" + File.separator + skinFile;
    skinCombo.setModel(new SkinsComboboxModel(new File(defaultSkinPath)));
    skinCombo.setSelectedItem(new File(skinPath));
    skinCombo.setRenderer(new BasicComboBoxRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
            if ((component instanceof JLabel) && (value instanceof File)) {
                ((JLabel) component).setText(((File) value).getName());
            }
            return component;
        }

    });
    performanceGraphics.setSelectedItem(GpuMode.AUTO);
    avdName.getDocument().addDocumentListener(this);
    performanceCores.setModel(new javax.swing.SpinnerNumberModel(RECOMMENDED_NUMBER_OF_CORES, 1, MAX_NUMBER_OF_CORES, 1));
    //   initPlaystore();
    initMemory();
}
 
Example #17
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public DevicesTableModel(List<Device> devices) {
    this.devices = devices;
}
 
Example #18
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public static String getDiagonalSize(Device device) {
    return DF.format(device.getDefaultHardware().getScreen().getDiagonalLength()) + '"';
}
 
Example #19
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
private void initBootProperties( Device device) {
  for (Map.Entry<String, String> entry : device.getBootProps().entrySet()) {
    builder.addBootProp(entry.getKey(), entry.getValue());
  }
}
 
Example #20
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
/**
 * Creates new form AvdHwProfile
 */
public AvdHwProfile(Device device, DeviceManager deviceManager,boolean edit) {
    this.deviceManager = deviceManager;
    this.edit=edit;
    initComponents();
    deviceType.setModel(new DefaultComboBoxModel<>(DeviceType.values()));
    if (device != null) {
         String tagId = device.getTagId();
        initBootProperties(device);
        if (tagId == null) {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        } else if (DeviceType.TV.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (DeviceType.WEAR.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        }
        if (edit) {
            deviceName.setText(device.getDisplayName());
            deviceName.setEditable(false);
        }else{
            deviceName.setText(String.format("%s (Edited)", device.getDisplayName()));
        }
        if (CreateAvdVisualPanel1.isTv(device)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (HardwareConfigHelper.isWear(device)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        } else {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        }
        screenSize.setValue(device.getDefaultHardware().getScreen().getDiagonalLength());
        Dimension dimension = device.getScreenSize(device.getDefaultState().getOrientation());
        resolutionX.setValue(dimension.width);
        resolutionY.setValue(dimension.height);
        round.setSelected(device.isScreenRound());
        ram.setValue(device.getDefaultHardware().getRam().getSizeAsUnit(Storage.Unit.MiB));
        hwButt.setSelected(device.getDefaultHardware().getButtonType() == ButtonType.HARD);
        hwKeyb.setSelected(device.getDefaultHardware().getKeyboard() != Keyboard.NOKEY);
        List<State> states = device.getAllStates();
        portrait.setSelected(false);
        landscape.setSelected(false);
        for (State state : states) {
            if (state.getOrientation().equals(ScreenOrientation.PORTRAIT)) {
                portrait.setSelected(true);
            }
            if (state.getOrientation().equals(ScreenOrientation.LANDSCAPE)) {
                landscape.setSelected(true);
            }
        }
        Navigation nav = device.getDefaultHardware().getNav();
        switch (nav) {
            case NONAV:
                navigationStyle.setSelectedIndex(0);
                break;
            case DPAD:
                navigationStyle.setSelectedIndex(1);
                break;
            case TRACKBALL:
                navigationStyle.setSelectedIndex(2);
                break;
            case WHEEL:
                navigationStyle.setSelectedIndex(3);
                break;
        }
        cameraFront.setSelected(device.getDefaultHardware().getCamera(CameraLocation.FRONT) != null);
        cameraBack.setSelected(device.getDefaultHardware().getCamera(CameraLocation.BACK) != null);
        accelerometer.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.ACCELEROMETER));
        gyroscope.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GYROSCOPE));
        gps.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GPS));
        proximity.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.PROXIMITY_SENSOR));
        File skinFile = device.getDefaultHardware().getSkinFile();
        AndroidSdk defaultSdk = AndroidSdkProvider.getDefaultSdk();
        if (defaultSdk != null) {
            String skinPath = defaultSdk.getSdkPath() + File.separator + "skins";
            skin.setModel(new SkinsComboboxModel(new File(skinPath)));
        }
        skin.setSelectedItem(skinFile);
        playstore.setSelected(device.hasPlayStore());
    } else {
        deviceType.setSelectedItem(DeviceType.MOBILE);
        navigationStyle.setSelectedIndex(0);
        deviceName.setText(getUniqueId(null));
    }
    skin.setRenderer(new BasicComboBoxRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
            if ((component instanceof JLabel) && (value instanceof File)) {
                ((JLabel) component).setText(((File) value).getName());
            }
            return component;
        }

    });
}
 
Example #21
Source File: CreateAvdWizardIterator.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public Set<?> instantiate() throws IOException {
    // TODO return set of FileObject (or DataObject) you have created

    //path /home/arsi/.android/avd/Nexus_5_API_27.avd
    //avd name Nexus_5_API_27
    //skinFolder /jetty/android-studio-sdk/skins/nexus_5
    //skinname null
    //sdcard 512M
    //
    //hw.dPad => no  x
    //hw.lcd.height => 1920 x
    //fastboot.chosenSnapshotFile => 
    //runtime.network.speed => full
    //hw.accelerometer => yes x
    //hw.device.name => Nexus 5 x
    //vm.heapSize => 128
    //skin.dynamic => yes
    //hw.device.manufacturer => Google x
    //hw.lcd.width => 1080 x
    //skin.path => /jetty/android-studio-sdk/skins/nexus_5
    //hw.gps => yes x
    //hw.initialOrientation => Portrait
    //hw.audioInput => yes x
    //showDeviceFrame => yes
    //hw.camera.back => emulated
    //hw.mainKeys => no x
    //AvdId => Nexus_5_API_27
    //hw.lcd.density => 480 x
    //hw.camera.front => emulated
    //avd.ini.displayname => Nexus 5 API 27
    //hw.gpu.mode => auto/host/software
    //hw.device.hash2 => MD5:1c925b9117dd9f33c5128dac289a0d68 x
    //fastboot.forceChosenSnapshotBoot => no
    //fastboot.forceFastBoot => yes
    //hw.trackBall => no x
    //hw.ramSize => 1536
    //hw.battery => yes x
    //fastboot.forceColdBoot => no
    //hw.cpu.ncore => 4
    //hw.sdCard => yes xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    //runtime.network.latency => none
    //hw.keyboard => yes
    //hw.sensors.proximity => yes x
    //hw.sensors.orientation => yesx
    //disk.dataPartition.size => 2G
    //hw.gpu.enabled => yes
    //
    //dev has playstore true
    //create snapshot false
    //removeprev false
    //editExisting true
    AndroidSdk defaultSdk = (AndroidSdk) wizard.getProperty(ANDROID_SDK);
    AvdManager avdManager = (AvdManager) wizard.getProperty(AVD_MANAGER);
    Device selectedDevice = (Device) wizard.getProperty(DEVICE_SELECTED);
    SystemImageDescription selectedImage = (SystemImageDescription) wizard.getProperty(SYSTEM_IMAGE);
    String displayName = (String) wizard.getProperty(AVD_DISPLAY_NAME);
    String avdId = (String) wizard.getProperty(AVD_ID_NAME);
    Map<String, String> hardwareProperties = DeviceManager.getHardwareProperties(selectedDevice);
    Map<String, String> userHardwareProperties = (Map<String, String>) wizard.getProperty(AVD_USER_HW_CONFIG);
    hardwareProperties.putAll(userHardwareProperties);
    String skinPath = hardwareProperties.get("skin.path");
    String sdcard = (String) wizard.getProperty(AVD_SDCARD);
    try {
        String avdPath = avdManager.getBaseAvdFolder().getAbsoluteFile().getAbsolutePath() + File.separator + avdId + ".avd";
        avdManager.createAvd(new File(avdPath), avdId, selectedImage.getSystemImage(),
                new File(skinPath), null, sdcard, hardwareProperties, selectedDevice.getBootProps(), selectedDevice.hasPlayStore()&&selectedImage.getSystemImage().hasPlayStore(), false, false, true, new StdLogger(StdLogger.Level.INFO));
    } catch (AndroidLocation.AndroidLocationException androidLocationException) {
    }
    changeListener.stateChanged(null);
    return Collections.emptySet();
}
 
Example #22
Source File: AndroidSdkImpl.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<Device> getDevices() {
    return getDeviceManager().getDevices(DeviceManager.ALL_DEVICES);
}
 
Example #23
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public static String getDensityString(Device device) {
    return device.getDefaultHardware().getScreen().getPixelDensity().getResourceValue();
}
 
Example #24
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public static String getDimensionString(Device device) {
    Dimension size = device.getScreenSize(device.getDefaultState().getOrientation());
    return size == null ? "Unknown Resolution" : String.format(Locale.getDefault(), "%dx%d", size.width, size.height);
}
 
Example #25
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public static boolean isTv(Device d) {
    return HardwareConfigHelper.isTv(d) || d.getDefaultHardware().getScreen().getDiagonalLength() >= TV_SIZE_CUTOFF;
}
 
Example #26
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public static boolean isTablet(Device d) {
    return d.getDefaultHardware().getScreen().getDiagonalLength() >= PHONE_SIZE_CUTOFF;
}
 
Example #27
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public static boolean isPhone(Device d) {
    return d.getDefaultHardware().getScreen().getDiagonalLength() < PHONE_SIZE_CUTOFF;
}
 
Example #28
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
private void refreshDevices() {
    List<Device> allDevices = new ArrayList<>(deviceManager.getDevices(EnumSet.of(DeviceManager.DeviceFilter.DEFAULT, DeviceManager.DeviceFilter.USER, DeviceManager.DeviceFilter.VENDOR, DeviceManager.DeviceFilter.SYSTEM_IMAGES)));
    userDevices = new ArrayList<>(deviceManager.getDevices(EnumSet.of(DeviceManager.DeviceFilter.USER)));
    for (Device device : userDevices) {
        boolean playStore = NbPreferences.forModule(CreateAvdVisualPanel1.class).getBoolean(device.getId(), false);
        if (playStore) {
            try {
                Field declaredField = Device.class.getDeclaredField("mHasPlayStore");
                declaredField.setAccessible(true);
                declaredField.setBoolean(device, true);
            } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
                Exceptions.printStackTrace(ex);
            }
            List<Software> allSoftware = device.getAllSoftware();
            for (int i = 0; i < allSoftware.size(); i++) {
                Software software = allSoftware.get(i);
                software.setPlayStoreEnabled(true);
            }
        }
        device.getId();
    }
    tvDevices = allDevices.stream().filter((t) -> {
        return isTv(t);
    }).collect(Collectors.toList());
    allDevices.removeAll(tvDevices);
    wearDevices = allDevices.stream().filter((t) -> {
        return HardwareConfigHelper.isWear(t);
    }).collect(Collectors.toList());
    allDevices.removeAll(wearDevices);
    mobileDevices = allDevices.stream().filter((t) -> {
        return isPhone(t);
    }).collect(Collectors.toList());
    allDevices.removeAll(mobileDevices);
    tabletDevices = allDevices.stream().filter((t) -> {
        return isTablet(t);
    }).collect(Collectors.toList());
    allDevices.removeAll(tabletDevices);
    modelMobile = new DevicesTableModel(mobileDevices);
    modelTablet = new DevicesTableModel(tabletDevices);
    modelTv = new DevicesTableModel(tvDevices);
    modelWear = new DevicesTableModel(wearDevices);
    tableMobile.setModel(modelMobile);
    tableTablet.setModel(modelTablet);
    tableTv.setModel(modelTv);
    tableWear.setModel(modelWear);
}
 
Example #29
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public List<Device> getDevices() {
    return devices;
}
 
Example #30
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Whether the given device is a TV device
 */
public static boolean isTv(@Nullable Device device) {
    return device != null && device.getId().startsWith(ID_PREFIX_TV);
}