Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
feat(policy): implement phone state listener
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <rhernandez@teclib.com>
  • Loading branch information
rafaelje authored and Hector Rondon committed Feb 2, 2018
1 parent 404d3b6 commit c65a0cc
Showing 1 changed file with 16 additions and 0 deletions.
Expand Up @@ -29,6 +29,8 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;

import org.flyve.mdm.agent.data.PoliciesData;
import org.flyve.mdm.agent.services.PoliciesConnectivity;
Expand Down Expand Up @@ -57,6 +59,20 @@ public void onReceive(Context context, Intent intent) {
return;
}

try {
// TELEPHONY MANAGER class object to register one listner
TelephonyManager tmgr = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);

//Create Listener
CustomPhoneStateListener phoneListener = new CustomPhoneStateListener();

// Register listener for LISTEN_CALL_STATE
tmgr.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
}

if("android.provider.Telephony.SMS_RECEIVED".equalsIgnoreCase(action)) {
FlyveLog.d("SMS Received");
if(cache.getSmsMms()!=null && !cache.getSmsMms().equals("")) {
Expand Down

0 comments on commit c65a0cc

Please sign in to comment.