Search in sources :

Example 86 with BluetoothAdapter

use of android.bluetooth.BluetoothAdapter in project bitcoin-wallet by bitcoin-wallet.

the class WalletApplication method onCreate.

@Override
public void onCreate() {
    // init proper random number generator
    new LinuxSecureRandom();
    Logging.init(getFilesDir());
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().permitDiskReads().permitDiskWrites().penaltyLog().build());
    Threading.throwOnLockCycles();
    org.bitcoinj.core.Context.enableStrictMode();
    org.bitcoinj.core.Context.propagate(Constants.CONTEXT);
    log.info("=== starting app using configuration: {}, {}", Constants.TEST ? "test" : "prod", Constants.NETWORK_PARAMETERS.getId());
    super.onCreate();
    CrashReporter.init(getCacheDir());
    final PackageInfo packageInfo = packageInfo();
    Threading.uncaughtExceptionHandler = new Thread.UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(final Thread thread, final Throwable throwable) {
            log.info("bitcoinj uncaught exception", throwable);
            CrashReporter.saveBackgroundTrace(throwable, packageInfo);
        }
    };
    initMnemonicCode();
    activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    walletFile = getFileStreamPath(Constants.Files.WALLET_FILENAME_PROTOBUF);
    loadWalletFromProtobuf();
    final Configuration config = getConfiguration();
    if (config.versionCodeCrossed(packageInfo.versionCode, VERSION_CODE_SHOW_BACKUP_REMINDER) && !wallet.getImportedKeys().isEmpty()) {
        log.info("showing backup reminder once, because of imported keys being present");
        config.armBackupReminder();
    }
    config.updateLastVersionCode(packageInfo.versionCode);
    final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter != null)
        config.updateLastBluetoothAddress(Bluetooth.getAddress(bluetoothAdapter));
    afterLoadWallet();
    cleanupFiles();
    initNotificationManager();
}
Also used : StrictMode(android.os.StrictMode) PackageInfo(android.content.pm.PackageInfo) LinuxSecureRandom(org.bitcoinj.crypto.LinuxSecureRandom) BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Example 87 with BluetoothAdapter

use of android.bluetooth.BluetoothAdapter in project DevRing by LJYcoder.

the class CommonUtil method getDeviceUniqueId.

// 获取设备唯一ID号
// 需加入<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
// 和<uses-permission android:name="android.permission.BLUETOOTH"/>权限
public static String getDeviceUniqueId(Context context) {
    TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
    String m_szImei = TelephonyMgr.getDeviceId();
    String m_szDevIDShort = // we make this look like a valid IMEI
    "35" + Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + // 13 digits
    Build.USER.length() % 10;
    String m_szAndroidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
    BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    String m_szBTMAC = m_BluetoothAdapter == null ? "" : m_BluetoothAdapter.getAddress();
    /**
     * 综上所述,我们一共有五种方式取得设备的唯一标识。它们中的一些可能会返回null,或者由于硬件缺失、权限问题等获取失败。
     *         但你总能获得至少一个能用。所以,最好的方法就是通过拼接,或者拼接后的计算出的MD5值来产生一个结果。
     */
    String uniqueId = m_szImei + m_szDevIDShort + m_szAndroidID + m_szWLANMAC + m_szBTMAC;
    return EncryptUtil.md5Crypt(uniqueId.getBytes());
}
Also used : WifiManager(android.net.wifi.WifiManager) TelephonyManager(android.telephony.TelephonyManager) BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Aggregations

BluetoothAdapter (android.bluetooth.BluetoothAdapter)87 Intent (android.content.Intent)15 Location (android.location.Location)12 LocationListener (android.location.LocationListener)12 LocationManager (android.location.LocationManager)12 Bundle (android.os.Bundle)12 BluetoothDevice (android.bluetooth.BluetoothDevice)11 IntentFilter (android.content.IntentFilter)7 Handler (android.os.Handler)6 TextToSpeech (android.speech.tts.TextToSpeech)6 ArrayAdapter (android.widget.ArrayAdapter)6 TextView (android.widget.TextView)6 BluetoothActivityEnergyInfo (android.bluetooth.BluetoothActivityEnergyInfo)5 BluetoothProfile (android.bluetooth.BluetoothProfile)5 ServiceListener (android.bluetooth.BluetoothProfile.ServiceListener)5 ScanFilter (android.bluetooth.le.ScanFilter)5 WifiActivityEnergyInfo (android.net.wifi.WifiActivityEnergyInfo)5 RemoteException (android.os.RemoteException)5 SynchronousResultReceiver (android.os.SynchronousResultReceiver)5 ModemActivityInfo (android.telephony.ModemActivityInfo)5