Class java.io.FileInputStream for Android Q - file-io

A library I am using JID3 which uses the Class java.io.FileInputStream written by A. von Hoff
https://en.wikipedia.org/wiki/Arthur_van_Hoff
Stacktrace:
2020-08-08 14:09:23.164 23212-23212/com.flyingdutchman.newplaylistmanager W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
2020-08-08 14:09:23.164 23212-23212/com.flyingdutchman.newplaylistmanager W/System.err: Caused by: java.io.FileNotFoundException: /storage/AD7D-190E/Music/Gerry Rafferty/City to City/01 - The Ark.mp3: open failed: EACCES (Permission denied)
2020-08-08 14:09:23.164 23212-23212/com.flyingdutchman.newplaylistmanager W/System.err: at libcore.io.IoBridge.open(IoBridge.java:496)
2020-08-08 14:09:23.164 23212-23212/com.flyingdutchman.newplaylistmanager W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:159)
2020-08-08 14:09:23.164 23212-23212/com.flyingdutchman.newplaylistmanager W/System.err: at org.blinkenlights.jid3.io.FileSource.getInputStream(FileSource.java:86)
2020-08-08 14:09:23.164 23212-23212/com.flyingdutchman.newplaylistmanager W/System.err: at org.blinkenlights.jid3.MP3File.getID3V2Tag(MP3File.java:455)
Has anyone amended this to allow file operations under Android Q (api29) and above ?

Related

Kotlin Unzipping Files

Having troubles trying to figure out how to unzip a zip folder into /Documents/CardGameXXX/ I've tried just about every unzip example I can get my hands on, and either I get a crash or it just fails, any ideas.
Added : an example code of unzipping a zip file from https://mobikul.com/zip-unzip-file-folder-android-programmatically/ which doesn't work well it does, in the documents folder "CardGameXXX" folder is made and inside "Deck1" folder is created however everything stops there no files are extracted "Deck2" folder isn't even extracted, is this broken example code or have I royally messed something up here.
object ZipManager {
private const val BUFFER_SIZE = 6 * 1024
#Throws(
IOException::class
)
fun unzip(zipFile: String?,location: String) {
try {
val f = File(location)
if (!f.isDirectory) {
f.mkdirs()
}
val zin = ZipInputStream(FileInputStream(zipFile))
try {
var ze: ZipEntry // = null
while (zin.nextEntry
.also {
ze = it
} != null
) {
val path = location + File.separator + ze.name
if (ze.isDirectory) {
val unzipFile = File(path)
if (!unzipFile.isDirectory) {
unzipFile.mkdirs()
}
} else {
val fout = FileOutputStream( path,false )
fout.use { fout ->
var c: Int = zin.read()
while (c != -1) {
fout.write( c )
c = zin.read()
}
zin.closeEntry()
}
}
}
} finally {
zin.close()
}
} catch (e: java.lang.Exception) {
e.printStackTrace()
Log.d("METAG","Unzip exception",e)
}
}
}
class Tools {
/* ----------------------------------------------------------------------------
* Setup App Configuration
*/
fun exSetupApp(AppContext: Context,AppContentResolver : ContentResolver ,folder : String) {
val values = ContentValues()
values.put(MediaStore.MediaColumns.RELATIVE_PATH, "${Environment.DIRECTORY_DOCUMENTS}/CardGameXXX/")
AppContentResolver.insert(MediaStore.Files.getContentUri("external"), values)
//
// copy zip to documents/cardgamexxx folder somehow!?
//
// Copies the Assets.Zip into /cache
val infileassetzip : String = getFileFromAssets(AppContext,"assets.zip").toString() // copy zip to cache folder
//val target : String = Environment.DIRECTORY_DOCUMENTS
val target = File("/storage/emulated/0/Documents/CardGameXXX")
// Now that it's in /cache unzip it from /cache to /Documents/CardGameXXX
ZipManager.unzip(infileassetzip,target.toString())
Log.d("METAG",infileassetzip)
Log.d("METAG",target.toString())
Toast.makeText(AppContext,"\"CardGameXXX\" created", Toast.LENGTH_SHORT).show()
// defunt code but someday might feel useful!
// Works, but crashes if already exists.
//File(infileassetzip).copyTo(File("/storage/emulated/0/Documents/assets.zip"));
}
}
Maybe this will help not sure, that said the file it says 'exists' on inspection with "Device File Explorer" it absolutely doesn't exist and never did.
23074-23074/com.example.cardgamexxx W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Documents/CardGameXXX/deck1/giphy.gif: open failed: EEXIST (File exists)
23074-23074/com.example.cardgamexxx W/System.err: at libcore.io.IoBridge.open(IoBridge.java:492)
23074-23074/com.example.cardgamexxx W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:236)
23074-23074/com.example.cardgamexxx W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:157)
23074-23074/com.example.cardgamexxx W/System.err: at com.example.cardgamexxx.ZipManager.unzip(MainActivity.kt:80)
23074-23074/com.example.cardgamexxx W/System.err: at com.example.cardgamexxx.Tools.exSetupApp(MainActivity.kt:121)
23074-23074/com.example.cardgamexxx W/System.err: at com.example.cardgamexxx.MainActivity.onCreate(MainActivity.kt:366)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.Activity.performCreate(Activity.java:8000)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.Activity.performCreate(Activity.java:7984)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
23074-23074/com.example.cardgamexxx W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
23074-23074/com.example.cardgamexxx W/System.err: at android.os.Looper.loop(Looper.java:223)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7656)
23074-23074/com.example.cardgamexxx W/System.err: at java.lang.reflect.Method.invoke(Native Method)
23074-23074/com.example.cardgamexxx W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
23074-23074/com.example.cardgamexxx W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
23074-23074/com.example.cardgamexxx W/System.err: Caused by: android.system.ErrnoException: open failed: EEXIST (File exists)
23074-23074/com.example.cardgamexxx W/System.err: at libcore.io.Linux.open(Native Method)
23074-23074/com.example.cardgamexxx W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
23074-23074/com.example.cardgamexxx W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
23074-23074/com.example.cardgamexxx W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
23074-23074/com.example.cardgamexxx W/System.err: at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7542)
23074-23074/com.example.cardgamexxx W/System.err: at libcore.io.IoBridge.open(IoBridge.java:478)
23074-23074/com.example.cardgamexxx W/System.err: ... 20 more

IBM MobileFirst - Android connection error on IPV6

We are using worklight 7 application and getting handshake error on below version.
7.1.0.00.20160401-2103
While app connecting through IPV6 getting below error on android where as it work fine when connect over IPV4.
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at com.android.org.conscrypt.SSLNullSession.getPeerCertificates(SSLNullSession.java:104)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:99)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at com.worklight.wlclient.aeknjhzpue.awklahudcn.verify(SourceFile:42)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at com.worklight.wlclient.vpinofqvte.createSocket(SourceFile:94)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:170)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:169)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:124)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:366)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560)
05-19 18:31:56.840 16157-16658/com.sampleapp W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:492)
05-19 18:31:56.841 16157-16658/com.sampleapp W/System.err: at com.worklight.wlclient.ncyludlxhw.run(SourceFile:47)
05-19 18:31:56.841 16157-16658/com.sampleapp W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
05-19 18:31:56.841 16157-16658/com.sampleapp W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
05-19 18:31:56.841 16157-16658/com.sampleapp W/System.err: at java.lang.Thread.run(Thread.java:761)
05-19 18:31:56.855 16157-16369/com.sampleapp D/wl.certManager: aeknjhzpue.awklahudcn in SourceFile:258 :: Key store cleared.
05-19 18:31:56.860 16157-16369/com.sampleapp D/NONE: Client registration failed with error: {"responseHeaders":{},"status":500,"responseText":"","errorCode":"UNEXPECTED_ERROR","errorMsg":"Unexpected errorCode occurred. Please try again.","invocationContext":null}
05-19 18:31:56.871 16157-16369/com.sampleapp E/NONE: [/apps/services/api/sampleapp/android/query] failure. state: 500, response: undefined
05-19 18:31:56.877 16157-16157/com.sampleapp I/chromium: [INFO:CONSOLE(311)] "{"status":500,"errorCode":"UNEXPECTED_ERROR","errorMsg":"Unexpected errorCode occurred. Please try again.","invocationContext":null}", source: file:///android_asset/wwwBD/default/js/main.js (311)
WLClient.properties
wlServerProtocol = https
wlServerHost = uatdomain.com
wlServerPort = 443
wlServerContext = /bankcontext/
wlAppId = bankcontext
wlAppVersion = 1.0
GcmSenderId =
enableSettings = false
testWebResourcesChecksum = false
ignoredFileExtensions =
webResourcesSize = 5734268
wlUid = nzhTmU3E/iVLhJLzR+BT9w==
wlPlatformVersion = 7.1.0.0
wlMainFilePath = index.html
wlShareCookies =
wlShareUserCert = false
wlSecureDirectUpdatePublicKey =
wlBuildId = 7.1.0.00.20160401-2103
Could you please verify using openssl tool on IPV6 and IPV4 network.
Need to check what exactly return by server on handshake.
Use below command to check and share the result.
openssl s_client -connet domain:443

FileInputStream error No such file or directory

The issue is that when I run my program in Android Studio the FileInputStream can't find the c:\poi-test.xls file.
The simple test java program that I'm running in Android Studio is:
try {
File file = new File("C:\\poi-test.xls");
FileInputStream fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
In Android Studio I step through and the file object is created but when I step through the FileInputStream I get the following error:
C:\poi-test.xls: open failed: ENOENT (No such file or directory)
I've spent hours trying to resolve the issue via SO and google and haven't found a solution.
The complete error listing is:
W/System: ClassLoader referenced unknown path: /data/app/com.jake.testforreadxls-1/lib/x86_64
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
**W/System.err: java.io.FileNotFoundException: C:\poi-test.xls: open failed: ENOENT (No such file or directory)**
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:452)
W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:76)
W/System.err: at com.jake.testforreadxls.MainActivity.onCreate(MainActivity.java:21)
W/System.err: at android.app.Activity.performCreate(Activity.java:6237)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
W/System.err: at android.app.ActivityThread.-wrap11(ActivityThread.java)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err: at android.os.Looper.loop(Looper.java:148)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
W/System.err: at libcore.io.Posix.open(Native Method)
W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:438)
W/System.err: ... 14 more
Disconnected from the target VM, address: 'localhost:8734', transport: 'socket'
App running inside emulator/android device cannot access the file system of your PC. Android OS has no idea where C:\\poi-test.xls is. File must be stored on your sd card of internal storage of your device for your solution to work.

Service: Amazon S3; Status Code: 403; Error Code: AllAccessDisabled;

I have implemented Amazon S3 in my project. But I am getting Service: Amazon S3; Status Code: 403; Error Code: AllAccessDisabled; I fined in google but I have not found this issue. Please tell me where I have done wrong. One more thing When I sign up the Amazon S3 I have chosen basic not Developer or business.
com.amazonaws.services.s3.model.AmazonS3Exception: All access to this object has been disabled (Service: Amazon S3; Status Code: 403; Error Code: AllAccessDisabled; Request ID: XXXXXXXXXXXXXXX), S3 Extended Request ID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
11-28 18:30:00.410 30990-10598/com.example.sanjitpatra.myapplication W/System.err: at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:712)
11-28 18:30:00.410 30990-10598/com.example.sanjitpatra.myapplication W/System.err: at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:388)
11-28 18:30:00.410 30990-10598/com.example.sanjitpatra.myapplication W/System.err: at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199)
11-28 18:30:00.410 30990-10598/com.example.sanjitpatra.myapplication W/System.err: at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4375)
11-28 18:30:00.410 30990-10598/com.example.sanjitpatra.myapplication W/System.err: at com.amazonaws.services.s3.AmazonS3Client.getObject(AmazonS3Client.java:1357)

titanium image factory quality

I have this code that works perfectly on iOS but crashes on android platform.
var quality = Ti.Platform.osname=="android"?80:ImageFactory.QUALITY_LOW;
Ti.API.info(quality);
var resizedImage = ImageFactory.imageAsResized(imageView, {height : h,width:w, quality: quality});
the 2nd line of code shows 80, but I got an error that says
[INFO] : 80
[WARN] : W/System.err: java.lang.IllegalArgumentException: quality must be 0..100
[WARN] : W/System.err: at android.graphics.Bitmap.compress(Bitmap.java:873)
[WARN] : W/System.err: at ti.imagefactory.ImageFactoryModule.imageTransform(ImageFactoryModule.java:137)
[WARN] : W/System.err: at ti.imagefactory.ImageFactoryModule.imageAsResized(ImageFactoryModule.java:181)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:57)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:43)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function$1.run(V8Function.java:70)
[WARN] : W/System.err: at android.os.Handler.handleCallback(Handler.java:725)
[WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:92)
[WARN] : W/System.err: at android.os.Looper.loop(Looper.java:137)
[WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
[ERROR] : TiExceptionHandler: (main) [454,43722] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,43722] - In views/share.js:58,34
[ERROR] : TiExceptionHandler: (main) [0,43722] - Message: Uncaught Error: quality must be 0..100
[ERROR] : TiExceptionHandler: (main) [0,43722] - Source:
[ERROR] : V8Exception: Exception occurred at views/share.js:58: Uncaught Error: quality must be 0..100
what's wrong?
Try this
if (Ti.Platform.osname=="android"){
// For android
resizedImage = ImageFactory.imageAsResized(imageView, {height : h,width:w});
}else{
// For iOS
resizedImage = ImageFactory.imageAsResized(imageView, {height : h,width:w, quality: quality});
}
for more please refer app.js of android and iOS
For image resizing you can use.
[TiBlob] imageAsResized([int] width, [int] height)
Example : -
var blob = myimage.toBlob();
var smallBlob = blob.imageAsResized(80, 80);
also refer