Skip to content

Phone Hardware Detection

There are numerous hardware components in mobile phones. How can we determine the condition of these hardware components? This article provides a solution for detecting the hardware of mobile phones. The detection methods can be broadly categorized into: ©

  • Technical solution, implemented through code
  • Engineering solution, implemented through business methods which will be enclosed in brackets in Implementation section
  • Hybrid solution, combining technical and engineering solution

Implementation

Hardware ComponentWeightAndroidIOSWeb
Front camera3(Take photo)(Take photo)(Take photo)
Rear camera3(Take photo)(Take photo)(Take photo)
Touchscreen3(Multi-touch)(Multi-touch)(Multi-touch)
Bluetooth2BluetoothAdapterCoreBluetoothBluetooth.getAvailability
Wifi2WifiManager + ConnectivityManagerNWPathMonitorNetworkInformation
Face ID/Touch ID2BiometricManagerLAContext
Fingerprint2FingerPrintManagerLAContext
Battery2BatteryManagerUIDeviceBatteryManager.getBattery
Microphone1AudioManager/(Record)AVAudioSession/(Record)navigator.mediaDevices
External speaker1AudioManager + (Play random OTP)AVAudioSession + (Play random OTP)(Play random OTP)
Earpiece1AudioManager + (Play random OTP)AudioManager + (Play random OTP)
Vibration1(Vibrate for N seconds randomly)(Vibrate for N seconds randomly)(Vibrate for N seconds randomly)
Volume keys1KeyDown + Volume change listenerVolume change listenerkeydown + Volume change listener
Proximity sensor1SensorManagerUIDeviceProximitySensor
Accelerometer1SensorManagerUIDeviceDeviceMotionEvent
Flashlight1(Turn on flashlight for photo)(Turn on flashlight for photo)
GPS1LocationManagerCoreLocationnavigator.geolocation

Scoring

Different weights are assigned to various hardware components based on their priority. Then, the scores are calculated by combining the weights of all detected items, resulting in a total score out of 100.

totalWeight = sum(weight)
totalScore = (sum of weights of detection passed items) / totalWeight * 100

Caveat

This solution assumes that the mobile phone is able to boot and run apps or open a browser, so components like the CPU and RAM are assumed to be functioning properly and do not need to be tested.