2

I am building a custom Android lock screen with custom PIN. I would like to allow users to answer incoming calls without having to enter the PIN and without compromising the security of the phone.

Both Next Lock Screen and GoLocker have this feature.

Two bad alternatives: (1) force the user to enter the PIN or (2) completely unlock the phone when the user receives a phone call

Any suggestions, please?

Thanks!

alexyes
  • 773
  • 2
  • 7
  • 14

1 Answers1

0

Just listen to TelephonyManager states with a broadcast receiver and decide what to do. Register a receiver for:

<intent-filter>
    <action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>

...and whenever onReceive kicks in check if...

intent.getStringExtra(TelephonyManager.EXTRA_STATE) == TelephonyManager.EXTRA_STATE_RINGING

That means you're getting a call, so you can hide your "lock screen", but that would be a major security flaw - whoever has the person's number and a SIM pin unlocked phone (e.g. someone who just stole it and happens to know your number...) will just kill your "custom PIN" feature by faking a call.

If you want to answer a call directly by your app, you're in very different, yet more problematic waters than just that - Android does not allow unprivileged apps (non-root) to answer calls, and all the methods I know are either hacks of the reflection type, of the "bluetooth headset press" emulation type, or no-longer-working shell program invocation type... There is nothing that works consistently across devices, you have to mix and match, and some devices will require conditionals because trying one of those might crash that specific rom. That's why there no longer exist many true "in call screen" apps on the market, just dialers that trigger the system's in call screen before a call, or overlays on top of the system's screen when receiving a call (which pretty much do what I described at the beginning of this answer).

leRobot
  • 1,497
  • 1
  • 18
  • 30