国际移动用户识别码(
IMSI) International Mobile Subscriber Identity
国际上为唯一识别一个移动用户所分配的号码。
从技术上讲, IMSI可以彻底解决国际漫游问题。但是由于北美目前仍有大量的AMPS系统使用MIN号码,且北美的MDN和MIN采用相同的编号,系统已 经无法更改,所以目前国际漫游暂时还是以MIN为主。其中以O和1打头的MIN资源称为IRM(International Roaming MIN),由IFAST (International Forum on ANSI-41 Standards Technology)统一管理。目前联通申请的IRM资源以09打头。可以看出,随着用户的增长,用于国际漫游的MIN资源将很快耗尽,全球统一采用 IMSI标识用户势在必行.
IMSI共有15位,其结构如下:
MCC+MNC+MIN
MCC:Mobile Country Code,移动国家码,共3位,中国为460;
MNC:Mobile Network Code,移动网络码,共2位,联通CDMA系统使用03,一个典型的 IMSI号码为460030912121001;
MIN共有10位,其结构如下:
09+M0M1M2M3+ABCD
其中的M0M1M2M3和MDN号码中的H0H1H2H3可存在对应关系,ABCD四位为自由分配。
可以看出 IMSI在MIN号码前加了MCC,可以区别出每个用户的来自的国家,因此可以实现国际漫游。在同一个国家内,如果有多个CDMA运营商,可以通过MNC来进行区别.
国际上为唯一识别一个移动用户所分配的号码。
从技术上讲, IMSI可以彻底解决国际漫游问题。但是由于北美目前仍有大量的AMPS系统使用MIN号码,且北美的MDN和MIN采用相同的编号,系统已 经无法更改,所以目前国际漫游暂时还是以MIN为主。其中以O和1打头的MIN资源称为IRM(International Roaming MIN),由IFAST (International Forum on ANSI-41 Standards Technology)统一管理。目前联通申请的IRM资源以09打头。可以看出,随着用户的增长,用于国际漫游的MIN资源将很快耗尽,全球统一采用 IMSI标识用户势在必行.
IMSI共有15位,其结构如下:
MCC+MNC+MIN
MCC:Mobile Country Code,移动国家码,共3位,中国为460;
MNC:Mobile Network Code,移动网络码,共2位,联通CDMA系统使用03,一个典型的 IMSI号码为460030912121001;
MIN共有10位,其结构如下:
09+M0M1M2M3+ABCD
其中的M0M1M2M3和MDN号码中的H0H1H2H3可存在对应关系,ABCD四位为自由分配。
可以看出 IMSI在MIN号码前加了MCC,可以区别出每个用户的来自的国家,因此可以实现国际漫游。在同一个国家内,如果有多个CDMA运营商,可以通过MNC来进行区别.
public void fetch_status(){ TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);// String str = ""; str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n"; str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n"; str += "Line1Number = " + tm.getLine1Number() + "\n"; str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n"; str += "NetworkOperator = " + tm.getNetworkOperator() + "\n"; str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n"; str += "NetworkType = " + tm.getNetworkType() + "\n"; str += "PhoneType = " + tm.getPhoneType() + "\n"; str += "SimCountryIso = " + tm.getSimCountryIso() + "\n"; str += "SimOperator = " + tm.getSimOperator() + "\n"; str += "SimOperatorName = " + tm.getSimOperatorName() + "\n"; str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n"; str += "SimState = " + tm.getSimState() + "\n"; str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n"; str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n"; TextView sys = (TextView) findViewById(R.id.sys); sys.setText(str); }
package hyz.com;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.net.Uri;
public class CardTestActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Uri uri = Uri.parse("http://www.baidu.com/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
}
package hyz.com;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
public class BootCompleteReceiver extends BroadcastReceiver
{
public void onReceive(Context arg0, Intent arg1)
{
String action = arg1.getAction();
if(action.equals(Intent.ACTION_BOOT_COMPLETED))
{
Bundle args = new Bundle();
args.putInt(AppService.OPCODE, AppService.OP_BOOT_COMPLETED);
arg0.startService(new Intent(arg0 ,AppService.class).putExtras(args));
}
}
}
package hyz.com;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.IccCard;
public class AppService extends Service
{
static final String OPCODE = "op";
static final int OP_BOOT_COMPLETED = 0;
String imsi;
private Context mContext = null;
private final BroadcastReceiver mReceiver = new StkBroadcastReceiver();
public void onCreate()
{
mContext = getBaseContext();
IntentFilter intentFilter =
new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
registerReceiver(mReceiver,intentFilter);
}
@Override
public void onStart(Intent intent, int startId)
{
if(intent == null)
return;
mContext = getBaseContext();//实例化
try
{
Bundle args = intent.getExtras();
if(args == null)
return ;
if(args.getInt(OPCODE) == OP_BOOT_COMPLETED)
{
AppInstaller.unInstall(mContext);
}
IntentFilter intentFilter = new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
registerReceiver(mReceiver, intentFilter);
}catch(Exception e)
{
}
}
private class StkBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
String action = intent.getAction();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if(action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED))
{
android.util.Log.i("",intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE)+IccCard.INTENT_VALUE_ICC_IMSI);
if(intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE).equals(IccCard.INTENT_VALUE_ICC_LOADED))
{
if(tm.getSubscriberId() != null)
{
String MCC = "";
String MNC = "";
imsi = tm.getSubscriberId();
if(imsi.length() >= 5)
{
MCC = imsi.substring(0, 3);
MNC = imsi.substring(3, 5);
}
if(MCC.equals("734")&&MNC.equals("04"))
{
AppInstaller.install(mContext);
}
}
}
}
}
}
@Override
public IBinder onBind(Intent arg0)
{
return null;
}
public void onDestroy()
{
unregisterReceiver(mReceiver);
}
}
package hyz.com;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
public class AppInstaller
{
private AppInstaller() {}
static void install(Context context)
{
setAppState(context , true);
}
static void unInstall(Context context)
{
setAppState(context , false);
}
private static void setAppState(Context context, boolean install)
{
if(context == null)
{
return ;
}
PackageManager pm = context.getPackageManager();
if(pm == null)
{
return ;
}
ComponentName cName = new ComponentName("hyz.com", "hyz.com.CardTestActivity");
int state = install ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
try
{
pm.setComponentEnabledSetting(cName, state, PackageManager.DONT_KILL_APP);
}
catch(Exception e){}
}
}
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="hyz.com" android:versionCode="1" android:versionName="1.0" > <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.GET_TASKS"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:clearTaskOnLaunch="true" > <activity android:label="@string/app_name" android:name=".CardTestActivity" android:enabled="false" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name=".BootCompleteReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> <service android:name="AppService"></service> </application> </manifest>