Why are these functions abstract, where to find the body (concrete implementation) of them?

Screenshot

I want to know the implementation of the function getPackageInfo(because I want to know where the package they refer to is stored), so I went to this to see the source code, but only found an abstract method there.

public abstract PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException;

Where is the method implemented?

+4
source share
2 answers

the implementation of the getPackageInfo method is in com.android.server.pm.PackageManagerService

 @Override
public PackageInfo getPackageInfo(String packageName, int flags, int userId) {
    // reader
    synchronized (mPackages) {
        PackageParser.Package p = mPackages.get(packageName);
        if (DEBUG_PACKAGE_INFO)
            Log.v(TAG, "getPackageInfo " + packageName + ": " + p);
        if (p != null) {
            return generatePackageInfo(p, flags);
        }
        if((flags & PackageManager.GET_UNINSTALLED_PACKAGES) != 0) {
            return generatePackageInfoFromSettingsLPw(packageName, flags, userId);
        }
    }
    return null;
}

you can look here

+2
source

PackageManager, , , MockPackageManager. , getPackageInfo. , , UnsupportedOperationException!

, , ? ! , !

?

, , getPackageManager , PackageManager MockPackageManager . getPackageManager +, Android Studio Windows. OS X + .

-1

Source: https://habr.com/ru/post/1621682/


All Articles