|
2 | 2 |
|
3 | 3 | import android.app.Activity; |
4 | 4 | import android.content.Intent; |
| 5 | +import android.os.Build; |
5 | 6 | import android.os.Bundle; |
6 | 7 | import android.view.Menu; |
7 | 8 | import android.view.MenuItem; |
|
17 | 18 | import java.io.InputStreamReader; |
18 | 19 | import java.io.OutputStreamWriter; |
19 | 20 | import java.util.ArrayList; |
| 21 | +import com.marcohc.toasteroid.Toasteroid; |
| 22 | + |
20 | 23 |
|
21 | 24 | /* |
22 | 25 | The page that allows gives the user below functionalities |
@@ -44,10 +47,10 @@ protected void onCreate(Bundle savedInstanceState) { |
44 | 47 | uname = intent.getStringExtra("uname"); |
45 | 48 |
|
46 | 49 | root_status =(TextView) findViewById(R.id.rootStatus); |
47 | | - // Display root status |
| 50 | + // Display root status |
48 | 51 | showRootStatus(); |
49 | | - |
50 | | - |
| 52 | + // Display emulator status |
| 53 | + checkEmulatorStatus(); |
51 | 54 |
|
52 | 55 | transfer_button = (Button) findViewById(R.id.trf_button); |
53 | 56 | transfer_button.setOnClickListener(new View.OnClickListener() { |
@@ -82,7 +85,36 @@ public void onClick(View v) { |
82 | 85 | }); |
83 | 86 | } |
84 | 87 |
|
85 | | - void showRootStatus() { |
| 88 | + private void checkEmulatorStatus() { |
| 89 | + Boolean isEmulator = checkIfDeviceIsEmulator(); |
| 90 | + if(isEmulator==true) |
| 91 | + { |
| 92 | + Toasteroid.show(this, "Application running on Emulator", Toasteroid.STYLES.ERROR, Toasteroid.LENGTH_LONG); |
| 93 | + } |
| 94 | + else |
| 95 | + { |
| 96 | + Toasteroid.show(this, "Application running on Real device", Toasteroid.STYLES.SUCCESS, Toasteroid.LENGTH_LONG); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + private Boolean checkIfDeviceIsEmulator() { |
| 101 | + |
| 102 | + if(Build.FINGERPRINT.startsWith("generic") |
| 103 | + || Build.FINGERPRINT.startsWith("unknown") |
| 104 | + || Build.MODEL.contains("google_sdk") |
| 105 | + || Build.MODEL.contains("Emulator") |
| 106 | + || Build.MODEL.contains("Android SDK built for x86") |
| 107 | + || Build.MANUFACTURER.contains("Genymotion") |
| 108 | + || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) |
| 109 | + || "google_sdk".equals(Build.PRODUCT)) |
| 110 | + { |
| 111 | + return true; |
| 112 | + } |
| 113 | + return false; |
| 114 | + } |
| 115 | + |
| 116 | + |
| 117 | + void showRootStatus() { |
86 | 118 | boolean isrooted = doesSuperuserApkExist("/system/app/Superuser.apk")|| |
87 | 119 | doesSUexist(); |
88 | 120 | if(isrooted==true) |
|
0 commit comments