Android源代码功能奇特

时间:2012-03-19 19:27:50

标签: android function

Android源代码中的许多功能都有以LI,LPw,LPr结尾的特殊名称。有谁知道这些首字母缩略词的含义,因为理解函数名称及其用途会更有帮助。

示例:

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

感谢。

4 个答案:

答案 0 :(得分:1)

看起来你正在看一些奇怪的源代码。你知道grepcode吗?

答案 1 :(得分:1)

看看第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();

答案 2 :(得分:0)

LPr表示对mPackages的读访问权 LPw表示对mPackages的写访问权

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

lastnamePanel

答案 3 :(得分:0)

已经有一个已接受的答案,但我认为以下信息对其他用户有帮助。只是想了解LPr,LPw,LI和LIF后缀,并在文档中找到了以下内容:

在内部有两个重要的锁:

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