Java Code Examples for android.os.Build#SERIAL
The following examples show how to use
android.os.Build#SERIAL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Identity.java From Android-Commons with Apache License 2.0 | 6 votes |
/** * Returns an identifier that is unique for this device * * The identifier is usually reset when performing a factory reset on the device * * On devices with multi-user capabilities, each user usually has their own identifier * * In general, you may not use this identifier for advertising purposes * * @param context a context reference * @return the unique identifier */ @SuppressLint("NewApi") public static String getDeviceId(final Context context) { if (mDeviceId == null) { final String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); if (androidId != null && !androidId.equals("") && !androidId.equalsIgnoreCase("9774d56d682e549c")) { mDeviceId = androidId; } else { if (Build.VERSION.SDK_INT >= 9) { if (Build.SERIAL != null && !Build.SERIAL.equals("")) { mDeviceId = Build.SERIAL; } else { mDeviceId = getInstallationId(context); } } else { mDeviceId = getInstallationId(context); } } } return mDeviceId; }
Example 2
Source File: BugReportBuilder.java From AppOpsXposed with GNU General Public License v3.0 | 6 votes |
private String getDeviceId() { final String raw = Build.SERIAL + Build.FINGERPRINT; byte[] bytes; try { final MessageDigest md = MessageDigest.getInstance("SHA1"); bytes = md.digest(raw.getBytes()); } catch(NoSuchAlgorithmException e) { bytes = raw.getBytes(); } final StringBuilder sb = new StringBuilder(bytes.length); for(byte b : bytes) sb.append(Integer.toString((b & 0xff ) + 0x100, 16).substring(1)); return sb.substring(0, 12); }
Example 3
Source File: SysUtils.java From android with MIT License | 6 votes |
/** * 获取手机信息 * * @param context */ public static void printSystemInfo(Context context) { try { // MAC地址(如:1C:B0:94:ED:6C:AC) WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo info = manager.getConnectionInfo(); String macAddress = info.getMacAddress(); // imei maybe null TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imei = TelephonyMgr.getDeviceId(); } catch (Exception e) { e.printStackTrace(); } int sdk = Build.VERSION.SDK_INT;// API版本号(如:14) String version = Build.VERSION.RELEASE; // 系统版本号(如:4.0) String model = Build.MODEL;// 手机型号(如:Galaxy Nexus) String serial = Build.SERIAL; }
Example 4
Source File: SignupFragment.java From Android with MIT License | 6 votes |
private void getDetailsMANUFACTURER() { //============================== Field[] fields = Build.VERSION_CODES.class.getFields(); String osName = fields[Build.VERSION.SDK_INT + 1].getName(); ////=============================== Details_MANUFACTURER = "SERIAL: " + Build.SERIAL + "\n" + "MODEL: " + Build.MODEL + "\n" + "ID: " + Build.ID + "\n" + "Manufacture: " + Build.MANUFACTURER + "\n" + "Brand: " + Build.BRAND + "\n" + "Type: " + Build.TYPE + "\n" + "User: " + Build.USER + "\n" + "BASE: " + Build.VERSION_CODES.BASE + "\n" + "INCREMENTAL: " + Build.VERSION.INCREMENTAL + "\n" + "SDK: " + Build.VERSION.SDK +" OS:"+osName+ "\n" + "BOARD: " + Build.BOARD + "\n" + "BRAND: " + Build.BRAND + "\n" + "HOST: " + Build.HOST + "\n" + "FINGERPRINT: " + Build.FINGERPRINT + "\n" + "Version Code: " + Build.VERSION.RELEASE + "Display : " + Build.DISPLAY; //Log.e("TAG",Details_MANUFACTURER); }
Example 5
Source File: DeviceUtils.java From NoVIP with Apache License 2.0 | 6 votes |
public static String getUniqueId(Context context) { String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); String id = androidID + Build.SERIAL; try { return toMD5(id); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return id; } }
Example 6
Source File: StringCipher.java From line-sdk-android with Apache License 2.0 | 5 votes |
@NonNull private String generateDevicePackageSpecificId(@NonNull Context context) { @SuppressLint("HardwareIds") String androidId = Settings.Secure.getString( context.getContentResolver(), Settings.Secure.ANDROID_ID); String serial = isSerialIncludedInDevicePackageSpecificId ? Build.SERIAL : ""; return Build.MODEL + Build.MANUFACTURER + serial + androidId + context.getPackageName(); }
Example 7
Source File: Specifications.java From batteryhub with Apache License 2.0 | 5 votes |
/** * Returns the build serial number. May only work for 2.3 and up. * * @return the build serial number. */ public static String getBuildSerial() { // TODO: Review this approach // return android.os.Build.Serial; // return System.getProperty("ro.serial", TYPE_UNKNOWN); return Build.SERIAL; }
Example 8
Source File: Device.java From letv with Apache License 2.0 | 5 votes |
@TargetApi(9) private static String getSerial() { try { return Build.SERIAL; } catch (Throwable e) { FLOG.w(TAG, "get serial failed(Throwable): " + e.getMessage()); return null; } }
Example 9
Source File: PRNGFixes.java From NoteCrypt with GNU General Public License v3.0 | 5 votes |
/** * Gets the hardware serial number of this device. * * @return serial number or {@code null} if not available. */ private static String getDeviceSerialNumber() { try { return Build.SERIAL; } catch (Exception ignored) { return null; } }
Example 10
Source File: AppUtils.java From CrashReporter with Apache License 2.0 | 5 votes |
public static String getDeviceDetails(Context context) { return "Device Information\n" + "\nDEVICE.ID : " + getDeviceId(context) + "\nUSER.ID : " + getUserIdentity(context) + "\nAPP.VERSION : " + getAppVersion(context) + "\nLAUNCHER.APP : " + getCurrentLauncherApp(context) + "\nTIMEZONE : " + timeZone() + "\nVERSION.RELEASE : " + Build.VERSION.RELEASE + "\nVERSION.INCREMENTAL : " + Build.VERSION.INCREMENTAL + "\nVERSION.SDK.NUMBER : " + Build.VERSION.SDK_INT + "\nBOARD : " + Build.BOARD + "\nBOOTLOADER : " + Build.BOOTLOADER + "\nBRAND : " + Build.BRAND + "\nCPU_ABI : " + Build.CPU_ABI + "\nCPU_ABI2 : " + Build.CPU_ABI2 + "\nDISPLAY : " + Build.DISPLAY + "\nFINGERPRINT : " + Build.FINGERPRINT + "\nHARDWARE : " + Build.HARDWARE + "\nHOST : " + Build.HOST + "\nID : " + Build.ID + "\nMANUFACTURER : " + Build.MANUFACTURER + "\nMODEL : " + Build.MODEL + "\nPRODUCT : " + Build.PRODUCT + "\nSERIAL : " + Build.SERIAL + "\nTAGS : " + Build.TAGS + "\nTIME : " + Build.TIME + "\nTYPE : " + Build.TYPE + "\nUNKNOWN : " + Build.UNKNOWN + "\nUSER : " + Build.USER; }
Example 11
Source File: AdbDevice.java From test-butler with Apache License 2.0 | 5 votes |
@SuppressLint("HardwareIds") @TargetApi(Build.VERSION_CODES.O) @Nullable private static AdbDevice findCurrentDevicePreO(List<AdbDevice> devices) { // first try using device serial String serial = Build.SERIAL; for (AdbDevice device : devices) { if (serial.equals(device.deviceId)) { return device; } } return null; }
Example 12
Source File: Messaging.java From Android-SDK with MIT License | 5 votes |
static void init( Context context ) { if( android.os.Build.VERSION.SDK_INT < 27 ) id = Build.SERIAL; else id = Settings.Secure.getString( context.getContentResolver(), Settings.Secure.ANDROID_ID ); }
Example 13
Source File: EasyDeviceMod.java From easydeviceinfo with Apache License 2.0 | 5 votes |
/** * Gets serial. * * @return the serial */ @SuppressLint("HardwareIds") public final String getSerial() { String result = null; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { result = Build.SERIAL; } else { if (PermissionUtil.hasPermission(context, Manifest.permission.READ_PHONE_STATE)) { result = Build.getSerial(); } } return CheckValidityUtil.checkValidData(result); }
Example 14
Source File: PhoneUtils.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
/** * Return the serial of device. * * @return the serial of device */ @SuppressLint("HardwareIds") @RequiresPermission(READ_PHONE_STATE) public static String getSerial() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { try { return Build.getSerial(); } catch (SecurityException e) { e.printStackTrace(); return ""; } } return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? Build.getSerial() : Build.SERIAL; }
Example 15
Source File: ConnectingHelper.java From letv with Apache License 2.0 | 4 votes |
public static boolean register(Context context, long j, boolean z) { byte[] bArr = new byte[128]; String a = h.a(context); String b = h.b(context); String a2 = cn.jpush.android.util.a.a(context, z[22]); String j2 = cn.jpush.android.util.a.j(context); String i = cn.jpush.android.util.a.i(context); String g = cn.jpush.android.util.a.g(context, " "); String i2 = cn.jpush.android.util.a.i(context, " "); String str = Build.SERIAL; if (ai.a(j2)) { j2 = " "; } if (ai.a(i)) { i = " "; } if (ai.a(g)) { g = " "; } if (ai.a(i2)) { i2 = " "; } if (ai.a(str) || z[54].equalsIgnoreCase(str)) { str = " "; } a.l(i2); a.m(i); a.n(g); str = cn.jpush.android.util.a.a + z[59] + j2 + z[59] + i2 + z[59] + i + z[59] + g + z[59] + str; new StringBuilder(z[52]).append(a).append(z[55]).append(b).append(z[51]).append(a2).append(z[56]).append(str); z.b(); if (PushProtocol.RegPush(j, a.k(), a, b, a2, str) == -991) { return false; } int RecvPush = PushProtocol.RecvPush(j, bArr, 30); if (RecvPush > 0) { h a3 = d.a(bArr); if (a3 == null) { z.e(); return false; } a3.toString(); z.b(); if (a3.d() != 0) { z.e(); return false; } k kVar = (k) a3; RecvPush = kVar.g; a.c(context, RecvPush); if (RecvPush == 0) { long a4 = kVar.a(); g = kVar.g(); i2 = kVar.h(); a = kVar.i(); z.c(z[2], new StringBuilder(z[48]).append(a4).append(z[57]).append(i2).append(z[53]).append(a).toString()); new StringBuilder(z[61]).append(g); z.a(); if (ai.a(i2) || 0 == a4) { z.e(z[2], z[50]); } cn.jpush.android.util.a.j(context, a); a.a(a4, g, i2, a, e.f); e.g = a4; e.h = g; if (!z) { cn.jpush.android.util.a.a(context, z[64], z[68], i2); } return true; } z.e(z[2], new StringBuilder(z[62]).append(RecvPush).append(z[67]).append(kVar.h).toString()); i = cn.jpush.android.service.r.a(RecvPush); if (i != null) { z.d(z[2], new StringBuilder(z[66]).append(i).toString()); } if (LiveRoomConstant.LIVE_ROOM_LOADER_HK_VARIETY_ID == RecvPush) { a.o(); } else if (LiveRoomConstant.LIVE_ROOM_LOADER_HK_MUSIC_ID == RecvPush) { z.c(); } else if (LiveRoomConstant.LIVE_ROOM_LOADER_HK_TVSERIES_ID == RecvPush) { j2 = new StringBuilder(z[58]).append(e.c).append(z[60]).append(e.f).append(z[65]).toString(); cn.jpush.android.util.a.c(context, j2, j2); a.o(); } else if (1009 == RecvPush) { a.o(); } else { new StringBuilder(z[63]).append(RecvPush); z.c(); } } else { z.e(z[2], new StringBuilder(z[49]).append(RecvPush).toString()); } return false; }
Example 16
Source File: DeviceUidGenerator.java From Ticket-Analysis with MIT License | 4 votes |
public static String generate(Context context) throws Exception { Monitor.start(); String uid; while (true) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); uid = tm.getDeviceId(); if (!TextUtils.isEmpty(uid)) { Monitor.log("from imei"); break; } WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); uid = info.getMacAddress(); if (!TextUtils.isEmpty(uid)) { Monitor.log("from mac"); break; } if (Build.VERSION.SDK_INT >= 9 && !TextUtils.isEmpty(Build.SERIAL) && !"unknown".equalsIgnoreCase(Build.SERIAL)) { uid = Build.SERIAL; Monitor.log("from serial id"); break; } String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); if (!TextUtils.isEmpty(androidId) && !BuildConfig.DEVICE_ID.equals(androidId)) { uid = androidId; Monitor.log("from android id"); break; } try { uid = fromUuid(context); Monitor.log("from uuid"); break; } catch (Exception e) { Monitor.finish("Could not generate uid from device!!!"); throw new RuntimeException("Could not generate uid from device!!!"); } } /*//uid 服务器长度 if (uid.length() > 14) { uid = uid.substring(0, 13); }*/ Monitor.finish(uid); return uid; }
Example 17
Source File: AppUtil.java From xpay with Apache License 2.0 | 4 votes |
public static String getUniqueId(Context context) { String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); String id = androidID + Build.SERIAL; return toMD5(id); }
Example 18
Source File: DeviceUtils.java From Box with Apache License 2.0 | 4 votes |
@SuppressLint("MissingPermission") @RequiresPermission(READ_PHONE_STATE) public static String getSN() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? Build.getSerial() : Build.SERIAL; }
Example 19
Source File: DeviceInfo.java From product-emm with Apache License 2.0 | 2 votes |
/** * Returns the hardware serial number. * @return - Hardware serial number. */ public String getDeviceSerialNumber() { return Build.SERIAL; }
Example 20
Source File: SysUtil.java From ONE-Unofficial with Apache License 2.0 | 2 votes |
/** * 获得设备序列号,但在某些山寨或定制设备上会得到垃圾数据 * @return 手机设备序列号 */ public static String getPhoneSerial(){ return Build.SERIAL; }