public void testRun_whileRinging() throws Exception {
    startTask(TextToSpeech.SUCCESS);

    expect(tts.isSpeaking()).andStubReturn(false);

    // Run the announcement
    AndroidMock.replay(tts);
    PhoneStateListener phoneListener = phoneListenerCapture.getValue();
    phoneListener.onCallStateChanged(TelephonyManager.CALL_STATE_RINGING, null);
    task.run(null);
    AndroidMock.verify(mockTask, tts);
  }
 public void onServiceStateChanged(android.telephony.ServiceState serviceState) {
   if (callbackProcs[CB_SERVICE_STATE_CHANGED] != null) {
     super.onServiceStateChanged(serviceState);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_SERVICE_STATE_CHANGED],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), serviceState));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onServiceStateChanged(serviceState);
   }
 }
Exemple #3
0
 public final void onSignalStrengthsChanged(SignalStrength paramSignalStrength) {
   super.onSignalStrengthsChanged(paramSignalStrength);
   if (bo.a(this.geG) == 2) bo.ep(paramSignalStrength.getCdmaDbm());
   if (bo.a(this.geG) == 1) bo.ep(-113 + 2 * paramSignalStrength.getGsmSignalStrength());
   if (bo.b(this.geG) != null) bo.b(this.geG).listen(bo.c(this.geG), 0);
   bo.d(this.geG);
 }
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {

      super.onCallStateChanged(state, incomingNumber);

      Toast.makeText(MyService.this, incomingNumber + ":" + state, Toast.LENGTH_LONG).show();

      //	int num = Integer.parseInt(incomingNumber);

      String loc = "";

      if (state == TelephonyManager.CALL_STATE_RINGING) {

        try {
          BufferedReader br = new BufferedReader(new FileReader(filePath));
          loc = br.readLine();
          br.close();

        } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

        Toast.makeText(MyService.this, loc + ":" + state, Toast.LENGTH_LONG).show();

        SmsManager smsManager = SmsManager.getDefault();

        smsManager.sendTextMessage(incomingNumber, null, loc, null, null);
      }
    }
 public void onDataActivity(int direction) {
   if (callbackProcs[CB_DATA_ACTIVITY] != null) {
     super.onDataActivity(direction);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_DATA_ACTIVITY],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), direction));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onDataActivity(direction);
   }
 }
 public void onSignalStrengthChanged(int asu) {
   if (callbackProcs[CB_SIGNAL_STRENGTH_CHANGED] != null) {
     super.onSignalStrengthChanged(asu);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_SIGNAL_STRENGTH_CHANGED],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), asu));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onSignalStrengthChanged(asu);
   }
 }
  public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);

    if (callbackContext == null) return;

    String msg = "";

    switch (state) {
      case TelephonyManager.CALL_STATE_IDLE:
        msg = "IDLE";
        Log.d(TAG, "IDLE");
        break;

      case TelephonyManager.CALL_STATE_OFFHOOK:
        msg = "OFFHOOK";
        Log.d(TAG, "OFFHOOK");
        break;

      case TelephonyManager.CALL_STATE_RINGING:
        msg = "RINGING";
        Log.d(TAG, "RINGING");
        break;
    }

    PluginResult result = new PluginResult(PluginResult.Status.OK, msg);
    result.setKeepCallback(true);

    callbackContext.sendPluginResult(result);
    Log.d(TAG, "Result: " + result);
  }
 public void onCellLocationChanged(android.telephony.CellLocation location) {
   if (callbackProcs[CB_CELL_LOCATION_CHANGED] != null) {
     super.onCellLocationChanged(location);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_CELL_LOCATION_CHANGED],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), location));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onCellLocationChanged(location);
   }
 }
 public void onCallForwardingIndicatorChanged(boolean cfi) {
   if (callbackProcs[CB_CALL_FORWARDING_INDICATOR_CHANGED] != null) {
     super.onCallForwardingIndicatorChanged(cfi);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_CALL_FORWARDING_INDICATOR_CHANGED],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), cfi));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onCallForwardingIndicatorChanged(cfi);
   }
 }
 public void onMessageWaitingIndicatorChanged(boolean mwi) {
   if (callbackProcs[CB_MESSAGE_WAITING_INDICATOR_CHANGED] != null) {
     super.onMessageWaitingIndicatorChanged(mwi);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_MESSAGE_WAITING_INDICATOR_CHANGED],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), mwi));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onMessageWaitingIndicatorChanged(mwi);
   }
 }
		@Override
		public void onCallStateChanged(int state, String incomingNumber) {
			// TODO Auto-generated method stub
			super.onCallStateChanged(state, incomingNumber);
			switch (state) {
			case TelephonyManager.CALL_STATE_RINGING:
				String result = dao.findMode(incomingNumber);
				if ("1".equals(result) || "3".equals(result)) {
					Uri uri = Uri.parse("content://call_log/calls");
					CallLogObserver observer = new CallLogObserver(incomingNumber,new Handler());
					getContentResolver().registerContentObserver(uri, true, observer);
					endCall();//在另外一个进程里运行的远程服务的方法
					//删除呼叫记录
					//另外的一个应用程序联系人的应用的私有数据库
					//deleteCallLog(incomingNumber);
				}
				break;

			default:
				break;
			}
			
			
			
		}
 @Override
 public void onCallStateChanged(int state, String incomingNumber) {
   // TODO Auto-generated method stub
   switch (state) {
     case TelephonyManager.CALL_STATE_RINGING:
       onshowToast(AddressDao.location(incomingNumber));
       Log.i("message", "响铃");
       break;
     case TelephonyManager.CALL_STATE_IDLE: // 莫名问题,挂断电话会判断两次。。。,如果每次都removeView,第二次会报空异常
       Log.i("message", "挂断");
       /*if(mWM!=null)
       {
       	Log.i("message", "mWM");
       }
       if(rl!=null)
       {
       	Log.i("message", "rl");
       }*/
       if (rl != null) // 判断rl是否存在再remove就ok了,一般移除子部分主要关心rl是否存在的问题S
       {
         mWM.removeView(rl);
       }
       break;
     case TelephonyManager.CALL_STATE_OFFHOOK:
       Log.i("message", "接听");
       break;
     default:
       break;
   }
   super.onCallStateChanged(state, incomingNumber);
 }
 public void onDataConnectionStateChanged(int state) {
   if (callbackProcs[CB_DATA_CONNECTION_STATE_CHANGED] != null) {
     super.onDataConnectionStateChanged(state);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_DATA_CONNECTION_STATE_CHANGED],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), state));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onDataConnectionStateChanged(state);
   }
 }
 @Override
 public void onCallStateChanged(int state, String incomingNumber) {
   super.onCallStateChanged(state, incomingNumber);
   if (state == TelephonyManager.CALL_STATE_RINGING) {
     if (comingCallDialog != null && comingCallDialog.isShowing()) {
       return;
     }
     lastComingPhone = incomingNumber;
     comingCallDialog =
         new AlertDialog.Builder(mContext)
             .setTitle(R.string.warning)
             .setMessage(getString(R.string.project_join_current, lastComingPhone))
             .setPositiveButton(
                 R.string.confirm,
                 new DialogInterface.OnClickListener() {
                   @Override
                   public void onClick(DialogInterface dialog, int which) {
                     // 迁移
                     if (updateParentTask != null) {
                       updateParentTask.cancel(true);
                       updateParentTask = null;
                     }
                     updateParentTask = new UpdateParentTask();
                     updateParentTask.execute(
                         new String[] {project.getPROJECT_ID(), lastComingPhone});
                   }
                 })
             .setNegativeButton(R.string.cancel, null)
             .create();
     comingCallDialog.setCanceledOnTouchOutside(false);
     comingCallDialog.show();
   }
 }
 @Override
 public void onCellLocationChanged(CellLocation location) {
   super.onCellLocationChanged(location);
   if (location instanceof GsmCellLocation) {
     db = new DatabaseHandler(getApplicationContext());
     GsmCellLocation gcLoc = (GsmCellLocation) location;
     String cellid = String.valueOf(gcLoc.getCid()); // Cell ID
     String lac = String.valueOf(gcLoc.getLac()); // Location Area Code
     // TextView txtCid = (TextView)findViewById(R.id.cellIdTextView);
     String cellId = cellid + ":" + lac;
     String locationName = db.getLocation(cellId);
     GlobalValuesNStatus.getInstance().currentCellId = cellId;
     GlobalValuesNStatus.getInstance().currentCellLocation = locationName;
     // final TiTiGlobal globalVariable = (TiTiGlobal)(getApplicationContext());
     // globalVariable.setCurrentCellId(cellId);
     NotificationHelper notificationHelper = new NotificationHelper(getApplicationContext());
     if (locationName.isEmpty()) {
       Intent intent2 = new Intent(getApplicationContext(), LearnLocations.class);
       intent2.putExtra("cellId", cellId);
       notificationHelper.createNotification(
           "TiTi@" + "Unknown Location", cellId, 2324, intent2, true, true, "s2");
     } else {
       notificationHelper.createNotification(
           "TiTi@" + locationName,
           cellId,
           2324,
           new Intent(getApplicationContext(), MainActivity.class),
           false,
           true,
           "s2");
     }
   }
 }
 @Override
 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
   super.onSignalStrengthsChanged(signalStrength);
   if (signalStrength.isGsm()) {
     int asu = signalStrength.getGsmSignalStrength();
     int RSSIindBM = -113 + 2 * asu;
     NotificationHelper notificationHelper = new NotificationHelper(getApplicationContext());
     SharedPreferences settings = getSharedPreferences("TiTiPreferences", 0);
     int threshold = settings.getInt("NetworkSignalStrengthThreshold", -90);
     if (RSSIindBM < threshold) {
       if (GlobalValuesNStatus.getInstance().muteSignalStrengthAlertForNTimes <= 0) {
         notificationHelper.createNotification(
             "TiTi",
             "Network Signal is getting poor... " + RSSIindBM + "db Calls may drop",
             6767,
             new Intent(getApplicationContext(), NetworkSignalStrengthSettings.class),
             true,
             false,
             "serious");
         GlobalValuesNStatus.getInstance().muteSignalStrengthAlertForNTimes =
             5; // mute for 5 occurrence
       } else {
         GlobalValuesNStatus.getInstance().muteSignalStrengthAlertForNTimes--;
       }
     } else {
       NotificationManager nMgr =
           (NotificationManager)
               getApplicationContext()
                   .getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
       nMgr.cancel(6767); // Signals improved cancel notification
       GlobalValuesNStatus.getInstance().muteSignalStrengthAlertForNTimes = 0;
     }
   }
 }
 public void onCallStateChanged(int state, java.lang.String incomingNumber) {
   if (callbackProcs[CB_CALL_STATE_CHANGED] != null) {
     super.onCallStateChanged(state, incomingNumber);
     try {
       RuntimeHelpers.invoke(
           getRuby().getCurrentContext(),
           callbackProcs[CB_CALL_STATE_CHANGED],
           "call",
           JavaUtil.convertJavaToRuby(getRuby(), state),
           JavaUtil.convertJavaToRuby(getRuby(), incomingNumber));
     } catch (RaiseException re) {
       re.printStackTrace();
     }
   } else {
     super.onCallStateChanged(state, incomingNumber);
   }
 }
Exemple #18
0
 public final void onSignalStrengthsChanged(SignalStrength paramSignalStrength) {
   super.onSignalStrengthsChanged(paramSignalStrength);
   if (!paramSignalStrength.isGsm()) {
     ba.lL(paramSignalStrength.getCdmaDbm());
     return;
   }
   ba.lL(paramSignalStrength.getGsmSignalStrength());
 }
 @Override
 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
   super.onSignalStrengthsChanged(signalStrength);
   mSignalStrength = signalStrength;
   sendLog();
   mEventBus.post(new SignalStrengthChanged());
   LOG.info("Signal strength changed!");
 }
 @Override
 public void onCellLocationChanged(CellLocation location) {
   super.onCellLocationChanged(location);
   mCellLocation = location;
   sendLog();
   mEventBus.post(new CellLocationChanged());
   LOG.info("Cell location changed!");
 }
 // Get the Signal strength from the provider, each time there is an update
 @Override
 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
   super.onSignalStrengthsChanged(signalStrength);
   sigLevel = signalStrength.getGsmSignalStrength();
   GsmCellLocation gsmInfo = (GsmCellLocation) phoneStateManager.getCellLocation();
   cellID = gsmInfo.getCid() / 10; // cut off sector ID
   postSignalLocation();
 }
  public void testRun_ringWhileSpeaking() throws Exception {
    startTask(TextToSpeech.SUCCESS);

    expect(tts.isSpeaking()).andStubReturn(true);
    expect(tts.stop()).andReturn(TextToSpeech.SUCCESS);

    AndroidMock.replay(tts);

    // Update the state to ringing - this should stop the current announcement.
    PhoneStateListener phoneListener = phoneListenerCapture.getValue();
    phoneListener.onCallStateChanged(TelephonyManager.CALL_STATE_RINGING, null);

    // Run the announcement - this should do nothing.
    task.run(null);

    AndroidMock.verify(mockTask, tts);
  }
    @Override
    /** 监听电话状态 */
    public void onCallStateChanged(int state, String incomingNumber) {
      // TODO Auto-generated method stub
      super.onCallStateChanged(state, incomingNumber);
      switch (state) {
        case TelephonyManager.CALL_STATE_RINGING:
          if (serviceState) {
            boolean falg = new BlackNumDao(ShowAddressService.this).find(incomingNumber);
            if (falg) {
              ringOff();
              getContentResolver()
                  .registerContentObserver(
                      CallLog.Calls.CONTENT_URI,
                      true,
                      new CallLogChangeObserver(new Handler(), incomingNumber));
              return;
            }
          }

          String value = AddressService.getAddressService(incomingNumber);
          view = inflater.inflate(R.layout.show_phone_address, null);
          TextView address_tv = (TextView) view.findViewById(R.id.show_phone_address_address);
          TextView phone_tv = (TextView) view.findViewById(R.id.show_phone_address_phone);
          address_tv.setText(value);
          String phoneName =
              new MyContentProvider(ShowAddressService.this).getPhoneName(incomingNumber);
          if (phoneName != null) {
            phone_tv.setText(phoneName);
          } else {
            phone_tv.setText(incomingNumber);
          }

          WindowManager.LayoutParams params = new LayoutParams();
          params.height = WindowManager.LayoutParams.WRAP_CONTENT + 70;
          params.width = WindowManager.LayoutParams.WRAP_CONTENT + 200;

          params.y = params.y + 23;
          new Thread(new SaveParamsCoord(params.x, params.y, params.width, params.height)).start();
          params.flags =
              WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                  | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                  | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
          params.format = PixelFormat.TRANSLUCENT;
          params.type = WindowManager.LayoutParams.TYPE_TOAST;
          params.setTitle("Toast");

          windowManager.addView(view, params);
          break;
        case TelephonyManager.CALL_STATE_IDLE:
          if (view != null) {
            windowManager.removeView(view);
            view = null;
          }
        default:
          break;
      }
    }
 @Override
 public void onCallStateChanged(int state, String incomingNumber) {
   // TODO Auto-generated method stub
   super.onCallStateChanged(state, incomingNumber);
   // 如果当前状态为空闲,上次状态为响铃中的话,则认为是未接来电
   if (lastetState == TelephonyManager.CALL_STATE_RINGING
       && state == TelephonyManager.CALL_STATE_IDLE) {
     mHandler.sendEmptyMessageDelayed(0, 2000);
   }
   // 最后改变当前值
   lastetState = state;
 }
Exemple #25
0
 public final void onSignalStrengthsChanged(SignalStrength paramSignalStrength) {
   super.onSignalStrengthsChanged(paramSignalStrength);
   if (at.a(iau) == 2) {
     at.iY(paramSignalStrength.getCdmaDbm());
   }
   if (at.a(iau) == 1) {
     at.iY(paramSignalStrength.getGsmSignalStrength() * 2 - 113);
   }
   if (at.b(iau) != null) {
     at.b(iau).listen(at.c(iau), 0);
   }
   at.d(iau);
 }
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
      switch (state) {
          // 电话铃声正在响
        case TelephonyManager.CALL_STATE_RINGING:
          // 查询出电话号码的归属地
          NumberAddressDao numberAddressDao = new NumberAddressDao(getApplicationContext());
          String address = numberAddressDao.getAddress(incomingNumber);

          // 通过布局填充器将布局转换为view
          view = View.inflate(getApplicationContext(), R.layout.show_address, null);
          LinearLayout ll = (LinearLayout) view.findViewById(R.id.ll_show_address);
          int style = sp.getInt("which", 0);
          ll.setBackgroundResource(bg_styles[style]);
          TextView tv = (TextView) view.findViewById(R.id.tv_show_address);
          tv.setText(address);

          final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
          params.height = WindowManager.LayoutParams.WRAP_CONTENT;
          params.width = WindowManager.LayoutParams.WRAP_CONTENT;
          params.flags =
              WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                  | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                  | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
          // 显示在窗体上的style为半透明
          params.format = PixelFormat.TRANSLUCENT;
          // 窗体view的类型为吐司
          params.type = WindowManager.LayoutParams.TYPE_TOAST;
          windowManager.addView(view, params);
          break;
          // 电话空闲状态
        case TelephonyManager.CALL_STATE_IDLE:
          // 将窗体上的吐司移除
          if (view != null) {
            windowManager.removeView(view);
            view = null;
          }
          break;
          // 电话接通状态
        case TelephonyManager.CALL_STATE_OFFHOOK:
          // 将窗体上的吐司移除
          if (view != null) {
            windowManager.removeView(view);
            view = null;
          }
          break;
      }

      super.onCallStateChanged(state, incomingNumber);
    }
    @Override
    public synchronized void onCallStateChanged(int state, String incomingNumber) {
      Log.i(TAG, "state: " + state);
      switch (state) {
        case TelephonyManager.CALL_STATE_RINGING:
          MyService.this.isCalling = true;
          String content;
          if (incomingNumber.charAt(0) == '+') {
            incomingNumber = "0" + incomingNumber.substring(2);
          }
          incomingNumber = CommonMethod.instance().convertToNumberPhone(incomingNumber);
          if (contentContacts.contains(new ContentContact(null, incomingNumber))) {
            String name =
                contentContacts
                    .get((contentContacts.indexOf(new ContentContact(null, incomingNumber))))
                    .getName();
            content = name + " calling";
          } else {
            content = incomingNumber + " calling";
          }
          Log.i(TAG, "content: " + content);
          MyService.this.startTalking(content);
          break;
          // endcall
        case TelephonyManager.CALL_STATE_IDLE:
          MyService.this.isCalling = false;
          MyService.this.isMakePhoneCall = false;
          //                    if ( MyService.this.checkRegisterBroadcastCall ) {
          //                        Log.i(TAG, "treeeeeeeeeeee");
          //                        initComponent();
          //
          // MyService.this.mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
          //                    }

          checkLoopTextToSpeechCall = false;
          if (textToSpeech != null) textToSpeech.stop();
          break;
          // answer
        case TelephonyManager.CALL_STATE_OFFHOOK:
          checkLoopTextToSpeechCall = false;
          if (textToSpeech != null) textToSpeech.stop();
          if (MyService.this.checkRegisterBroadcastCall) {
            Log.i(TAG, "treeeeeeeeeeee");
            initComponent();
            MyService.this.mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
          }
          break;
      }
      super.onCallStateChanged(state, incomingNumber);
    }
 @Override
 public void onCallStateChanged(int state, String incomingNumber) {
   switch (state) {
     case TelephonyManager.CALL_STATE_RINGING: // 电话响了
       Log.e("AddressService", "来电话了");
       String address = AddressDB.getAddress(incomingNumber);
       // ToastUtils.showToast(getApplicationContext(), address);
       showToast(address);
       break;
     case TelephonyManager.CALL_STATE_IDLE: // 电话闲置状态
       if (windowManager != null) {
         windowManager.removeView(view); // 移除view
       }
   }
   super.onCallStateChanged(state, incomingNumber);
 }
  @Override
  public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);

    switch (state) {
      case TelephonyManager.CALL_STATE_IDLE:
        if (SharedValues.previousCallState == TelephonyManager.CALL_STATE_RINGING) {
          new SmsSender(SharedValues.MISSED_CALL, icNum, null).start();
        } else if ((SharedValues.previousCallState == TelephonyManager.CALL_STATE_OFFHOOK)
            && SharedValues.isIcCall) {
          SharedValues.isIcCall = false;
          SharedValues.callEndTime = System.currentTimeMillis();
          SharedValues.callDuration = SharedValues.callEndTime - SharedValues.callStartTime;
          new SmsSender(SharedValues.IC_CALL, icNum, SharedValues.callDuration / 1000 + "").start();
        } else if ((SharedValues.previousCallState == TelephonyManager.CALL_STATE_OFFHOOK)
            && SharedValues.isOgCall) {
          SharedValues.isOgCall = false;
          SharedValues.callEndTime = System.currentTimeMillis();
          SharedValues.callDuration = SharedValues.callEndTime - SharedValues.callStartTime;
          new SmsSender(
                  SharedValues.OG_CALL,
                  SharedValues.ogCallNumber,
                  SharedValues.callDuration / 1000 + "")
              .start();
        }

        SharedValues.previousCallState = TelephonyManager.CALL_STATE_IDLE;
        break;

      case TelephonyManager.CALL_STATE_RINGING:
        icNum = incomingNumber;
        SharedValues.isIcCall = true;

        SharedValues.previousCallState = TelephonyManager.CALL_STATE_RINGING;
        break;

      case TelephonyManager.CALL_STATE_OFFHOOK:
        if (SharedValues.previousCallState == TelephonyManager.CALL_STATE_RINGING) {
          SharedValues.callStartTime = System.currentTimeMillis();
        } else if (SharedValues.previousCallState == TelephonyManager.CALL_STATE_IDLE) {
          SharedValues.callStartTime = System.currentTimeMillis();
        }

        SharedValues.previousCallState = TelephonyManager.CALL_STATE_OFFHOOK;
        break;
    }
  }
Exemple #30
0
 // 当呼叫的状态发生变化的时候 调用的方法
 @Override
 public void onCallStateChanged(int state, String incomingNumber) {
   super.onCallStateChanged(state, incomingNumber);
   switch (state) {
     case TelephonyManager.CALL_STATE_RINGING: // 响铃状态
       String address = AddressDao.getAddress(incomingNumber);
       // Toast.makeText(getApplicationContext(), address, 1).show();
       showMyToast(address);
       break;
     case TelephonyManager.CALL_STATE_IDLE: // 空闲状体
       if (view != null) {
         wm.removeView(view);
         view = null;
       }
       break;
   }
 }