0

i'm trying to build a custom dialer that's contains two buttons for answer and decline the call. For answer the incoming call i use the code find in this post.

That's work very well in many devices ( Samsung, Nexus 5, Huawei), but only with ASUS devices, Android Monitor give me this Exception when i try to answer:

Permission denied: injecting event from pid 30792 uid 10246 to window Window{3c7cf834 u0 com.asus.asusincallui/com.asus.asusincallui.InCallActivity} owned by uid 10011 <br>
FATAL EXCEPTION IN SYSTEM PROCESS: main java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission

This happens only when the screen is off. I have already try to add INJECT_EVENT to manifest but didn't works (it's a system permission). Any ideas?

My manifest:`

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.INJECT_EVENTS" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />`

And my Build.gradle:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "com.noatel.customdialer"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
   ...
    }
}

}

dependencies { compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.google.android.gms:play-services-gcm:8.4.0' compile 'com.android.support:support-v4:23.4.0' compile 'hanks.xyz:htextview-library:0.1.5' compile 'com.github.castorflex.smoothprogressbar:library-circular:1.2.0'

}

Community
  • 1
  • 1
giuseppe trubia
  • 142
  • 1
  • 13
  • Root the device and make your app a system app. – CommonsWare Nov 07 '16 at 16:24
  • @CommonsWare i need to run this app in not rooted devices – giuseppe trubia Nov 07 '16 at 16:27
  • Can you post your Manifest, so we can see details, also the `build.gradle` might help. It is likely that users have denied, or applications have denied the permission usually on Android `L` and forward. – Bonatti Nov 07 '16 at 16:45
  • @Bonatti I'have added the files. – giuseppe trubia Nov 07 '16 at 16:59
  • Well, you are under the `Marshmallow` build target, so the runtime permission system applies. You are also assuming that the user/system has allowed the permission. It is possible that the manufacturer has disabled any sort of system level permissions on their devices, but I cant tell for sure. Can you Log and collect that info? – Bonatti Nov 08 '16 at 11:19
  • @Bonatti Today i try to build project with SDK 22. Now, sometimes, Asus devices answer correctly to call (however the exception is launched). – giuseppe trubia Nov 08 '16 at 13:59
  • The device likely has non-compliant changes to its buidl, thats is why its likely its just that manufacturer that has issues. While Android is AOSP, it can be altered without consequences for its distributors. Before API 21, permissions were given at install time, then, on API 20, started the compatibility mode, then on 22+, then runtime permission system. How are you calling the `Activity`, or `Window`? – Bonatti Nov 08 '16 at 15:19
  • I call AnswerActivity from a Window. – giuseppe trubia Nov 09 '16 at 08:16

0 Answers0