5

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?

jeka
  • 330
  • 2
  • 11
  • "I believe Samsung is the only one manufacturing these at the moment" -- no, there is more than just Samsung. BlackBerry has at least one such model (Priv), for example. – CommonsWare Oct 19 '17 at 19:04
  • Could Samsung SDKs be any help ? http://developer.samsung.com/galaxy/edge/edge-guide – 10101010 Oct 19 '17 at 19:32
  • So, something along these lines should do the trick then: Slook slook = new Slook(); try { slook.initialize(this); // edge } catch (SsdkUnsupportedException e) { // not an edge } correct? But we'd have to include com.samsung.android.sdk.look and the corresponding components. – jeka Oct 20 '17 at 21:13

1 Answers1

0

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.

aldok
  • 17,295
  • 5
  • 53
  • 64