List of usage examples for android.content Context WIFI_SERVICE
String WIFI_SERVICE
To view the source code for android.content Context WIFI_SERVICE.
Click Source Link
From source file:com.savor.ads.core.Session.java
public String getMacAddr() { if (TextUtils.isEmpty(macAddress)) { try {//from www. j a v a2 s .co m WifiManager wifi = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); macAddress = info.getMacAddress(); } catch (Exception ex) { LogUtils.e(ex.toString()); } } return macAddress; }
From source file:com.jesjimher.bicipalma.MesProperesActivity.java
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("ocultarVaciosPref")) actualizarListado();//from w ww .j a va 2 s . c om if (key.equals("activarWifiPref")) { if (sharedPreferences.getBoolean("activarWifiPref", false)) { WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); wm.setWifiEnabled(true); } } }
From source file:com.haoqee.chatsdk.net.Utility.java
/** * Get a HttpClient object which is setting correctly . * //w ww .j ava 2s . c om * @param context * : context of activity * @return HttpClient: HttpClient object */ public static DefaultHttpClient getHttpClient(Context context) { BasicHttpParams httpParameters = new BasicHttpParams(); // Set the default socket timeout (SO_TIMEOUT) // in // milliseconds which is the timeout for waiting for data. HttpConnectionParams.setConnectionTimeout(httpParameters, Utility.SET_CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(httpParameters, Utility.SET_SOCKET_TIMEOUT); DefaultHttpClient client = new DefaultHttpClient(httpParameters); WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { // ??PN???? Uri uri = Uri.parse("content://telephony/carriers/preferapn"); Cursor mCursor = context.getContentResolver().query(uri, null, null, null, null); if (mCursor != null && mCursor.moveToFirst()) { // ?????? String proxyStr = mCursor.getString(mCursor.getColumnIndex("proxy")); if (proxyStr != null && proxyStr.trim().length() > 0) { HttpHost proxy = new HttpHost(proxyStr, 80); client.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, proxy); } mCursor.close(); } } return client; }
From source file:com.trigger_context.Main_Service.java
private boolean testConditions(String mac) { SharedPreferences conditions = getSharedPreferences(mac, MODE_PRIVATE); Map<String, ?> cond_map = conditions.getAll(); Set<String> key_set = cond_map.keySet(); boolean takeAction = true; if (key_set.contains("bluetooth")) { // checking the current state against the state set by the user final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); takeAction = new Boolean(bluetoothAdapter.isEnabled()) .equals(conditions.getString("bluetooth", "false")); }/*w ww . ja va2 s.co m*/ if (takeAction && key_set.contains("wifi")) { final WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); takeAction = new Boolean(wm.isWifiEnabled()) == conditions.getBoolean("wifi", false); } if (takeAction && key_set.contains("gps")) { final LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); takeAction = new Boolean(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) .equals(conditions.getString("gps", "false")); } if (takeAction && key_set.contains("sms")) { final Uri SMS_INBOX = Uri.parse("content://sms/inbox"); Cursor c = getContentResolver().query(SMS_INBOX, null, "read = 0", null, null); if (c != null) { int unreadMessagesCount = c.getCount(); c.close(); takeAction = new Boolean(unreadMessagesCount > 0).equals(conditions.getString("sms", "false")); } else { takeAction = false; } } // "NOT TESTED" head set, missed call, accelerometer, proximity, gyro, // orientation if (takeAction && key_set.contains("headset")) { AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); takeAction = am.isMusicActive() == conditions.getBoolean("headset", false); // am.isWiredHeadsetOn() is deprecated } /* * if(takeAction && key_set.contains("missedCall")) { final String[] * projection = null; final String selection = null; final String[] * selectionArgs = null; final String sortOrder = * android.provider.CallLog.Calls.DATE + " DESC"; Cursor cursor = null; * try{ cursor = getApplicationContext().getContentResolver().query( * Uri.parse("content://call_log/calls"), projection, selection, * selectionArgs, sortOrder); while (cursor.moveToNext()) { String * callLogID = * cursor.getString(cursor.getColumnIndex(android.provider.CallLog * .Calls._ID)); String callNumber = * cursor.getString(cursor.getColumnIndex * (android.provider.CallLog.Calls.NUMBER)); String callDate = * cursor.getString * (cursor.getColumnIndex(android.provider.CallLog.Calls.DATE)); String * callType = * cursor.getString(cursor.getColumnIndex(android.provider.CallLog * .Calls.TYPE)); String isCallNew = * cursor.getString(cursor.getColumnIndex * (android.provider.CallLog.Calls.NEW)); if(Integer.parseInt(callType) * == android.provider.CallLog.Calls.MISSED_CALL_TYPE && * Integer.parseInt(isCallNew) > 0){ * * } } }catch(Exception ex){ }finally{ cursor.close(); } * * } */ return takeAction; }
From source file:de.schildbach.wallet.worldcoin.service.BlockchainServiceImpl.java
@Override public void onCreate() { Log.d(TAG, ".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, lockName); wifiLock.setReferenceCounted(false); application = (WalletApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); final int versionCode = application.applicationVersionCode(); prefs.edit().putInt(Constants.PREFS_KEY_LAST_VERSION, versionCode).commit(); bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);// w ww . j av a 2s.c o m final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { Log.d(TAG, "blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); copyBlockchainSnapshot(blockChainFile); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); if (!blockChainFileExists) { // Starting from scratch try { final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); final InputStream checkpointsFileIn = getAssets().open("checkpoints"); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsFileIn, blockStore, earliestKeyCreationTime); } catch (IOException e) { Log.d("worldcoin", "Couldn't find checkpoints file; starting from genesis"); } } blockStore.getChainHead(); // detect corruptions as early as possible } catch (final BlockStoreException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } catch (final NullPointerException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); }
From source file:de.schildbach.wallet.digitalcoin.service.BlockchainServiceImpl.java
@Override public void onCreate() { Log.d(TAG, ".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, lockName); wifiLock.setReferenceCounted(false); application = (WalletApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); final int versionCode = application.applicationVersionCode(); prefs.edit().putInt(Constants.PREFS_KEY_LAST_VERSION, versionCode).commit(); bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);//from ww w. j a v a2 s .c o m final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { Log.d(TAG, "blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); copyBlockchainSnapshot(blockChainFile); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); if (!blockChainFileExists) { // Starting from scratch try { final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); final InputStream checkpointsFileIn = getAssets().open("checkpoints"); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsFileIn, blockStore, earliestKeyCreationTime); } catch (IOException e) { Log.d("digitalcoin", "Couldn't find checkpoints file; starting from genesis"); } } blockStore.getChainHead(); // detect corruptions as early as possible } catch (final BlockStoreException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } catch (final NullPointerException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); }
From source file:com.feathercoin.wallet.feathercoin.service.BlockchainServiceImpl.java
@Override public void onCreate() { Log.d(TAG, ".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, lockName); wifiLock.setReferenceCounted(false); application = (WalletApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); final int versionCode = application.applicationVersionCode(); prefs.edit().putInt(Constants.PREFS_KEY_LAST_VERSION, versionCode).commit(); bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);/*from w w w. j a va2 s . c o m*/ final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { Log.d(TAG, "blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); copyBlockchainSnapshot(blockChainFile); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); if (!blockChainFileExists) { // Starting from scratch try { final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); final InputStream checkpointsFileIn = getAssets().open("checkpoints"); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsFileIn, blockStore, earliestKeyCreationTime); } catch (IOException e) { Log.d("Feathercoin", "Couldn't find checkpoints file; starting from genesis"); } } blockStore.getChainHead(); // detect corruptions as early as possible } catch (final BlockStoreException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } catch (final NullPointerException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); }
From source file:de.schildbach.wallet.goldcoin.service.BlockchainServiceImpl.java
@Override public void onCreate() { Log.d(TAG, ".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, lockName); wifiLock.setReferenceCounted(false); application = (WalletApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); final int versionCode = application.applicationVersionCode(); prefs.edit().putInt(Constants.PREFS_KEY_LAST_VERSION, versionCode).commit(); bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);/*from w w w .j ava2 s . c o m*/ final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { Log.d(TAG, "blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); copyBlockchainSnapshot(blockChainFile); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); if (!blockChainFileExists) { // Starting from scratch try { final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); final InputStream checkpointsFileIn = getAssets().open("checkpoints"); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsFileIn, blockStore, earliestKeyCreationTime); } catch (IOException e) { Log.d("Litecoin", "Couldn't find checkpoints file; starting from genesis"); } } blockStore.getChainHead(); // detect corruptions as early as possible } catch (final BlockStoreException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } catch (final NullPointerException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); }
From source file:de.schildbach.wallet.service.BlockchainServiceImpl.java
@Override public void onCreate() { Log.d(TAG, ".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, lockName); wifiLock.setReferenceCounted(false); application = (WalletApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); final int versionCode = application.applicationVersionCode(); prefs.edit().putInt(Constants.PREFS_KEY_LAST_VERSION, versionCode).commit(); bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);//ww w.jav a 2s . co m final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { Log.d(TAG, "blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); blockStore.getChainHead(); // detect corruptions as early as possible final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); if (!blockChainFileExists && earliestKeyCreationTime > 0) { try { final InputStream checkpointsInputStream = getAssets().open(Constants.CHECKPOINTS_FILENAME); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsInputStream, blockStore, earliestKeyCreationTime); } catch (final IOException x) { // continue without checkpoints x.printStackTrace(); } } } catch (final BlockStoreException x) { try { blockStore = new BoundedOverheadBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); blockStore.getChainHead(); // detect corruptions as early as possible } catch (final BlockStoreException x2) { blockChainFile.delete(); x2.printStackTrace(); throw new Error("blockstore cannot be created", x2); } } Log.i(TAG, "using " + blockStore.getClass().getName()); try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); }
From source file:com.tapjoy.TapjoyConnectCore.java
/** * Initialize data from the device information and application info. * This data is used in our URL connection to the Tapjoy server. *//* w w w . j a v a2s.co m*/ private void init() { PackageManager manager = context.getPackageManager(); try { // ANDROID_ID androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); // Get app version. PackageInfo packageInfo = manager.getPackageInfo(context.getPackageName(), 0); appVersion = packageInfo.versionName; // Device platform. Same as device type. deviceType = TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE; platformName = TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE; // Get the device model. deviceModel = android.os.Build.MODEL; deviceManufacturer = android.os.Build.MANUFACTURER; // Get the Android OS Version. deviceOSVersion = android.os.Build.VERSION.RELEASE; // Get the device country and language code. deviceCountryCode = Locale.getDefault().getCountry(); deviceLanguage = Locale.getDefault().getLanguage(); // Tapjoy SDK Library version. libraryVersion = TapjoyConstants.TJC_LIBRARY_VERSION_NUMBER; SharedPreferences settings = context.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0); try { TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager != null) { deviceID = telephonyManager.getDeviceId(); carrierName = telephonyManager.getNetworkOperatorName(); carrierCountryCode = telephonyManager.getNetworkCountryIso(); // getNetworkOperator() returns MCC + MNC, so make sure it's 5 or 6 digits total. // MCC is 3 digits // MNC is 2 or 3 digits if (telephonyManager.getNetworkOperator() != null && (telephonyManager.getNetworkOperator().length() == 5 || telephonyManager.getNetworkOperator().length() == 6)) { mobileCountryCode = telephonyManager.getNetworkOperator().substring(0, 3); mobileNetworkCode = telephonyManager.getNetworkOperator().substring(3); } } TapjoyLog.i(TAPJOY_CONNECT, "deviceID: " + deviceID); boolean invalidDeviceID = false; //---------------------------------------- // Is the device ID null or empty? //---------------------------------------- if (deviceID == null) { TapjoyLog.e(TAPJOY_CONNECT, "Device id is null."); invalidDeviceID = true; } else //---------------------------------------- // Is this an emulator device ID? //---------------------------------------- if (deviceID.length() == 0 || deviceID.equals("000000000000000") || deviceID.equals("0")) { TapjoyLog.e(TAPJOY_CONNECT, "Device id is empty or an emulator."); invalidDeviceID = true; } //---------------------------------------- // Valid device ID. //---------------------------------------- else { // Lower case the device ID. deviceID = deviceID.toLowerCase(); } TapjoyLog.i(TAPJOY_CONNECT, "ANDROID SDK VERSION: " + android.os.Build.VERSION.SDK); // Is this at least Android 2.3+? // Then let's get the serial. if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 9) { TapjoyLog.i(TAPJOY_CONNECT, "TRYING TO GET SERIAL OF 2.3+ DEVICE..."); // THIS CLASS IS ONLY LOADED FOR ANDROID 2.3+ TapjoyHardwareUtil hardware = new TapjoyHardwareUtil(); serialID = hardware.getSerial(); // Is there no IMEI or MEID? if (invalidDeviceID) { deviceID = serialID; } TapjoyLog.i(TAPJOY_CONNECT, "===================="); TapjoyLog.i(TAPJOY_CONNECT, "SERIAL: deviceID: [" + deviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "===================="); //---------------------------------------- // Is the device ID null or empty? //---------------------------------------- if (deviceID == null) { TapjoyLog.e(TAPJOY_CONNECT, "SERIAL: Device id is null."); invalidDeviceID = true; } else //---------------------------------------- // Is this an emulator device ID? //---------------------------------------- if (deviceID.length() == 0 || deviceID.equals("000000000000000") || deviceID.equals("0") || deviceID.equals("unknown")) { TapjoyLog.e(TAPJOY_CONNECT, "SERIAL: Device id is empty or an emulator."); invalidDeviceID = true; } //---------------------------------------- // Valid device ID. //---------------------------------------- else { // Lower case the device ID. deviceID = deviceID.toLowerCase(); invalidDeviceID = false; } } // Is the device ID invalid? This is probably an emulator or pre-production device. if (invalidDeviceID) { StringBuffer buff = new StringBuffer(); buff.append("EMULATOR"); String deviceId = settings.getString(TapjoyConstants.PREF_EMULATOR_DEVICE_ID, null); // Do we already have an emulator device id stored for this device? if (deviceId != null && !deviceId.equals("")) { deviceID = deviceId; } // Otherwise generate a deviceID for emulator testing. else { String constantChars = "1234567890abcdefghijklmnopqrstuvw"; for (int i = 0; i < 32; i++) { int randomChar = (int) (Math.random() * 100); int ch = randomChar % 30; buff.append(constantChars.charAt(ch)); } deviceID = buff.toString().toLowerCase(); // Save the emulator device ID in the prefs so we can reuse it. SharedPreferences.Editor editor = settings.edit(); editor.putString(TapjoyConstants.PREF_EMULATOR_DEVICE_ID, deviceID); editor.commit(); } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting deviceID. e: " + e.toString()); deviceID = null; } // Set the userID to the deviceID as the initial value. if (userID.length() == 0) userID = deviceID; // Save the SHA-2 hash of the device id. sha2DeviceID = TapjoyUtil.SHA256(deviceID); // Get screen density, dimensions and layout. try { // This is a backwards compatibility fix for Android 1.5 which has no display metric API. // If this is 1.6 or higher, then load the class, otherwise the class never loads and // no crash occurs. if (Integer.parseInt(android.os.Build.VERSION.SDK) > 3) { TapjoyDisplayMetricsUtil displayMetricsUtil = new TapjoyDisplayMetricsUtil(context); deviceScreenDensity = "" + displayMetricsUtil.getScreenDensity(); deviceScreenLayoutSize = "" + displayMetricsUtil.getScreenLayoutSize(); } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting screen density/dimensions/layout: " + e.toString()); } // Get mac address. try { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiManager != null) { WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { macAddress = wifiInfo.getMacAddress(); if (macAddress != null && macAddress.length() > 0) { macAddress = macAddress.toUpperCase(); sha1MacAddress = TapjoyUtil.SHA1(macAddress); } } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting device mac address: " + e.toString()); } // Alternate market. if (getFlagValue(TapjoyConnectFlag.ALTERNATE_MARKET) != null) { marketName = getFlagValue(TapjoyConnectFlag.ALTERNATE_MARKET); // Check for existing/supported market names. ArrayList<String> supportedMarketNames = new ArrayList<String>(); supportedMarketNames.add(TapjoyConnectFlag.MARKET_GFAN); // Warning for undefined market names. if (!supportedMarketNames.contains(marketName)) { Log.w(TAPJOY_CONNECT, "Warning -- undefined ALTERNATE_MARKET: " + marketName); } } // Get the referral URL String tempReferralURL = settings.getString(TapjoyConstants.PREF_REFERRAL_URL, null); if (tempReferralURL != null && !tempReferralURL.equals("")) referralURL = tempReferralURL; // Get the client package name. clientPackage = context.getPackageName(); TapjoyLog.i(TAPJOY_CONNECT, "Metadata successfully loaded"); TapjoyLog.i(TAPJOY_CONNECT, "APP_ID = [" + appID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "ANDROID_ID: [" + androidID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "CLIENT_PACKAGE = [" + clientPackage + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceID: [" + deviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "sha2DeviceID: [" + sha2DeviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_SERIAL_ID + ": [" + serialID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_MAC_ADDRESS + ": [" + macAddress + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_SHA1_MAC_ADDRESS + ": [" + sha1MacAddress + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceName: [" + deviceModel + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceManufacturer: [" + deviceManufacturer + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceType: [" + deviceType + "]"); TapjoyLog.i(TAPJOY_CONNECT, "libraryVersion: [" + libraryVersion + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceOSVersion: [" + deviceOSVersion + "]"); TapjoyLog.i(TAPJOY_CONNECT, "COUNTRY_CODE: [" + deviceCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "LANGUAGE_CODE: [" + deviceLanguage + "]"); TapjoyLog.i(TAPJOY_CONNECT, "density: [" + deviceScreenDensity + "]"); TapjoyLog.i(TAPJOY_CONNECT, "screen_layout: [" + deviceScreenLayoutSize + "]"); TapjoyLog.i(TAPJOY_CONNECT, "carrier_name: [" + carrierName + "]"); TapjoyLog.i(TAPJOY_CONNECT, "carrier_country_code: [" + carrierCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MOBILE_COUNTRY_CODE + ": [" + mobileCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MOBILE_NETWORK_CODE + ": [" + mobileNetworkCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MARKET_NAME + ": [" + marketName + "]"); TapjoyLog.i(TAPJOY_CONNECT, "referralURL: [" + referralURL + "]"); if (connectFlags != null) { TapjoyLog.i(TAPJOY_CONNECT, "Connect Flags:"); TapjoyLog.i(TAPJOY_CONNECT, "--------------------"); Set<Entry<String, String>> entries = connectFlags.entrySet(); Iterator<Entry<String, String>> iterator = entries.iterator(); while (iterator.hasNext()) { Entry<String, String> item = iterator.next(); TapjoyLog.i(TAPJOY_CONNECT, "key: " + item.getKey() + ", value: " + Uri.encode(item.getValue())); } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error initializing Tapjoy parameters. e=" + e.toString()); } }