Example usage for android.os Process FIRST_APPLICATION_UID

List of usage examples for android.os Process FIRST_APPLICATION_UID

Introduction

In this page you can find the example usage for android.os Process FIRST_APPLICATION_UID.

Prototype

int FIRST_APPLICATION_UID

To view the source code for android.os Process FIRST_APPLICATION_UID.

Click Source Link

Document

Defines the start of a range of UIDs (and GIDs), going from this number to #LAST_APPLICATION_UID that are reserved for assigning to applications.

Usage

From source file:Main.java

public static String getUIDName(Integer id) {
    if (UNAMES.containsKey(id)) {
        return UNAMES.get(id);

    } else if (id >= 10000) {
        Integer uid = id / 100000;
        Integer gid = id % Process.FIRST_APPLICATION_UID;

        return "u" + uid + "_a" + gid + "";
    }/*from   w ww .ja  va2 s  .  c  om*/

    return null;
}

From source file:Main.java

public static Integer getUID(String name) {
    if (name != null) {
        if (name.matches("^[0-9]+$")) {
            return Integer.parseInt(name);
        }//from  w ww .jav  a2  s. com

        if (UIDS.containsKey(name)) {
            return UIDS.get(name);

        } else if (name.startsWith("u")) {
            Integer sep = name.indexOf("_");

            if (sep > 0) {
                Integer uid = Integer.parseInt(name.substring(1, sep));
                Integer gid = Integer.parseInt(name.substring(sep + 2));

                return uid * 100000 + ((Process.FIRST_APPLICATION_UID + gid) % 100000);
            }
        }
    }

    return -10000;
}