Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect Android Go?

Is there any way to detect that device is running Android Go edition? Need to determine if device is capable of providing SYSTEM_ALERT_WINDOW since API 29.

According the reference, Settings.canDrawOverlays(Context context) will always return false on API 29 Go. Without knowing if the system is possible to give access to SYSTEM_ALERT_WINDOW it's hard to work around the case.

like image 831
Orange Avatar asked Oct 11 '19 11:10

Orange


People also ask

How can I tell if I have Android Go?

You'll need to know your Android version for a lot of different reasons, like troubleshooting or finding features. To see what version of Android you're using, go to "Settings > About phone/device > Software Information/Android Version.

What are Android Go devices?

Android Go, officially Android (Go Edition), is a stripped-down version of the Android operating system, designed for low-end and ultra-budget smartphones. It is intended for smartphones with less than 2 GB of RAM and was first made available for Android Oreo.

Can Android Go be installed on any device?

More and more Android Go devices have recently been introduced in various markets around the globe, and now you can get Android Go installed on pretty much any device that currently runs on Android.

What is difference between Android and Android Go?

So, to put it plainly: Android One is a line of phones—hardware, defined and managed by Google—and Android Go is pure software that can run on any hardware. There aren't specific hardware requirements on Go like on One, though the former is designed explicitly for lower-end hardware.


Video Answer


3 Answers

ActivityManager am = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
am.isLowRamDevice();

The following code is available in ActivityManager.java

    /**
     * Returns true if this is a low-RAM device.  Exactly whether a device is low-RAM
     * is ultimately up to the device configuration, but currently it generally means
     * something with 1GB or less of RAM.  This is mostly intended to be used by apps
     * to determine whether they should turn off certain features that require more RAM.
     */
    public boolean isLowRamDevice() {
        return isLowRamDeviceStatic();
    }
like image 193
greywolf82 Avatar answered Oct 20 '22 08:10

greywolf82


You can refer to the implementation of the Android 11 source code. It only uses ActivityManager.isLowRamDevice() to check if the SYSTEM_ALERT_WINDOW permission is available.

packages\apps\Settings\src\com\android\settings\Utils.java

/**
 * Returns true if SYSTEM_ALERT_WINDOW permission is available.
 * Starting from Q, SYSTEM_ALERT_WINDOW is disabled on low ram phones.
 */
public static boolean isSystemAlertWindowEnabled(Context context) {
    // SYSTEM_ALERT_WINDOW is disabled on on low ram devices starting from Q
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    return !(am.isLowRamDevice() && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q));
}
like image 45
Sam Lu Avatar answered Oct 20 '22 07:10

Sam Lu


You can simply query PackageManager to check if one of the Android GO preloaded apps is installed, as they have different package names. For example:

Gmail Go package name: "com.google.android.gm.lite"

Regular Gmail package name: "com.google.android.gm"

fun isGoDevice(): Boolean {
    val GMAIL_GO_PACKAGE_NAME = "com.google.android.gm.lite"
    val packageManager = context.getPackageManager()
    return try {
        packageManager.getPackageInfo(GMAIL_GO_PACKAGE_NAME, 0)
        true
    } catch (e: PackageManager.NameNotFoundException) {
        false
    }
}
like image 2
Rotem Matityahu Avatar answered Oct 20 '22 09:10

Rotem Matityahu