List of usage examples for android.os Build FINGERPRINT
String FINGERPRINT
To view the source code for android.os Build FINGERPRINT.
Click Source Link
From source file:com.mobicage.rogerthat.util.logging.L.java
private static void logToServer(final String s, final Throwable t) { try {/* w w w.j av a 2s.c o m*/ if (sMainService == null) return; final long currentTimeMillis = sMainService.currentTimeMillis(); if (currentTimeMillis - sLastErrorLogTimestamp < MAX_SEND_RATE) return; sLastErrorLogTimestamp = currentTimeMillis; try { throw new Exception(); } catch (final Exception e) { if (sMainService.getRegisteredFromConfig()) { sMainService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { if (sMainService == null) return; LogErrorRequestTO request = new LogErrorRequestTO(); request.description = s; request.platform = 1; request.timestamp = currentTimeMillis / 1000; request.mobicageVersion = (sMainService.isDebug() ? "-" : "") + sMainService.getMajorVersion() + "." + sMainService.getMinorVersion(); request.platformVersion = Build.FINGERPRINT + " (-) " + SystemUtils.getAndroidVersion() + " (-) " + Build.MODEL; setErrorMessageOnLogErrorRequest(t == null ? e : t, request); Rpc.logError(new ResponseHandler<LogErrorResponseTO>(), request); } }); } else { new AsyncTask<Object, Object, Object>() { @Override protected Object doInBackground(Object... params) { if (sMainService == null) return null; try { HttpPost httpPostRequest = new HttpPost(CloudConstants.LOG_ERROR_URL); httpPostRequest.setHeader("Content-Type", "application/x-www-form-urlencoded"); RegistrationWizard2 wiz = RegistrationWizard2.getWizard(sMainService); List<NameValuePair> formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("install_id", wiz.getInstallationId())); formParams.add(new BasicNameValuePair("device_id", wiz.getDeviceId())); formParams .add(new BasicNameValuePair("language", Locale.getDefault().getLanguage())); formParams.add(new BasicNameValuePair("country", Locale.getDefault().getCountry())); formParams.add(new BasicNameValuePair("description", s)); formParams.add(new BasicNameValuePair("platform", "1")); formParams.add(new BasicNameValuePair("platform_version", "" + SystemUtils.getAndroidVersion())); formParams.add(new BasicNameValuePair("timestamp", "" + System.currentTimeMillis() / 1000)); formParams.add(new BasicNameValuePair("mobicage_version", MainService.getVersion(sMainService))); formParams.add(new BasicNameValuePair("error_message", getStackTraceString(t == null ? e : t))); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, HTTP.UTF_8); httpPostRequest.setEntity(entity); HTTPUtil.getHttpClient().execute(httpPostRequest); } catch (Exception e1) { L.d("Error while posting error to server", e1); } return null; } }.execute(); } } } catch (Exception e) { L.d("Error while posting error to server", e); } }
From source file:com.gm.goldencity.util.Utils.java
/** * Get Device fingerprint//from ww w. j a v a2 s . co m * * @return */ public static String getMobileFingerprint() { // Device model return Build.FINGERPRINT; }
From source file:at.jclehner.appopsxposed.BugReportBuilder.java
private String getDeviceId() { final String raw = Build.SERIAL + Build.FINGERPRINT; byte[] bytes; try {/*from www . ja va2 s . co m*/ 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); }
From source file:jp.ne.sakura.kkkon.java.net.socketimpl.testapp.android.SocketImplHookTestApp.java
/** Called when the activity is first created. */ @Override//w w w .ja v a 2 s . co m public void onCreate(Bundle savedInstanceState) { final Context context = this.getApplicationContext(); { SocketImplHookFactory.initialize(); } { ProxySelector proxySelector = ProxySelector.getDefault(); Log.d(TAG, "proxySelector=" + proxySelector); if (null != proxySelector) { URI uri = null; try { uri = new URI("http://www.google.com/"); } catch (URISyntaxException e) { Log.d(TAG, e.toString()); } List<Proxy> proxies = proxySelector.select(uri); if (null != proxies) { for (final Proxy proxy : proxies) { Log.d(TAG, " proxy=" + proxy); } } } } super.onCreate(savedInstanceState); /* Create a TextView and set its content. * the text is retrieved by calling a native * function. */ LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); TextView tv = new TextView(this); tv.setText("ExceptionHandler"); layout.addView(tv); Button btn1 = new Button(this); btn1.setText("invoke Exception"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final int count = 2; int[] array = new int[count]; int value = array[count]; // invoke IndexOutOfBOundsException } }); layout.addView(btn1); { Button btn = new Button(this); btn.setText("upload http AsyncTask"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AsyncTask<String, Void, Boolean> asyncTask = new AsyncTask<String, Void, Boolean>() { @Override protected Boolean doInBackground(String... paramss) { Boolean result = true; Log.d(TAG, "upload AsyncTask tid=" + android.os.Process.myTid()); try { //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS) Log.d(TAG, "fng=" + Build.FINGERPRINT); final List<NameValuePair> list = new ArrayList<NameValuePair>(16); list.add(new BasicNameValuePair("fng", Build.FINGERPRINT)); HttpPost httpPost = new HttpPost(paramss[0]); //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) ); httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8)); DefaultHttpClient httpClient = new DefaultHttpClient(); Log.d(TAG, "socket.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(5 * 1000)); httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(5 * 1000)); Log.d(TAG, "socket.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); // <uses-permission android:name="android.permission.INTERNET"/> // got android.os.NetworkOnMainThreadException, run at UI Main Thread HttpResponse response = httpClient.execute(httpPost); Log.d(TAG, "response=" + response.getStatusLine().getStatusCode()); } catch (Exception e) { Log.d(TAG, "got Exception. msg=" + e.getMessage(), e); result = false; } Log.d(TAG, "upload finish"); return result; } }; asyncTask.execute("http://kkkon.sakura.ne.jp/android/bug"); asyncTask.isCancelled(); } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("pre DNS query(0.0.0.0)"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { isReachable = false; Thread thread = new Thread(new Runnable() { public void run() { try { destHost = InetAddress.getByName("0.0.0.0"); if (null != destHost) { try { if (destHost.isReachable(5 * 1000)) { Log.d(TAG, "destHost=" + destHost.toString() + " reachable"); } else { Log.d(TAG, "destHost=" + destHost.toString() + " not reachable"); } } catch (IOException e) { } } } catch (UnknownHostException e) { } Log.d(TAG, "destHost=" + destHost); } }); thread.start(); try { thread.join(1000); } catch (InterruptedException e) { } } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("pre DNS query(www.google.com)"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { isReachable = false; Thread thread = new Thread(new Runnable() { public void run() { try { InetAddress dest = InetAddress.getByName("www.google.com"); if (null == dest) { dest = destHost; } if (null != dest) { try { if (dest.isReachable(5 * 1000)) { Log.d(TAG, "destHost=" + dest.toString() + " reachable"); isReachable = true; } else { Log.d(TAG, "destHost=" + dest.toString() + " not reachable"); } destHost = dest; } catch (IOException e) { } } else { } } catch (UnknownHostException e) { Log.d(TAG, "dns error" + e.toString()); destHost = null; } { if (null != destHost) { Log.d(TAG, "destHost=" + destHost); } } } }); thread.start(); try { thread.join(); { final String addr = (null == destHost) ? ("") : (destHost.toString()); final String reachable = (isReachable) ? ("reachable") : ("not reachable"); Toast toast = Toast.makeText(context, "DNS result=\n" + addr + "\n " + reachable, Toast.LENGTH_LONG); toast.show(); } } catch (InterruptedException e) { } } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("pre DNS query(kkkon.sakura.ne.jp)"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { isReachable = false; Thread thread = new Thread(new Runnable() { public void run() { try { InetAddress dest = InetAddress.getByName("kkkon.sakura.ne.jp"); if (null == dest) { dest = destHost; } if (null != dest) { try { if (dest.isReachable(5 * 1000)) { Log.d(TAG, "destHost=" + dest.toString() + " reachable"); isReachable = true; } else { Log.d(TAG, "destHost=" + dest.toString() + " not reachable"); } destHost = dest; } catch (IOException e) { } } else { } } catch (UnknownHostException e) { Log.d(TAG, "dns error" + e.toString()); destHost = null; } { if (null != destHost) { Log.d(TAG, "destHost=" + destHost); } } } }); thread.start(); try { thread.join(); { final String addr = (null == destHost) ? ("") : (destHost.toString()); final String reachable = (isReachable) ? ("reachable") : ("not reachable"); Toast toast = Toast.makeText(context, "DNS result=\n" + addr + "\n " + reachable, Toast.LENGTH_LONG); toast.show(); } } catch (InterruptedException e) { } } }); layout.addView(btn); } setContentView(layout); }
From source file:com.appbackr.android.tracker.Tracker.java
/** * Generates a unique ID for the device. * //from w ww . j ava 2 s .c o m * This function obtain the Unique ID from the phone. The Unique ID consist of * Build.BOARD + Build.BRAND + Build.CPU_ABI * + Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST * + Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT * + Build.TAGS + Build.TYPE + Build.USER; * + IMEI (GSM) or MEID/ESN (CDMA) * + Android-assigned id * * The Android ID may be changed everytime the user perform Factory Reset * I heard that IMEI values might not be unique because phone factory * might reuse IMEI values to cut cost. * * While the ID might be different from the same device, but resetting of the * Android phone should not occur that often. The values should be close * enough. * * @param c android application contact * @return unique ID as md5 hash generated of available parameters from device and cell phone service provider */ private static String getUDID(Context c) { // Get some of the hardware information String buildParams = Build.BOARD + Build.BRAND + Build.CPU_ABI + Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST + Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT + Build.TAGS + Build.TYPE + Build.USER; // Requires READ_PHONE_STATE TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE); // gets the imei (GSM) or MEID/ESN (CDMA) String imei = tm.getDeviceId(); // gets the android-assigned id String androidId = Secure.getString(c.getContentResolver(), Secure.ANDROID_ID); // concatenate the string String fullHash = buildParams.toString() + imei + androidId; return md5(fullHash); }
From source file:de.uni_weimar.mheinz.androidtouchscope.TouchScopeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_touch_scope); Toolbar toolbar = (Toolbar) findViewById(R.id.scope_toolbar); setSupportActionBar(toolbar);/*from w ww . j a va 2 s . c o m*/ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // assert mDrawerLayout != null; // mDrawerLayout.setScrimColor(Color.TRANSPARENT); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } createDrawerToggle(toolbar); mDrawerLayout.addDrawerListener(mDrawerToggle); // disables touch-to-open mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); assert toolbar != null; toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDrawerLayout.openDrawer(GravityCompat.START); } }); mLeftDrawer = (NavigationView) findViewById(R.id.left_drawer); assert mLeftDrawer != null; mLeftDrawer.setNavigationItemSelectedListener(mLeftDrawerSelectedListener); mRightMenu = (LinearLayout) findViewById(R.id.right_menu); mHostView = (HostView) findViewById(R.id.hostView); mHostView.setOnDoCommand(new OnDataChangedInterface.OnDataChanged() { @Override public void doCommand(ScopeInterface.Command command, int channel, Object specialData) { if (mActiveScope != null) { mActiveScope.doCommand(command, channel, true, specialData); } } }); mScopeView = (ScopeView) findViewById(R.id.scopeView); mMeasurementView = mHostView.getMeasureView(); mLearningView = (LearningView) findViewById(R.id.learningView); ToggleButton runStopButton = (ToggleButton) findViewById(R.id.buttonRunStop); assert runStopButton != null; runStopButton.setChecked(true); // test if it is emulator initScope(!Build.FINGERPRINT.contains("generic")); }
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 w w .j a va 2s . c o m Class.forName("android.app.AppOpsManager"); sb.append("YES"); } catch (ClassNotFoundException e) { sb.append("NO!"); } }
From source file:jp.ne.sakura.kkkon.java.net.inetaddress.testapp.android.NetworkConnectionCheckerTestApp.java
/** Called when the activity is first created. */ @Override/*from www . java 2s . co m*/ public void onCreate(Bundle savedInstanceState) { final Context context = this.getApplicationContext(); { NetworkConnectionChecker.initialize(); } super.onCreate(savedInstanceState); /* Create a TextView and set its content. * the text is retrieved by calling a native * function. */ LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); TextView tv = new TextView(this); tv.setText("reachable="); layout.addView(tv); this.textView = tv; Button btn1 = new Button(this); btn1.setText("invoke Exception"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final int count = 2; int[] array = new int[count]; int value = array[count]; // invoke IndexOutOfBOundsException } }); layout.addView(btn1); { Button btn = new Button(this); btn.setText("disp isReachable"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final boolean isReachable = NetworkConnectionChecker.isReachable(); Toast toast = Toast.makeText(context, "IsReachable=" + isReachable, Toast.LENGTH_LONG); toast.show(); } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("upload http AsyncTask"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AsyncTask<String, Void, Boolean> asyncTask = new AsyncTask<String, Void, Boolean>() { @Override protected Boolean doInBackground(String... paramss) { Boolean result = true; Log.d(TAG, "upload AsyncTask tid=" + android.os.Process.myTid()); try { //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS) Log.d(TAG, "fng=" + Build.FINGERPRINT); final List<NameValuePair> list = new ArrayList<NameValuePair>(16); list.add(new BasicNameValuePair("fng", Build.FINGERPRINT)); HttpPost httpPost = new HttpPost(paramss[0]); //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) ); httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8)); DefaultHttpClient httpClient = new DefaultHttpClient(); Log.d(TAG, "socket.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(5 * 1000)); httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(5 * 1000)); Log.d(TAG, "socket.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); // <uses-permission android:name="android.permission.INTERNET"/> // got android.os.NetworkOnMainThreadException, run at UI Main Thread HttpResponse response = httpClient.execute(httpPost); Log.d(TAG, "response=" + response.getStatusLine().getStatusCode()); } catch (Exception e) { Log.d(TAG, "got Exception. msg=" + e.getMessage(), e); result = false; } Log.d(TAG, "upload finish"); return result; } }; asyncTask.execute("http://kkkon.sakura.ne.jp/android/bug"); asyncTask.isCancelled(); } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("pre DNS query(0.0.0.0)"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { isReachable = false; Thread thread = new Thread(new Runnable() { public void run() { try { destHost = InetAddress.getByName("0.0.0.0"); if (null != destHost) { try { if (destHost.isReachable(5 * 1000)) { Log.d(TAG, "destHost=" + destHost.toString() + " reachable"); } else { Log.d(TAG, "destHost=" + destHost.toString() + " not reachable"); } } catch (IOException e) { } } } catch (UnknownHostException e) { } Log.d(TAG, "destHost=" + destHost); } }); thread.start(); try { thread.join(1000); } catch (InterruptedException e) { } } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("pre DNS query(www.google.com)"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { isReachable = false; Thread thread = new Thread(new Runnable() { public void run() { Log.d(TAG, "start"); try { InetAddress dest = InetAddress.getByName("www.google.com"); if (null == dest) { dest = destHost; } if (null != dest) { final String[] uris = new String[] { "http://www.google.com/", "https://www.google.com/" }; for (final String destURI : uris) { URI uri = null; try { uri = new URI(destURI); } catch (URISyntaxException e) { //Log.d( TAG, e.toString() ); } if (null != uri) { URL url = null; try { url = uri.toURL(); } catch (MalformedURLException ex) { Log.d(TAG, "got exception:" + ex.toString(), ex); } URLConnection conn = null; if (null != url) { Log.d(TAG, "openConnection before"); try { conn = url.openConnection(); if (null != conn) { conn.setConnectTimeout(3 * 1000); conn.setReadTimeout(3 * 1000); } } catch (IOException e) { //Log.d( TAG, "got Exception" + e.toString(), e ); } Log.d(TAG, "openConnection after"); if (conn instanceof HttpURLConnection) { HttpURLConnection httpConn = (HttpURLConnection) conn; int responceCode = -1; try { Log.d(TAG, "getResponceCode before"); responceCode = httpConn.getResponseCode(); Log.d(TAG, "getResponceCode after"); } catch (IOException ex) { Log.d(TAG, "got exception:" + ex.toString(), ex); } Log.d(TAG, "responceCode=" + responceCode); if (0 < responceCode) { isReachable = true; destHost = dest; } Log.d(TAG, " HTTP ContentLength=" + httpConn.getContentLength()); httpConn.disconnect(); Log.d(TAG, " HTTP ContentLength=" + httpConn.getContentLength()); } } } // if uri if (isReachable) { //break; } } // for uris } else { } } catch (UnknownHostException e) { Log.d(TAG, "dns error" + e.toString()); destHost = null; } { if (null != destHost) { Log.d(TAG, "destHost=" + destHost); } } Log.d(TAG, "end"); } }); thread.start(); try { thread.join(); { final String addr = (null == destHost) ? ("") : (destHost.toString()); final String reachable = (isReachable) ? ("reachable") : ("not reachable"); Toast toast = Toast.makeText(context, "DNS result=\n" + addr + "\n " + reachable, Toast.LENGTH_LONG); toast.show(); } } catch (InterruptedException e) { } } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("pre DNS query(kkkon.sakura.ne.jp)"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { isReachable = false; Thread thread = new Thread(new Runnable() { public void run() { Log.d(TAG, "start"); try { InetAddress dest = InetAddress.getByName("kkkon.sakura.ne.jp"); if (null == dest) { dest = destHost; } if (null != dest) { try { if (dest.isReachable(5 * 1000)) { Log.d(TAG, "destHost=" + dest.toString() + " reachable"); isReachable = true; } else { Log.d(TAG, "destHost=" + dest.toString() + " not reachable"); } destHost = dest; } catch (IOException e) { } } else { } } catch (UnknownHostException e) { Log.d(TAG, "dns error" + e.toString()); destHost = null; } { if (null != destHost) { Log.d(TAG, "destHost=" + destHost); } } Log.d(TAG, "end"); } }); thread.start(); try { thread.join(); { final String addr = (null == destHost) ? ("") : (destHost.toString()); final String reachable = (isReachable) ? ("reachable") : ("not reachable"); Toast toast = Toast.makeText(context, "DNS result=\n" + addr + "\n " + reachable, Toast.LENGTH_LONG); toast.show(); } } catch (InterruptedException e) { } } }); layout.addView(btn); } { Button btn = new Button(this); btn.setText("pre DNS query(kkkon.sakura.ne.jp) support proxy"); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { isReachable = false; Thread thread = new Thread(new Runnable() { public void run() { try { String target = null; { ProxySelector proxySelector = ProxySelector.getDefault(); Log.d(TAG, "proxySelector=" + proxySelector); if (null != proxySelector) { URI uri = null; try { uri = new URI("http://www.google.com/"); } catch (URISyntaxException e) { Log.d(TAG, e.toString()); } List<Proxy> proxies = proxySelector.select(uri); if (null != proxies) { for (final Proxy proxy : proxies) { Log.d(TAG, " proxy=" + proxy); if (null != proxy) { if (Proxy.Type.HTTP == proxy.type()) { final SocketAddress sa = proxy.address(); if (sa instanceof InetSocketAddress) { final InetSocketAddress isa = (InetSocketAddress) sa; target = isa.getHostName(); break; } } } } } } } if (null == target) { target = "kkkon.sakura.ne.jp"; } InetAddress dest = InetAddress.getByName(target); if (null == dest) { dest = destHost; } if (null != dest) { try { if (dest.isReachable(5 * 1000)) { Log.d(TAG, "destHost=" + dest.toString() + " reachable"); isReachable = true; } else { Log.d(TAG, "destHost=" + dest.toString() + " not reachable"); { ProxySelector proxySelector = ProxySelector.getDefault(); //Log.d( TAG, "proxySelector=" + proxySelector ); if (null != proxySelector) { URI uri = null; try { uri = new URI("http://www.google.com/"); } catch (URISyntaxException e) { //Log.d( TAG, e.toString() ); } if (null != uri) { List<Proxy> proxies = proxySelector.select(uri); if (null != proxies) { for (final Proxy proxy : proxies) { //Log.d( TAG, " proxy=" + proxy ); if (null != proxy) { if (Proxy.Type.HTTP == proxy.type()) { URL url = uri.toURL(); URLConnection conn = null; if (null != url) { try { conn = url.openConnection(proxy); if (null != conn) { conn.setConnectTimeout( 3 * 1000); conn.setReadTimeout(3 * 1000); } } catch (IOException e) { Log.d(TAG, "got Exception" + e.toString(), e); } if (conn instanceof HttpURLConnection) { HttpURLConnection httpConn = (HttpURLConnection) conn; if (0 < httpConn .getResponseCode()) { isReachable = true; } Log.d(TAG, " HTTP ContentLength=" + httpConn .getContentLength()); Log.d(TAG, " HTTP res=" + httpConn .getResponseCode()); //httpConn.setInstanceFollowRedirects( false ); //httpConn.setRequestMethod( "HEAD" ); //conn.connect(); httpConn.disconnect(); Log.d(TAG, " HTTP ContentLength=" + httpConn .getContentLength()); Log.d(TAG, " HTTP res=" + httpConn .getResponseCode()); } } } } } } } } } } destHost = dest; } catch (IOException e) { Log.d(TAG, "got Excpetion " + e.toString()); } } else { } } catch (UnknownHostException e) { Log.d(TAG, "dns error" + e.toString()); destHost = null; } { if (null != destHost) { Log.d(TAG, "destHost=" + destHost); } } } }); thread.start(); try { thread.join(); { final String addr = (null == destHost) ? ("") : (destHost.toString()); final String reachable = (isReachable) ? ("reachable") : ("not reachable"); Toast toast = Toast.makeText(context, "DNS result=\n" + addr + "\n " + reachable, Toast.LENGTH_LONG); toast.show(); } } catch (InterruptedException e) { } } }); layout.addView(btn); } setContentView(layout); }
From source file:com.silentcircle.silenttext.util.DeviceUtils.java
public static JSONObject getDebugInformationJSON(Context context) { try {/* w ww . j av a 2 s.com*/ JSONObject json = new JSONObject(); json.put("timestamp", JSONUtils.getDate(System.currentTimeMillis())); JSONObject android = new JSONObject(); android.put("version", Build.VERSION.RELEASE); android.put("api", Build.VERSION.SDK_INT); android.put("build", Build.FINGERPRINT); json.put("android", android); JSONObject application = new JSONObject(); try { PackageInfo pinfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); application.put("version_name", pinfo.versionName); application.put("version_code", pinfo.versionCode); setInstallAndUpdateTimes(pinfo, application); } catch (NameNotFoundException impossible) { throw new RuntimeException(impossible); } json.put("application", application); JSONObject device = new JSONObject(); Configuration resourceConfiguration = context.getResources().getConfiguration(); device.put("locale", resourceConfiguration.locale); device.put("orientation", resourceConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE ? "landscape" : "portrait"); device.put("density", getScreenDensity(resourceConfiguration)); device.put("screen", getScreenDimensions(resourceConfiguration)); device.put("manufacturer", Build.MANUFACTURER); device.put("model", Build.MODEL); JSONObject encryption = new JSONObject(); encryption.put("supported", isFullDiskEncryptionSupported(context)); encryption.put("enabled", isEncrypted(context)); device.put("encryption", encryption); json.put("device", device); JSONObject build = new JSONObject(); build.put("date", context.getString(R.string.build_date)); build.put("version", context.getString(R.string.build_version)); build.put("commit", context.getString(R.string.build_commit)); json.put("build", build); JSONObject connection = new JSONObject(); SilentTextApplication global = SilentTextApplication.from(context); XMPPTransport client = global.getXMPPTransport(); JSONObject xmpp = new JSONObject(); xmpp.put("status", global.getXMPPTransportConnectionStatus()); if (client != null) { boolean online = client.isConnected(); xmpp.put("online", online); if (online) { xmpp.put("host", client.getServerHost()); xmpp.put("port", client.getServerPort()); } } connection.put("xmpp", xmpp); json.put("connection", connection); ServiceConfiguration serviceConfig = ServiceConfiguration.getInstance(); JSONObject services = new JSONObject(); services.put("debug", serviceConfig.debug); services.put("experimental", serviceConfig.experimental); services.put("logging_enabled", serviceConfig.loggingEnabled); services.put("environment", serviceConfig.environment); services.put("dns.use_custom_server", serviceConfig.useCustomDNS); if (serviceConfig.useCustomDNS) { services.put("dns.custom_server", serviceConfig.customDNS); } services.put("validate_certificates", serviceConfig.shouldValidateCertificates); services.put("api.override", serviceConfig.api.override); services.put("api.perform_srv_lookup", serviceConfig.api.performSRVLookup); services.put("api.host", serviceConfig.api.host); services.put("api.port", serviceConfig.api.port); services.put("api.service_name", serviceConfig.api.serviceName); services.put("feature.check_user_availability", serviceConfig.features.checkUserAvailability); services.put("feature.generate_default_avatars", serviceConfig.features.generateDefaultAvatars); services.put("gcm.sender_id", serviceConfig.gcm.senderID); services.put("gcm.target", serviceConfig.gcm.target); services.put("scimp.enable_pki", serviceConfig.scimp.enablePKI); services.put("scloud.url", serviceConfig.scloud.url); services.put("xmpp.override", serviceConfig.xmpp.override); services.put("xmpp.perform_srv_lookup", serviceConfig.xmpp.performSRVLookup); services.put("xmpp.host", serviceConfig.xmpp.host); services.put("xmpp.port", serviceConfig.xmpp.port); services.put("xmpp.service_name", serviceConfig.xmpp.serviceName); services.put("xmpp.background", serviceConfig.xmpp.background); services.put("passcode_set", !OptionsDrawer.isEmptyPasscode(context)); services.put("silent_contacts_v1", SilentContactRepositoryV1.supports(context)); services.put("silent_contacts_v2", SilentContactRepositoryV2.supports(context)); services.put("silent_phone", SilentPhone.supports(context)); json.put("configuration", services); return json; } catch (JSONException impossible) { throw new RuntimeException(impossible); } }
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 ava 2 s .c om*/ return true; result |= Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"); if (result) return true; result |= "google_sdk".equals(Build.PRODUCT); return result; }