Exemplo n.º 1
0
        static public PhoneStatLog GetInstance()
        {
            if (logInstance == null)
            {
                logInstance = new PhoneStatLog();
            }

            return(logInstance);
        }
Exemplo n.º 2
0
        public override void OnReceive(Context context, Intent intent)
        {
            Toast.MakeText(context, intent.ToString(), ToastLength.Long);

            Intent serviceStart = new Intent(context, typeof(CollectService));

            context.StartService(serviceStart);

            PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "8");
        }
Exemplo n.º 3
0
 public override void OnReceive(Context context, Intent intent)
 {
     try
     {
         if (intent.Action != IntentAction)
         {
             return;
         }
         PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "4");
     }
     catch (Exception ex)
     {
         Toast.MakeText(context, ex.Message, ToastLength.Long).Show();
     }
 }
Exemplo n.º 4
0
        public override void OnDataActivity(DataActivity direction)
        {
            base.OnDataActivity(direction);

            if (direction == DataActivity.None || direction == DataActivity.Dormant)
            {
                if (mDataActivity != 7)
                {
                    mDataActivity = 7;
                    PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "7");
                }
            }
            else
            {
                if (mDataActivity != 6)
                {
                    mDataActivity = 6;
                    PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "6");
                }
            }
        }
Exemplo n.º 5
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            Log.Debug(TAG, "OnStartCommand called at {2}, flags={0}, startid={1}", flags, startId, DateTime.UtcNow);

            RegisterReceiver(smsReceiver, new IntentFilter("android.provider.Telephony.SMS_RECEIVED"));
            RegisterReceiver(phoneCallReceiver, new IntentFilter("android.intent.action.PHONE_STATE"));
            RegisterReceiver(shutdownReceiver, new IntentFilter("android.intent.action.ACTION_SHUTDOWN"));

            var tm = (TelephonyManager)base.GetSystemService(TelephonyService);

            tm.Listen(phoneStateDecetor, PhoneStateListenerFlags.DataActivity | PhoneStateListenerFlags.CellLocation);

            PhoneStatLog.GetInstance().DeviceID = tm.DeviceId;

            locationManager = (LocationManager)base.GetSystemService(LocationService);
            locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, mGPSLocLogger);
            locationManager.RequestLocationUpdates(LocationManager.NetworkProvider, 0, 0, mNetworkLocaLogger);

            RegisterForegroundService();

            return(StartCommandResult.Sticky);
        }
Exemplo n.º 6
0
        public override void OnDestroy()
        {
            base.OnDestroy();

            Log.Debug(TAG, "SimpleService destroyed at {0}.", DateTime.UtcNow);
            UnregisterReceiver(smsReceiver);
            UnregisterReceiver(phoneCallReceiver);

            var tm = (TelephonyManager)base.GetSystemService(TelephonyService);

            tm.Listen(phoneStateDecetor, PhoneStateListenerFlags.None);

            PhoneStatLog.GetInstance().Close();

            locationManager.RemoveUpdates(mGPSLocLogger);
            locationManager.RemoveUpdates(mNetworkLocaLogger);

            StopForeground(true);

            var notificationManager = (NotificationManager)GetSystemService(NotificationService);

            notificationManager.Cancel(10000);
        }
Exemplo n.º 7
0
 public PhoneCallState Idle()
 {
     PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "3");
     //Log.Debug("X:" + typeof(PhoneCallReceiver).Name, "2: Incoming call ended.");
     return(PhoneCallIdle.GetInstance());
 }
Exemplo n.º 8
0
 public PhoneCallState Offhook()
 {
     PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "2");
     //Log.Debug("X:" + typeof(PhoneCallReceiver).Name, "1: Incoming call answered.");
     return(PhoneCallOffhook.GetInstance());
 }
Exemplo n.º 9
0
 public PhoneCallState Offhook()
 {
     PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "0");
     return(PhoneCallOffhook.GetInstance());
 }
Exemplo n.º 10
0
 public PhoneCallState Ring()
 {
     PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "1");
     return(PhoneCallRing.GetInstance());
 }
Exemplo n.º 11
0
 public PhoneCallState Idle()
 {
     PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "3");
     return(PhoneCallIdle.GetInstance());
 }
Exemplo n.º 12
0
 public override void OnReceive(Context context, Intent intent)
 {
     PhoneStatLog.GetInstance().LogPhone(DateTime.Now.ToString(), "9");
 }
Exemplo n.º 13
0
        public override void OnCellLocationChanged(CellLocation location)
        {
            base.OnCellLocationChanged(location);

            var locationManager = (LocationManager)mContext.GetSystemService(Context.LocationService);
            var teleManager     = (TelephonyManager)mContext.GetSystemService(Context.TelephonyService);

            int cid = -1;
            int lac = -1;

            if (location is Android.Telephony.Gsm.GsmCellLocation)
            {
                cid = ((Android.Telephony.Gsm.GsmCellLocation)location).Cid;
                lac = ((Android.Telephony.Gsm.GsmCellLocation)location).Lac;
            }
            else if (location is Android.Telephony.Cdma.CdmaCellLocation)
            {
                cid = ((Android.Telephony.Cdma.CdmaCellLocation)location).BaseStationId;
                lac = ((Android.Telephony.Cdma.CdmaCellLocation)location).NetworkId;
            }

            if (mType != NetworkType.Unknown && mCid == cid && mLac == lac)
            {
                return;
            }

            mCid  = cid;
            mLac  = lac;
            mType = teleManager.NetworkType;

            double lat      = -1.0;
            double lng      = -1.0;
            string gps_type = "unknown";

            Location gps_pos     = null;
            Location network_pos = null;

            if (locationManager.IsProviderEnabled(LocationManager.GpsProvider))
            {
                gps_pos = locationManager.GetLastKnownLocation(LocationManager.GpsProvider);
            }

            if (locationManager.IsProviderEnabled(LocationManager.NetworkProvider))
            {
                network_pos = locationManager.GetLastKnownLocation(LocationManager.NetworkProvider);
            }

            if (gps_pos != null && network_pos != null)
            {
                if (gps_pos.Time >= network_pos.Time)
                {
                    lat      = gps_pos.Latitude;
                    lng      = gps_pos.Longitude;
                    gps_type = "GPS";
                }
                else
                {
                    lat      = network_pos.Latitude;
                    lng      = network_pos.Longitude;
                    gps_type = "Network";
                }
            }
            else if (gps_pos != null)
            {
                lat      = gps_pos.Latitude;
                lng      = gps_pos.Longitude;
                gps_type = "GPS";
            }
            else if (network_pos != null)
            {
                lat      = network_pos.Latitude;
                lng      = network_pos.Longitude;
                gps_type = "Network";
            }

            PhoneStatLog.GetInstance().LogCell(DateTime.Now.ToString(),
                                               cid.ToString(), lac.ToString(),
                                               lat.ToString(), lng.ToString(), gps_type,
                                               teleManager.NetworkOperatorName, teleManager.NetworkType.ToString());
        }
Exemplo n.º 14
0
 public void OnLocationChanged(Location location)
 {
     PhoneStatLog.GetInstance().LogGPS(DateTime.Now.ToString(), location.Latitude.ToString(), location.Longitude.ToString(), "Network");
 }