Exemplo n.º 1
0
 /**
  * Clean up existing voice and data connection then turn off radio power.
  *
  * <p>Hang up the existing voice calls to decrease call drop rate.
  */
 public void powerOffRadioSafely(DcTrackerBase dcTracker) {
   synchronized (this) {
     if (!mPendingRadioPowerOffAfterDataOff) {
       // In some network, deactivate PDP connection cause releasing of RRC connection,
       // which MM/IMSI detaching request needs. Without this detaching, network can
       // not release the network resources previously attached.
       // So we are avoiding data detaching on these networks.
       String[] networkNotClearData =
           mPhoneBase
               .getContext()
               .getResources()
               .getStringArray(com.android.internal.R.array.networks_not_clear_data);
       String currentNetwork = mSS.getOperatorNumeric();
       if ((networkNotClearData != null) && (currentNetwork != null)) {
         for (int i = 0; i < networkNotClearData.length; i++) {
           if (currentNetwork.equals(networkNotClearData[i])) {
             // Don't clear data connection for this carrier
             if (DBG) log("Not disconnecting data for " + currentNetwork);
             hangupAndPowerOff();
             return;
           }
         }
       }
       // To minimize race conditions we call cleanUpAllConnections on
       // both if else paths instead of before this isDisconnected test.
       if (dcTracker.isDisconnected()) {
         // To minimize race conditions we do this after isDisconnected
         dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
         if (DBG) log("Data disconnected, turn off radio right away.");
         hangupAndPowerOff();
       } else {
         dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
         Message msg = Message.obtain(this);
         msg.what = EVENT_SET_RADIO_POWER_OFF;
         msg.arg1 = ++mPendingRadioPowerOffAfterDataOffTag;
         if (sendMessageDelayed(msg, 30000)) {
           if (DBG) log("Wait upto 30s for data to disconnect, then turn off radio.");
           mPendingRadioPowerOffAfterDataOff = true;
         } else {
           log("Cannot send delayed Msg, turn off radio right away.");
           hangupAndPowerOff();
         }
       }
     }
   }
 }