SystemStats::getDeviceDescription and Notched Android Phones

Certain Android phones imitate the “notch” first introduced by the iPhone, particularly the Google Pixel 3 XL. The problem with the notch is that my app uses a full screen, and the notch ends up covering parts of the interface.

I have a workaround for this on the iPhone:

  void adjustScreenToPhoneModel() {
    String deviceDescription = SystemStats::getDeviceDescription();
    
    if(deviceDescription == "iPhone 11 Pro Max"
       || deviceDescription == "iPhone 11 Pro"
       || deviceDescription == "iPhone X"
       || deviceDescription == "iPhone Xs"
       || deviceDescription == "iPhone Xs Max") {
        setBounds(0,0, getWidth() - 30, getHeight());
    }
    else if (deviceDescription == "iPhone 11"
               || deviceDescription == "iPhone Xʀ"){
        setBounds(0,0, getWidth() - 33, getHeight());
    }
}

I was able to figure this out by testing virtual iPhones using Xcode. I tried doing the same with Android Studio, but SystemStats::getDeviceDescription gives a value (“sdk_gphone_x86_arm-unknown”) that is specific to the virtual device, not likely what the real device would return. (I also tried this with a Pixel 3 virtual device, and it returned “AOSP on IA Emulator-unknown”).

I don’t want to have to buy / borrow a real device just to figure out what SystemStats::getDeviceDescription will return in real life every time a new Android phone with a notch comes out. Does anyone know a way around this?

1 Like