Merge "DO NOT MERGE Ensure package names read from config are system packages." into pi-dev

This commit is contained in:
TreeHugger Robot
2020-03-05 20:17:47 +00:00
committed by Android (Google) Code Review

View File

@@ -20710,7 +20710,29 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
@Override
public String getSystemTextClassifierPackageName() {
return mContext.getString(R.string.config_defaultTextClassifierPackage);
return ensureSystemPackageName(mContext.getString(
R.string.config_defaultTextClassifierPackage));
}
@Nullable
private String ensureSystemPackageName(@Nullable String packageName) {
if (packageName == null) {
return null;
}
long token = Binder.clearCallingIdentity();
try {
if (getPackageInfo(packageName, MATCH_FACTORY_ONLY, UserHandle.USER_SYSTEM) == null) {
PackageInfo packageInfo = getPackageInfo(packageName, 0, UserHandle.USER_SYSTEM);
if (packageInfo != null) {
EventLog.writeEvent(0x534e4554, "145981139", packageInfo.applicationInfo.uid,
"");
}
return null;
}
} finally {
Binder.restoreCallingIdentity(token);
}
return packageName;
}
@Override