Example usage for android.net Credentials getPid

List of usage examples for android.net Credentials getPid

Introduction

In this page you can find the example usage for android.net Credentials getPid.

Prototype

public int getPid() 

Source Link

Usage

From source file:com.facebook.stetho.server.SecureHttpRequestHandler.java

private static void enforcePermission(Context context, LocalSocket peer)
        throws IOException, PeerAuthorizationException {
    Credentials credentials = peer.getPeerCredentials();

    int uid = credentials.getUid();
    int pid = credentials.getPid();

    if (LogUtil.isLoggable(Log.VERBOSE)) {
        LogUtil.v("Got request from uid=%d, pid=%d", uid, pid);
    }/*from w w  w  .j a  v a 2 s  .c  o  m*/

    String requiredPermission = Manifest.permission.DUMP;
    int checkResult = context.checkPermission(requiredPermission, pid, uid);
    if (checkResult != PackageManager.PERMISSION_GRANTED) {
        throw new PeerAuthorizationException(
                "Peer pid=" + pid + ", uid=" + uid + " does not have " + requiredPermission);
    }
}