From a32a1a41b0572633efc2d10b94fda8c23b4a564d Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Wed, 31 Mar 2021 07:31:30 -0700 Subject: [PATCH] [starvation] add model for WifiManager.getConnectionInfo Summary: As per title. Reviewed By: ezgicicek Differential Revision: D27459704 fbshipit-source-id: 0e08f45fb --- infer/src/concurrency/StarvationModels.ml | 5 +++-- .../codetoanalyze/java/starvation/Binders.java | 6 ++++++ .../codetoanalyze/java/starvation/issues.exp | 17 +++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/infer/src/concurrency/StarvationModels.ml b/infer/src/concurrency/StarvationModels.ml index 12a152bf3..2548c641f 100644 --- a/infer/src/concurrency/StarvationModels.ml +++ b/infer/src/concurrency/StarvationModels.ml @@ -146,7 +146,7 @@ let may_do_ipc = ; methods= ["transact"] ; actuals_pred= (fun actuals -> List.nth actuals 4 |> Option.exists ~f:HilExp.is_int_zero) } - ; (* indirectly makes a transact call*) + ; (* indirectly make a transact call *) { default with classname= "android.net.ConnectivityManager" ; methods= ["getActiveNetworkInfo"] } @@ -155,7 +155,8 @@ let may_do_ipc = ; methods= ["getStreamVolume"; "getRingerMode"] } ; { default with classname= "android.content.Context" - ; methods= ["checkPermission"; "checkSelfPermission"] } ]) + ; methods= ["checkPermission"; "checkSelfPermission"] } + ; {default with classname= "android.net.wifi.WifiManager"; methods= ["getConnectionInfo"]} ]) let is_monitor_wait = diff --git a/infer/tests/codetoanalyze/java/starvation/Binders.java b/infer/tests/codetoanalyze/java/starvation/Binders.java index 768cb1929..76a5a9512 100644 --- a/infer/tests/codetoanalyze/java/starvation/Binders.java +++ b/infer/tests/codetoanalyze/java/starvation/Binders.java @@ -8,6 +8,7 @@ import android.content.Context; import android.media.AudioManager; import android.net.ConnectivityManager; +import android.net.wifi.WifiManager; import android.os.Binder; import android.os.RemoteException; import android.support.annotation.UiThread; @@ -85,4 +86,9 @@ class Binders { int doCheckSelfPermissionBad(Context c) { return c.checkSelfPermission(""); } + + @UiThread + void doGetConnectionInfoBad(WifiManager w) { + w.getConnectionInfo(); + } } diff --git a/infer/tests/codetoanalyze/java/starvation/issues.exp b/infer/tests/codetoanalyze/java/starvation/issues.exp index f904aa2d4..9ff6f358e 100644 --- a/infer/tests/codetoanalyze/java/starvation/issues.exp +++ b/infer/tests/codetoanalyze/java/starvation/issues.exp @@ -1,13 +1,14 @@ codetoanalyze/java/starvation/AsyncTaskGet.java, AsyncTaskGet.lockOnUiThreadBad():void, 31, STARVATION, no_bucket, ERROR, [[Trace 1] `void AsyncTaskGet.lockOnUiThreadBad()`, locks `this.lock` in `class AsyncTaskGet`,[Trace 2] `void AsyncTaskGet.taskGetUnderLock()`, locks `this.lock` in `class AsyncTaskGet`,calls `Object AsyncTask.get()`] codetoanalyze/java/starvation/AsyncTaskGet.java, AsyncTaskGet.taskGetOnUiThreadBad():void, 20, STARVATION, no_bucket, ERROR, [`void AsyncTaskGet.taskGetOnUiThreadBad()`,calls `Object AsyncTask.get()`] -codetoanalyze/java/starvation/Binders.java, Binders.annotationBad():void, 44, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.annotationBad()`,Method call: `void Binders.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`] -codetoanalyze/java/starvation/Binders.java, Binders.doCheckPermissionBad(android.content.Context):int, 81, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doCheckPermissionBad(Context)`,calls `int Context.checkPermission(String,int,int)`] -codetoanalyze/java/starvation/Binders.java, Binders.doCheckSelfPermissionBad(android.content.Context):int, 86, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doCheckSelfPermissionBad(Context)`,calls `int Context.checkSelfPermission(String)`] -codetoanalyze/java/starvation/Binders.java, Binders.doGetRingerModeBad(android.media.AudioManager):int, 76, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doGetRingerModeBad(AudioManager)`,calls `int AudioManager.getRingerMode()`] -codetoanalyze/java/starvation/Binders.java, Binders.doGetStreamVolumeBad(android.media.AudioManager):int, 71, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doGetStreamVolumeBad(AudioManager)`,calls `int AudioManager.getStreamVolume(int)`] -codetoanalyze/java/starvation/Binders.java, Binders.getActiveNetworkInfoBad(android.net.ConnectivityManager):void, 66, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.getActiveNetworkInfoBad(ConnectivityManager)`,calls `NetworkInfo ConnectivityManager.getActiveNetworkInfo()`] -codetoanalyze/java/starvation/Binders.java, Binders.interBad():void, 34, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.interBad()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`] -codetoanalyze/java/starvation/Binders.java, Binders.intraBad():void, 39, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.intraBad()`,Method call: `void Binders.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`] +codetoanalyze/java/starvation/Binders.java, Binders.annotationBad():void, 45, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.annotationBad()`,Method call: `void Binders.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`] +codetoanalyze/java/starvation/Binders.java, Binders.doCheckPermissionBad(android.content.Context):int, 82, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doCheckPermissionBad(Context)`,calls `int Context.checkPermission(String,int,int)`] +codetoanalyze/java/starvation/Binders.java, Binders.doCheckSelfPermissionBad(android.content.Context):int, 87, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doCheckSelfPermissionBad(Context)`,calls `int Context.checkSelfPermission(String)`] +codetoanalyze/java/starvation/Binders.java, Binders.doGetConnectionInfoBad(android.net.wifi.WifiManager):void, 92, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.doGetConnectionInfoBad(WifiManager)`,calls `WifiInfo WifiManager.getConnectionInfo()`] +codetoanalyze/java/starvation/Binders.java, Binders.doGetRingerModeBad(android.media.AudioManager):int, 77, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doGetRingerModeBad(AudioManager)`,calls `int AudioManager.getRingerMode()`] +codetoanalyze/java/starvation/Binders.java, Binders.doGetStreamVolumeBad(android.media.AudioManager):int, 72, IPC_ON_UI_THREAD, no_bucket, WARNING, [`int Binders.doGetStreamVolumeBad(AudioManager)`,calls `int AudioManager.getStreamVolume(int)`] +codetoanalyze/java/starvation/Binders.java, Binders.getActiveNetworkInfoBad(android.net.ConnectivityManager):void, 67, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.getActiveNetworkInfoBad(ConnectivityManager)`,calls `NetworkInfo ConnectivityManager.getActiveNetworkInfo()`] +codetoanalyze/java/starvation/Binders.java, Binders.interBad():void, 35, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.interBad()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`] +codetoanalyze/java/starvation/Binders.java, Binders.intraBad():void, 40, IPC_ON_UI_THREAD, no_bucket, WARNING, [`void Binders.intraBad()`,Method call: `void Binders.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`] codetoanalyze/java/starvation/Countdwn.java, Countdwn.awaitOnMainByAnnotBad():void, 21, STARVATION, no_bucket, ERROR, [`void Countdwn.awaitOnMainByAnnotBad()`,calls `void CountDownLatch.await()`] codetoanalyze/java/starvation/Countdwn.java, Countdwn.awaitOnMainByCallBad():void, 16, STARVATION, no_bucket, ERROR, [`void Countdwn.awaitOnMainByCallBad()`,calls `void CountDownLatch.await()`] codetoanalyze/java/starvation/FutureGet.java, FutureGet.getDirectBad():void, 21, STARVATION, no_bucket, ERROR, [`void FutureGet.getDirectBad()`,calls `Object Future.get()`]