List of usage examples for android.os Build MODEL
String MODEL
To view the source code for android.os Build MODEL.
Click Source Link
From source file:org.cocos2dx.lib.Cocos2dxActivity.java
private final static boolean isAndroidEmulator() { String model = Build.MODEL; Log.d(TAG, "model=" + model); String product = Build.PRODUCT; Log.d(TAG, "product=" + product); boolean isEmulator = false; if (product != null) { isEmulator = product.equals("sdk") || product.contains("_sdk") || product.contains("sdk_"); }//from w ww .j av a 2 s . com Log.d(TAG, "isEmulator=" + isEmulator); return isEmulator; }
From source file:net.microtrash.clapcamera.Preview.java
public void openCamera() { Log.d(TAG, "openCamera()"); if (this.camera == null) { try {/* w ww. ja va2 s . c o m*/ this.camera = Camera.open(); this.camera.setErrorCallback(new ErrorCallback() { @Override public void onError(int error, Camera camera) { Log.e(TAG, "error! code:" + error); Toast.makeText(context, "Camera error occured: " + error, 8000).show(); } }); requestLayout(); // -> onSizeChanged() -> onLayout() } catch (Exception e) { String errorMessage = "Manufacturer: " + Build.MANUFACTURER + "; Model:" + Build.MODEL + "; Camera: " + this.camera + "; Stacktrace:" + Tools.exception2String(e); Log.d(TAG, "error occured: " + errorMessage); Toast.makeText(context, "Uuups, I am sorry! Could not connect to the camera device. Please restart me or your phone.", 8000).show(); Crittercism.logHandledException(e); } } }
From source file:at.jclehner.appopsxposed.BugReportBuilder.java
private void collectDeviceInfo(StringBuilder sb) { sb.append("\n---------------------------------------------------"); sb.append("\n------------------- DEVICE INFO -------------------"); sb.append("\nAndroid version: " + Build.VERSION.RELEASE + " (" + Build.VERSION.SDK_INT + ")"); sb.append("\nFingerprint : " + Build.FINGERPRINT); sb.append("\nDevice name : " + Build.MANUFACTURER + " " + Build.MODEL + " (" + Build.PRODUCT + "/" + Build.HARDWARE + ")"); sb.append("\nAppOpsManager : "); try {/*from w ww. ja va 2 s . co m*/ Class.forName("android.app.AppOpsManager"); sb.append("YES"); } catch (ClassNotFoundException e) { sb.append("NO!"); } }
From source file:org.gluu.oxpush2.u2f.v2.SoftwareDevice.java
public TokenResponse enroll(String jsonRequest, OxPush2Request oxPush2Request, Boolean isDeny) throws JSONException, IOException, U2FException { JSONObject request = (JSONObject) new JSONTokener(jsonRequest).nextValue(); if (request.has("registerRequests")) { JSONArray registerRequestArray = request.getJSONArray("registerRequests"); if (registerRequestArray.length() == 0) { throw new U2FException("Failed to get registration request!"); }/*w ww. j a v a2 s. co m*/ request = (JSONObject) registerRequestArray.get(0); } if (!request.getString(JSON_PROPERTY_VERSION).equals(SUPPORTED_U2F_VERSION)) { throw new U2FException("Unsupported U2F_V2 version!"); } String version = request.getString(JSON_PROPERTY_VERSION); String appParam = request.getString(JSON_PROPERTY_APP_ID); String challenge = request.getString(JSON_PROPERTY_SERVER_CHALLENGE); String origin = oxPush2Request.getIssuer(); EnrollmentResponse enrollmentResponse = u2fKey .register(new EnrollmentRequest(version, appParam, challenge, oxPush2Request)); if (BuildConfig.DEBUG) Log.d(TAG, "Enrollment response: " + enrollmentResponse); JSONObject clientData = new JSONObject(); if (isDeny) { clientData.put(JSON_PROPERTY_REQUEST_TYPE, REGISTER_CANCEL_TYPE); } else { clientData.put(JSON_PROPERTY_REQUEST_TYPE, REQUEST_TYPE_REGISTER); } clientData.put(JSON_PROPERTY_SERVER_CHALLENGE, challenge); clientData.put(JSON_PROPERTY_SERVER_ORIGIN, origin); String clientDataString = clientData.toString(); byte[] resp = rawMessageCodec.encodeRegisterResponse(enrollmentResponse); String deviceType = getDeviceType(); String versionName = getVersionName(); DeviceData deviceData = new DeviceData(); deviceData.setUuid(DeviceUuidManager.getDeviceUuid(context).toString()); deviceData.setPushToken(PushNotificationManager.getRegistrationId(context)); deviceData.setType(deviceType); deviceData.setPlatform("android"); deviceData.setName(Build.MODEL); deviceData.setOsName(versionName); deviceData.setOsVersion(Build.VERSION.RELEASE); String deviceDataString = new Gson().toJson(deviceData); JSONObject response = new JSONObject(); response.put("registrationData", Utils.base64UrlEncode(resp)); response.put("clientData", Utils.base64UrlEncode(clientDataString.getBytes(Charset.forName("ASCII")))); response.put("deviceData", Utils.base64UrlEncode(deviceDataString.getBytes(Charset.forName("ASCII")))); TokenResponse tokenResponse = new TokenResponse(); tokenResponse.setResponse(response.toString()); tokenResponse.setChallenge(new String(challenge)); tokenResponse.setKeyHandle(new String(enrollmentResponse.getKeyHandle())); return tokenResponse; }
From source file:com.catchnotes.api.CatchAPI.java
/** * Constructor.//w w w. j a v a2s . co m * * @param appName The name of your application. * @param context Android context. */ public CatchAPI(String appName, Context context) { source = appName; mContext = context; String version = "x.xx"; try { PackageInfo info = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0); version = info.versionName; } catch (Exception e) { } StringBuilder locale = new StringBuilder(5); String language = Locale.getDefault().getLanguage(); if (language != null) { locale.append(language); String country = Locale.getDefault().getCountry(); if (country != null) { locale.append('-'); locale.append(country); } } userAgent = appName + '/' + version + " (Android; " + Build.VERSION.RELEASE + "; " + Build.BRAND + "; " + Build.MODEL + "; " + locale.toString() + ')'; try { if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.ECLAIR_0_1) { // We can use Time & TimeFormatException on Android 2.0.1 // (API level 6) or greater. It crashes the VM otherwise. timestamper = new Time(); } } catch (Exception e) { } }
From source file:org.pixmob.fm2.util.HttpUtils.java
/** * Get Http User Agent for this application. *//*from w ww. java 2 s. com*/ public static final String getUserAgent(Context context) { if (applicationVersion == null) { try { applicationVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { applicationVersion = "0.0.0"; } } return APPLICATION_NAME_USER_AGENT + "/" + applicationVersion + " (" + Build.MANUFACTURER + " " + Build.MODEL + " with Android " + Build.VERSION.RELEASE + "/" + Build.VERSION.SDK_INT + ")"; }
From source file:com.CloudRecognition.CloudReco.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(LOGTAG, "onCreate"); super.onCreate(savedInstanceState); comm = new ConexionSiabra(this); vuforiaAppSession = new SampleApplicationSession(this); startLoadingAnimation();/*from w w w .j a va 2 s . com*/ vuforiaAppSession.initAR(this, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Creates the GestureDetector listener for processing double tap mGestureDetector = new GestureDetector(this, new GestureListener()); mIsDroidDevice = android.os.Build.MODEL.toLowerCase().startsWith("droid"); }
From source file:com.framgia.android.emulator.EmulatorDetector.java
private boolean checkBasic() { boolean result = Build.FINGERPRINT.startsWith("generic") || Build.MODEL.contains("google_sdk") || Build.MODEL.toLowerCase().contains("droid4x") || Build.MODEL.contains("Emulator") || Build.MODEL.contains("Android SDK built for x86") || Build.MANUFACTURER.contains("Genymotion") || Build.HARDWARE.equals("goldfish") || Build.HARDWARE.equals("vbox86") || Build.PRODUCT.equals("sdk") || Build.PRODUCT.equals("google_sdk") || Build.PRODUCT.equals("sdk_x86") || Build.PRODUCT.equals("vbox86p") || Build.BOARD.toLowerCase().contains("nox") || Build.BOOTLOADER.toLowerCase().contains("nox") || Build.HARDWARE.toLowerCase().contains("nox") || Build.PRODUCT.toLowerCase().contains("nox") || Build.SERIAL.toLowerCase().contains("nox"); if (result)/* w w w .j ava2 s . com*/ return true; result |= Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"); if (result) return true; result |= "google_sdk".equals(Build.PRODUCT); return result; }
From source file:org.gluu.com.ox_push2.u2f.v2.SoftwareDevice.java
public TokenResponse enroll(String jsonRequest, OxPush2Request oxPush2Request, Boolean isDeny) throws JSONException, IOException, U2FException { JSONObject request = (JSONObject) new JSONTokener(jsonRequest).nextValue(); if (request.has("registerRequests")) { JSONArray registerRequestArray = request.getJSONArray("registerRequests"); if (registerRequestArray.length() == 0) { throw new U2FException("Failed to get registration request!"); }/* w ww. ja v a2s . c o m*/ request = (JSONObject) registerRequestArray.get(0); } if (!request.getString(JSON_PROPERTY_VERSION).equals(SUPPORTED_U2F_VERSION)) { throw new U2FException("Unsupported U2F_V2 version!"); } // Init device UUID service DeviceUuidManager deviceUuidFactory = new DeviceUuidManager(); deviceUuidFactory.init(context); String version = request.getString(JSON_PROPERTY_VERSION); String appParam = request.getString(JSON_PROPERTY_APP_ID); String challenge = request.getString(JSON_PROPERTY_SERVER_CHALLENGE); String origin = oxPush2Request.getIssuer(); EnrollmentResponse enrollmentResponse = u2fKey .register(new EnrollmentRequest(version, appParam, challenge, oxPush2Request)); if (BuildConfig.DEBUG) Log.d(TAG, "Enrollment response: " + enrollmentResponse); JSONObject clientData = new JSONObject(); if (isDeny) { clientData.put(JSON_PROPERTY_REQUEST_TYPE, REGISTER_CANCEL_TYPE); } else { clientData.put(JSON_PROPERTY_REQUEST_TYPE, REQUEST_TYPE_REGISTER); } clientData.put(JSON_PROPERTY_SERVER_CHALLENGE, challenge); clientData.put(JSON_PROPERTY_SERVER_ORIGIN, origin); String clientDataString = clientData.toString(); byte[] resp = rawMessageCodec.encodeRegisterResponse(enrollmentResponse); String deviceType = getDeviceType(); String versionName = getVersionName(); DeviceData deviceData = new DeviceData(); deviceData.setUuid(DeviceUuidManager.getDeviceUuid(context).toString()); deviceData.setPushToken(PushNotificationManager.getRegistrationId(context)); deviceData.setType(deviceType); deviceData.setPlatform("android"); deviceData.setName(Build.MODEL); deviceData.setOsName(versionName); deviceData.setOsVersion(Build.VERSION.RELEASE); String deviceDataString = new Gson().toJson(deviceData); JSONObject response = new JSONObject(); response.put("registrationData", Utils.base64UrlEncode(resp)); response.put("clientData", Utils.base64UrlEncode(clientDataString.getBytes(Charset.forName("ASCII")))); response.put("deviceData", Utils.base64UrlEncode(deviceDataString.getBytes(Charset.forName("ASCII")))); TokenResponse tokenResponse = new TokenResponse(); tokenResponse.setResponse(response.toString()); tokenResponse.setChallenge(new String(challenge)); tokenResponse.setKeyHandle(new String(enrollmentResponse.getKeyHandle())); return tokenResponse; }
From source file:org.opendatakit.survey.activities.MediaCaptureVideoActivity.java
@Override protected void onResume() { super.onResume(); if (afterResult) { // this occurs if we re-orient the phone during the save-recording // action returnResult();//from www . j a va2 s. c om } else if (!hasLaunched && !afterResult) { Intent i = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); // to make the name unique... File f = ODKFileUtils.getRowpathFile(appName, tableId, instanceId, (uriFragmentToMedia == null ? uriFragmentNewFileBase : uriFragmentToMedia)); int idx = f.getName().lastIndexOf('.'); if (idx == -1) { i.putExtra(Video.Media.DISPLAY_NAME, f.getName()); } else { i.putExtra(Video.Media.DISPLAY_NAME, f.getName().substring(0, idx)); } // Need to have this ugly code to account for // a bug in the Nexus 7 on 4.3 not returning the mediaUri in the data // of the intent - using the MediaStore.EXTRA_OUTPUT to get the data // Have it saving to an intermediate location instead of final destination // to allow the current location to catch issues with the intermediate file WebLogger.getLogger(appName).i(t, "The build of this device is " + android.os.Build.MODEL); if (NEXUS7.equals(android.os.Build.MODEL) && Build.VERSION.SDK_INT == 18) { nexus7Uri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO); i.putExtra(MediaStore.EXTRA_OUTPUT, nexus7Uri); } try { hasLaunched = true; startActivityForResult(i, ACTION_CODE); } catch (ActivityNotFoundException e) { String err = getString(R.string.activity_not_found, MediaStore.ACTION_VIDEO_CAPTURE); WebLogger.getLogger(appName).e(t, err); Toast.makeText(this, err, Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); finish(); } } }