android.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS or be the installer on record - permissions

while setting an app whitelist to setAutoRevokeWhitelisted i get the following error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mcn.honeydew, PID: 31152
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mcn.honeydew/com.mcn.honeydew.ui.main.MainActivity}: java.lang.SecurityException: Caller must either hold android.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS or be the installer on record
MyCode->
private void RemovePermissionsIfAppIsUnused() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (!getApplicationContext().getPackageManager().isAutoRevokeWhitelisted()) { getApplicationContext().getPackageManager().setAutoRevokeWhitelisted(getApplicationContext().getPackageName(),true); } } }

Related

Kotlin JNI - Unsatisfied link error when calling external function but not when loading library

C++ method signature:
JNIEXPORT void JNICALL
Java_abc_de_fg_jni_ProxyControls_startProxy(JNIEnv *env, jobject obj);
Loading the library doesn't cause any errors:
package abc.de.fg.jni
class ProxyControls {
init {
System.load("/Users/***/***/lib***.dylib")
println("loaded library")
}
external fun startProxy()
}
But running the startProxy method throws the error:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: 'void abc.de.fg.jni.ProxyControls.startProxy()'
at abc.de.fg.jni.ProxyControls.startProxy(Native Method)
What have I done wrong?
More info:
Throwing an error on JNI_OnLoad crashes the app but throwing an error on startProxy() doesn't change the exception. So JNI_OnLoad is called but startProxy isn't called.
nm output: (filtered)
0000000000001e58 T _JNI_OnLoad
0000000000001ef4 T __Z51Java_abc_de_fg_jni_ProxyControls_startProxyP7JNIEnv_P8_jobject

Kotlin: Mediaplayer: Couldn't open content://com.android.externalstorage.: java.lang.SecurityException: Permission Denial: reading com.android.ext

Not able to play a song stored as a Uri in SQLite,
The file selected by below function is playing well
private fun selectMusicFile() {
val intent = Intent()
intent.type = "audio/*"
intent.action = Intent.ACTION_GET_CONTENT
startActivityForResult(Intent.createChooser(intent, "Select Audio"), 123)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 123) {
if (data?.data != null){
musicFileUri = data?.data!!
binding.tvMusicFile.text = data?.data!!.toString()
setupMediaPlayer()
}
}
}
The same uri is stored in SQLite as a text field. When i try to play this uri then i get error
here is code for setting up the mediaplayer using uri from SQLite which gets store in the textview
private fun setupMediaPlayer() {
val vUri = Uri.parse(binding.tvMusicFile.text.toString())
mediaPlayer.setDataSource(this, vUri)
mediaPlayer.prepare()
}
it fails at setDataSource
setupMediaPlayer() works well when called from onActivityResult, but fails when called from other place e.i. after fetching uri from SQLite table
Can someone please help
here is error log
W/MediaPlayer: Couldn't open content://com.android.externalstorage.documents/document/primary%3AMusic%2FThe%20Man%20Machine%2FThe%20Model.mp3: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/document/primary%3AMusic%2FThe%20Man%20Machine%2FThe%20Model.mp3 from pid=23509, uid=10264 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
E/MediaPlayerNative: Unable to create media player
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx, PID: 23509
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx/com.xxx.configure.ConfigureActivity}: java.io.IOException: setDataSource failed.: status=0x80000000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2861)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2943)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1630)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6626)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
Caused by: java.io.IOException: setDataSource failed.: status=0x80000000
at android.media.MediaPlayer.nativeSetDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1172)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1160)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1078)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1003)
at com.xxx.configure.ConfigureActivity.setupMediaPlayer(ConfigureActivity.kt:189)
at com.xxx.configure.ConfigureActivity.onCreate(ConfigureActivity.kt:115)
at android.app.Activity.performCreate(Activity.java:7032)
at android.app.Activity.performCreate(Activity.java:7023)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1236)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2814)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2943) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1630) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6626) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811) 

Camel Route to Upload to S3 fails

Im trying to construct a basic route that detects a .csv file and uploads it to my S3 bucket.
The csv file gets gedected and the route works except of the .to("aws-s3...") part.
I've tried the solution from this question but it fails.
My Route:
public class CsvToS3Route extends RouteBuilder {
#Override
public void configure() throws Exception {
from("file:./src/main/resources/mycsvfilesfolder?filterFile=${file:name.ext.single} =~ 'csv'")
.convertBodyTo(byte[].class)
.setHeader(S3Constants.CONTENT_LENGTH, simple("${in.header.CamelFileLength}"))
.setHeader(S3Constants.KEY,simple("${in.header.CamelFileNameOnly}"))
.to("aws-s3://my-bucket?deleteAfterWrite=false&region=eu-west-1&accessKey=mypublickey&secretKey=RAW(mysecretkey)")
.log("done.");
}}
My Main Class:
#Component
public class CamelRoutes {
Logger logger = LoggerFactory.getLogger(CamelRoutes.class);
private Main main;
private CamelContext context;
#Bean
public void run() throws Exception {
this.main = new Main();
this.context = new DefaultCamelContext(registry);
context.addRoutes(new CsvToS3Route());
main.getCamelContexts().clear();
main.getCamelContexts().add(context);
// Run Camel forever
logger.info("Starting Camel Application");
main.setDuration(-1);
main.run();
}}
The Error
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.apache.camel.support.DefaultComponent.doStart(DefaultComponent.java:245)
The following method did not exist:
org.apache.camel.CamelContext.getPropertiesComponent(Z)Lorg/apache/camel/spi/PropertiesComponent;
The method's class, org.apache.camel.CamelContext, is available from the following locations:
jar:file:/Users/myuser/.gradle/caches/modules-2/files-2.1/org.apache.camel/camel-core/2.23.2.fuse-750029-redhat-00001/93a0f16a539d46373c121d4b10cd9fc844c8779a/camel-core-2.23.2.fuse-750029-redhat-00001.jar!/org/apache/camel/CamelContext.class
jar:file:/Users/myuser/.gradle/caches/modules-2/files-2.1/org.apache.camel/camel-api/3.0.0-M2/7724c277b1f57116083c555ccb3bfd63a4e74ea0/camel-api-3.0.0-M2.jar!/org/apache/camel/CamelContext.class
It was loaded from the following location:
file:/Users/myuser/.gradle/caches/modules-2/files-2.1/org.apache.camel/camel-core/2.23.2.fuse-750029-redhat-00001/93a0f16a539d46373c121d4b10cd9fc844c8779a/camel-core-2.23.2.fuse-750029-redhat-00001.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.camel.CamelContext
2020-02-13 12:53:28.898 INFO 31954 --- [ngupInterceptor] o.a.c.m.MainSupport$HangupInterceptor : Received hang up - stopping the main instance.
2020-02-13 12:53:28.899 INFO 31954 --- [ngupInterceptor] o.apache.camel.impl.DefaultCamelContext : Apache Camel 2.23.2.fuse-750029-redhat-00001 (CamelContext: camel-1) is shutting down
2020-02-13 12:53:28.911 INFO 31954 --- [ngupInterceptor] o.apache.camel.impl.DefaultCamelContext : Apache Camel 2.23.2.fuse-750029-redhat-00001 (CamelContext: camel-1) uptime 0.213 seconds
2020-02-13 12:53:28.911 INFO 31954 --- [ngupInterceptor] o.apache.camel.impl.DefaultCamelContext : Apache Camel 2.23.2.fuse-750029-redhat-00001 (CamelContext: camel-1) is shutdown in 0.012 seconds
Process finished with exit code 1
Is there something I am missing?

Red5 Application fails to connect

I am attempting to run a basic application on Red5 that just makes an attempt to connect to the red5 server (on localhost). The source for this application is below:
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.scope.IScope;
// import org.red5.server.api.service.ServiceUtils;
/**
* Sample application that uses the client manager.
*
* #author The Red5 Project (red5#osflash.org)
*/
public class Application extends ApplicationAdapter {
/** {#inheritDoc} */
#Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
return true;
}
/** {#inheritDoc} */
#Override
public void disconnect(IConnection conn, IScope scope) {
super.disconnect(conn, scope);
}
}
My client code is also pretty basic. For brevity, the snippet is below:
public function onCreationComplete(event:FlexEvent) : void {
// setup connection code
connection = new NetConnection();
connection.connect("rtmp://localhost/Player");
connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
connection.client = this;
}
public function onConnectionNetStatus(event:NetStatusEvent) : void {
// did we successfully connect
if(event.info.code == "NetConnection.Connect.Success") {
Alert.show("Successful Connection", "Information");
} else {
Alert.show("Unsuccessful Connection "+event.info.code, "Information");
}
Note that I make the alert box show the error code so I can see what happens.
On the client side, when I attempt to connect, I get two failure messages:
Unsuccessful Connection NetConnection.Connect.Closed
Unsuccessful Connection NetConnection.Connect.Rejected
And on the server side I am seeing the following:
[INFO] [NioProcessor-10]
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder - Action connect
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPConnection -
Setting object encoding to AMF3
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPHandler - Scope
Player not found on localhost
[WARN] [Red5_Scheduler_Worker-3]
org.red5.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection
from 127.0.0.1 : 50051 to localhost (in: 3334 out 3256 ), with id 9
due to long handshake
It seems clear that something is wrong due to some kind of mis- configuration. Unfortunately, I have no idea where to look for the problem.
Could someone please give some idea of what is going wrong and how I can fix this? Thank you...
ADDITION: Startup Exception that occurs when running Red5 v1 RC2:
Exception in thread "Launcher:/Player" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with
name 'web.context' defined in ServletContext resource [/WEB-INF/red5-web.xml]:
Unsatisfied dependency expressed through bean property 'clientRegistry': : Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml];
nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1199)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.red5.server.tomcat.TomcatLoader$1.run(TomcatLoader.java:593)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:833)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1184)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
... 19 more
Another Fact could be that u have 2 Red5.jars so u have to delete one. In my case it worked rly good.
Big Ty for this post
Change org.red5.server.WebScope to org.red5.server.scope.WebScope in your red5-web.xml file.
what version of Red5 is that?
Are there any exceptions when you startup your custom webapp? There might be already an error in the startup of the server that consequently leads to your issue.
Sebastian
The application scope that you are attempting to connect to "Player" does not exist on the server; the log notes this as "Scope Player not found on localhost". What this means in general is that your application didn't load. The reason that it didn't load looks like class package error for WebScope. Change the beans class attribute to org.red5.server.scope.WebScope and try again.

Runtime exception when functional test running

public class MyTest extends FunctionalTest {
#Test
public void gtest() {
Http.Response response = GET("http://google.com"); // <--- RuntimeException
assertIsOk(response);
assertContentType("text/html", response);
assertCharset("utf-8", response);
}
}
This code throw :
java.lang.RuntimeException: java.util.concurrent.ExecutionException: play.exceptions.UnexpectedException: Unexpected Error
at play.test.FunctionalTest.makeRequest(FunctionalTest.java:299)
at play.test.FunctionalTest.makeRequest(FunctionalTest.java:305)
at play.test.FunctionalTest.GET(FunctionalTest.java:103)
at play.test.FunctionalTest.GET(FunctionalTest.java:57)
at MyTest.gtest(MyTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Can u tell why this error occurs ? And how to fix it? Playframework 1.2.4 / Java 1.7.0_02.
You probably just need to increase your execution pool size, which is by default 1 in dev mode (which also means test, by default). You're running out of threads and thus the exception occurs.
Try with a setting like this in your application.conf:
%test.play.pool=2