Android 10+ android.permission.NETWORK_STACK for hidden api - android

I am testing a new app on a physical device:
REDMI NOTE 9 PRO
android 10
MIUI 12
I am trying to access to startSoftAp that is a hidden method of WifiManager class. That is I want programmatically start and stop tethering.
Following this approach and many other links such as:
https://www.xda-developers.com/android-development-bypass-hidden-api-restrictions/
https://www.reddit.com/r/androiddev/comments/deyz14/apparently_you_can_destroy_hidden_api_blacklist/
I am facing a new issue regarding
android.permission.NETWORK_STACK
that I am not able to fix. The main cause is
Caused by: **java.lang.SecurityException: WifiService: Neither user
10448 nor current process has android.permission.NETWORK_STACK.
Obviously I tried to specify this via manifest file but this is a non-SDK permission or hidden permission. Then them method described by many programmer to bypass hidden API seems is missing something about this permission.
Here is the stack trace.
**java.lang.reflect.InvocationTargetException**
at java.lang.reflect.Method.invoke(Native Method)
at com.example.tel_info.MainActivity.setHotspot(MainActivity.java:111)
at com.example.tel_info.MainActivity.onCreate(MainActivity.java:85)
at android.app.Activity.performCreate(Activity.java:7893)
at android.app.Activity.performCreate(Activity.java:7880)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5372)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5280)
at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7562)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.example.tel_info.HideClass.startSoftApInstance(HideClass.java:42)
Caused by: **java.lang.SecurityException: WifiService: Neither user 10448 nor current process has android.permission.NETWORK_STACK.**
at android.os.Parcel.createException(Parcel.java:2074)
at android.os.Parcel.readException(Parcel.java:2042)
at android.os.Parcel.readException(Parcel.java:1990)
at android.net.wifi.IWifiManager$Stub$Proxy.startSoftAp(IWifiManager.java:3031)
at android.net.wifi.WifiManager.startSoftAp(WifiManager.java:2721)
Caused by: android.os.RemoteException: Remote stack trace:
at android.app.ContextImpl.enforce(ContextImpl.java:1906)
at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1934)
at com.android.server.wifi.WifiServiceImpl.enforceNetworkStackPermission(WifiServiceImpl.java:915)
at com.android.server.wifi.WifiServiceImpl.startSoftAp(WifiServiceImpl.java:1206)
at android.net.wifi.IWifiManager$Stub.onTransact(IWifiManager.java:1359)
How to grant this to my app? Thanks in advance.

Related

Android 13 crash: Getting securityException (calling identity is not authorized) crash on android 13

facebookincubator/Battery-Metrics repo's getSnapshot method in class SystemMetricsCollector is crashing because of java.lang.SecurityException: Calling identity is not authorized on android 13. It was working on android 12 and on versions before. Logs for the crash are:
java.lang.RuntimeException: Unable to start activity ComponentInfo{AppName/com.AppName.ux.activity.MainActivity}: java.lang.SecurityException: Calling identity is not authorized at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3686) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3823) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7892) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by: java.lang.SecurityException: Calling identity is not authorized at android.os.Parcel.createExceptionOrNull(Parcel.java:3011) at android.os.Parcel.createException(Parcel.java:2995) at android.os.Parcel.readException(Parcel.java:2978) at android.os.Parcel.readException(Parcel.java:2920) at android.net.INetworkStatsService$Stub$Proxy.openSessionForUsageStats(INetworkStatsService.java:469) at android.app.usage.NetworkStats.<init>(NetworkStats.java:111) at android.app.usage.NetworkStatsManager.querySummary(NetworkStatsManager.java:424) at android.app.usage.NetworkStatsManager.querySummary(NetworkStatsManager.java:397) at com.facebook.battery.metrics.network.NetworkStatsManagerBytesCollector.getBytesForType(NetworkStatsManagerBytesCollector.java:51) at com.facebook.battery.metrics.network.NetworkStatsManagerBytesCollector.getTotalBytes(NetworkStatsManagerBytesCollector.java:38) at com.facebook.battery.metrics.network.NetworkMetricsCollector.getSnapshot(NetworkMetricsCollector.java:53) at com.facebook.battery.metrics.network.NetworkMetricsCollector.getSnapshot(NetworkMetricsCollector.java:33) at com.facebook.battery.metrics.composite.CompositeMetricsCollector.getSnapshot(CompositeMetricsCollector.java:99) at com.AppName.features.appsetup.ux.workflow.tasks.LaunchScreenTask.process(LaunchScreenTask.java:66) at com.AppName.features.appsetup.ux.workflow.WorkflowExecutor.execute(WorkflowExecutor.java:84) at com.AppName.ux.activity.MainActivity.startWorkflow(MainActivity.java:414) at com.AppName.ux.activity.MainActivity.workflowDelegation(MainActivity.java:1134) at com.AppName.ux.activity.MainActivity.ecsEventHandler(MainActivity.java:568) at com.AppName.ux.activity.MainActivity.onCreate(MainActivity.java:324) at android.app.Activity.performCreate(Activity.java:8285) at android.app.Activity.performCreate(Activity.java:8264) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1384) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3667)

Need Help Diagnosing why Kivy Android App Crashes on Launch

I've developed a KivyMD app which runs fine on my Windows machine. However, my company has locked down all my USB ports, so I'm not able to "deploy" the app for testing with Buildozer. Instead, I'm using Android Studio to emulate Android. I'm able to install my APK file (produced with Buildozer) on the virtual device, but when I launch the app I only see a Kivy splash screen which says "Loading..." for a second and then it crashes.
Android Studio provides the following log, but as far as I can tell it offers no clue to what the problem is.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.facefinder, PID: 3493
java.lang.RuntimeException: Unable to resume activity {com.example.facefinder/com.example.facefinder.MainActivity}:
java.lang.NullPointerException: Attempt to get length of null array
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4205)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.example.facefinder.MainActivity.onResume(MainActivity.java:81)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446)
at android.app.Activity.performResume(Activity.java:7939)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237) 
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7356) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
What can I do to diagnose my problem? Thanks in advance for any guidance!

How can I get address information using latitude and longitude?

I made this tutorial for get user's address and location but I got error when I changed AVD's location. When I didn't call getCityName function at getLastLocation function, I can get user's location but when I call it, it gave that error. How can I solve it?
it was give an error which was :
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.slidework3, PID: 15792
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
Caused by: java.io.IOException: grpc failed
at android.location.Geocoder.getFromLocation(Geocoder.java:136)
at com.example.slidework3.AdresPage.getCityName(AdresPage.kt:152)
at com.example.slidework3.AdresPage.access$getCityName(AdresPage.kt:20)
at com.example.slidework3.AdresPage$getLastLocation$1.onComplete(AdresPage.kt:66)
at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
Edit:
I tried real device, location services working well I can get city name, street name etc. But in simulator it was give error again. I tried to change AVD's location after that it was going to crash. I believe solution is simple but I don't know how can I search this situation.
Try run the operation in a new Thread, and then if I need to update some UI view I'll do it on runOnUiThread.
https://developer.android.com/training/location/display-address#java

React Native app crashing at startup on Android: Didn't find class "com.facebook.react.devsupport.DevSupportManagerImpl"

I am using React Native v 0.62.2 and I am trying to get my project running on Android as well. Up until now, I had focussed development on iOS and therefore did never run the Android app. Now I wanted to run the android app but the app crashes on startup right after the splash screen was shown with the following stacktrace:
java.lang.RuntimeException: Unable to create application com.myapp.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6612)
at android.app.ActivityThread.access$1300(ActivityThread.java:233)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at com.facebook.react.devsupport.a.a(:90)
at com.facebook.react.q.<init>(:238)
at com.facebook.react.r.b(:281)
at com.facebook.react.t.a(:87)
at com.facebook.react.t.h(:39)
at com.myapp.MainApplication.onCreate(:48)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607)
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
Caused by: java.lang.ClassNotFoundException: com.facebook.react.devsupport.DevSupportManagerImpl
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at com.facebook.react.devsupport.a.a(:68)
at com.facebook.react.q.<init>(:238) 
at com.facebook.react.r.b(:281) 
at com.facebook.react.t.a(:87) 
at com.facebook.react.t.h(:39) 
at com.myapp.MainApplication.onCreate(:48) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607) 
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.devsupport.DevSupportManagerImpl" on path: DexPathList[[zip file "/data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/base.apk"],nativeLibraryDirectories=[/data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/lib/x86, /data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/base.apk!/lib/x86, /system/lib, /system_ext/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:454) 
at java.lang.Class.forName(Class.java:379) 
at com.facebook.react.devsupport.a.a(:68) 
at com.facebook.react.q.<init>(:238) 
at com.facebook.react.r.b(:281) 
at com.facebook.react.t.a(:87) 
at com.facebook.react.t.h(:39) 
at com.myapp.MainApplication.onCreate(:48) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607) 
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
I searched the web for solutions or at least hints but did unfortunately not find any solution or even any idea of what could be done to fix this issue.
Does anyone have any idea? Also please let me know if you need any further information in order to be able to answer the question.
Thanks a lot!
For all who are struggling with this issue as well - after a long period of research plus try and error, I got it finally fixed.
It seems that this issue actually is correlated to OK HTTP. The steps that made me get it running were the following:
Enable MultiDex but also keep attention on going for the AndroidX solution (as I use the latest version of React Native which already leverages AndroidX) as stated in the following answer:
https://stackoverflow.com/a/56875424/9055450
Follow the instructions given in the following comment adding ProGuard files: https://github.com/facebook/react-native/issues/9043#issuecomment-298832659

Cannot connect to android.support.test.orchestrator.OrchestratorService

Not able to run instrumentation test with android orchestrator,
I have followed developer doc and made same changes but it's not working.
Screen shot and logs are attached.
Any help would be appreciated thanks in advance
Logcat:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ctpl.myinstrumentationtest, PID: 6608
java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{com.example.ctpl.myinstrumentationtest.test/android.support.test.runner.AndroidJUnitRunner}: java.lang.RuntimeException: Cannot connect to android.support.test.orchestrator.OrchestratorService
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5868)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.RuntimeException: Cannot connect to android.support.test.orchestrator.OrchestratorService
at android.support.test.orchestrator.instrumentationlistener.OrchestratedInstrumentationListener.connect(OrchestratedInstrumentationListener.java:87)
at android.support.test.runner.AndroidJUnitRunner.onCreate(AndroidJUnitRunner.java:303)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5863)
at android.app.ActivityThread.access$1100(ActivityThread.java:199) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6669) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
List item
I had the same problem but with androidx orchestrator. I was getting the same exception but the package was different:
Caused by: java.lang.RuntimeException: Cannot connect to androidx.test.orchestrator.OrchestratorService.
I have found the description of possbile root cause in this github thread. There's an iteresting discussion, but it seems that there's no general solution for this yet.
For me the problem was caused by setting the target sdk to 30 and launching the app on an android 30 emulator. So launching tests on emulator with api < 30 resolved this.

Categories

Resources