SecurityException Huawei phone

472 views Asked by At

Our app is getting a SecurityEception on a Huawei device (Huawei P30 Pro, Android 10). We have no idea what might be causing this, and Googling for it gave no results. The complete stacktrace:

java.lang.SecurityException: 
  at android.os.Parcel.createException (Parcel.java:2071)
  at android.os.Parcel.readException (Parcel.java:2039)
  at android.os.Parcel.readException (Parcel.java:1987)
  at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo (IConnectivityManager.java:2153)
  at android.net.ConnectivityManager.getActiveNetworkInfo (ConnectivityManager.java:1006)
  at com.huawei.android.totemweather.common.NetUtil.isNetworkAvaialble (NetUtil.java:107)
  at com.huawei.android.totemweather.widget.controller.AutoRefreshManager.sendRefresh (AutoRefreshManager.java:78)
  at com.huawei.android.totemweather.widget.controller.WidgetWeatherServiceAgent$WeatherDataObserver$WeatherReceiver.lambda$onReceive$0$WidgetWeatherServiceAgent$WeatherDataObserver$WeatherReceiver (WidgetWeatherServiceAgent.java:509)
  at com.huawei.android.totemweather.widget.controller.WidgetWeatherServiceAgent$WeatherDataObserver$WeatherReceiver$$Lambda$0.run (WidgetWeatherServiceAgent.java:2)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at java.lang.Thread.run (Thread.java:929)
Caused by: android.os.RemoteException: 
  at android.app.ContextImpl.enforce (ContextImpl.java:2001)
  at android.app.ContextImpl.enforceCallingOrSelfPermission (ContextImpl.java:2029)
  at com.android.server.ConnectivityService.enforceAccessPermission (ConnectivityService.java:2195)
  at com.android.server.ConnectivityService.getActiveNetworkInfo (ConnectivityService.java:1507)
  at com.android.server.HwConnectivityService.getActiveNetworkInfo (HwConnectivityService.java:2559)

Does anyone have an idea of what might be causing this? It seems it might have to do with an exception being raised when the network is accessed from the Huawei Weather widget.

Edit: we create a custom launcher.

2

There are 2 answers

0
Zinna On

So I searched up what remoteException meant and it seems to happen when the remote object is no longer available, typically meaning it crashed. Given it's a widget they are trying to access information on, the widget or the app might be crashing as it is trying to access information that is not available. The SeurityException that is being reported can be caused by missing permissions. So there may be missing permissions that is preventing the information of the widget/app from being properly accessed and therefore crashing and not working as expected. Please check your manifest for missing permissions, especially ones to connectivity/internet access.

0
nils277 On

From experience i can tell you that widgets from Huawei do not play well with third party launchers. I also have a launcher on Google Play myself and a significant amount of crashes were (and still are) coming from widgets on Hauwei devices. In the last weeks i also had multiple similar crashes specifically from the Huawei P30. The problems are (almost) always security exceptions inside the widgets. However there does not seem to be a permission you can add to the manifest to solve this problem. There is also no way i know of to catch these exceptions.

From what i read and heard from other third party launcher (and what i also do) is to filter out all widgets from Huawei so that they cannot be added. I'm afraid that there is not other way to fix this problem from your side. You can take a look at the repository of the Lawnchair Launcher to get an ideo of how to blacklist the huawei widgets: https://github.com/LawnchairLauncher/Lawnchair/blob/87c0ab17050bca7fe354bf99d41a461b04aa9958/src/com/android/launcher3/compat/AppWidgetManagerCompat.java

However at least one widget from Huawei on the P30 is not excluded by this. It would be really cool if there was a list of widgets from Hauwei so one can exclude them more reliable.