Java Code Examples for android.os.Build#ID

The following examples show how to use android.os.Build#ID . 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: AutoErrorReporter.java    From AutoCrashReporter with Apache License 2.0 6 votes vote down vote up
private void recordInformations(Context context) {
	try {
		PackageManager pm = context.getPackageManager();
		PackageInfo pi;
		// Version
		pi = pm.getPackageInfo(context.getPackageName(), 0);
		versionName = pi.versionName;
		//buildNumber = currentVersionNumber(context);
		// Package name
		packageName = pi.packageName;

		// Device model
		phoneModel = Build.MODEL;
		// Android version
		androidVersion = Build.VERSION.RELEASE;

		board = Build.BOARD;
		brand = Build.BRAND;
		device = Build.DEVICE;
		display = Build.DISPLAY;
		fingerPrint = Build.FINGERPRINT;
		host = Build.HOST;
		id = Build.ID;
		model = Build.MODEL;
		product = Build.PRODUCT;
		manufacturer = Build.MANUFACTURER;
		tags = Build.TAGS;
		time = Build.TIME;
		type = Build.TYPE;
		user = Build.USER;

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 2
Source File: BluetoothManager.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * コンストラクタ
 * @param context
 * @param name サービス名, 任意, nullまたは空文字列ならば端末のモデルとIDを使う
 * @param secureProfileUUID 接続に使用するプロトコル(プロファイル)を識別するためのUUID。セキュア接続用。Android同士でつなぐなら任意で可。PC等のBluetoothシリアル通信を行うならUUID_SPPを使う
 * @param inSecureProfileUUID 接続に使用するプロトコル(プロファイル)を識別するためのUUID。インセキュア接続用。Android同士でつなぐなら任意で可。PC等のBluetoothシリアル通信を行うならUUID_SPPを使う nullならsecureProfileUUIDを使う
 * @param callback
 */
public BluetoothManager(@NonNull final Context context, final String name,
	@NonNull final UUID secureProfileUUID,
	@Nullable final UUID inSecureProfileUUID,
	@NonNull final BluetoothManagerCallback callback) {

	mWeakContext = new WeakReference<Context>(context);
	mName = !TextUtils.isEmpty(name) ? name : Build.MODEL + "_" + Build.ID;
	mSecureProfileUUID = secureProfileUUID;
	mInSecureProfileUUID = inSecureProfileUUID != null ? inSecureProfileUUID : secureProfileUUID;
	if (callback != null) {
		mCallbacks.add(callback);
	}
	mAdapter = BluetoothAdapter.getDefaultAdapter();
	if ((mAdapter == null) || !mAdapter.isEnabled()) {
		throw new IllegalStateException("bluetoothに対応していないか無効になっている");
	}
	mState = STATE_NONE;
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
	filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
	context.registerReceiver(mBroadcastReceiver, filter);
}
 
Example 3
Source File: NativeDeviceInfoProvider.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
public String getUserAgentString() {
    return "Android-Finsky/" + URLEncoder.encode(gsfVersionProvider.getVendingVersionString(true)).replace("+", "%20") + " ("
        + "api=3"
        + ",versionCode=" + gsfVersionProvider.getVendingVersionCode(true)
        + ",sdk=" + Build.VERSION.SDK_INT
        + ",device=" + Build.DEVICE
        + ",hardware=" + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO ? Build.HARDWARE : Build.PRODUCT)
        + ",product=" + Build.PRODUCT
        + ",platformVersionRelease=" + Build.VERSION.RELEASE
        + ",model=" + URLEncoder.encode(Build.MODEL).replace("+", "%20")
        + ",buildId=" + Build.ID
        + ",isWideScreen=" + (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? "1" : "0")
        + ",supportedAbis=" + TextUtils.join(";", getPlatforms())
        + ")"
    ;
}
 
Example 4
Source File: StatusbarUtil.java    From MainActivityUIUtil with Apache License 2.0 6 votes vote down vote up
private static String getHandSetInfo() {
    String handSetInfo = "手机型号:" + Build.MODEL
            + "\n系统版本:" + Build.VERSION.RELEASE
            + "\n产品型号:" + Build.PRODUCT
            + "\n版本显示:" + Build.DISPLAY
            + "\n系统定制商:" + Build.BRAND
            + "\n设备参数:" + Build.DEVICE
            + "\n开发代号:" + Build.VERSION.CODENAME
            + "\nSDK版本号:" + Build.VERSION.SDK_INT
            + "\nCPU类型:" + Build.CPU_ABI
            + "\n硬件类型:" + Build.HARDWARE
            + "\n主机:" + Build.HOST
            + "\n生产ID:" + Build.ID
            + "\nROM制造商:" + Build.MANUFACTURER // 这行返回的是rom定制商的名称
            ;
    Log.e("tt",handSetInfo);
    return handSetInfo;
}
 
Example 5
Source File: ChannelServiceHttpClientForTest.java    From line-sdk-android with Apache License 2.0 6 votes vote down vote up
@NonNull
public String getUserAgent() {
    if (cachedUserAgent != null) {
        return cachedUserAgent;
    }

    String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName;
    String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName;
    Locale locale = Locale.getDefault();

    cachedUserAgent = packageName + "/" + versionName
            + " ChannelSDK/" + LINE_SDK_VERSION_FOR_TEST
            + " (Linux; U; Android " + Build.VERSION.RELEASE + "; "
            + locale.getLanguage() + "-" + locale.getCountry() + "; "
            + Build.MODEL
            + " Build/" + Build.ID + ")";
    return cachedUserAgent;
}
 
Example 6
Source File: UserAgentGenerator.java    From line-sdk-android with Apache License 2.0 6 votes vote down vote up
@NonNull
public String getUserAgent() {
    if (cachedUserAgent != null) {
        return cachedUserAgent;
    }

    String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName;
    String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName;
    Locale locale = Locale.getDefault();

    cachedUserAgent = packageName + "/" + versionName
            + " ChannelSDK/" + sdkVersion
            + " (Linux; U; Android " + Build.VERSION.RELEASE + "; "
            + locale.getLanguage() + "-" + locale.getCountry() + "; "
            + Build.MODEL
            + " Build/" + Build.ID + ")";
    return cachedUserAgent;
}
 
Example 7
Source File: BuildInfo.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@CalledByNative
private static String[] getAll() {
    BuildInfo buildInfo = getInstance();
    String hostPackageName = ContextUtils.getApplicationContext().getPackageName();
    return new String[] {
            Build.BRAND, Build.DEVICE, Build.ID, Build.MANUFACTURER, Build.MODEL,
            String.valueOf(Build.VERSION.SDK_INT), Build.TYPE, Build.BOARD, hostPackageName,
            String.valueOf(buildInfo.hostVersionCode), buildInfo.hostPackageLabel,
            buildInfo.packageName, String.valueOf(buildInfo.versionCode), buildInfo.versionName,
            buildInfo.androidBuildFingerprint, buildInfo.gmsVersionCode,
            buildInfo.installerPackageName, buildInfo.abiString, BuildConfig.FIREBASE_APP_ID,
            buildInfo.customThemes, buildInfo.resourcesVersion, buildInfo.extractedFileSuffix,
    };
}
 
Example 8
Source File: HeaderInterceptor.java    From android with Apache License 2.0 5 votes vote down vote up
private String getDefaultUserAgent(String cversion) {
    StringBuilder result = new StringBuilder(64);

    if (cversion != null) {
        result.append("MalaysiaPrayerTimes/");
        result.append(cversion);
    } else {
        result.append("Dalvik/");
        result.append(System.getProperty("java.vm.version")); // such as 1.1.0
    }

    result.append(" (Linux; U; Android ");

    String version = Build.VERSION.RELEASE; // "1.0" or "3.4b5"
    result.append(version.length() > 0 ? version : "1.0");

    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        String model = Build.MODEL;
        if (model.length() > 0) {
            result.append("; ");
            result.append(model);
        }
    }
    String id = Build.ID; // "MASTER" or "M4-rc20"
    if (id.length() > 0) {
        result.append(" Build/");
        result.append(id);
    }
    result.append(")");
    return result.toString();
}
 
Example 9
Source File: AppUtils.java    From CrashReporter with Apache License 2.0 5 votes vote down vote up
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 10
Source File: AndroidModel.java    From android-beacon-library with Apache License 2.0 5 votes vote down vote up
public static AndroidModel forThisDevice() {
    return new AndroidModel(
        Build.VERSION.RELEASE,
        Build.ID,
        Build.MODEL,
        Build.MANUFACTURER);
}
 
Example 11
Source File: VersionInfoUtils.java    From aliyun-log-android-sdk with MIT License 5 votes vote down vote up
/**
 * 获取系统UA值
 *
 * @return
 */
public static String getDefaultUserAgent() {
    String result = System.getProperty("http.agent");
    if (!TextUtils.isEmpty(result)) {
        result = "("+ System.getProperty("os.name")+"/Android "  + Build.VERSION.RELEASE + "/" +
                Build.MODEL+"/"+ Build.ID+")";
    }
    return result.replaceAll("[^\\p{ASCII}]", "?");
}
 
Example 12
Source File: BuildInfo.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@CalledByNative
public static String getAndroidBuildId() {
    return Build.ID;
}
 
Example 13
Source File: OtherUtils.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
/**
 * @param context if null, use the default format
 *                (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30).
 * @return
 */
public static String getUserAgent(Context context) {
    String webUserAgent = null;
    if (context != null) {
        try {
            Class sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = context.getString(resId);
        } catch (Throwable ignored) {
        }
    }
    if (TextUtils.isEmpty(webUserAgent)) {
        webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1";
    }

    Locale locale = Locale.getDefault();
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        buffer.append(version);
    } else {
        // default to "1.0"
        buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
        buffer.append(language.toLowerCase());
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase());
        }
    } else {
        // default to "en"
        buffer.append("en");
    }
    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        final String model = Build.MODEL;
        if (model.length() > 0) {
            buffer.append("; ");
            buffer.append(model);
        }
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        buffer.append(" Build/");
        buffer.append(id);
    }
    return String.format(webUserAgent, buffer, "Mobile ");
}
 
Example 14
Source File: Device.java    From unity-ads-android with Apache License 2.0 4 votes vote down vote up
public static String getBuildId() {
	return Build.ID;
}
 
Example 15
Source File: HttpHeaders.java    From RxEasyHttp with Apache License 2.0 4 votes vote down vote up
/**
 * User-Agent: Mozilla/5.0 (Linux; U; Android 5.0.2; zh-cn; Redmi Note 3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
 */
public static String getUserAgent() {
    if (TextUtils.isEmpty(userAgent)) {
        String webUserAgent = null;
        try {
            Class<?> sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = EasyHttp.getContext().getString(resId);
        } catch (Exception e) {
            // We have nothing to do
        }
        if (TextUtils.isEmpty(webUserAgent)) {
            webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/5.0 %sSafari/533.1";
        }

        Locale locale = Locale.getDefault();
        StringBuffer buffer = new StringBuffer();
        // Add version
        final String version = Build.VERSION.RELEASE;
        if (version.length() > 0) {
            buffer.append(version);
        } else {
            // default to "1.0"
            buffer.append("1.0");
        }
        buffer.append("; ");
        final String language = locale.getLanguage();
        if (language != null) {
            buffer.append(language.toLowerCase(locale));
            final String country = locale.getCountry();
            if (!TextUtils.isEmpty(country)) {
                buffer.append("-");
                buffer.append(country.toLowerCase(locale));
            }
        } else {
            // default to "en"
            buffer.append("en");
        }
        // add the model for the release build
        if ("REL".equals(Build.VERSION.CODENAME)) {
            final String model = Build.MODEL;
            if (model.length() > 0) {
                buffer.append("; ");
                buffer.append(model);
            }
        }
        final String id = Build.ID;
        if (id.length() > 0) {
            buffer.append(" Build/");
            buffer.append(id);
        }
        userAgent = String.format(webUserAgent, buffer, "Mobile ");
        return userAgent;
    }
    return userAgent;
}
 
Example 16
Source File: BuildInfo.java    From matomo-sdk-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public String getBuildId() {
    return Build.ID;
}
 
Example 17
Source File: OtherUtils.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
/**
 * @param context if null, use the default format
 *                (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30).
 * @return
 */
public static String getUserAgent(Context context) {
    String webUserAgent = null;
    if (context != null) {
        try {
            Class sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = context.getString(resId);
        } catch (Throwable ignored) {
        }
    }
    if (TextUtils.isEmpty(webUserAgent)) {
        webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1";
    }

    Locale locale = Locale.getDefault();
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        buffer.append(version);
    } else {
        // default to "1.0"
        buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
        buffer.append(language.toLowerCase());
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase());
        }
    } else {
        // default to "en"
        buffer.append("en");
    }
    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        final String model = Build.MODEL;
        if (model.length() > 0) {
            buffer.append("; ");
            buffer.append(model);
        }
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        buffer.append(" Build/");
        buffer.append(id);
    }
    return String.format(webUserAgent, buffer, "Mobile ");
}
 
Example 18
Source File: HttpHeaders.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
/**
 * User-Agent: Mozilla/5.0 (Linux; U; Android 5.0.2; zh-cn; Redmi Note 3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
 */
public static String getUserAgent() {
    if (TextUtils.isEmpty(userAgent)) {
        String webUserAgent = null;
        try {
            Class<?> sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = DokitOkGo.getInstance().getContext().getString(resId);
        } catch (Exception e) {
            // We have nothing to do
        }
        if (TextUtils.isEmpty(webUserAgent)) {
            webUserAgent = "okhttp-okgo/jeasonlzy";
        }

        Locale locale = Locale.getDefault();
        StringBuffer buffer = new StringBuffer();
        // Add version
        final String version = Build.VERSION.RELEASE;
        if (version.length() > 0) {
            buffer.append(version);
        } else {
            // default to "1.0"
            buffer.append("1.0");
        }
        buffer.append("; ");
        final String language = locale.getLanguage();
        if (language != null) {
            buffer.append(language.toLowerCase(locale));
            final String country = locale.getCountry();
            if (!TextUtils.isEmpty(country)) {
                buffer.append("-");
                buffer.append(country.toLowerCase(locale));
            }
        } else {
            // default to "en"
            buffer.append("en");
        }
        // add the model for the release build
        if ("REL".equals(Build.VERSION.CODENAME)) {
            final String model = Build.MODEL;
            if (model.length() > 0) {
                buffer.append("; ");
                buffer.append(model);
            }
        }
        final String id = Build.ID;
        if (id.length() > 0) {
            buffer.append(" Build/");
            buffer.append(id);
        }
        userAgent = String.format(webUserAgent, buffer, "Mobile ");
        return userAgent;
    }
    return userAgent;
}
 
Example 19
Source File: HttpHeaders.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
/**
 * User-Agent: Mozilla/5.0 (Linux; U; Android 5.0.2; zh-cn; Redmi Note 3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
 */
public static String getUserAgent() {
    if (TextUtils.isEmpty(userAgent)) {
        String webUserAgent = null;
        try {
            Class<?> sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = DokitOkGo.getInstance().getContext().getString(resId);
        } catch (Exception e) {
            // We have nothing to do
        }
        if (TextUtils.isEmpty(webUserAgent)) {
            webUserAgent = "okhttp-okgo/jeasonlzy";
        }

        Locale locale = Locale.getDefault();
        StringBuffer buffer = new StringBuffer();
        // Add version
        final String version = Build.VERSION.RELEASE;
        if (version.length() > 0) {
            buffer.append(version);
        } else {
            // default to "1.0"
            buffer.append("1.0");
        }
        buffer.append("; ");
        final String language = locale.getLanguage();
        if (language != null) {
            buffer.append(language.toLowerCase(locale));
            final String country = locale.getCountry();
            if (!TextUtils.isEmpty(country)) {
                buffer.append("-");
                buffer.append(country.toLowerCase(locale));
            }
        } else {
            // default to "en"
            buffer.append("en");
        }
        // add the model for the release build
        if ("REL".equals(Build.VERSION.CODENAME)) {
            final String model = Build.MODEL;
            if (model.length() > 0) {
                buffer.append("; ");
                buffer.append(model);
            }
        }
        final String id = Build.ID;
        if (id.length() > 0) {
            buffer.append(" Build/");
            buffer.append(id);
        }
        userAgent = String.format(webUserAgent, buffer, "Mobile ");
        return userAgent;
    }
    return userAgent;
}
 
Example 20
Source File: DeviceUtil.java    From SimpleProject with MIT License 2 votes vote down vote up
/**
 * 获取设备AndroidId
 * @return
 */
public static String getAndroidId() {
	return Build.ID;
}