当前位置: 首页>>代码示例>>Java>>正文


Java InstallException类代码示例

本文整理汇总了Java中com.android.ddmlib.InstallException的典型用法代码示例。如果您正苦于以下问题:Java InstallException类的具体用法?Java InstallException怎么用?Java InstallException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InstallException类属于com.android.ddmlib包,在下文中一共展示了InstallException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performAction

import com.android.ddmlib.InstallException; //导入依赖的package包/类
@Override
protected void performAction(Node[] activatedNodes) {
    Node node = activatedNodes[0];
    FileObject fo = node.getLookup().lookup(FileObject.class);
    Project owner = FileOwnerQuery.getOwner(fo);
    if (owner != null) {
        AndroidSdk sdk = owner.getLookup().lookup(AndroidSdk.class);
        if (sdk != null) {
            AndroidLauncher launcher = new AndroidLauncherImpl();
            LaunchConfiguration cfg = ConfigBuilder.builder()
                    .withName("dummy").withTargetMode(LaunchConfiguration.TargetMode.AUTO).config().getLaunchConfiguration();
            AvdSelector.LaunchData launchData = launcher.configAvd(
                    sdk.getAndroidSdkHandler(), AndroidSdkProvider.getDefaultSdk(), null, cfg);
            if (launchData == null || launchData.getDevice() == null) {
                return;
            }
            try {
                launchData.getDevice().installPackage(fo.getPath(), true);
            } catch (InstallException ex) {
                String message = ex.getMessage();
                NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notifyLater(nd);
            }
        }
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:27,代码来源:InstallApkAction.java

示例2: buildAndInstallAPK

import com.android.ddmlib.InstallException; //导入依赖的package包/类
/**
 * Builds the transfered .apk file, uploads and then installs it on the current device.
 *
 * @param shouldForceInstall
 *        - force install an APK if the parameter is <code>true</code>
 * @throws CommandFailedException
 *         thrown when install and build APK fails
 */
public void buildAndInstallAPK(boolean shouldForceInstall) throws CommandFailedException {
    if (tempApkFile == null || tempApkFileOutputStream == null) {
        throw new IllegalStateException("Temp .apk file should be created (by calling initAPKInstall()) before any calls to appendToAPK() and buildAndInstallAPK().");
    }

    try {
        tempApkFileOutputStream.flush();
        tempApkFileOutputStream.close();
        tempApkFileOutputStream = null;
        String absolutePathToApk = tempApkFile.getAbsolutePath();

        device.installPackage(absolutePathToApk, shouldForceInstall);
        discardAPK();
    } catch (InstallException | IOException e) {
        LOGGER.error("Installing apk failed.", e);
        throw new CommandFailedException("Installing .apk file failed.", e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:27,代码来源:ApkInstaller.java

示例3: installAPK

import com.android.ddmlib.InstallException; //导入依赖的package包/类
public void installAPK(OnDeviceComponent onDeviceComponent) {
    String statusMessage = String.format(COMPONENT_INSTALLATION_MESSAGE, onDeviceComponent.getHumanReadableName());
    LOGGER.info(statusMessage);

    String componentPath = ON_DEVICE_COMPONENT_FILES_PATH.concat(onDeviceComponent.getFileName());

    try {
        String grantPermissionsAutomatically = "";
        String deviceApiLevel = device.getProperty(IDevice.PROP_BUILD_API_LEVEL);
        if (deviceApiLevel != null && Integer.parseInt(deviceApiLevel) >= 23) {
            grantPermissionsAutomatically = "-g";
        }

        device.installPackage(componentPath, true, grantPermissionsAutomatically);
    } catch (InstallException e) {
        String errorMessage = String.format(COMPONENT_INSTALLATION_FAILED_MESSAGE,
                                            onDeviceComponent.getHumanReadableName());
        LOGGER.fatal(errorMessage, e);
        throw new ComponentInstallationFailedException(errorMessage, e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:22,代码来源:ApkInstaller.java

示例4: testSuccessfulDeviceInstall

import com.android.ddmlib.InstallException; //导入依赖的package包/类
/**
 * Verify that successful installation on device results in true.
 */
@Test
public void testSuccessfulDeviceInstall() {
  File apk = new File("/some/file.apk");
  final AtomicReference<String> apkPath = new AtomicReference<>();

  TestDevice device = new TestDevice() {
    @Override
    public String installPackage(String s, boolean b, String... strings) throws InstallException {
      apkPath.set(s);
      return null;
    }
  };
  device.setSerialNumber("serial#1");
  device.setName("testDevice");

  assertTrue(basicAdbHelper.installApkOnDevice(device, apk, false));
  assertEquals(apk.getAbsolutePath(), apkPath.get());
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:22,代码来源:AdbHelperTest.java

示例5: testSuccessfulDeviceInstall

import com.android.ddmlib.InstallException; //导入依赖的package包/类
/** Verify that successful installation on device results in true. */
@Test
public void testSuccessfulDeviceInstall() {
  File apk = new File("/some/file.apk");
  final AtomicReference<String> apkPath = new AtomicReference<>();

  TestDevice device =
      new TestDevice() {
        @Override
        public void installPackage(String s, boolean b, String... strings)
            throws InstallException {
          apkPath.set(s);
        }
      };
  device.setSerialNumber("serial#1");
  device.setName("testDevice");

  assertTrue(createAndroidDevice(device).installApkOnDevice(apk, false, false, false));
  assertEquals(apk.getAbsolutePath(), apkPath.get());
}
 
开发者ID:facebook,项目名称:buck,代码行数:21,代码来源:RealAndroidDeviceTest.java

示例6: testFailedDeviceInstallWithReason

import com.android.ddmlib.InstallException; //导入依赖的package包/类
/** Verify that if failure reason is returned, installation is marked as failed. */
@Test
public void testFailedDeviceInstallWithReason() {
  File apk = new File("/some/file.apk");
  TestDevice device =
      new TestDevice() {
        @Override
        public void installPackage(String s, boolean b, String... strings)
            throws InstallException {
          throw new InstallException("[SOME REASON]");
        }
      };
  device.setSerialNumber("serial#1");
  device.setName("testDevice");
  assertFalse(createAndroidDevice(device).installApkOnDevice(apk, false, false, false));
}
 
开发者ID:facebook,项目名称:buck,代码行数:17,代码来源:RealAndroidDeviceTest.java

示例7: testFailedDeviceInstallWithException

import com.android.ddmlib.InstallException; //导入依赖的package包/类
/** Verify that if exception is thrown during installation, installation is marked as failed. */
@Test
public void testFailedDeviceInstallWithException() {
  File apk = new File("/some/file.apk");

  TestDevice device =
      new TestDevice() {
        @Override
        public void installPackage(String s, boolean b, String... strings)
            throws InstallException {
          throw new InstallException("Failed to install on test device.", null);
        }
      };
  device.setSerialNumber("serial#1");
  device.setName("testDevice");
  assertFalse(createAndroidDevice(device).installApkOnDevice(apk, false, false, false));
}
 
开发者ID:facebook,项目名称:buck,代码行数:18,代码来源:RealAndroidDeviceTest.java

示例8: onEventReceived

import com.android.ddmlib.InstallException; //导入依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
    try {
        device.uninstallPackage(packageName);
    } catch (InstallException e) {
        LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, e.getMessage());
        e.printStackTrace();
        System.exit(-1);
    }
    return null;
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:12,代码来源:UninstallAppEvent.java

示例9: onData

import com.android.ddmlib.InstallException; //导入依赖的package包/类
public void onData(SocketIOClient client, String jsonStr, AckRequest ack)
        throws Exception {
    InstallBean bean = JsonUtil.jsonTobean(jsonStr, InstallBean.class);
    logger.info(jsonStr);
    if(bean != null){
        List<String> serialNumberList = bean.getSerialNumberList();
        String apkPath = bean.getApkPath();
        if(serialNumberList != null && apkPath != null && FileUtil.isFileExist(apkPath)){
            for(String serialNumber : serialNumberList){
                DeviceEntity deviceEntity = DeviceContainerHandler.getDevice(serialNumber);
                if(deviceEntity != null){
                    IDevice idevice = deviceEntity.getIdevice();
                    if(idevice != null && idevice.isOnline()){
                        executorService.execute(new Runnable() {
                            @Override
                            public void run() {
                                SystemWSSender.msg(client,"设备["+deviceEntity.getSerialNumber()+"] 开始安装应用");
                                try {
                                    idevice.installPackage(apkPath, true);
                                    SystemWSSender.msg(client,"设备["+deviceEntity.getSerialNumber()+"] 应用安装成功");
                                } catch (InstallException e) {
                                    logger.error(serialNumber+":安装apk["+apkPath+"] 出错",e);
                                    SystemWSSender.error(client,"设备["+serialNumber+"]apk安装出错,原因:"+e.getMessage());
                                }
                            
                            }
                        });
                    }
                }
            }
        }
    }
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:34,代码来源:InstallListener.java

示例10: installPackages

import com.android.ddmlib.InstallException; //导入依赖的package包/类
@Override
public void installPackages(List<File> apks,
                            boolean reinstall,
                            List<String> installOptions,
                            long timeout,
                            TimeUnit timeoutUnit)
    throws InstallException {
    // TODO Auto-generated method stub

}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:11,代码来源:ShellCommandExecutorTest.java

示例11: installPackage

import com.android.ddmlib.InstallException; //导入依赖的package包/类
@Override
public boolean installPackage(String path) {
    try {
        String result = device.installPackage(path, true);
        if (result != null) {
            LOG.log(Level.SEVERE, "Got error installing package: "+ result);
            return false;
        }
        return true;
    } catch (InstallException e) {
        LOG.log(Level.SEVERE, "Error installing package: " + path, e);
        return false;
    }
}
 
开发者ID:utds3lab,项目名称:SMVHunter,代码行数:15,代码来源:AdbChimpDevice.java

示例12: removePackage

import com.android.ddmlib.InstallException; //导入依赖的package包/类
@Override
public boolean removePackage(String packageName) {
    try {
        String result = device.uninstallPackage(packageName);
        if (result != null) {
            LOG.log(Level.SEVERE, "Got error uninstalling package "+ packageName + ": " +
                    result);
            return false;
        }
        return true;
    } catch (InstallException e) {
        LOG.log(Level.SEVERE, "Error installing package: " + packageName, e);
        return false;
    }
}
 
开发者ID:utds3lab,项目名称:SMVHunter,代码行数:16,代码来源:AdbChimpDevice.java

示例13: run

import com.android.ddmlib.InstallException; //导入依赖的package包/类
@Override
public boolean run(Project project, IDevice device, AndroidFacet facet, String packageName) {
    try {
        String errorCode = device.uninstallPackage(packageName);
        if (errorCode == null) {
            info(String.format("<b>%s</b> uninstalled on %s", packageName, device.getName()));
            return true;
        } else {
            error(String.format("<b>%s</b> is not installed on %s", packageName, device.getName()));
        }
    } catch (InstallException e1) {
        error("Uninstall fail... " + e1.getMessage());
    }
    return false;
}
 
开发者ID:pbreault,项目名称:adb-idea,代码行数:16,代码来源:UninstallCommand.java

示例14: installApk

import com.android.ddmlib.InstallException; //导入依赖的package包/类
private void installApk() {
    File apk = new File("apk/SmartToolsApk.apk");
    
    try {
        System.out.println(apk.getAbsolutePath());
        mCurDevice.installPackage(apk.getAbsolutePath(), false, new String[]{});
    } catch (InstallException e) {
        e.printStackTrace();
    }
}
 
开发者ID:HoneyFish,项目名称:SmartTools,代码行数:11,代码来源:DeviceConnectWorker.java

示例15: installApkOnDevice

import com.android.ddmlib.InstallException; //导入依赖的package包/类
/**
 * Installs apk on specific device. Reports success or failure to console.
 */
@SuppressWarnings("PMD.PrematureDeclaration")
public boolean installApkOnDevice(IDevice device, File apk, boolean installViaSd) {
  String name;
  if (device.isEmulator()) {
    name = device.getSerialNumber() + " (" + device.getAvdName() + ")";
  } else {
    name = device.getSerialNumber();
    String model = device.getProperty("ro.product.model");
    if (model != null) {
      name += " (" + model + ")";
    }
  }

  if (!isDeviceTempWritable(device, name)) {
    return false;
  }

  getBuckEventBus().post(ConsoleEvent.info("Installing apk on %s.", name));
  try {
    String reason = null;
    if (installViaSd) {
      reason = deviceInstallPackageViaSd(device, apk.getAbsolutePath());
    } else {
      reason = device.installPackage(apk.getAbsolutePath(), true);
    }
    if (reason != null) {
      console.printBuildFailure(String.format("Failed to install apk on %s: %s.", name, reason));
      return false;
    }
    return true;
  } catch (InstallException ex) {
    console.printBuildFailure(String.format("Failed to install apk on %s.", name));
    ex.printStackTrace(console.getStdErr());
    return false;
  }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:40,代码来源:AdbHelper.java


注:本文中的com.android.ddmlib.InstallException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。