/**
   * Determines whether or not to current phone type is cdma.
   *
   * @param simId SIM identity, SIM 1 is zero, SIM 2 is one.
   * @return true if current phone type is cdma, false otherwise.
   */
  private static boolean isCdmaVoiceEx(int simId) {
    int activePhone = PHONE_TYPE_GSM;

    try {
      ITelephonyEx iTelephonyEx =
          ITelephonyEx.Stub.asInterface(ServiceManager.getService("phoneEx"));
      if (iTelephonyEx != null) {
        activePhone = iTelephonyEx.getActivePhoneType(simId);
      } else {
        activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
      }
    } catch (RemoteException ex) {
      activePhone = PHONE_TYPE_GSM;
    }

    return (PHONE_TYPE_CDMA == activePhone);
  }
 @Override
 protected Void doInBackground(Void... args) {
   Log.i(TAG, "[ShowSimCardStorageInfoTask]: doInBackground_beg");
   sSurplugMap.clear();
   List<SimInfoRecord> simInfos =
       getSortedInsertedSimInfoList(SimInfoManager.getInsertedSimInfoList(mContext));
   Log.i(TAG, "[ShowSimCardStorageInfoTask]: simInfos.size = " + simInfos.size());
   if (!mIsCancelled && (simInfos != null) && simInfos.size() > 0) {
     StringBuilder build = new StringBuilder();
     int simId = 0;
     for (SimInfoRecord simInfo : simInfos) {
       if (simId > 0) {
         build.append("\n\n");
       }
       simId++;
       int[] storageInfos = null;
       Log.i(
           TAG,
           "[ShowSimCardStorageInfoTask] simName = "
               + simInfo.mDisplayName
               + "; simSlot = "
               + simInfo.mSimSlotId
               + "; simId = "
               + simInfo.mSimInfoId);
       build.append(simInfo.mDisplayName);
       build.append(":\n");
       try {
         ITelephonyEx phoneEx =
             ITelephonyEx.Stub.asInterface(ServiceManager.checkService("phoneEx"));
         if (!mIsCancelled && phoneEx != null) {
           storageInfos = phoneEx.getAdnStorageInfo(simInfo.mSimSlotId);
           if (storageInfos == null) {
             mIsException = true;
             Log.i(TAG, " storageInfos is null");
             return null;
           }
           Log.i(TAG, "[ShowSimCardStorageInfoTask] infos: " + storageInfos.toString());
         } else {
           Log.i(TAG, "[ShowSimCardStorageInfoTask]: phone = null");
           mIsException = true;
           return null;
         }
       } catch (RemoteException ex) {
         Log.i(TAG, "[ShowSimCardStorageInfoTask]_exception: " + ex);
         mIsException = true;
         return null;
       }
       Log.i(
           TAG,
           "slotId:"
               + simInfo.mSimSlotId
               + "||storage:"
               + (storageInfos == null ? "NULL" : storageInfos[1])
               + "||used:"
               + (storageInfos == null ? "NULL" : storageInfos[0]));
       if (storageInfos != null && storageInfos[1] > 0) {
         sSurplugMap.put(simInfo.mSimSlotId, storageInfos[1] - storageInfos[0]);
       }
       build.append(
           mContext
               .getResources()
               .getString(R.string.dlg_simstorage_content, storageInfos[1], storageInfos[0]));
       if (mIsCancelled) {
         return null;
       }
     }
     mDlgContent = build.toString();
   }
   Log.i(TAG, "[ShowSimCardStorageInfoTask]: doInBackground_end");
   return null;
 }
Exemple #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simcard);

    boolean Sim1Exist = false;
    boolean Sim2Exist = false;

    sim1TextView = (TextView) this.findViewById(R.id.simcard_sim1_info);
    sim2TextView = (TextView) this.findViewById(R.id.simcard_sim2_info);
    successButton = (Button) this.findViewById(R.id.simcard_bt_ok);
    failButton = (Button) this.findViewById(R.id.simcard_bt_failed);
    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      final ITelephonyEx iTel =
          ITelephonyEx.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICEEX));
      try {
        Sim1Exist = iTel.hasIccCard(0);
        Sim2Exist = iTel.hasIccCard(1);
      } catch (RemoteException e) {
        Log.i(TAG, "RemoteException happens......");
      }

      if (Sim1Exist) {
        sim1TextView.setText(R.string.sim1_info_ok); // sim1TextView.setText("sim1 exist");
      } else {
        sim1TextView.setText(R.string.sim1_info_failed); // sim1TextView.setText("sim1 not exist");
      }
      if (Sim2Exist) {
        sim2TextView.setText(R.string.sim2_info_ok); // sim2TextView.setText("sim2 exist");
      } else {
        sim2TextView.setText(R.string.sim2_info_failed); // sim2TextView.setText("sim1 not exist");
      }
    } else {
      final ITelephonyEx iTel =
          ITelephonyEx.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICEEX));
      try {
        Sim1Exist = iTel.hasIccCard(0);
        Sim2Exist = false;
      } catch (RemoteException e) {
        Log.i(TAG, "RemoteException happens......");
      }
      if (Sim1Exist) {
        sim1TextView.setText(R.string.sim1_info_ok); // sim1TextView.setText("sim1 exist");
      } else {
        sim1TextView.setText(R.string.sim1_info_failed); // sim1TextView.setText("sim1 not exist");
      }
      sim2TextView.setVisibility(View.GONE);
    }

    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      if ((getIntent().getIntExtra("currentTestMode", 0) == 2
              || getIntent().getIntExtra("currentTestMode", 0) == 1)
          && Sim1Exist
          && Sim2Exist) {
        successButton.setEnabled(true);
        // succesButton.performClick();
        Intent intent = new Intent(SimCard.this, FactoryMode.class);
        setResult(RESULT_OK, intent);
        finish();
      } else if (Sim1Exist && Sim2Exist) {
        successButton.setEnabled(true);
      } else {
        successButton.setEnabled(false);
      }
    } else {
      if ((getIntent().getIntExtra("currentTestMode", 0) == 2
              || getIntent().getIntExtra("currentTestMode", 0) == 1)
          && Sim1Exist) {
        successButton.setEnabled(true);
        // succesButton.performClick();
        Intent intent = new Intent(SimCard.this, FactoryMode.class);
        setResult(RESULT_OK, intent);
        finish();
      } else if (Sim1Exist) {
        successButton.setEnabled(true);
      } else {
        successButton.setEnabled(false);
      }
    }

    successButton.setOnClickListener(
        new Button.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(SimCard.this, FactoryMode.class);
            setResult(RESULT_OK, intent);
            finish();
          }
        });
    failButton.setOnClickListener(
        new Button.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(SimCard.this, FactoryMode.class);
            setResult(RESULT_CANCELED, intent);
            finish();
          }
        });
  }