Jake
Jake

Reputation: 16837

Android source code functions peculiar names

A lot of functions in the Android source code have peculiar names ending with LI, LPw, LPr. Does anyone know what these acronyms mean, as it would be more helpful to understand the function name and its purpose.

Example:

PackageManagerService.installPackageLI()
PackageManagerService.updatePermissionsLPw()
Settings.peekPackageLPr()

Thanks.

Upvotes: 1

Views: 517

Answers (4)

khetanrajesh
khetanrajesh

Reputation: 300

There is already an accepted answer , but I assume the below information will be helpful for other users . Was just trying to understand the LPr , LPw , LI and LIF suffixes and found the below in documentation :

Internally there are two important locks:

1) **mPackages** is used to guard all in-memory parsed package details
   and other related state. It is a fine-grained lock that should only be 
   held momentarily, as it's one of the most contended locks in the system.

2) **mInstallLock** is used to guard all installd access, whose
   operations typically involve heavy lifting of application data on disk. 
   Since installd is single-threaded, and it's operations can often be slow,
   this lock should never be acquired while already holding mPackages . 
   Conversely, it's safe to acquire mPackages momentarily while already
   holding mInstallLock.

Many internal methods rely on the caller to hold the appropriate locks, and
this contract is expressed through method name suffixes:

fooLI():  the caller must hold mInstallLock
fooLIF(): the caller must hold mInstallLock and the package being modified 
          must be frozen
fooLPr(): the caller must hold mPackages for reading
fooLPw(): the caller must hold mPackages for writing

Upvotes: 1

cyberwjf
cyberwjf

Reputation: 1

LPr means read access to mPackages
LPw means write access to mPackages

http://androidxref.com/4.0.3_r1/xref/frameworks/base/services/java/com/android/server/pm/PackageManagerService.java#293

// Keys are String (package name), values are Package.  This also serves
// as the lock for the global state.  Methods that must be called with
// this lock held have the prefix "LP".
final HashMap<String, PackageParser.Package> mPackages =
        new HashMap<String, PackageParser.Package>();

Upvotes: 0

Snicolas
Snicolas

Reputation: 38168

Look at line 234 :

234     // Lock for state used when installing and doing other long running
235     // operations.  Methods that must be called with this lock held have
236     // the prefix "LI".
237     final Object mInstallLock = new Object();

Upvotes: 1

Snicolas
Snicolas

Reputation: 38168

It looks like you are looking at some weird source code. Do you know grepcode ?

Upvotes: 1

Related Questions