Java Code Examples for com.android.sdklib.devices.Device#getId()

The following examples show how to use com.android.sdklib.devices.Device#getId() . 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: 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 2
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);
}