Open syslogic opened 9 years ago
+1
Have this problem too, which is started from KitKat (!). Author is inactive since May 2017. Seems I should fork it and add this libraries :/ So sorry Kamran, there's no choise(
for example:
@Before
public void setup() throws IOException {
dir = Files.createTempDirectory("tartest").toFile();
dir.mkdirs();
}
should be something alike:
@Before
public void setup() throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
dir = java.nio.file.Files.createTempDirectory("tartest").toFile();
} else {
/* obtain a temporary directory for API < 26 */
this.mContext = InstrumentationRegistry.getTargetContext();
dir = this.mContext.getCacheDir();
}
}
One just would needs the permission to read/write and needs to handle temporary files differently and file system permissions - on Android < API level 26. have imported the library to Android Studio and this is what it basically tells me. Building it for nothing but >= API level 26 should be no problem at all.
No-no-no, that's wrong. PermissionUtils.java file regulates a POSIX permissions, not Android read/write permissions, because this jTar library was written for native Java, so there's no ANY Android compatible code, please don't confuse it. Android supported POSIX since API 26 (not before), but not fully, there's such a stubs in many its methods, so there's no need to narrow supported Android versions for API 26 and higher, so I've cut the POSIX support from the code, now it's working like a sharm at all API versions, but I won't make the pull request in this project, because now it's separated project specially for Android. Have you interesting in it?
well, I can write to /data/user/0/org.kamranzafar.jtar.test/cache
... by Context.getCacheDir()
.
It's because you've using Android API, not because jTar supports Android. It's simple native Java code which is using some native Java wrappers, not Android, you can simply use it with your Android code, and as it's a native Java code, you can work with it via Android in your project, but can't work with Android directly from its code. But there's no need for you because you have an Android project where you can simply include this library and use it in your project without touching its code.
Can only tell that this is the reason why it can't work; for reference: http://developer.android.com/reference/java/nio/package-summary.html On Android 6.0 the permissions are meanwhile obtained at runtime / per application, while the effective permissions depend on the mode in which the output stream was opened. that /storage/emulated/0/ is an abstraction layer which may cause octal permissions to be irrelevant - it's probably it's rather about the SE Linux context, which applications can obtain in order to read/write. https://developer.android.com/reference/android/support/v4/content/PermissionChecker.html