Java Code Examples for com.android.prefs.AndroidLocation#AndroidLocationException

The following examples show how to use com.android.prefs.AndroidLocation#AndroidLocationException . 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: CreateAvdVisualPanel3.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
public List<AvdInfo> getAvds(boolean forceRefresh) {
    if (forceRefresh) {
        try {
            avdManager.reloadAvds(new NullLogger());
        } catch (AndroidLocation.AndroidLocationException e) {
            Exceptions.printStackTrace(e);
        }
    }
    ArrayList<AvdInfo> avdInfos = Lists.newArrayList(avdManager.getAllAvds());
    boolean needsRefresh = false;
    for (AvdInfo info : avdInfos) {
        if (info.getStatus() == AvdInfo.AvdStatus.ERROR_DEVICE_CHANGED) {
            updateDeviceChanged(info);
            needsRefresh = true;
        }
    }
    if (needsRefresh) {
        return getAvds(true);
    } else {
        return avdInfos;
    }
}
 
Example 2
Source File: SigningConfig.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a SigningConfig with a given name.
 *
 * @param name the name of the signingConfig.
 */
public SigningConfig(@NonNull String name) {
    super(name);

    if (BuilderConstants.DEBUG.equals(name)) {
        try {
            initDebug();
        } catch (AndroidLocation.AndroidLocationException e) {
            throw new BuildException("Failed to get default debug keystore location", e);
        }
    }
}
 
Example 3
Source File: ValidateSigningTask.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@TaskAction
public void validate() throws AndroidLocation.AndroidLocationException, KeytoolException {
    File storeFile = signingConfig.getStoreFile();
    if (storeFile == null) {
        throw new IllegalArgumentException(
                "Keystore file not set for signing config " + signingConfig.getName());
    }
    if (!storeFile.exists()) {
        if (KeystoreHelper.defaultDebugKeystoreLocation().equals(storeFile.getAbsolutePath())) {
            checkState(signingConfig.isSigningReady(), "Debug signing config not ready.");

            getLogger().info(
                    "Creating default debug keystore at {}",
                    storeFile.getAbsolutePath());

            //noinspection ConstantConditions - isSigningReady() called above
            if (!KeystoreHelper.createDebugStore(
                    signingConfig.getStoreType(), signingConfig.getStoreFile(),
                    signingConfig.getStorePassword(), signingConfig.getKeyPassword(),
                    signingConfig.getKeyAlias(), getILogger())) {
                throw new BuildException("Unable to recreate missing debug keystore.", null);
            }
        } else {
            throw new IllegalArgumentException(
                    String.format(
                            "Keystore file %s not found for signing config '%s'.",
                            storeFile.getAbsolutePath(),
                            signingConfig.getName()));
        }
    }
}
 
Example 4
Source File: AvdManager.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void refreshAvds() {
    try {
        avdManager.reloadAvds(new NullLogger());
    } catch (AndroidLocation.AndroidLocationException ex) {
        Exceptions.printStackTrace(ex);
    }
    AvdInfo[] validAvds = avdManager.getValidAvds();
    model = new ExistingDevicesTableModel(validAvds);
    table.setModel(model);
}
 
Example 5
Source File: AndroidExtension.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public AndroidExtension(Project project, ToolingModelBuilderRegistry registry) {
    this.project = project;

    this.extraModelInfo = new ExtraModelInfo(new ProjectOptions(project), project.getLogger());

    this.signingConfig = project.getExtensions().create("signingConfig", SigningConfig.class, "signing");
    this.packagingOptions = project.getExtensions().create("packagingOptions", PackagingOptions.class);
    this.dexOptions = project.getExtensions().create("dexOptions", DexOptions.class, extraModelInfo);

    try {
        this.buildCache = FileCache.getInstanceWithMultiProcessLocking(new File(AndroidLocation.getFolder(), "build-cache"));
    } catch (AndroidLocation.AndroidLocationException e) {
        throw new RuntimeException(e);
    }

    LoggerWrapper loggerWrapper = new LoggerWrapper(project.getLogger());

    this.sdkHandler = new SdkHandler(project, loggerWrapper);
    this.androidBuilder = new AndroidBuilder(
            project == project.getRootProject() ? project.getName() : project.getPath(),
            "JavaFX Mobile",
            new GradleProcessExecutor(project),
            new GradleJavaProcessExecutor(project),
            extraModelInfo,
            loggerWrapper,
            false);

    this.androidTaskRegistry = new AndroidTaskRegistry();
    this.taskFactory = new TaskContainerAdaptor(project.getTasks());

    installDirectory = new File(project.getBuildDir(), "javafxports/android");
    project.getLogger().info("Android install directory: " + installDirectory);

    temporaryDirectory = new File(project.getBuildDir(), "javafxports/tmp/android");
    project.getLogger().info("Android temporary output directory: " + temporaryDirectory);

    resourcesDirectory = new File(temporaryDirectory, "resources");
    resourcesDirectory.mkdirs();
    project.getLogger().info("Resources directory: " + resourcesDirectory);

    multidexOutputDirectory = new File(temporaryDirectory, "multi-dex");
    multidexOutputDirectory.mkdirs();
    project.getLogger().info("Multi-dex output directory: " + multidexOutputDirectory);

    dexOutputDirectory = new File(temporaryDirectory, "dex");
    dexOutputDirectory.mkdirs();
    project.getLogger().info("Dex output directory: " + dexOutputDirectory);
}
 
Example 6
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 7
Source File: EmulatorLauncher.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public Future<IDevice> launchEmulator(AvdInfo avdInfo, LaunchConfiguration launchCfg) {
    final String cookie = Long.toString(System.currentTimeMillis());
    ExecutionDescriptor descriptor = new ExecutionDescriptor()
            .frontWindow(true).postExecution(new Runnable() {
        @Override
        public void run() {
            cancel = true;
            semaphore.release();
        }
    });

    ProcessBuilder processBuilder = ProcessBuilder.getLocal();
    processBuilder.setExecutable(getEmulatorBinaryPath());
    List<String> arguments = new ArrayList<>();
    arguments.add(FLAG_AVD);
    arguments.add(avdInfo.getName());
    arguments.add(FLAG_PROP);
    arguments.add(LAUNCH_COOKIE + "=" + cookie);
    if(SelectDeviceAction.wipeData.isSelected()){
        arguments.add(FLAG_WIPE_DATA);
    }
    for (String arg : Splitter.on(' ').omitEmptyStrings().split(launchCfg.getEmulatorOptions())) {
        arguments.add(arg);
    }
    processBuilder.setArguments(arguments);
    AndroidSdk defaultSdk = AndroidSdkProvider.getDefaultSdk();
    if (defaultSdk != null) {
        try {
            AvdManager avdManager = AvdManager.getInstance(defaultSdk.getAndroidSdkHandler(), new NullLogger());
            if (avdManager != null) {
                File baseAvdFolder = avdManager.getBaseAvdFolder();
                processBuilder.getEnvironment().setVariable("ANDROID_AVD_HOME", baseAvdFolder.getAbsolutePath());
            }
        } catch (AndroidLocation.AndroidLocationException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

    ExecutionService service = ExecutionService.newService(
            processBuilder, descriptor, "Android emulator");
    final Future<Integer> taskStatus = service.run();
    return EXECUTOR.submit(new Callable<IDevice>() {

        @Override
        public IDevice call() throws Exception {

            ProgressHandle handle = ProgressHandle.createHandle("Emulator starting", new Cancellable() {
                @Override
                public boolean cancel() {
                    cancel = true;
                    semaphore.release();
                    return true;
                }
            });
            handle.start();
            while (true) {
                Map<String, IDevice> runningEmulators = AdbUtils.getRunningEmulators();
                IDevice device = runningEmulators.get(avdInfo.getName());
                if (device != null && device.isOnline()) {
                    handle.finish();
                    LOG.log(Level.INFO, "Started emulator device connected.");
                    return device;
                } else if (cancel) {
                    handle.finish();
                    LOG.log(Level.INFO, "Emulator start canceled");
                    return null;
                }
                semaphore.tryAcquire(2, TimeUnit.SECONDS);
            }
        }

    });
}