public int startDmDataConnectivity() throws IOException { Assert.assertFalse( "startDmDataConnectivity MUST NOT be called in direct internet conn.", Options.UseDirectInternet); // if gemini is set int result = -1; simId = DmCommomFun.getSimRegisterID(mContext); if (simId == -1) { Log.e(TAG.Connection, "Get Register SIM ID error in start data connection"); return result; } // for gemini if (MTKOptions.MTK_GEMINI_SUPPORT == true) { // begin for connectity gemini if (mDmDatabase.DmApnReady(simId) == false) { Log.e(TAG.Connection, "Dm apn table is not ready!"); return result; } result = beginDmDataConnectivityGemini(simId); } else { if (mDmDatabase.DmApnReady(GEMINI_SIM_1) == false) { Log.e(TAG.Connection, "Dm apn table is not ready!"); return result; } result = beginDmDataConnectivity(); } if (result == MTKPhone.APN_TYPE_NOT_AVAILABLE || result == MTKPhone.APN_REQUEST_FAILED) { Log.e(TAG.Connection, "start Dmdate Connectivity error"); } // for test begin if (result == MTKPhone.APN_ALREADY_ACTIVE) { Log.i( TAG.Connection, "DataConnection is already exist and send MSG_WAP_CONNECTION_SUCCESS to client"); notifyHandlers(IDmPersistentValues.MSG_WAP_CONNECTION_SUCCESS); } // for test end return result; }
public void stopDmDataConnectivity() { Assert.assertFalse( "stopDmDataConnectivity MUST NOT be called in direct internet conn.", Options.UseDirectInternet); Log.v(TAG.Connection, "stopDmDataConnectivity"); try { simId = DmCommomFun.getSimRegisterID(mContext); if (simId == -1) { Log.e(TAG.Connection, "Get Register SIM ID error in stop data connection"); return; } if (MTKOptions.MTK_GEMINI_SUPPORT == true) { // begin for connectity gemini endDmConnectivityGemini(simId); } else { endDmDataConnectivity(); } ScreenLock.releaseWakeLock(mContext); ScreenLock.enableKeyguard(mContext); } finally { Log.v(TAG.Connection, "stopUsingNetworkFeature end"); } }
@Override public void onReceive(Context context, Intent intent) { if (context == null || intent == null) return; if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { Log.d(TAG.Connection, "ConnectivityReceiver Receive android.net.conn.CONNECTIVITY_CHANGE"); Bundle mBdl = intent.getExtras(); if (mBdl != null) { NetworkInfo info = (NetworkInfo) mBdl.get(ConnectivityManager.EXTRA_NETWORK_INFO); if (info == null) { Log.e(TAG.Connection, "[dm-conn]->Get NetworkInfo error"); return; } simId = DmCommomFun.getSimRegisterID(mContext); if (simId == -1) { Log.e(TAG.Connection, "[dm-conn]->Get Register SIM ID error in connetivity receiver"); return; } int networkSimId = MTKConnectivity.getSimId(info); int intentSimId = intent.getIntExtra(MTKConnectivity.EXTRA_SIM_ID, 0); int networkType = info.getType(); if (intentSimId == simId && networkType == MTKConnectivity.TYPE_MOBILE_DM) { Log.i( TAG.Connection, "[dm-conn]->type == " + info.getTypeName() + "(" + networkType + ")"); Log.i(TAG.Connection, "[dm-conn]->intent_sim_Id == " + intentSimId); Log.i(TAG.Connection, "[dm-conn]->network_sim_Id == " + networkSimId); Log.i(TAG.Connection, "[dm-conn]->registered_sim_Id == " + simId); State state = info.getState(); if (state == State.CONNECTED) { Log.i(TAG.Connection, "[dm-conn]->state == CONNECTED"); try { ensureRouteToHost(); // store CONNECTED event. DmApplication.getInstance().queueEvent(SessionEventQueue.EVENT_CONN_CONNECTED); Log.i(TAG.Connection, ">>sending msg WAP_CONN_SUCCESS"); notifyHandlers(IDmPersistentValues.MSG_WAP_CONNECTION_SUCCESS); } catch (Exception ex) { Log.e(TAG.Connection, "[dm-conn]->ensureRouteToHost() failed:", ex); } } else if (state == State.CONNECTING) { Log.i(TAG.Connection, "[dm-conn]->state == CONNECTING"); return; } else if (state == State.DISCONNECTED) { Log.i(TAG.Connection, "[dm-conn]->state == DISCONNECTED"); // store DISCONNECTED event. DmApplication.getInstance().queueEvent(SessionEventQueue.EVENT_CONN_DISCONNECTED); return; } } } } else if (intent.getAction().equalsIgnoreCase(DmConst.intentAction.NET_DETECT_TIMEOUT)) { Log.i(TAG.Connection, "[dm-conn]->action == com.mediatek.MediatekDM.NETDETECTTIMEOUT"); Log.i(TAG.Connection, ">>>sending msg WAP_CONN_TIMEOUT"); notifyHandlers(IDmPersistentValues.MSG_WAP_CONNECTION_TIMEOUT); } } // onReceive