jeka
jeka

Reputation: 330

How to programmatically detect if an app is running on a Samsung "Edge" screen?

Is there an API to use to determine if the device an app is running on happens to be one of the Samsung "Edge" devices? That is, a device with a rounded edge as opposed to the one with the right-angled edges. (I believe Samsung is the only one manufacturing these at the moment.)

Additionally, some of the older "Edge" devices had only one rounded edge, while the newer ones have two. Is it possible to differentiate between these cases: no rounded edges, one rounded edge, two rounded edges?

Upvotes: 5

Views: 1625

Answers (1)

Aldo Wachyudi
Aldo Wachyudi

Reputation: 18001

I've encounter this problem too, after reading at the SDK docs, inspect the jar, and a few try and error; This is the method I use to check Samsung Edge devices (i.e Samsung Galaxy S8/S9.) without adding SDK libraries.

internal fun isEdgeDevice(): Boolean {
  var hasCocktailPanel = false
  try {
    val sLookImplClass = Class.forName("com.samsung.android.sdk.look.SlookImpl")
    if (sLookImplClass != null) {
      val isFeatureEnabledMethod =
        sLookImplClass.getDeclaredMethod("isFeatureEnabled", Int::class.java)
      hasCocktailPanel = isFeatureEnabledMethod.invoke(null, 7) as Boolean
    }
  } catch (ignored: Exception) {
  }
  return hasCocktailPanel
}

Explanation:

This method try to find SlookImpl class.

Jar

If it found one, then we can query the COCKTAIL_PANEL availability.

cocktail

Note: Before calling isEdgeDevice() method, I will check if the Build.MANUFACTURER and Build.BRAND is "samsung", then I will proceed to check whether its edge device or not.

Upvotes: 0

Related Questions