From af8b1fded8726c30b4cec658cf8336bbf5731892 Mon Sep 17 00:00:00 2001 From: Jens Date: Sun, 2 Apr 2023 23:51:09 +0200 Subject: [PATCH] PhoneStatusListener --- .../receivers/PhoneStatusListener.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/src/main/java/com/jens/automation2/receivers/PhoneStatusListener.java b/app/src/main/java/com/jens/automation2/receivers/PhoneStatusListener.java index 41d816b..0790b75 100644 --- a/app/src/main/java/com/jens/automation2/receivers/PhoneStatusListener.java +++ b/app/src/main/java/com/jens/automation2/receivers/PhoneStatusListener.java @@ -160,6 +160,41 @@ public class PhoneStatusListener implements AutomationListenerInterface, Executo } } + public static class IncomingCallsReceiverNew() + { + void start() + { + TelephonyManager telephonyManager = (TelephonyManager) AutomationService.getInstance().getSystemService(Context.TELEPHONY_SERVICE); + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + { + Executor executor = new Executor() + { + @Override + public void execute(Runnable runnable) + { + + } + }; + + TelephonyCallback callback = new TelephonyCallback(); + + telephonyManager.registerTelephonyCallback(context.mainExecutor, new TelephonyCallback()); + object : TelephonyCallback(), TelephonyCallback.CallStateListener { + override fun onCallStateChanged(state: Int) { + } + }) + } + else + { + telephonyManager.listen(object : PhoneStateListener() { + override fun onCallStateChanged(state: Int, phoneNumber: String?) { + } + }, PhoneStateListener.LISTEN_CALL_STATE) + } + } + } + static void setLastPhoneDirection(int i) { lastPhoneDirection = i;