Merge "PackageManagerNative: Implement getModuleMetadataPackageName" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
abb0b0275a
@@ -64,6 +64,7 @@ public class ModuleInfoProvider {
|
|||||||
|
|
||||||
// TODO: Move this to an earlier boot phase if anybody requires it then.
|
// TODO: Move this to an earlier boot phase if anybody requires it then.
|
||||||
private volatile boolean mMetadataLoaded;
|
private volatile boolean mMetadataLoaded;
|
||||||
|
private volatile String mPackageName;
|
||||||
|
|
||||||
ModuleInfoProvider(Context context, IPackageManager packageManager) {
|
ModuleInfoProvider(Context context, IPackageManager packageManager) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -81,9 +82,9 @@ public class ModuleInfoProvider {
|
|||||||
|
|
||||||
/** Called by the {@code PackageManager} when it has completed its boot sequence */
|
/** Called by the {@code PackageManager} when it has completed its boot sequence */
|
||||||
public void systemReady() {
|
public void systemReady() {
|
||||||
final String packageName = mContext.getResources().getString(
|
mPackageName = mContext.getResources().getString(
|
||||||
R.string.config_defaultModuleMetadataProvider);
|
R.string.config_defaultModuleMetadataProvider);
|
||||||
if (TextUtils.isEmpty(packageName)) {
|
if (TextUtils.isEmpty(mPackageName)) {
|
||||||
Slog.w(TAG, "No configured module metadata provider.");
|
Slog.w(TAG, "No configured module metadata provider.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -91,13 +92,13 @@ public class ModuleInfoProvider {
|
|||||||
final Resources packageResources;
|
final Resources packageResources;
|
||||||
final PackageInfo pi;
|
final PackageInfo pi;
|
||||||
try {
|
try {
|
||||||
pi = mPackageManager.getPackageInfo(packageName,
|
pi = mPackageManager.getPackageInfo(mPackageName,
|
||||||
PackageManager.GET_META_DATA, UserHandle.USER_SYSTEM);
|
PackageManager.GET_META_DATA, UserHandle.USER_SYSTEM);
|
||||||
|
|
||||||
Context packageContext = mContext.createPackageContext(packageName, 0);
|
Context packageContext = mContext.createPackageContext(mPackageName, 0);
|
||||||
packageResources = packageContext.getResources();
|
packageResources = packageContext.getResources();
|
||||||
} catch (RemoteException | NameNotFoundException e) {
|
} catch (RemoteException | NameNotFoundException e) {
|
||||||
Slog.w(TAG, "Unable to discover metadata package: " + packageName, e);
|
Slog.w(TAG, "Unable to discover metadata package: " + mPackageName, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,4 +202,11 @@ public class ModuleInfoProvider {
|
|||||||
|
|
||||||
return mModuleInfo.get(packageName);
|
return mModuleInfo.get(packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getPackageName() {
|
||||||
|
if (!mMetadataLoaded) {
|
||||||
|
throw new IllegalStateException("Call to getVersion before metadata loaded");
|
||||||
|
}
|
||||||
|
return mPackageName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24074,6 +24074,11 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
| (appInfo.isVendor() ? IPackageManagerNative.LOCATION_VENDOR : 0)
|
| (appInfo.isVendor() ? IPackageManagerNative.LOCATION_VENDOR : 0)
|
||||||
| (appInfo.isProduct() ? IPackageManagerNative.LOCATION_PRODUCT : 0));
|
| (appInfo.isProduct() ? IPackageManagerNative.LOCATION_PRODUCT : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleMetadataPackageName() throws RemoteException {
|
||||||
|
return PackageManagerService.this.mModuleInfoProvider.getPackageName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PackageManagerInternalImpl extends PackageManagerInternal {
|
private class PackageManagerInternalImpl extends PackageManagerInternal {
|
||||||
|
|||||||
Reference in New Issue
Block a user