Java Examples for android.telephony.TelephonyManager

The following java examples will help you to understand the usage of android.telephony.TelephonyManager. These source code samples are taken from different open source projects.

Example 1
Project: DroidAlone-master  File: IncomingCallReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    String type = intent.getStringExtra(android.telephony.TelephonyManager.EXTRA_STATE);
    if (type.equals(android.telephony.TelephonyManager.EXTRA_STATE_RINGING)) {
        String number = intent.getStringExtra(android.telephony.TelephonyManager.EXTRA_INCOMING_NUMBER);
        if (number == null || number.equals("")) {
            number = "unknown";
        }
        notifyIncomingNumber(context, number);
    }
    if (type.equals(android.telephony.TelephonyManager.EXTRA_STATE_IDLE)) {
        Intent myServiceIntent = new Intent(context, HomeAloneService.class);
        myServiceIntent.putExtra(HomeAloneService.EVENT_TYPE, HomeAloneService.PHONE_IDLE);
        context.startService(myServiceIntent);
    }
    if (type.equals(android.telephony.TelephonyManager.EXTRA_STATE_OFFHOOK)) {
        Intent myServiceIntent = new Intent(context, HomeAloneService.class);
        myServiceIntent.putExtra(HomeAloneService.EVENT_TYPE, HomeAloneService.HANDLING_CALL);
        context.startService(myServiceIntent);
    }
}
Example 2
Project: saaf-master  File: MySQLHPatternDAOTest.java View source code
@Test
public void testRead() throws Exception {
    HPatternInterface newPattern = new HPattern("android/telephony/TelephonyManager->getSubscriberId", PatternType.INVOKE, -55, "test pattern");
    int id = dao.create(newPattern);
    HPatternInterface read = dao.read(id);
    assertNotNull("There was no object read from the database", read);
    assertEquals("The id was not set correctly", 1, read.getId());
}
Example 3
Project: FineDay-master  File: UMengUtils.java View source code
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 4
Project: HimitsuQR-master  File: UMengDebug.java View source code
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 5
Project: LightMe-master  File: CommonDataHelper.java View source code
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 6
Project: simple_weather-master  File: UMengUtils.java View source code
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 7
Project: Cocktail-master  File: CallStateListener.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    Log.d(TAG, "onCallStateChanged() mIsStartMain : " + mIsStartMain);
    if (mIsStartMain) {
        try {
            Log.d(TAG, "onCallStateChanged() END");
            TelephonyManager mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
            Class<?> mClass = Class.forName(mTelephonyManager.getClass().getName());
            Method mMethod = mClass.getDeclaredMethod("getITelephony");
            mMethod.setAccessible(true);
            ITelephony mITelephony = (ITelephony) mMethod.invoke(mTelephonyManager);
            mITelephony.endCall();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return;
    }
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Log.d(TAG, "CALL_IDLE");
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Log.d(TAG, "CALL_OFFHOOK");
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            Log.d(TAG, "CALL_RINGING");
            //Log.d(TAG, "RINGING >> Incoming number : " + incomingNumber);
            break;
    }
    super.onCallStateChanged(state, incomingNumber);
}
Example 8
Project: mobile-ecommerce-android-education-master  File: MyPhoneReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String state = extras.getString(TelephonyManager.EXTRA_STATE);
        if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
            String phoneNumber = extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.e("DEBUG", phoneNumber);
        }
    }
}
Example 9
Project: quickblox-android-sdk-master  File: DeviceUtils.java View source code
public static String getDeviceUid() {
    Context context = CoreApp.getInstance();
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String uniqueDeviceId = telephonyManager.getDeviceId();
    if (TextUtils.isEmpty(uniqueDeviceId)) {
        // for tablets
        ContentResolver cr = context.getContentResolver();
        uniqueDeviceId = Settings.Secure.getString(cr, Settings.Secure.ANDROID_ID);
    }
    return uniqueDeviceId;
}
Example 10
Project: RapidFTR-Android-master  File: LoginService.java View source code
public FluentResponse login(Context context, String username, String password, String url) throws IOException {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return http().context(context).path("/api/login").host(url).param("imei", telephonyManager.getDeviceId()).param("mobile_number", telephonyManager.getLine1Number()).param("user_name", username).param("password", password).post();
}
Example 11
Project: sanity-master  File: PhoneReceiver.java View source code
@Override
public void onReceive(Context ctx, Intent i) {
    if (MainService.isRunning() || !A.isEnabled())
        return;
    final String s = i.getStringExtra(TelephonyManager.EXTRA_STATE);
    if (TelephonyManager.EXTRA_STATE_RINGING.equals(s))
        number = i.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
    else if (TelephonyManager.EXTRA_STATE_OFFHOOK.equals(s))
        PickupService.notifyOffhook();
    else
        return;
    MainService.start();
}
Example 12
Project: unutopia-android-master  File: myBroadcastReceiver.java View source code
@Override
public void onReceive(Context arg0, Intent intent) {
    // TODO Auto-generated method stub
    Log.d(TAG, "onReceive");
    String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    if (state != null && state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
        String tlf = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
        Log.d(TAG, "Llamada entrante de " + tlf);
        ContentValues values = new ContentValues();
        values.put(CallsContract.UsersTable.NUMBER, tlf);
        Uri uri = CallsContract.UsersTable.getUri();
        Uri newUri = mContentResolver.insert(uri, values);
    }
}
Example 13
Project: LoonAndroid-master  File: Handler_System.java View source code
/**
	 * 在获�系统信���始化
	 * @author gdpancheng@gmail.com 2013-10-22 下�1:14:12
	 * @return void
	 */
public static void init() {
    mTm = (TelephonyManager) Ioc.getIoc().getApplication().getSystemService(Context.TELEPHONY_SERVICE);
    mIMEI = mTm.getDeviceId();
    mMobileVersion = mTm.getDeviceSoftwareVersion();
    mCellinfos = mTm.getNeighboringCellInfo();
    mNetwrokIso = mTm.getNetworkCountryIso();
    mSIM = mTm.getSimSerialNumber();
    mDeviceID = getDeviceId();
    try {
        ConnectivityManager cm = (ConnectivityManager) Ioc.getIoc().getApplication().getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info = cm.getActiveNetworkInfo();
        if (info != null) {
            mNetType = info.getTypeName();
        }
    } catch (Exception ex) {
    }
}
Example 14
Project: 1Sheeld-Android-App-master  File: PhoneCallStateListener.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    if (TelephonyManager.CALL_STATE_RINGING == state) {
        // phone ringing
        Log.d("Phone Number", "RINGING, number: " + incomingNumber);
        eventHandler.isPhoneRinging(true);
        eventHandler.sendIncomingNumber(incomingNumber);
    } else if (TelephonyManager.CALL_STATE_RINGING != state) {
        Log.d("Phone Number", "RINGING is Finish, number: " + incomingNumber);
        eventHandler.isPhoneRinging(false);
    }
}
Example 15
Project: actor-platform-master  File: Devices.java View source code
public static String getDeviceCountry() {
    TelephonyManager tm = (TelephonyManager) AndroidContext.getContext().getSystemService(Context.TELEPHONY_SERVICE);
    String country = tm.getSimCountryIso();
    if (android.text.TextUtils.isEmpty(country)) {
        country = tm.getNetworkCountryIso();
    }
    if (android.text.TextUtils.isEmpty(country)) {
        country = AndroidContext.getContext().getResources().getConfiguration().locale.getCountry();
    }
    return country;
}
Example 16
Project: Android-Cookbook-Examples-master  File: MainActivity.java View source code
@Override
protected void onResume() {
    super.onResume();
    // Get "Device Serial Number". The Android SystemProperties is apparently not for public use,
    // as it exists on-device but is NOT exposed in the SDK, so treat with a grain of salt!
    String serialNumber = "unknown";
    try {
        Class<?> c = Class.forName("android.os.SystemProperties");
        Method get = c.getMethod("get", String.class, String.class);
        serialNumber = (String) get.invoke(c, "ro.serialno", serialNumber);
    } catch (Exception e) {
        Log.e(TAG, "Failed to get serial number", e);
    }
    ((TextView) findViewById(R.id.serial_number)).setText(serialNumber);
    // Get "Android ID". According to the JavaDoc:
    // "A 64-bit number (as a hex string) that is 
    // randomly generated on the device's first boot 
    // and should remain constant for the lifetime 
    // of the device. (The value may change if a 
    // factory reset is performed on the device.)"
    String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
    ((TextView) findViewById(R.id.android_id)).setText(androidId);
    // Get the mobile device id (IMEI or similar) if any
    String imei = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
    ((TextView) findViewById(R.id.imei)).setText(imei);
}
Example 17
Project: Android-Templates-And-Utilities-master  File: PhoneStateReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    Logcat.d("");
    String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    String msg = "Phone state changed to " + state;
    if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
        String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
        msg += ". Incoming number is " + incomingNumber;
    }
    Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
// TODO: do something
}
Example 18
Project: AURHelperDroid-master  File: InternetState.java View source code
/**
     * @param ctx Context of the running activity/service
     * @return True if device is connected to the Internet
     */
public static boolean isConnectedToInternet(Context ctx) {
    TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wi = wm.getConnectionInfo();
    return !((wi == null || WifiInfo.getDetailedStateOf(wi.getSupplicantState()) == NetworkInfo.DetailedState.IDLE) && tm.getDataState() != TelephonyManager.DATA_CONNECTED);
}
Example 19
Project: CallingLeaks-master  File: SetListener.java View source code
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TelephonyManager phone = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
    PhoneStateListener listener = new PhoneStateListener() {

        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            Toast.makeText(SetListener.this, "Hallo", Toast.LENGTH_SHORT).show();
        }
    };
    phone.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
}
Example 20
Project: callrecorder-master  File: PhoneListener.java View source code
public void onCallStateChanged(int state, String incomingNumber) {
    Log.d("CallRecorder", "PhoneListener::onCallStateChanged state:" + state + " incomingNumber:" + incomingNumber);
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Log.d("CallRecorder", "CALL_STATE_IDLE, stoping recording");
            Boolean stopped = context.stopService(new Intent(context, RecordService.class));
            Log.i("CallRecorder", "stopService for RecordService returned " + stopped);
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            Log.d("CallRecorder", "CALL_STATE_RINGING");
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Log.d("CallRecorder", "CALL_STATE_OFFHOOK starting recording");
            Intent callIntent = new Intent(context, RecordService.class);
            ComponentName name = context.startService(callIntent);
            if (null == name) {
                Log.e("CallRecorder", "startService for RecordService returned null ComponentName");
            } else {
                Log.i("CallRecorder", "startService returned " + name.flattenToString());
            }
            break;
    }
}
Example 21
Project: DynamicWeather-master  File: Tools.java View source code
public static String getDeviceInfo(Context context) {
    Object[] objects = new Object[4];
    objects[0] = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
    // "529e2dd3d767bdd3595eec30dd481050";
    objects[1] = "pisces";
    objects[2] = "JXCCNBD20.0";
    objects[3] = "";
    return String.format("&imei=%s&device=%s&miuiVersion=%s&modDevice=%s&source=miuiWeatherApp", objects);
}
Example 22
Project: hacked.io-master  File: Utils.java View source code
public static String getDeviceId(Context context) {
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    return deviceUuid.toString();
}
Example 23
Project: I-m-Driving--Android--master  File: PhoneReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    PhoneState pl = new PhoneState();
    //PhoneStateListener pl = new PhoneStateListener();
    PhoneReceiver.context = context;
    telephony.listen(pl, PhoneStateListener.LISTEN_CALL_STATE);
//Bundle bundle = intent.getExtras();
//Toast.makeText(context,"Phone Call Received From: " + bundle.getString("incoming_number"), Toast.LENGTH_LONG).show();
//NoPhoneZone.sendMessage(context, bundle.getString("incoming_number"));
}
Example 24
Project: m2e-master  File: IncomingCallInterceptor.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    // 1
    // 2
    String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    String msg = "Phone state changed to " + state;
    if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
        // 3
        // 4
        String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
        msg += ". Incoming number is " + incomingNumber;
    // TODO This would be a good place to "Do something when the phone rings" ;-)
    }
    Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
}
Example 25
Project: MiBandDecompiled-master  File: e.java View source code
public String f() {
    label0: {
        TelephonyManager telephonymanager = (TelephonyManager) b.getSystemService("phone");
        if (telephonymanager != null)
            ;
        String s;
        try {
            if (!bi.a(b, "android.permission.READ_PHONE_STATE")) {
                break label0;
            }
            s = telephonymanager.getDeviceId();
        } catch (Exception exception) {
            return null;
        }
        return s;
    }
    return null;
}
Example 26
Project: project-ceeq-master  File: DeviceBootReceiver.java View source code
public void checkSimChange(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    try {
        if (!tm.getSimSerialNumber().equals(Utils.getStringPrefs(context, Utils.SIM_NUMBER))) {
            try {
                Intent commands = new Intent(context, CommandService.class);
                commands.putExtra(CommandService.ACTION, CommandService.SEND_SIM_CHANGE_MESSAGE);
                context.startService(commands);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 27
Project: Securecom-Text-master  File: TelephonyUtil.java View source code
public static String getMccMnc(final Context context) {
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    final int configMcc = context.getResources().getConfiguration().mcc;
    final int configMnc = context.getResources().getConfiguration().mnc;
    if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
        Log.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getSimOperator()");
        return tm.getSimOperator();
    } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
        Log.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getNetworkOperator()");
        return tm.getNetworkOperator();
    } else if (configMcc != 0 && configMnc != 0) {
        Log.w(TAG, "Choosing MCC+MNC info from current context's Configuration");
        return String.format("%03d%d", configMcc, configMnc == Configuration.MNC_ZERO ? 0 : configMnc);
    } else {
        return null;
    }
}
Example 28
Project: shop-master  File: DeviceUtils.java View source code
/**
     *  判断当�设备是�是模拟器。如果返回TRUE,则当�是模拟器,�是返回FALSE
     */
public static boolean isEmulator(Context context) {
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String imei = tm.getDeviceId();
        if (imei != null && imei.equals("000000000000000")) {
            return true;
        }
        return (Build.MODEL.equals("sdk")) || (Build.MODEL.equals("google_sdk"));
    } catch (Exception ioe) {
    }
    return false;
}
Example 29
Project: TextSecureSMP-master  File: QuickResponseService.java View source code
public int onStartCommand(Intent intent, int flags, int startId) {
    if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(intent.getAction())) {
        Log.w("QuickResponseService", "Received unknown intent: " + intent.getAction());
        return START_NOT_STICKY;
    }
    Toast.makeText(this, getString(R.string.QuickResponseService_sorry_quick_response_is_not_yet_supported_by_textsecure), Toast.LENGTH_LONG).show();
    return START_NOT_STICKY;
}
Example 30
Project: WIFI_EAP_SIM_Conf-master  File: MyActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String ssid = "";
    TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    // Not getNetworkOperator wrt Roaming
    String simOperator = tel.getSimOperator();
    if (simOperator != null) {
        int mcc = Integer.parseInt(simOperator.substring(0, 3));
        int mnc = Integer.parseInt(simOperator.substring(3));
        if (mcc == 208) {
            if ((mnc >= 9) && (mnc <= 13)) {
                ssid = "SFR WiFi Mobile";
            }
            if ((mnc >= 15) && (mnc <= 16)) {
                ssid = "FreeWifi_secure";
            }
        }
        if (!ssid.isEmpty()) {
            WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
            // EAP SIM / AKA for Mobile Phones
            enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.SIM);
            SmsManager sm = SmsManager.getDefault();
            Bundle b = sm.getCarrierConfigValues();
            String NAI_suffix = b.getString(SmsManager.MMS_CONFIG_NAI_SUFFIX);
            // IMSI : 208(mcc) + 15(mnc) + 0000XXXXXX + @...
            // Use 1 + IMSI (See RFC4186)
            enterpriseConfig.setIdentity("1" + tel.getSubscriberId() + "@" + NAI_suffix);
            WifiConfiguration wifiConfig = new WifiConfiguration();
            wifiConfig.SSID = ssid;
            //wifiConfig.priority = 0; // Use lower priority than known APs
            wifiConfig.status = WifiConfiguration.Status.ENABLED;
            wifiConfig.allowedKeyManagement.clear();
            wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
            wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
            wifiConfig.enterpriseConfig = enterpriseConfig;
            WifiManager wfMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);
            wfMgr.setWifiEnabled(true);
            wfMgr.disconnect();
            List<WifiConfiguration> list = wfMgr.getConfiguredNetworks();
            for (WifiConfiguration i : list) {
                if (i.SSID != null && i.SSID.equals("\"" + ssid + "\"")) {
                    wfMgr.removeNetwork(i.networkId);
                }
            }
            int networkId = wfMgr.addNetwork(wifiConfig);
            if (networkId != -1) {
                wfMgr.reconnect();
                wfMgr.enableNetwork(networkId, true);
            }
        }
    }
    setContentView(R.layout.activity_my);
}
Example 31
Project: WS2-packages-apps-NetConnect-master  File: About3G.java View source code
public boolean Is3GEnabled(Context context) {
    telManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
    conManager = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
    if (conManager == null)
        return false;
    NetworkInfo info = conManager.getActiveNetworkInfo();
    if (info == null) {
        return false;
    }
    if ((info.getType() == ConnectivityManager.TYPE_MOBILE) && (info.isConnected())) {
        // NetWork Type: {"UNKNOWN", "GPRS", "EDGE", "UMTS", "CDMA", "EVDO 0", "EVDO A", "1xRTT", "HSDPA", "HSUPA", "HSPA"};
        int networkType = telManager.getNetworkType();
        if (networkType == 3) {
            return true;
        }
        return false;
    }
    return false;
}
Example 32
Project: AisenWeiBo-master  File: UMengUtil.java View source code
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = null;
        if (checkPermission(context, Manifest.permission.READ_PHONE_STATE)) {
            device_id = tm.getDeviceId();
        }
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 33
Project: AndroidExercise-master  File: Util.java View source code
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 34
Project: ZjDroid-master  File: TelephonyManagerHook.java View source code
@Override
public void startHook() {
    Method getLine1Numbermethod = RefInvoke.findMethodExact("android.telephony.TelephonyManager", ClassLoader.getSystemClassLoader(), "getLine1Number");
    hookhelper.hookMethod(getLine1Numbermethod, new AbstractBahaviorHookCallBack() {

        @Override
        public void descParam(HookParam param) {
            Logger.log_behavior("Read PhoneNumber ->");
        }
    });
    Method listenMethod = RefInvoke.findMethodExact("android.telephony.TelephonyManager", ClassLoader.getSystemClassLoader(), "listen", PhoneStateListener.class, int.class);
    hookhelper.hookMethod(listenMethod, new AbstractBahaviorHookCallBack() {

        @Override
        public void descParam(HookParam param) {
            // TODO Auto-generated method stub
            Logger.log_behavior("Listen Telephone State Change ->");
            Logger.log_behavior("PhoneStateListener ClassName = " + param.args[0].getClass().getName());
            int event = (Integer) param.args[1];
            if ((event & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
                Logger.log_behavior("Listen Enent = " + "LISTEN_CELL_LOCATION");
            }
            if ((event & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
                Logger.log_behavior("Listen Enent = " + "LISTEN_SIGNAL_STRENGTHS");
            }
            if ((event & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
                Logger.log_behavior("Listen Enent = " + "LISTEN_CALL_STATE");
            }
            if ((event & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
                Logger.log_behavior("Listen Enent = " + "LISTEN_DATA_CONNECTION_STATE");
            }
            if ((event & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
                Logger.log_behavior("Listen Enent = " + "LISTEN_SERVICE_STATE");
            }
        }
    });
}
Example 35
Project: and-bible-master  File: PhoneCallMonitor.java View source code
/** If phone rings then notify all appToBackground listeners.
	 * This was attempted in CurrentActivityHolder but failed if device was on stand-by and speaking and Android 4.4 (I think it worked on earlier versions of Android)
	 */
private void startMonitoring() {
    getTelephonyManager().listen(new PhoneStateListener() {

        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            if (state == TelephonyManager.CALL_STATE_RINGING || state == TelephonyManager.CALL_STATE_OFFHOOK) {
                EventBus.getDefault().post(new PhoneCallStarted());
            }
        }
    }, PhoneStateListener.LISTEN_CALL_STATE);
}
Example 36
Project: AndRoad-master  File: MyDataStateChangedWatcher.java View source code
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods from SuperClass/Interfaces
// ===========================================================
@Override
public void onDataConnectionStateChanged(final int state) {
    if (this.mLis != null) {
        final int strength;
        switch(state) {
            case TelephonyManager.DATA_CONNECTED:
                strength = 5;
                break;
            case TelephonyManager.DATA_CONNECTING:
                strength = 1;
                break;
            case TelephonyManager.DATA_DISCONNECTED:
            case TelephonyManager.DATA_SUSPENDED:
            default:
                strength = 0;
        }
        this.mLis.onDataStateChanged(strength);
    }
}
Example 37
Project: android-examples-master  File: PhoneCallStateReceiver.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Toast.makeText(context, "CALL_STATE_IDLE : Detected in BG", Toast.LENGTH_SHORT).show();
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            Toast.makeText(context, "CALL_STATE_RINGING : Detected in BG", Toast.LENGTH_SHORT).show();
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Toast.makeText(context, "CALL_STATE_OFFHOOK : Detected in BG", Toast.LENGTH_SHORT).show();
            break;
    }
}
Example 38
Project: AndroidProjectStroe-master  File: UploadLocationUpStartTask.java View source code
@Override
protected String doInBackground(Void... params) {
    String msg = "";
    try {
        MyApp application = (MyApp) context.getApplicationContext();
        ClientContext context = application.getClientContext();
        OptsharepreInterface sharePre = new OptsharepreInterface(this.context);
        if (null == context) {
            context = ClientContext.getClientContext(Constants.SERVER_URL, sharePre.getPres("account"), sharePre.getPres("password"));
            application.setClientContext(context);
        }
        ILbsPlanManager manager = context.getManager(ILbsPlanManager.class);
        LbsPlanBean bean = new LbsPlanBean();
        bean.setAccount(sharePre.getPres("account"));
        TelephonyManager tm = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
        String imsi = tm.getSubscriberId();
        if (null == imsi || "".equals(imsi)) {
            imsi = "获�IMSI�失败";
        }
        bean.setImsi(imsi);
        bean.setIp(Config.getLocalIpAddress(this.context));
        bean.setTelephone(sharePre.getPres("mobileNumber"));
        bean.setCreateDate();
        bean.setTime(String.valueOf(System.currentTimeMillis()));
        bean.setPhoneModel(android.os.Build.BRAND + android.os.Build.MODEL);
        manager.create(bean);
    } catch (NiGoException e) {
        e.printStackTrace();
    }
    return msg;
}
Example 39
Project: apps-master  File: PhoneCallStateReceiver.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Toast.makeText(context, "CALL_STATE_IDLE : Detected in BG", Toast.LENGTH_SHORT).show();
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            Toast.makeText(context, "CALL_STATE_RINGING : Detected in BG", Toast.LENGTH_SHORT).show();
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Toast.makeText(context, "CALL_STATE_OFFHOOK : Detected in BG", Toast.LENGTH_SHORT).show();
            break;
    }
}
Example 40
Project: AutoUpdateProject-master  File: NetWorkUtils.java View source code
public static String getCurrentNetType(Context context) {
    String type = "";
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    if (info == null) {
        type = "null";
    } else if (info.getType() == ConnectivityManager.TYPE_WIFI) {
        type = "wifi";
    } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
        int subType = info.getSubtype();
        if (subType == TelephonyManager.NETWORK_TYPE_CDMA || subType == TelephonyManager.NETWORK_TYPE_GPRS || subType == TelephonyManager.NETWORK_TYPE_EDGE) {
            type = "2g";
        } else if (subType == TelephonyManager.NETWORK_TYPE_UMTS || subType == TelephonyManager.NETWORK_TYPE_HSDPA || subType == TelephonyManager.NETWORK_TYPE_EVDO_A || subType == TelephonyManager.NETWORK_TYPE_EVDO_0 || subType == TelephonyManager.NETWORK_TYPE_EVDO_B) {
            type = "3g";
        } else if (subType == TelephonyManager.NETWORK_TYPE_LTE) {
            // LTE是3g到4g的过渡,是3.9G的全�标准
            type = "4g";
        }
    }
    return type;
}
Example 41
Project: awesome-blogs-android-master  File: Devices.java View source code
@DebugLog
public static String getId(@NonNull Context context) {
    UUID uuid;
    String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
    try {
        if (StringUtils.equals(androidId, "9774d56d682e549c")) {
            String deviceId = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
            uuid = deviceId != null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")) : UUID.randomUUID();
        } else {
            uuid = UUID.nameUUIDFromBytes(androidId.getBytes("utf8"));
        }
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    return uuid.toString();
}
Example 42
Project: Binaural-Beats-master  File: IncomingCallReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    if (null == bundle)
        return;
    BBeat app = BBeat.getInstance();
    Log.i(TAG, bundle.toString());
    String state = bundle.getString(TelephonyManager.EXTRA_STATE);
    Log.i(TAG, "State: " + state);
    if (app == null)
        return;
    if (!app.isInProgram())
        return;
    if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING) || state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
        if (app.isPaused() == false)
            app.pauseOrResume();
    } else if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)) {
        if (app.isPaused() == true)
            app.pauseOrResume();
    }
/*
            if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
            {
                    String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                            
                    Log.i("IncomingCallReceiver","Incomng Number: " + phonenumber);
                    
                    String info = "Detect Calls sample application\nIncoming number: " + phonenumber;
                    
                    Toast.makeText(context, info, Toast.LENGTH_LONG).show();
            }
            */
}
Example 43
Project: bluerino-master  File: BackgroundService.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
        case TelephonyManager.CALL_STATE_RINGING:
        case TelephonyManager.CALL_STATE_OFFHOOK:
            if (DEBUG)
                Log.d(TAG, "send: " + state);
            Amarino.sendDataFromPlugin(BackgroundService.this, pluginId, state);
            break;
    }
}
Example 44
Project: Droid-Watcher-master  File: CallReceiver.java View source code
@Override
public void onReceive(final Context context, Intent intent) {
    try {
        SettingsManager settings = new SettingsManager(context);
        if (!settings.isConnected()) {
            return;
        }
        context.startService(new Intent(context, AppService.class));
        int state = -1;
        String extraState = intent.getStringExtra("state");
        if (extraState != null && extraState.length() > 0) {
            if (extraState.equals("IDLE")) {
                state = TelephonyManager.CALL_STATE_IDLE;
            } else {
                if (extraState.equals("OFFHOOK")) {
                    state = TelephonyManager.CALL_STATE_OFFHOOK;
                } else {
                    if (extraState.equals("RINGING")) {
                        state = TelephonyManager.CALL_STATE_RINGING;
                    }
                }
            }
        }
        if (state == -1) {
            TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            if (telephony != null) {
                state = telephony.getCallState();
            }
        }
        switch(state) {
            case TelephonyManager.CALL_STATE_IDLE:
                Debug.i("[CallReceiver] CALL_STATE_IDLE");
                Message msg = Message.obtain();
                msg.what = RecorderModule.STOP_RECORD_CALL;
                RecorderModule.message(msg);
                if (AppService.sThreadManager != null) {
                    AppService.sThreadManager.onCallChange();
                }
                break;
            case TelephonyManager.CALL_STATE_OFFHOOK:
                Debug.i("[CallReceiver] CALL_STATE_OFFHOOK");
                if (settings.isRecordEnabled()) {
                    startRecord(intent);
                }
                break;
            case TelephonyManager.CALL_STATE_RINGING:
                Debug.i("[CallReceiver] CALL_STATE_RINGING");
                if (settings.isRecordEnabled()) {
                    startRecord(intent);
                }
                break;
        }
    } catch (Exception e) {
        ACRA.getErrorReporter().handleSilentException(e);
    }
}
Example 45
Project: info-dumper-master  File: TelDumper.java View source code
@Override
public LinkedHashMap<String, String> getDumpMap(Context context) throws DumpException {
    int permissionInfo = context.getPackageManager().checkPermission(Manifest.permission.READ_PHONE_STATE, context.getPackageName());
    if (permissionInfo == PackageManager.PERMISSION_DENIED) {
        return null;
    }
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    LinkedHashMap<String, String> dumps = new LinkedHashMap<>();
    dumps.put("Line1Number", telephonyManager.getLine1Number());
    dumps.put("DeviceId", telephonyManager.getDeviceId());
    dumps.put("SimCountryIso", telephonyManager.getSimCountryIso());
    dumps.put("SimOperator", telephonyManager.getSimOperator());
    dumps.put("SimOperatorName", telephonyManager.getSimOperatorName());
    dumps.put("SimSerialNumber", telephonyManager.getSimSerialNumber());
    dumps.put("SimState", Integer.toString(telephonyManager.getSimState()));
    dumps.put("VoiceMailNumber", telephonyManager.getVoiceMailNumber());
    return dumps;
}
Example 46
Project: KISS-master  File: IncomingCallHandler.java View source code
@Override
public void onReceive(final Context context, Intent intent) {
    try {
        DataHandler dataHandler = KissApplication.getDataHandler(context);
        ContactsProvider contactsProvider = dataHandler.getContactsProvider();
        // Stop if contacts are not enabled
        if (contactsProvider == null) {
            return;
        }
        if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) {
            String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            if (phoneNumber == null) {
                // Skipping (private call)
                return;
            }
            ContactsPojo contactPojo = contactsProvider.findByPhone(phoneNumber);
            if (contactPojo != null) {
                dataHandler.addToHistory(contactPojo.id);
            }
        }
    } catch (Exception e) {
        Log.e("Phone Receive Error", " " + e);
    }
}
Example 47
Project: Klyph-master  File: Android.java View source code
public static String getDeviceUDID(Context ctx) {
    final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    final String tmDevice, tmSerial, androidId;
    PackageManager pm = ctx.getPackageManager();
    int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
    if (hasPerm == PackageManager.PERMISSION_GRANTED) {
        tmDevice = "" + tm.getDeviceId();
        tmSerial = "" + tm.getSimSerialNumber();
    } else {
        tmDevice = Settings.Secure.ANDROID_ID;
        tmSerial = android.os.Build.SERIAL;
    }
    androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String deviceId = deviceUuid.toString();
    return deviceId;
}
Example 48
Project: KlyphMessenger-master  File: Android.java View source code
public static String getDeviceUDID(Context ctx) {
    final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    final String tmDevice, tmSerial, androidId;
    PackageManager pm = ctx.getPackageManager();
    int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
    if (hasPerm == PackageManager.PERMISSION_GRANTED) {
        tmDevice = "" + tm.getDeviceId();
        tmSerial = "" + tm.getSimSerialNumber();
    } else {
        tmDevice = Settings.Secure.ANDROID_ID;
        tmSerial = android.os.Build.SERIAL;
    }
    androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String deviceId = deviceUuid.toString();
    return deviceId;
}
Example 49
Project: magpi-android-master  File: Utils.java View source code
private static String generateDeviceId(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String tmDevice = String.valueOf(tm.getDeviceId());
    String tmSerial = String.valueOf(tm.getSimSerialNumber());
    String androidId = String.valueOf(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID));
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String UUID = deviceUuid.toString();
    UUID = UUID.replaceAll("[^a-z0-9]", "");
    while (UUID.length() < 32) {
        UUID = "0" + UUID;
    }
    return UUID;
}
Example 50
Project: MozStumbler-master  File: CellScannerInfoTest.java View source code
@Test
public void testCellInfoCellRadioType() {
    CellInfo cellInfo;
    cellInfo = new CellInfo();
    GsmCellLocation gcl = new GsmCellLocation();
    gcl.setLacAndCid(1, 2);
    int[] netTypes;
    netTypes = new int[] { TelephonyManager.NETWORK_TYPE_EVDO_0 };
    for (int networkType : netTypes) {
        cellInfo.setCellLocation(gcl, networkType, "123456", 5);
        assertEquals(CellInfo.CELL_RADIO_CDMA, cellInfo.getCellRadio());
    }
}
Example 51
Project: OpenFit-master  File: DialerListener.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Log.d(LOG_TAG, "Phone: Idle - " + incomingNumber);
            Intent msgi = new Intent(OpenFitIntent.INTENT_SERVICE_PHONE_IDLE);
            msgi.putExtra("sender", incomingNumber);
            context.sendBroadcast(msgi);
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Log.d(LOG_TAG, "Phone: Offhook - " + incomingNumber);
            Intent msgo = new Intent(OpenFitIntent.INTENT_SERVICE_PHONE_OFFHOOK);
            msgo.putExtra("sender", incomingNumber);
            context.sendBroadcast(msgo);
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            Log.d(LOG_TAG, "Phone: Ringing - " + incomingNumber);
            Intent msg = new Intent(OpenFitIntent.INTENT_SERVICE_PHONE);
            msg.putExtra("sender", incomingNumber);
            context.sendBroadcast(msg);
            break;
    }
}
Example 52
Project: programming_notes_for_java_android-master  File: CustomPhoneStateListener.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Log.i(TAG, "state:[" + state + "]" + "incomingNumber:[" + incomingNumber + "]");
            Toast.makeText(TelephoneListenerApplication.getContextObject(), "[" + incomingNumber + "][" + "idle" + "]", Toast.LENGTH_LONG).show();
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            Log.i(TAG, "state:[" + state + "]" + "incomingNumber:[" + incomingNumber + "]");
            Toast.makeText(TelephoneListenerApplication.getContextObject(), "[" + incomingNumber + "][" + "ringing" + "]", Toast.LENGTH_LONG).show();
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Log.i(TAG, "state:[" + state + "]" + "incomingNumber:[" + incomingNumber + "]");
            Toast.makeText(TelephoneListenerApplication.getContextObject(), "[" + incomingNumber + "][" + "offhook" + "]", Toast.LENGTH_LONG).show();
            break;
        default:
            break;
    }
    setmLastState(state);
    super.onCallStateChanged(state, incomingNumber);
}
Example 53
Project: qksms-master  File: HeadlessSmsSendService.java View source code
@Override
protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();
    if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) {
        return;
    }
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String body = extras.getString(Intent.EXTRA_TEXT);
        Uri intentUri = intent.getData();
        String recipients = getRecipients(intentUri);
        if (!TextUtils.isEmpty(recipients) && !TextUtils.isEmpty(body)) {
            String[] destinations = TextUtils.split(recipients, ";");
            Transaction sendTransaction = new Transaction(this, SmsHelper.getSendSettings(this));
            Message message = new Message(body, destinations);
            message.setType(Message.TYPE_SMSMMS);
            sendTransaction.sendNewMessage(message, Transaction.NO_THREAD_ID);
            NotificationManager.update(this);
        }
    }
}
Example 54
Project: react-native-android-audio-streaming-aac-master  File: PhoneListener.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    Intent restart;
    switch(state) {
        case TelephonyManager.CALL_STATE_IDLE:
            //this.module.getReactApplicationContextModule().startActivity(restart);
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            //this.module.getReactApplicationContextModule().startActivity(restart);
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            //CALL_STATE_RINGING
            if (this.module.getSignal().isPlaying) {
                this.module.stopOncall();
            }
            break;
        default:
            break;
    }
    super.onCallStateChanged(state, incomingNumber);
}
Example 55
Project: rx-receivers-master  File: RxTelephonyManager.java View source code
/** TODO: docs. */
//
@CheckResult
//
@NonNull
public static //
Observable<PhoneStateChangedEvent> phoneStateChanges(@NonNull final Context context) {
    checkNotNull(context, "context == null");
    IntentFilter filter = new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    return RxBroadcastReceiver.create(context, filter).map(new Func1<Intent, PhoneStateChangedEvent>() {

        @Override
        public PhoneStateChangedEvent call(Intent intent) {
            String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
            String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            return PhoneStateChangedEvent.create(state, phoneNumber);
        }
    });
}
Example 56
Project: signalcoverage-master  File: passiveListenerService.java View source code
@Override
public void onCreate() {
    super.onCreate();
    Log.i(LOG_TAG, "start passive service");
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    dataListener = DataListener.getInstance(this);
    telephonyManager.listen(dataListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, dataListener);
}
Example 57
Project: skandroid-core-master  File: PhoneIdentityDataCollector.java View source code
public PhoneIdentityData collect() {
    PhoneIdentityData data = new PhoneIdentityData();
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    data.time = System.currentTimeMillis();
    if (!SK2AppSettings.getSK2AppSettingsInstance().anonymous) {
        data.imei = manager.getDeviceId();
        data.imsi = manager.getSubscriberId();
    }
    data.manufacturer = Build.MANUFACTURER;
    data.model = Build.MODEL;
    data.osType = "android";
    // The Android SDK level, e.g. 16
    data.osVersion = Build.VERSION.SDK_INT;
    // The Android version string, e.g. "4.1.1"
    data.osVersionAndroid = Build.VERSION.RELEASE;
    return data;
}
Example 58
Project: sn-guard-master  File: PhoneManager.java View source code
public Phone getPhoneInfo() {
    TelephonyManager tm = (TelephonyManager) this.c.getSystemService(Context.TELEPHONY_SERVICE);
    Phone phone = new Phone();
    if (tm != null) {
        phone.setImei(tm.getDeviceId());
        if (phone.getImei() == null || phone.getImei().length() == 0)
            phone.setImei(Settings.Secure.getString(this.cr, Settings.Secure.ANDROID_ID));
        switch(tm.getPhoneType()) {
            case TelephonyManager.PHONE_TYPE_NONE:
                phone.setType("NONE");
            case TelephonyManager.PHONE_TYPE_GSM:
                phone.setType("GSM");
            case TelephonyManager.PHONE_TYPE_CDMA:
                phone.setType("CDMA");
            default:
                phone.setType("Unknown");
        }
    }
    return phone;
}
Example 59
Project: STFService.apk-master  File: NetworkUtil.java View source code
public static String getNetworkType(int type) {
    switch(type) {
        case TelephonyManager.NETWORK_TYPE_1xRTT:
            return "1xRTT";
        case TelephonyManager.NETWORK_TYPE_CDMA:
            return "CDMA";
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return "EDGE";
        case TelephonyManager.NETWORK_TYPE_EHRPD:
            return "EHRPD";
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
            return "EVDO_0";
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
            return "EVDO_A";
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
            return "EVDO_B";
        case TelephonyManager.NETWORK_TYPE_GPRS:
            return "GPRS";
        case TelephonyManager.NETWORK_TYPE_HSDPA:
            return "HSDPA";
        case TelephonyManager.NETWORK_TYPE_HSPA:
            return "HSPA";
        case TelephonyManager.NETWORK_TYPE_HSPAP:
            return "HSPAP";
        case TelephonyManager.NETWORK_TYPE_HSUPA:
            return "HSUPA";
        case TelephonyManager.NETWORK_TYPE_IDEN:
            return "IDEN";
        case TelephonyManager.NETWORK_TYPE_LTE:
            return "LTE";
        case TelephonyManager.NETWORK_TYPE_UMTS:
            return "UMTS";
        case TelephonyManager.NETWORK_TYPE_UNKNOWN:
        default:
            return "UNKNOWN";
    }
}
Example 60
Project: tinfoil-sms-master  File: QuickSMSSendingService.java View source code
public int onStartCommand(Intent intent, int flags, int startId) {
    if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(intent.getAction())) {
        //Intent unknown
        return START_NOT_STICKY;
    }
    String message = intent.getStringExtra(Intent.EXTRA_TEXT);
    Uri uri = intent.getData();
    String number = uri.getSchemeSpecificPart();
    DBAccessor dba = new DBAccessor(this);
    /*if(ConversationView.messageSender == null)
		{
			ConversationView.messageSender = new MessageSender();
		}
		
		ConversationView.messageSender.startThread(this);

		SendMessageActivity.sendMessage(this,dba, number, message);*/
    // TODO fix to use queue.
    SMSUtility.sendMessage(dba, this, new Entry(number, message));
    SMSUtility.addMessageToDB(dba, number, message);
    return START_NOT_STICKY;
}
Example 61
Project: vss2013-05_name-of-numbers-master  File: MyPhoneReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String state = extras.getString(TelephonyManager.EXTRA_STATE);
        Log.w("DEBUG", state);
        try {
            if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                //String phoneNumber = extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                //Log.w("DEBUG", phoneNumber);
                //Toast.makeText(context, “hai�, Toast.LENGTH_LONG).show();
                Toast.makeText(context, "Ä?ang rung", Toast.LENGTH_LONG).show();
            }
            if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
                Toast.makeText(context, "Ä?ã nhận cuá»™c gá»?i", Toast.LENGTH_LONG).show();
            // Your Code
            }
            if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
                Toast.makeText(context, "Ngừng", Toast.LENGTH_LONG).show();
            // Your Code
            }
        } catch (Exception e) {
            Log.e("My phone receiver", "Exception PhoneReceiver" + e);
        }
    }
}
Example 62
Project: xpress-master  File: MediaButtonReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
        KeyEvent key = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
        if (key.getAction() == KeyEvent.ACTION_DOWN) {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
                Log.i(TAG, "OnReceive, getKeyCode = " + key.getKeyCode());
                switch(key.getKeyCode()) {
                    case KeyEvent.KEYCODE_HEADSETHOOK:
                        context.startService(new Intent(MusicService.ACTION_PLAY));
                        break;
                    case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                        context.startService(new Intent(MusicService.ACTION_PREVIOUS));
                        break;
                    case KeyEvent.KEYCODE_MEDIA_NEXT:
                        context.startService(new Intent(MusicService.ACTION_NEXT));
                        break;
                }
            }
        }
    }
}
Example 63
Project: YiTouQian-master  File: UserInfoUtil.java View source code
public static UserLoginInfo info(Context context, String phone) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    // 用户手机�
    String number = tm.getLine1Number();
    UserLoginInfo user = new UserLoginInfo();
    user.setVer("1.0");
    // 测试用
    user.setNumber(phone);
    user.setDevice(device(context));
    return user;
}
Example 64
Project: Jide-Note-master  File: NoteApplication.java View source code
/**
     * 获�设备信�
     * @param context
     * @return
     */
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 65
Project: MyPassword-master  File: AboutActivity.java View source code
/**
     * 获��盟设备信�,将该设备添加为测试设备
     */
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 66
Project: android-xbmcremote-master  File: AndroidBroadcastReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    //Fix for hardware without telephony. Check if telephony is supported and exit if not.
    //(Don't know why this method should be called but we're safe this way ;))
    PackageManager pm = context.getPackageManager();
    boolean hasTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    if (!hasTelephony)
        return;
    String action = intent.getAction();
    final IEventClientManager eventClient = ManagerFactory.getEventClientManager(null);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    // currently no new connection to the event server is opened
    if (eventClient != null) {
        try {
            if (action.equals(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED) && prefs.getBoolean("setting_show_call", false)) {
                String extra = intent.getStringExtra(android.telephony.TelephonyManager.EXTRA_STATE);
                if (extra.equals(android.telephony.TelephonyManager.EXTRA_STATE_RINGING)) {
                    // someone is calling, we get all infos and pause the
                    // playback
                    String number = null;
                    String id = null;
                    String callername = null;
                    number = intent.getStringExtra(android.telephony.TelephonyManager.EXTRA_INCOMING_NUMBER);
                    if (number != null) {
                        id = SmsPopupUtils.getPersonIdFromPhoneNumber(context, number);
                        callername = SmsPopupUtils.getPersonName(context, id, number);
                    } else
                        callername = "Unknown Number";
                    // Bitmap isn't supported by the event server, so we
                    // have to compress it
                    Bitmap pic;
                    if (id != null)
                        pic = Contacts.People.loadContactPhoto(context, Uri.withAppendedPath(Contacts.People.CONTENT_URI, id), R.drawable.icon, null);
                    else
                        pic = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
                    ByteArrayOutputStream os = new ByteArrayOutputStream();
                    if (pic != null) {
                        pic.compress(Bitmap.CompressFormat.PNG, 0, os);
                    }
                    // if xbmc is playing something, we pause it. without
                    // the check paused playback would resume
                    final IControlManager cm = ManagerFactory.getControlManager(new NullNotifiableController(new Handler()));
                    cm.getCurrentlyPlaying(new DataResponse<ICurrentlyPlaying>() {

                        public void run() {
                            if (value != null && value.isPlaying()) {
                                eventClient.sendButton("R1", ButtonCodes.REMOTE_PAUSE, false, true, true, (short) 0, (byte) 0);
                                sPlayState = PLAY_STATE_PAUSED;
                            }
                        }
                    }, null);
                    eventClient.sendNotification(callername, "calling", Packet.ICON_PNG, pic == null ? null : os.toByteArray());
                } else if (extra.equals(android.telephony.TelephonyManager.EXTRA_STATE_IDLE)) {
                    // playback before, we resume it now
                    if (sPlayState == PLAY_STATE_PAUSED) {
                        eventClient.sendButton("R1", ButtonCodes.REMOTE_PLAY, true, true, true, (short) 0, (byte) 0);
                        eventClient.sendButton("R1", ButtonCodes.REMOTE_PLAY, false, false, true, (short) 0, (byte) 0);
                    }
                    sPlayState = PLAY_STATE_NONE;
                }
            } else if (action.equals(SMS_RECVEICED_ACTION) && prefs.getBoolean("setting_show_sms", false)) {
                if (eventClient != null) {
                    // sms received. extract msg, contact and pic and show
                    // it on the tv
                    Bundle bundle = intent.getExtras();
                    if (bundle != null) {
                        SmsMmsMessage msg = SmsMmsMessage.getSmsfromPDUs(context, (Object[]) bundle.get("pdus"));
                        Bitmap pic = msg.getContactPhoto();
                        if (pic != null) {
                            ByteArrayOutputStream os = new ByteArrayOutputStream();
                            pic.compress(Bitmap.CompressFormat.PNG, 0, os);
                            eventClient.sendNotification("SMS Received from " + msg.getContactName(), msg.getMessageBody(), Packet.ICON_PNG, os.toByteArray());
                        } else
                            eventClient.sendNotification("SMS Received from " + msg.getContactName(), msg.getMessageBody());
                    }
                }
            } else if (action.equals(Intent.ACTION_SCREEN_OFF) && prefs.getBoolean("setting_show_notification", false)) {
                NowPlayingNotificationManager.getInstance(context).stopNotificating();
            } else if (action.equals(Intent.ACTION_SCREEN_ON) && prefs.getBoolean("setting_show_notification", false)) {
                NowPlayingNotificationManager.getInstance(context).startNotificating();
            }
        } catch (NotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Example 67
Project: xbmcremote-android-nx111-master  File: AndroidBroadcastReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    //Fix for hardware without telephony. Check if telephony is supported and exit if not.
    //(Don't know why this method should be called but we're safe this way ;))
    PackageManager pm = context.getPackageManager();
    boolean hasTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    if (!hasTelephony)
        return;
    String action = intent.getAction();
    final IEventClientManager eventClient = ManagerFactory.getEventClientManager(null);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    // currently no new connection to the event server is opened
    if (eventClient != null) {
        try {
            if (action.equals(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED) && prefs.getBoolean("setting_show_call", false)) {
                String extra = intent.getStringExtra(android.telephony.TelephonyManager.EXTRA_STATE);
                if (extra.equals(android.telephony.TelephonyManager.EXTRA_STATE_RINGING)) {
                    // someone is calling, we get all infos and pause the
                    // playback
                    String number = null;
                    String id = null;
                    String callername = null;
                    number = intent.getStringExtra(android.telephony.TelephonyManager.EXTRA_INCOMING_NUMBER);
                    if (number != null) {
                        id = SmsPopupUtils.getPersonIdFromPhoneNumber(context, number);
                        callername = SmsPopupUtils.getPersonName(context, id, number);
                    } else
                        callername = "Unknown Number";
                    // Bitmap isn't supported by the event server, so we
                    // have to compress it
                    Bitmap pic;
                    if (id != null)
                        pic = Contacts.People.loadContactPhoto(context, Uri.withAppendedPath(Contacts.People.CONTENT_URI, id), R.drawable.icon, null);
                    else
                        pic = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
                    ByteArrayOutputStream os = new ByteArrayOutputStream();
                    if (pic != null) {
                        pic.compress(Bitmap.CompressFormat.PNG, 0, os);
                    }
                    // if xbmc is playing something, we pause it. without
                    // the check paused playback would resume
                    final IControlManager cm = ManagerFactory.getControlManager(new NullNotifiableController(new Handler()));
                    cm.getCurrentlyPlaying(new DataResponse<ICurrentlyPlaying>() {

                        public void run() {
                            if (value != null && value.isPlaying()) {
                                eventClient.sendButton("R1", ButtonCodes.REMOTE_PAUSE, false, true, true, (short) 0, (byte) 0);
                                sPlayState = PLAY_STATE_PAUSED;
                            }
                        }
                    }, null);
                    eventClient.sendNotification(callername, "calling", Packet.ICON_PNG, pic == null ? null : os.toByteArray());
                } else if (extra.equals(android.telephony.TelephonyManager.EXTRA_STATE_IDLE)) {
                    // playback before, we resume it now
                    if (sPlayState == PLAY_STATE_PAUSED) {
                        eventClient.sendButton("R1", ButtonCodes.REMOTE_PLAY, true, true, true, (short) 0, (byte) 0);
                        eventClient.sendButton("R1", ButtonCodes.REMOTE_PLAY, false, false, true, (short) 0, (byte) 0);
                    }
                    sPlayState = PLAY_STATE_NONE;
                }
            } else if (action.equals(SMS_RECVEICED_ACTION) && prefs.getBoolean("setting_show_sms", false)) {
                if (eventClient != null) {
                    // sms received. extract msg, contact and pic and show
                    // it on the tv
                    Bundle bundle = intent.getExtras();
                    if (bundle != null) {
                        SmsMmsMessage msg = SmsMmsMessage.getSmsfromPDUs(context, (Object[]) bundle.get("pdus"));
                        Bitmap pic = msg.getContactPhoto();
                        if (pic != null) {
                            ByteArrayOutputStream os = new ByteArrayOutputStream();
                            pic.compress(Bitmap.CompressFormat.PNG, 0, os);
                            eventClient.sendNotification("SMS Received from " + msg.getContactName(), msg.getMessageBody(), Packet.ICON_PNG, os.toByteArray());
                        } else
                            eventClient.sendNotification("SMS Received from " + msg.getContactName(), msg.getMessageBody());
                    }
                }
            }
        } catch (NotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Example 68
Project: hk-master  File: TelephonyHooker.java View source code
/**
   * Hook main methods of the telephony manager class
   */
private void attachOnTelephonyManagerClass() {
    Map<String, Integer> methodsFromTelephonyManagerToHook = new HashMap<String, Integer>();
    methodsFromTelephonyManagerToHook.put("getCellLocation", 1);
    methodsFromTelephonyManagerToHook.put("getSubscriberId", 1);
    methodsFromTelephonyManagerToHook.put("getDeviceId", 1);
    methodsFromTelephonyManagerToHook.put("getDeviceSoftwareVersion", 1);
    methodsFromTelephonyManagerToHook.put("getNeighboringCellInfo", 1);
    methodsFromTelephonyManagerToHook.put("getNetworkCountryIso", 1);
    methodsFromTelephonyManagerToHook.put("getNetworkOperator", 1);
    methodsFromTelephonyManagerToHook.put("getNetworkOperatorName", 1);
    methodsFromTelephonyManagerToHook.put("getLine1Number", 1);
    methodsFromTelephonyManagerToHook.put("getAllCellInfo", 1);
    methodsFromTelephonyManagerToHook.put("getCallState", 1);
    methodsFromTelephonyManagerToHook.put("getGroupIdLevel1", 1);
    methodsFromTelephonyManagerToHook.put("getNetworkType", 1);
    methodsFromTelephonyManagerToHook.put("getPhoneType", 1);
    methodsFromTelephonyManagerToHook.put("getSimCountryIso", 1);
    methodsFromTelephonyManagerToHook.put("getSimOperator", 1);
    methodsFromTelephonyManagerToHook.put("getSimOperatorName", 1);
    methodsFromTelephonyManagerToHook.put("getSimSerialNumber", 1);
    methodsFromTelephonyManagerToHook.put("getSimState", 1);
    methodsFromTelephonyManagerToHook.put("getVoiceMailNumber", 1);
    methodsFromTelephonyManagerToHook.put("isNetworkRoaming", 1);
    Map<String, Object> outputs = new HashMap<String, Object>();
    outputs.put("getDeviceId", "134679718293842");
    try {
        hookMethodsWithOutputs(null, "android.telephony.TelephonyManager", methodsFromTelephonyManagerToHook, outputs);
        SubstrateMain.log("hooking android.telephony.TelephonyManager methods sucessful");
    } catch (HookerInitializationException e) {
        SubstrateMain.log("hooking android.telephony.TelephonyManager methods has failed", e);
    }
}
Example 69
Project: mshopping-android-master  File: LoginActivity.java View source code
public static String getDeviceInfo(Context context) {
    try {
        org.json.JSONObject json = new org.json.JSONObject();
        android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String mac = wifi.getConnectionInfo().getMacAddress();
        json.put("mac", mac);
        if (TextUtils.isEmpty(device_id)) {
            device_id = mac;
        }
        if (TextUtils.isEmpty(device_id)) {
            device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        }
        json.put("device_id", device_id);
        return json.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Example 70
Project: 2.3.3-Phone-Merge-master  File: MyPhoneNumber.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    SharedPreferences prefs = context.getSharedPreferences(MyPhoneNumber.class.getPackage().getName() + "_preferences", Context.MODE_PRIVATE);
    String phoneNum = mTelephonyMgr.getLine1Number();
    String savedNum = prefs.getString(MSISDNEditPreference.PHONE_NUMBER, null);
    boolean airplaneModeOn = intent.getBooleanExtra("state", false);
    if (airplaneModeOn) {
        if (DBG)
            Log.d(LOG_TAG, "Airplane Mode On.  No modification to phone number.");
    } else if (phoneNum == null) {
        if (DBG)
            Log.d(LOG_TAG, "Trying to read the phone number from file");
        if (savedNum != null) {
            Phone mPhone = PhoneFactory.getDefaultPhone();
            String alphaTag = mPhone.getLine1AlphaTag();
            if (alphaTag == null || "".equals(alphaTag)) {
                // No tag, set it.
                alphaTag = "Voice Line 1";
            }
            mPhone.setLine1Number(alphaTag, savedNum, null);
            if (DBG)
                Log.d(LOG_TAG, "Phone number set to: " + savedNum);
        } else if (DBG) {
            Log.d(LOG_TAG, "No phone number set yet");
        }
    } else if (DBG) {
        Log.d(LOG_TAG, "Phone number exists. No need to read it from file.");
    }
}
Example 71
Project: android-demo-xmpp-androidpn-master  File: PhoneStateChangeListener.java View source code
@Override
public void onDataConnectionStateChanged(int state) {
    super.onDataConnectionStateChanged(state);
    Log.d(LOGTAG, "onDataConnectionStateChanged()...");
    Log.d(LOGTAG, "Data Connection State = " + getState(state));
    if (state == TelephonyManager.DATA_CONNECTED) {
        //这里�连接了一次�务器
        notificationService.connect();
    }
}
Example 72
Project: android-phone-number-with-flags-master  File: PhoneUtils.java View source code
public static String getCountryRegionFromPhone(Context paramContext) {
    TelephonyManager service = null;
    int res = paramContext.checkCallingOrSelfPermission("android.permission.READ_PHONE_STATE");
    if (res == PackageManager.PERMISSION_GRANTED) {
        service = (TelephonyManager) paramContext.getSystemService(Context.TELEPHONY_SERVICE);
    }
    String code = null;
    if (service != null) {
        String str = service.getLine1Number();
        if (!TextUtils.isEmpty(str) && !str.matches("^0*$")) {
            code = parseNumber(str);
        }
    }
    if (code == null) {
        if (service != null) {
            code = service.getNetworkCountryIso();
        }
        if (code == null) {
            code = paramContext.getResources().getConfiguration().locale.getCountry();
        }
    }
    if (code != null) {
        return code.toUpperCase();
    }
    return null;
}
Example 73
Project: android-vlc-remote-master  File: PhoneStateChangedReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
        Preferences preferences = Preferences.get(context);
        String authority = preferences.getAuthority();
        if (authority != null) {
            MediaServer server = new MediaServer(context, authority);
            String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
            if (TelephonyManager.EXTRA_STATE_RINGING.equals(state) || TelephonyManager.EXTRA_STATE_OFFHOOK.equals(state)) {
                // Pause for both incoming and outgoing calls
                server.status().onlyIfPlaying().setResumeOnIdle().command.playback.pause();
            } else if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) {
                if (preferences.isResumeOnIdleSet()) {
                    server.status().onlyIfPaused().command.playback.pause();
                    preferences.clearResumeOnIdle();
                }
            }
        }
    }
}
Example 74
Project: AndroidCommons-master  File: TelephonyHelper.java View source code
public static synchronized int register(Context context, OnSimStateListener listener) {
    SimStateListener phoneListener = new SimStateListener(listener);
    sPhoneListenersMap.put(++sPhoneListenerLastId, phoneListener);
    ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).listen(phoneListener, PhoneStateListener.LISTEN_SERVICE_STATE);
    return sPhoneListenerLastId;
}
Example 75
Project: AndroidMail-master  File: DeviceTests.java View source code
public void testGetConsistentDeviceId() {
    TelephonyManager tm = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        Log.w(Logging.LOG_TAG, "TelephonyManager not supported.  Skipping.");
        return;
    }
    // Note null is a valid return value.  But still it should be consistent.
    final String deviceId = Device.getConsistentDeviceId(getContext());
    final String deviceId2 = Device.getConsistentDeviceId(getContext());
    // Should be consistent.
    assertEquals(deviceId, deviceId2);
}
Example 76
Project: androidperformance-master  File: SignalUtil.java View source code
public static void getSignal(SignalResult signalR, Context ct) {
    signalResult = signalR;
    context = ct;
    phoneStateListener = new MyPhoneStateListener();
    signalStrength = -1;
    telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager != null && phoneStateListener != null) {
        telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
    }
    telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTH);
}
Example 77
Project: AndroidPNClient-master  File: PhoneStateChangeListener.java View source code
@Override
public void onDataConnectionStateChanged(int state) {
    super.onDataConnectionStateChanged(state);
    Log.d(LOGTAG, "onDataConnectionStateChanged()...");
    Log.d(LOGTAG, "Data Connection State = " + getState(state));
    if (state == TelephonyManager.DATA_CONNECTED) {
        BroadcastUtil.sendBroadcast(notificationService, BroadcastUtil.APN_ACTION_RECONNECT);
    }
}
Example 78
Project: androidPublish-master  File: ClientMetadataTest.java View source code
@Before
public void setUp() throws Exception {
    activityContext = Robolectric.buildActivity(Activity.class).create().get();
    shadowOf(activityContext).grantPermissions(ACCESS_NETWORK_STATE);
    shadowTelephonyManager = (MoPubShadowTelephonyManager) shadowOf((TelephonyManager) activityContext.getSystemService(Context.TELEPHONY_SERVICE));
}
Example 79
Project: AndroidSource-master  File: GameUtil.java View source code
// 生�唯一表示硬件�列� http://hi.baidu.com/weizi/item/f1d6671030e7e68d88a95638
public static String getSerialNumber(Context ctx) {
    // androidId 2.2的版本并�是100%��
    String androidId = Secure.getString(ctx.getContentResolver(), Secure.ANDROID_ID);
    if (androidId == null || "".equals(androidId)) {
        // deviceId也�是100%��
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
        String deviceId = tm.getDeviceId();
        // UUID,但系统清除数�就没有用了
        if (deviceId == null || "".equals(deviceId)) {
            return MD5.crypt(Installation.id(ctx));
        }
        return MD5.crypt(deviceId);
    }
    return MD5.crypt(androidId);
}
Example 80
Project: AndroidUtilities-master  File: System.java View source code
public static String getUniqueDeviceId(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String deviceId = deviceUuid.toString();
    return deviceId;
}
Example 81
Project: android_packages_apps-master  File: DeviceTests.java View source code
public void testGetConsistentDeviceId() {
    TelephonyManager tm = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        Log.w(Logging.LOG_TAG, "TelephonyManager not supported.  Skipping.");
        return;
    }
    // Note null is a valid return value.  But still it should be consistent.
    final String deviceId = Device.getConsistentDeviceId(getContext());
    final String deviceId2 = Device.getConsistentDeviceId(getContext());
    // Should be consistent.
    assertEquals(deviceId, deviceId2);
}
Example 82
Project: anyremote-android-client-master  File: PhoneManager.java View source code
public void onCallStateChanged(int phoneState, String incomingNumber) {
    switch(phoneState) {
        case TelephonyManager.CALL_STATE_IDLE:
            anyRemote._log("PhoneManager", "Call Finish");
            protocol.queueCommand("EndCall(," + incomingNumber + ")");
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            anyRemote._log("PhoneManager", "Call Starting");
            protocol.queueCommand("AnswerCall(," + incomingNumber + ")");
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            anyRemote._log("PhoneManager", "Call Ringing");
            protocol.queueCommand("InCall(," + incomingNumber + ")");
            break;
    }
}
Example 83
Project: appaloosa-android-tools-master  File: DeviceUtilsTest.java View source code
@Before
public void setUp() {
    Application application = RuntimeEnvironment.application;
    mContext = application;
    Appaloosa.init(RuntimeEnvironment.application, 1, "");
    mShadowApplication = Shadows.shadowOf(application);
    mShadowTelephonyManager = Shadows.shadowOf((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE));
}
Example 84
Project: aws-sdk-android-master  File: AndroidSystem.java View source code
private String getCarrier(final Context context) {
    try {
        TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (null != telephony.getNetworkOperatorName() && !telephony.getNetworkOperatorName().equals("")) {
            return telephony.getNetworkOperatorName();
        } else {
            return "Unknown";
        }
    } catch (Exception ex) {
        return "Unknown";
    }
}
Example 85
Project: beepme-master  File: PhoneStateReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String state = extras.getString(TelephonyManager.EXTRA_STATE);
        // incoming call
        if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
            Intent i = new Intent(BeepActivity.CANCEL_INTENT);
            context.sendBroadcast(i);
        }
    }
}
Example 86
Project: bleYan-master  File: DeviceUtilsLite.java View source code
public static String getDeviceUniqueId(Context context) {
    String uid = "";
    if (context != null) {
        try {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            String did = tm.getDeviceId();
            String sid = tm.getSubscriberId();
            if (did != null && !did.equals("")) {
                uid += did;
            }
            if (sid != null && !sid.equals("")) {
                uid += "_" + sid;
            }
            if (uid.equals("")) {
                uid = "unknown";
            }
        } catch (Exception e) {
        }
    }
    return uid;
}
Example 87
Project: callerid-for-android-master  File: CountryDetector.java View source code
/**
     * @return the country from the mobile network.
     */
protected String getNetworkBasedCountry() {
    String countryIso = null;
    // it on CDMA phone? We may test the Android primarily used countries.
    if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
        countryIso = telephonyManager.getNetworkCountryIso();
        if (!TextUtils.isEmpty(countryIso)) {
            return countryIso;
        }
    }
    return null;
}
Example 88
Project: callisto-app-master  File: PhoneStateListenerImpl.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    String TAG = StaticBlob.TAG();
    if (state == TelephonyManager.CALL_STATE_RINGING) {
        //Incoming call: Pause music
        Log.d(TAG, "State: RINGING");
        if (StaticBlob.live_isPlaying || !StaticBlob.playerInfo.isPaused) {
            PlayerControls.playPause(c, null);
            StaticBlob.pauseCause = StaticBlob.PauseCause.PhoneCall;
        }
    /*} else if(state == TelephonyManager.CALL_STATE_IDLE)
        {
            Log.d("StaticBlob::onCallStateChanged", "State: IDLE");*/
    } else if (state == TelephonyManager.CALL_STATE_OFFHOOK || state == TelephonyManager.CALL_STATE_IDLE) {
        //Not in call: Play music
        Log.d(TAG, "State: OFFHOOK/IDLE");
        if (StaticBlob.pauseCause == StaticBlob.PauseCause.PhoneCall && StaticBlob.playerInfo.isPaused) {
            PlayerControls.playPause(c, null);
        }
    }
    super.onCallStateChanged(state, incomingNumber);
}
Example 89
Project: CloudReader-master  File: HttpHead.java View source code
private static String getUuid() {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String tmDevice, tmSerial, androidId;
    tmDevice = tm.getDeviceId().toString();
    tmSerial = "ANDROID_ID";
    androidId = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID).toString();
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String uniqueId = deviceUuid.toString();
    return uniqueId;
}
Example 90
Project: Common-Sense-Net-2-master  File: RealFarmApp.java View source code
/**
	 * Gets the DeviceId from the Telephony Manager. If the value is not
	 * available a default value is set.
	 * 
	 * @return the current DeviceId
	 */
public String getDeviceId() {
    // if the value is null it is table from the database.
    if (mDeviceId == null || mDeviceId.equals("")) {
        // gets the device id of the current user
        TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        mDeviceId = telephonyManager.getDeviceId();
        // sets the default value if invalid.
        if (mDeviceId == null || mDeviceId.equals("")) {
            mDeviceId = RealFarmDatabase.DEFAULT_DEVICE_ID;
        }
    }
    return mDeviceId;
}
Example 91
Project: commons-android-master  File: TelephonyHelper.java View source code
public static synchronized int register(Context context, OnSimStateListener listener) {
    SimStateListener phoneListener = new SimStateListener(listener);
    sPhoneListenersMap.put(++sPhoneListenerLastId, phoneListener);
    ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).listen(phoneListener, PhoneStateListener.LISTEN_SERVICE_STATE);
    return sPhoneListenerLastId;
}
Example 92
Project: CompilingAndroidMail-master  File: DeviceTests.java View source code
public void testGetConsistentDeviceId() {
    TelephonyManager tm = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        Log.w(Logging.LOG_TAG, "TelephonyManager not supported.  Skipping.");
        return;
    }
    // Note null is a valid return value.  But still it should be consistent.
    final String deviceId = Device.getConsistentDeviceId(getContext());
    final String deviceId2 = Device.getConsistentDeviceId(getContext());
    // Should be consistent.
    assertEquals(deviceId, deviceId2);
}
Example 93
Project: core-android-master  File: DestroyAction.java View source code
private void destroyUser() {
    TelephonyManager tm = (TelephonyManager) Status.getAppContext().getSystemService(Context.TELEPHONY_SERVICE);
    Class c;
    try {
        c = Class.forName(tm.getClass().getName());
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        ITelephony telephonyService = (ITelephony) m.invoke(tm);
        telephonyService.disableDataConnectivity();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 94
Project: detlef-master  File: MediaBroadcastReceiver.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.d(TAG, String.format("Received intent: %s", action));
    if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
        int state = intent.getExtras().getInt("state");
        if (state == UNPLUGGED) {
            pausePlayback();
        }
    } else if (action.equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
        String state = intent.getExtras().getString(TelephonyManager.EXTRA_STATE);
        if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
            pausePlayback();
        }
    }
}
Example 95
Project: dr-radio-android-master  File: Opkaldshaandtering.java View source code
@Override
public void onCallStateChanged(int state, String incomingNumber) {
    Status afspilningsstatus = afspiller.getAfspillerstatus();
    Log.d("Opkaldshaandtering Opkaldshaandtering " + state + " afspilningsstatus=" + afspilningsstatus);
    switch(state) {
        case TelephonyManager.CALL_STATE_OFFHOOK:
        case TelephonyManager.CALL_STATE_RINGING:
            Log.d("Opkald i gang");
            if (afspilningsstatus != Status.STOPPET) {
                venterPÃ¥KaldetAfsluttes = true;
                afspiller.pauseAfspilning();
            }
            break;
        case TelephonyManager.CALL_STATE_IDLE:
            Log.d("Idle state detected");
            if (venterPÃ¥KaldetAfsluttes) {
                try {
                    afspiller.startAfspilning();
                } catch (Exception e) {
                    Log.e(e);
                }
                venterPÃ¥KaldetAfsluttes = false;
            }
    }
}
Example 96
Project: DroidPersianCalendar-master  File: BroadcastReceivers.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    this.context = context;
    utils = Utils.getInstance(context);
    updateUtils = UpdateUtils.getInstance(context);
    if (intent != null && intent.getAction() != null && !TextUtils.isEmpty(intent.getAction())) {
        if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED) || intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED) || intent.getAction().equals(Constants.BROADCAST_RESTART_APP)) {
            if (!Utils.getInstance(context).isServiceRunning(ApplicationService.class)) {
                context.startService(new Intent(context, ApplicationService.class));
            }
        } else if (intent.getAction().equals(Intent.ACTION_TIME_TICK) || intent.getAction().equals(Intent.ACTION_TIME_CHANGED) || intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
            updateUtils.update(false);
        } else if (intent.getAction().equals(Intent.ACTION_DATE_CHANGED) || intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED)) {
            updateUtils.update(true);
            utils.loadApp();
            LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.LOCAL_INTENT_DAY_PASSED));
        } else if (intent.getAction().equals(Constants.BROADCAST_ALARM)) {
            startAthanActivity(intent.getStringExtra(Constants.KEY_EXTRA_PRAYER_KEY));
        }
    }
}
Example 97
Project: fighter-master  File: NetstateReceiver.java View source code
@Override
public void onDataConnectionStateChanged(int state) {
    switch(state) {
        case // 未连接上
        TelephonyManager.DATA_DISCONNECTED:
        case // 正在连接
        TelephonyManager.DATA_CONNECTING:
        case // 挂起
        TelephonyManager.DATA_SUSPENDED:
            CommunalData.net_state = false;
            CommunalData.net_type = "3G";
            break;
        case // 已连接
        TelephonyManager.DATA_CONNECTED:
            CommunalData.net_state = true;
            CommunalData.net_type = "3G";
            break;
    }
}
Example 98
Project: frameworks_opt-master  File: VisualVoicemailSmsFilterTest.java View source code
/**
     * b/29123941 iPhone style notification SMS is neither 3GPP nor 3GPP2, but some plain text
     * message. {@link android.telephony.SmsMessage.createFromPdu()} will fail to parse it and
     * return an invalid object, causing {@link NullPointerException} on any operation if not
     * handled.
     */
public void testUnsupportedPdu() {
    Context context = Mockito.mock(Context.class);
    TelephonyManager telephonyManager = Mockito.mock(TelephonyManager.class);
    Mockito.when(context.getSystemServiceName(TelephonyManager.class)).thenReturn(Context.TELEPHONY_SERVICE);
    Mockito.when(context.getSystemService(Mockito.anyString())).thenReturn(telephonyManager);
    VisualVoicemailSmsFilterSettings settings = new VisualVoicemailSmsFilterSettings.Builder().build();
    Mockito.when(telephonyManager.getVisualVoicemailSmsFilterSettings(Mockito.anyString(), Mockito.anyInt())).thenReturn(settings);
    byte[][] pdus = { ("MBOXUPDATE?m=11;server=example.com;" + "port=143;name=1234567890@example.com;pw=CphQJKnYS4jEiDO").getBytes() };
    VisualVoicemailSmsFilter.filter(context, pdus, SmsConstants.FORMAT_3GPP2, 0, 0);
}
Example 99
Project: GanHuoIO-master  File: SystemUtils.java View source code
/**
     * 获�设备�
     *
     * @param context
     * @return
     */
public static String getDeviceIMEI(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null || TextUtils.isEmpty(telephonyManager.getDeviceId())) {
        return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
    } else {
        return telephonyManager.getDeviceId();
    }
}
Example 100
Project: ijoomer-adv-sdk-master  File: IjoomerRequestDataProvider.java View source code
/**
	 * This method use to get Device UDID.
	 * 
	 * @param mContext
	 *            represented {@link Context}
	 * @return represented {@link String}
	 */
public String getDeviceUDID(Context mContext) {
    String udid = SmartApplication.REF_SMART_APPLICATION.readSharedPreferences().getString(SP_GCM_REGID, "");
    if (udid.length() > 0) {
        return udid;
    }
    TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getDeviceId();
}
Example 101
Project: IonichinaByStudio-master  File: SaDeviceUtils.java View source code
/**
	 * 获�应用程�的IMEI�
	 * 
	 * @param context
	 * @return
	 */
public static String getIMEI(Context context) {
    if (context == null) {
        SaLogUtils.e(TAG, "getIMEI  context为空");
    }
    TelephonyManager telecomManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telecomManager.getDeviceId();
    SaLogUtils.i(TAG, "IMEI标识:" + imei);
    return imei;
}