如何使用adb shell找出Android设备的对角线显示宽度或屏幕尺寸?

时间:2016-05-09 09:29:14

标签: android shell adb

我需要找出设备宽度以根据每个设备的不同宽度跟踪设置不同的操作,这进一步用于编写脚本以自动化该过程。通过我的研究,我发现使用某些命令,如 -

import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;

public class Playground {

   private static AtomicLong REVISION = new AtomicLong(0);
   private static int[] ARR = new int[10];

   private static final int NUM_THREADS = 100;
   private static final int NUM_UPDATES_PER_THREAD = 100;

   public static void main(String[] args) {
      new Thread(() -> {
         int totalRevs = NUM_THREADS * NUM_UPDATES_PER_THREAD;
         while (REVISION.get() < totalRevs) {
            System.out.println(Arrays.toString(ARR));
            try {
               Thread.sleep(50);
            } catch (Exception e) {}
         }
      }).start();
      for (int i = 0; i < NUM_THREADS; ++i) {
         final int iCopy = i;
         new Thread(() -> {
            for (int j = 0; j < NUM_UPDATES_PER_THREAD; ++j) {
               Random rnd = new Random();
               int sleepTime = rnd.nextInt(100);
               try {
                  Thread.sleep(sleepTime);
               } catch (Exception e) {}
               int index = rnd.nextInt(10);
               int value = rnd.nextInt();
               ARR[index] = value;
               REVISION.incrementAndGet();
            }
         }).start();
      }
   }
}

很想知道,如果还有其他更好的方法吗?

1 个答案:

答案 0 :(得分:-1)

dumpsys命令的精确格式取决于硬件供应商(图形芯片组/驱动程序和手机本身),但您应该能够在adb shell dumpsys显示输出中找到该信息