Get CPU Information

Source: Internet
Author: User

1 View Phone CPU information

CMD--ADB shell--cd/proc------Cat Cpuinfo

2 Get the CPU is the arm instruction set, ARMV7 instruction set, or neon instruction set

  1. /**
  2. *
  3. * [Get CPU type and schema]
  4. *
  5. * @return
  6. * Three array of parameter types, the first parameter identifies is not the arm schema, the second parameter identifies whether it is a V6 or V7 schema, and the third parameter identifies whether it is a neon instruction set
  7. */
  8. Public Static object[] Getcpuarchitecture () {
  9. if ((Integer) marmarchitecture[1]! =-1) {
  10. return marmarchitecture;
  11. }
  12. try {
  13. InputStream is = new FileInputStream ("/proc/cpuinfo");
  14. InputStreamReader ir = new InputStreamReader (IS);
  15. BufferedReader br = new BufferedReader (IR);
  16. try {
  17. String nameprocessor = "Processor";
  18. String namefeatures = "Features";
  19. String Namemodel = "model name";
  20. String namecpufamily = "CPU Family";
  21. While (true) {
  22. String line = Br.readline ();
  23. string[] pair = null;
  24. if (line = = null) {
  25. Break ;
  26. }
  27. Pair = Line.split (":");
  28. if (pair.length! = 2)
  29. continue;
  30. String key = pair[0].trim ();
  31. String val = pair[1].trim ();
  32. if (Key.compareto (nameprocessor) = = 0) {
  33. String n = "";
  34. For (int i = val.indexof ("ARMV") + 4; i < val.length (); i++) {
  35. String temp = Val.charat (i) + "";
  36. if (temp.matches ("\\d")) {
  37. n + = temp;
  38. } Else {
  39. Break ;
  40. }
  41. }
  42. marmarchitecture[0] = "ARM";
  43. marmarchitecture[1] = Integer.parseint (n);
  44. continue;
  45. }
  46. if (key.comparetoignorecase (namefeatures) = = 0) {
  47. if (Val.contains ("neon")) {
  48. marmarchitecture[2] = "neon";
  49. }
  50. continue;
  51. }
  52. if (key.comparetoignorecase (namemodel) = = 0) {
  53. if (Val.contains ("Intel")) {
  54. marmarchitecture[0] = "INTEL";
  55. marmarchitecture[2] = "atom";
  56. }
  57. continue;
  58. }
  59. if (key.comparetoignorecase (namecpufamily) = = 0) {
  60. marmarchitecture[1] = Integer.parseint (val);
  61. continue;
  62. }
  63. }
  64. } finally {
  65. Br.close ();
  66. Ir.close ();
  67. Is.close ();
  68. }
  69. } catch (Exception e) {
  70. E.printstacktrace ();
  71. }
  72. return marmarchitecture;
  73. }

Get CPU Information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.