Tag: root

Android SU权限IOException

if (DownloadManager.STATUS_SUCCESSFUL == c .getInt(columnIndex)) { mProgress.setProgress(70); mStatus.setText(R.string.status_backup); File dl_path = new File(DownloadManager.COLUMN_LOCAL_URI); File og_path = new File(“/system/app/app.apk”); String bu_path = “/sdcard/asdfgsd/backup/app.apk”; Process p; try { // Preform su to get root privledges p = Runtime.getRuntime().exec(“su”); // Attempt to write a file to a root-only DataOutputStream os = new DataOutputStream(p.getOutputStream()); os.writeBytes(“echo \”Do I have root?\” […]

Android:Screencap直接到字节 – 跳过保存到文件

我使用以下代码在root设备上截取屏幕截图: sh = Runtime.getRuntime().exec(“su”, null,null); os = sh.getOutputStream(); os.write((“/system/bin/screencap -p ” + “/sdcard/img.jpg” + “\n”).getBytes(“ASCII”)); os.flush(); os.close(); sh.waitFor(); myBitmap = BitmapFactory.decodeFile(“/sdcard/img.jpg”); 由于我想经常截取屏幕截图,我不想先将其保存到文件然后读取字节。 是否有更好的方法直接获取屏幕截图位图? 我只是想消除这种不必要的延迟。 非常感谢! 更新: 可以在此处查看screencap.cpp代码。 另外,它提到了这个: “usage: %s [-hp] [-d display-id] [FILENAME]\n” ” -h: this message\n” ” -p: save the file as a png.\n” ” -d: specify the display id to capture, default […]

使用幂方法计算Java中的第n个根

我试图使用Math.pow(n, 1.0/3)在java中获得立方根Math.pow(n, 1.0/3)但因为它除了双精度数,所以它不会返回确切的答案。 例如,对于125,这给出了4.9999999999。 有解决办法吗? 我知道有一个立方根函数但我想解决这个问题,所以我可以计算更高的根。 我不想舍入,因为我想知道一个数字是否具有整数根,通过这样做: Math.pow(n, 1.0 / 3) % ((int) Math.pow(n, 1.0 / 3)) 。

Android SU权限:如何使用它们?

这里有一种情况,我正在开发一个使用Java的Android应用程序。 我对这些东西非常熟悉,但现在这是我第一次需要使用SU权限。 我只需要替换(实际上,重命名)system / app目录中的文件,但看起来我无法以通常的方式执行它(File类中的renameTo方法),它只返回FALSE,这意味着操作中有一些错误。 那么有谁能告诉我如何使用SU? 我的测试手机完全符合SU 3.0.3.2,任何需要SU的应用程序都能完美运行。 我应该使用相同的方法,但在清单中添加了一些内容吗? 我应该以某种方式使用busybox吗? 我已经用Google搜索了,我找不到任何有用的信息。 此外,官方Android超级用户网站上没有文档。 提前致谢!

如何在不使用keytool命令行实用程序的情况下导入新的Java CA证书?

执行摘要:如何使用Java代码将新的根证书安装到Java中? 我们有一个桌面应用程序,可以访问各种Web服务。 最近其中一人将他们的SSL证书改为由Trustwave签署的证书。 虽然常规Internet浏览器接受Trustwave SSL证书,但Java似乎没有先决条件根证书,并且我们失去了对给定Web服务的访问权限,并显示以下错误消息: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 我们通过说服提供商切换回Verisign来暂时缓解,但当他们切换回来时我们必须做好准备。 所以我需要我们的桌面软件根据需要自动安装Trustwave根证书。 我们的客户对于使用keytool命令不够科技,我宁愿不编写脚本,因为这让我觉得它是一个脆弱的解决方案(Mac和PC的单独实现,对Vista执行限制的斗争,无法找到正确的JRE安装到等)。 我想keytool在内部使用Java。 我可以在Java中使用什么命令来复制keytool的function并以编程方式安装根证书?

Java应用程序是否有获得root权限的方法?

当运行Files.walk(Paths.get(“/var/”)).count()作为非特权用户时,执行可能会抛出exception,因为/var/中的文件夹需要遍历root权限。 我不是在寻找一种以root身份执行bash命令的方法(例如sudo find /var ),使用Process等。 我只是想确保Files.walk(Paths.get(“/var/”)).count()不会抛出AccessDeniedException : Exception in thread “restartedMain” java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0 at sun.reflect.NativeMethodAccessorImpl.invoke at sun.reflect.DelegatingMethodAccessorImpl.invoke at java.lang.reflect.Method.invoke at org.springframework.boot.devtools.restart.RestartLauncher.run Caused by: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: /var/cache/httpd at java.nio.file.FileTreeIterator.fetchNextIfNeeded at java.nio.file.FileTreeIterator.hasNext at java.util.Iterator.forEachRemaining at java.util.Spliterators$IteratorSpliterator.forEachRemaining at java.util.stream.AbstractPipeline.copyInto at java.util.stream.AbstractPipeline.wrapAndCopyInto at java.util.stream.ReduceOps$ReduceOp.evaluateSequential at java.util.stream.AbstractPipeline.evaluate at java.util.stream.LongPipeline.reduce at java.util.stream.LongPipeline.sum at java.util.stream.ReferencePipeline.count at com.example.DemoApplication.main … 5 more Caused […]

如何使用Jackson重命名JSON序列化中的根密钥

我正在使用Jackson进行JSON序列化对象列表。 这是我得到的: {“ArrayList”:[{“id”:1,”name”:”test name”}]} 但我想要这个: {“rootname”:[{“id”:1,”name”:”test name”}]} // ie showing the string I want as the root name. 以下是我的方法: 接口: public interface MyInterface { public long getId(); public String getName(); } 实施class: @JsonRootName(value = “rootname”) public class MyImpl implements MyInterface { private final long id; private String name; public MyImpl(final long id,final name) { this.id […]