Compilation failed in Java for "android.permission.READ_NETWORK_USAGE_HISTORY" - java

I am facing 1 issue and could not solve it yet.
ERROR : "java.lang.RuntimeException: java.lang.SecurityException: NetworkStats: Neither user 10053 nor current process has android.permission.READ_NETWORK_USAGE_HISTORY".
I am implementing this in API 23 which is having a runtime security implementation for permission, I hope you understand what I am trying to say. I was able to add android.permission.READ_NETWORK_USAGE_HISTORY in Manifest but I am not able to add the same permission in Java file because its giving the compilation error. Could you please help ?
Below is the Manifest.xml code :- (Working fine with a waring)
Below is the Java code :- (Compilation Failed)

It allows only for System Apps not for Normal Applications. So we can't get the access for read Network Usage History.
you want access network information you should use this permission
"android.permission.ACCESS_NETWORK_STATE"
Allows applications to access information about networks.
and refer this url : https://developer.android.com/training/basics/network-ops/managing.html

Related

Android application crashes in Debug mode with FORTIFY: fread: null FILE*

I am trying to run Android application on Paired Device via Wifi and it fail to run with following error:
I guess it is due to the audit warning that it cannot read respective file in /mnt/vendor folder, but Android is not my main technology field so I am at wits end what the solution might be.
It also look like the application is not trusted, but it have all the permissions as I am using example application from someone else and the AndroidManifest.xml permissions are the same.
Thanks a lot in advance!

Can't Load .SO library

I have A problem with Loading SO Libraries Dynamically in android and in order for people to understand why I actually need to do this and maybe suggest different ways to do it I'm going to explain briefly the project. I'm working on a research project to test the benefits of code offloading the flow that I have been working on is as follows :
The user triggers a function that was predetermined to be time-consuming the process is intercepted using Xposed Hooks, The Apk of the App is sent to server then the on the server I run the method from the APK dynamically for android nougat or even oreo this won't cause any troubles as I thought but the main problem some of the apps I'm working on use non-NDK libs and this causes some problems because the system won't allow the me to load the libraries dynamically I'm required to add these libraries to my app and this doesn't work for me because I the server app is one app fit all it receives a method name apk and package name and some parameters and it should run the function with the parameters of and return the result regardless of the apk or function name so cutting to the problem directly
I need to be able to run this code without trouble
the code :
val classLoader = DexClassLoader("/storage/emulated/0/ApkDir/base.apk", applicationContext.codeCacheDir.absolutePath,
"/storage/emulated/0/ApkDir/lib/arm64/" , this.javaClass.classLoader
The problems that the code raises for android oreo and above
01-15 03:19:22.729 10712-10712/com.sablab.myapplication W/b.myapplication: type=1400 audit(0.0:11387): avc: denied { execute } for path="/storage/emulated/0/APKDir/libs/libpngt.so" dev="fuse" ino=79 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:fuse:s0 tclass=file permissive=0
and if not this I get
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/storage/emulated/0/APKDir/libs/libpngt.so" segment 1: Permission denied

Is there some way of finding a missing SharePoint user?

So I have administrator privileges to a SharePoint site. The site crashes on loading due to a user not found. I keep getting this error:
Microsoft.SharePoint.SPException: User cannot be found.
at Microsoft.SharePoint.SPUserCollection.get_Item(String loginName)
I have access to the server code to view it, but not for running purposes. I know it has something to do with a new migration of users.
Does anyone know if there’s any way using the SharePoint administrative functions to view which invalid user causes a site crash?

android.permission.WRITE_SECURE_SETTINGS error

Hello my problem is that when I try to change weather or not the GPS setting is enabled I get the following error 10-20 05:44:31.890: E/AndroidRuntime(889): java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS while in my manifest file I do have the permission listed in the error inside my manifest file.
Manifest:
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
Any help would be appreciated
WRITE_SECURE_SETTINGS is a signatureOrSystem permission, meaning that ordinary SDK applications cannot hold it. Only apps that are related to the firmware can hold this permission.
Reading all answers for this particular issue, one way around for this is to use this code to enable the gps but it wont work, as CommonsWare pointed, the application has to be system app for getting this code to work..so one can convert the application into system app by using TitaniumBackup. THis is working perfectly fine for me now.
*Sony users will see another message "Will collect anonymous data while using gps" - to overcome this, 'Freeze' the "LEarning Client" app and everything will be fine.

Permissions required to create charts with JFreeChart

I'd like to use JFreeChart to create charts from code running under a security manager. This fails with the error message
java.lang.InternalError: Can't connect to window server - not enough permissions.
If I change my policy file to give the code unrestricted permissions, it works fine, so the error must be due to some permission missing in my policy. But which one? I tried various AWT-related permissions but nothing seems to work. Is there a way to find out which permissions are missing?
When you start the app , add the following to the jvm arguments - it produces a huge amount of output, but it will point you in the right direction when there are permissions failures.
-Djava.security.debug=access,failure

Categories