DO NOT MERGE Ensure package names read from config are system packages.
Fixes: 145981139 Test: manually tested ensureSystemPackageName() returns null for non-system app Change-Id: I1d23910cbd282f6702785c9dfb059d7be6b0e895
This commit is contained in:
@@ -3127,8 +3127,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
|
|
||||||
mWellbeingPackage = getWellbeingPackageName();
|
mWellbeingPackage = getWellbeingPackageName();
|
||||||
mDocumenterPackage = getDocumenterPackageName();
|
mDocumenterPackage = getDocumenterPackageName();
|
||||||
mConfiguratorPackage =
|
mConfiguratorPackage = getDeviceConfiguratorPackageName();
|
||||||
mContext.getString(R.string.config_deviceConfiguratorPackageName);
|
|
||||||
mAppPredictionServicePackage = getAppPredictionServicePackageName();
|
mAppPredictionServicePackage = getAppPredictionServicePackageName();
|
||||||
mIncidentReportApproverPackage = getIncidentReportApproverPackageName();
|
mIncidentReportApproverPackage = getIncidentReportApproverPackageName();
|
||||||
|
|
||||||
@@ -21118,7 +21117,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystemTextClassifierPackageName() {
|
public String getSystemTextClassifierPackageName() {
|
||||||
return mContext.getString(R.string.config_defaultTextClassifierPackage);
|
return ensureSystemPackageName(mContext.getString(
|
||||||
|
R.string.config_defaultTextClassifierPackage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -21128,7 +21128,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
if (flattenedComponentName != null) {
|
if (flattenedComponentName != null) {
|
||||||
ComponentName componentName = ComponentName.unflattenFromString(flattenedComponentName);
|
ComponentName componentName = ComponentName.unflattenFromString(flattenedComponentName);
|
||||||
if (componentName != null && componentName.getPackageName() != null) {
|
if (componentName != null && componentName.getPackageName() != null) {
|
||||||
return componentName.getPackageName();
|
return ensureSystemPackageName(componentName.getPackageName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -21153,9 +21153,15 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String getDeviceConfiguratorPackageName() {
|
||||||
|
return ensureSystemPackageName(mContext.getString(
|
||||||
|
R.string.config_deviceConfiguratorPackageName));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWellbeingPackageName() {
|
public String getWellbeingPackageName() {
|
||||||
return mContext.getString(R.string.config_defaultWellbeingPackage);
|
return ensureSystemPackageName(mContext.getString(R.string.config_defaultWellbeingPackage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -21170,7 +21176,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
if (appPredictionServiceComponentName == null) {
|
if (appPredictionServiceComponentName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return appPredictionServiceComponentName.getPackageName();
|
return ensureSystemPackageName(appPredictionServiceComponentName.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -21187,11 +21193,23 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
if (systemCaptionsServiceComponentName == null) {
|
if (systemCaptionsServiceComponentName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return systemCaptionsServiceComponentName.getPackageName();
|
return ensureSystemPackageName(systemCaptionsServiceComponentName.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIncidentReportApproverPackageName() {
|
public String getIncidentReportApproverPackageName() {
|
||||||
return mContext.getString(R.string.config_incidentReportApproverPackage);
|
return ensureSystemPackageName(mContext.getString(
|
||||||
|
R.string.config_incidentReportApproverPackage));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String ensureSystemPackageName(@Nullable String packageName) {
|
||||||
|
if (packageName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (getPackageInfo(packageName, MATCH_FACTORY_ONLY, UserHandle.USER_SYSTEM) == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user