Example #1
0
        public final void handleMessage(Message msg) {
          switch (msg.what) {
            case MSG_GET_SMSC_DONE:
              Bundle bd = (Bundle) msg.obj;
              if (FeatureOption.MTK_GEMINI_SUPPORT == true) {

                mResult = check_result.RIGHT;
                StringBuilder smscStr = new StringBuilder();
                for (SimInfoRecord simInfo : mSimInfoList) {
                  String curStr = bd.getString("SMSC" + simInfo.mSimSlotId);

                  CTSCLog.v("CheckSMSC", "SMSC" + simInfo.mSimSlotId + " " + curStr);
                  if (false == curStr.equalsIgnoreCase("+8613800100569")) {
                    if (smscStr.toString().length() != 0) {
                      smscStr.append("\n");
                    }
                    smscStr.append(
                        "Sim"
                            + (simInfo.mSimSlotId + 1)
                            + getContext().getString(R.string.smsc_not_correct));
                    mResult = check_result.WRONG;
                  }
                }
                setValue(smscStr.toString());

              } else {
                String smscStr = bd.getString("SMSC");

                if (smscStr.equalsIgnoreCase("+8613800100569")) {
                  setValue("");
                  mResult = check_result.RIGHT;
                } else {
                  setValue(R.string.smsc_not_correct);
                  mResult = check_result.WRONG;
                }
              }

              mSyncDone = true;
              if (true == mNeedNotify) {
                sendBroadcast();
              }
              break;
            case MSG_SET_SMSC_DONE:
              CTSCLog.v("SMSC", " set done");
              sendBroadcast();
              break;
            default:
              return;
          }
        }
Example #2
0
  public boolean onReset() {
    if (true == FeatureOption.MTK_GEMINI_SUPPORT) {
      for (Integer simId : mSimNeedSetAPN) {
        String where = "apn=\"" + checkAPN + "\"";
        int simNo = simId.intValue() + 1;
        Uri uri = Uri.parse("content://telephony/carriers_sim" + simNo);
        CTSCLog.v("CheckCurAPN", "where = " + where);
        Cursor cursor =
            getContext()
                .getContentResolver()
                .query(uri, new String[] {"_id", "name"}, where, null, null);

        if ((cursor != null) && (true == cursor.moveToFirst())) {
          cursor.moveToFirst();
          int index = cursor.getColumnIndex("_id");
          String apnId = cursor.getString(index);

          ContentValues values = new ContentValues();
          values.put("apn_id", apnId);

          getContext()
              .getContentResolver()
              .update(
                  Uri.parse("content://telephony/carriers_sim" + simNo + "/preferapn"),
                  values,
                  null,
                  null);
        }

        if (null != cursor) {
          cursor.close();
        }
      }
    } else {
      String where = "apn=\"" + checkAPN + "\"";
      Uri uri = Uri.parse("content://telephony/carriers");
      Cursor cursor =
          getContext()
              .getContentResolver()
              .query(uri, new String[] {"_id", "name"}, where, null, null);

      if ((cursor != null) && (true == cursor.moveToFirst())) {
        cursor.moveToFirst();
        int index = cursor.getColumnIndex("_id");
        String apnId = cursor.getString(index);
        cursor.close();

        ContentValues values = new ContentValues();
        values.put("apn_id", apnId);

        getContext()
            .getContentResolver()
            .update(Uri.parse("content://telephony/carriers/preferapn"), values, null, null);
      }
    }

    return true;
  }
Example #3
0
  public boolean onReset() {
    if (true == FeatureOption.MTK_GEMINI_SUPPORT) {
      for (Integer simId : mSimNeedSetAPN) {
        String where = "apn=\"labwap3\"";

        CTSCLog.v(TAG, "where = " + where);
        int simNo = simId.intValue() + 1;
        Uri uri = Uri.parse("content://telephony/carriers_sim" + simNo);
        Cursor cursor =
            getContext()
                .getContentResolver()
                .query(uri, new String[] {"_id", "numeric"}, where, null, null);

        APNBuilder apnBuilder =
            new APNBuilder(getContext(), simId.intValue(), "labwap3", "labwap3");

        if ((cursor != null) && (true == cursor.moveToFirst())) {
          cursor.moveToFirst();
          int index = cursor.getColumnIndex("_id");
          String apnId = cursor.getString(index);

          ContentValues values = new ContentValues();
          values.put(Telephony.Carriers.MCC, apnBuilder.getMCC());
          values.put(Telephony.Carriers.MNC, apnBuilder.getMNC());
          values.put(Telephony.Carriers.NUMERIC, apnBuilder.getSimOperator());

          values.put(Telephony.Carriers.NAME, "labwap3");
          values.put(Telephony.Carriers.PROXY, "192.168.230.8");
          values.put(Telephony.Carriers.PORT, "9028");

          if ((mCheckProperty & CHECK_MMS) != 0) {
            values.put(Telephony.Carriers.MMSC, "http://218.206.176.175:8181/was");
            values.put(Telephony.Carriers.MMSPROXY, "192.168.230.8");
            values.put(Telephony.Carriers.MMSPORT, "9028");
          }

          if ((mCheckProperty & CHECK_TYPE) != 0) {
            values.put(Telephony.Carriers.TYPE, "default,mms,net");
          }

          String whereUpdate = "_id=\"" + apnId + "\"";

          getContext()
              .getContentResolver()
              .update(
                  Uri.parse("content://telephony/carriers_sim" + simNo), values, whereUpdate, null);

          ContentValues values_prefer = new ContentValues();
          values_prefer.put("apn_id", apnId);

          getContext()
              .getContentResolver()
              .update(
                  Uri.parse("content://telephony/carriers_sim" + simNo + "/preferapn"),
                  values_prefer,
                  null,
                  null);

        } else {
          apnBuilder.setProxy("192.168.230.8").setPort("9028");
          if ((mCheckProperty & CHECK_MMS) != 0) {
            apnBuilder.setMMSC("http://218.206.176.175:8181/was");
            apnBuilder.setMMSProxy("192.168.230.8");
            apnBuilder.setMMSPort("9028");
          }

          if ((mCheckProperty & CHECK_TYPE) != 0) {
            apnBuilder.setApnType("default,mms,net");
          }

          apnBuilder.build().setAsCurrent();
        }

        if (null != cursor) {
          cursor.close();
        }
      }
    } else {
      String where = "apn=\"labwap3\"";
      Uri uri = Uri.parse("content://telephony/carriers");
      Cursor cursor =
          getContext()
              .getContentResolver()
              .query(uri, new String[] {"_id", "numeric"}, where, null, null);

      APNBuilder apnBuilder = new APNBuilder(getContext(), "labwap3", "labwap3");

      if ((cursor != null) && (true == cursor.moveToFirst())) {
        cursor.moveToFirst();

        int index = cursor.getColumnIndex("_id");
        String apnId = cursor.getString(index);

        ContentValues values = new ContentValues();
        values.put(Telephony.Carriers.MCC, apnBuilder.getMCC());
        values.put(Telephony.Carriers.MNC, apnBuilder.getMNC());
        values.put(Telephony.Carriers.NUMERIC, apnBuilder.getSimOperator());

        values.put(Telephony.Carriers.NAME, "labwap3");
        values.put(Telephony.Carriers.PROXY, "192.168.230.8");
        values.put(Telephony.Carriers.PORT, "9028");

        if ((mCheckProperty & CHECK_MMS) != 0) {
          values.put(Telephony.Carriers.MMSC, "http://218.206.176.175:8181/was");
          values.put(Telephony.Carriers.MMSPROXY, "192.168.230.8");
          values.put(Telephony.Carriers.MMSPORT, "9028");
        }

        if ((mCheckProperty & CHECK_TYPE) != 0) {
          values.put(Telephony.Carriers.TYPE, "default,mms,net");
        }

        String whereUpdate = "_id=\"" + apnId + "\"";

        getContext().getContentResolver().update(uri, values, whereUpdate, null);

        ContentValues values_prefer = new ContentValues();
        values_prefer.put("apn_id", apnId);

        getContext()
            .getContentResolver()
            .update(Uri.parse("content://telephony/carriers/preferapn"), values_prefer, null, null);

        cursor.close();

      } else {
        if (cursor != null) {
          cursor.close();
        }
        apnBuilder.setProxy("192.168.230.8").setPort("9028");
        if ((mCheckProperty & CHECK_MMS) != 0) {
          apnBuilder.setMMSC("http://218.206.176.175:8181/was");
          apnBuilder.setMMSProxy("192.168.230.8");
          apnBuilder.setMMSPort("9028");
        }

        if ((mCheckProperty & CHECK_TYPE) != 0) {
          apnBuilder.setApnType("default,mms,net");
        }

        apnBuilder.build().setAsCurrent();
      }
    }

    return true;
  }