Ignore print service settings activities if they are not exported.
1. The print spooler cannot start not exported activities and they should not be started from another application anyway. Therefore, we do not start them from settings too even though settings can do that since it is signed with the platform certificate. 2. Adding some string changes to meet the translation deadline. bug:10680224 Change-Id: I69c189e1c502985aceb68d269492f2e86de44ec4
This commit is contained in:
committed by
Svetoslav Ganov
parent
b8e39041a5
commit
17e72aa90b
@@ -27,7 +27,10 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.Loader;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.DataSetObserver;
|
||||
@@ -275,9 +278,14 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
||||
if (!TextUtils.isEmpty(settingsTitle) && !TextUtils.isEmpty(settingsComponentName)) {
|
||||
Intent settingsIntent = new Intent(Intent.ACTION_MAIN).setComponent(
|
||||
ComponentName.unflattenFromString(settingsComponentName.toString()));
|
||||
if (!getPackageManager().queryIntentActivities(settingsIntent, 0).isEmpty()) {
|
||||
mSettingsTitle = settingsTitle;
|
||||
mSettingsIntent = settingsIntent;
|
||||
List<ResolveInfo> resolvedActivities = getPackageManager().queryIntentActivities(
|
||||
settingsIntent, 0);
|
||||
if (!resolvedActivities.isEmpty()) {
|
||||
// The activity is a component name, therefore it is one or none.
|
||||
if (resolvedActivities.get(0).activityInfo.exported) {
|
||||
mSettingsTitle = settingsTitle;
|
||||
mSettingsIntent = settingsIntent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,9 +298,14 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
||||
&& !TextUtils.isEmpty(addPrintersComponentName)) {
|
||||
Intent addPritnersIntent = new Intent(Intent.ACTION_MAIN).setComponent(
|
||||
ComponentName.unflattenFromString(addPrintersComponentName.toString()));
|
||||
if (!getPackageManager().queryIntentActivities(addPritnersIntent, 0).isEmpty()) {
|
||||
mAddPrintersTitle = addPrintersTitle;
|
||||
mAddPrintersIntent = addPritnersIntent;
|
||||
List<ResolveInfo> resolvedActivities = getPackageManager().queryIntentActivities(
|
||||
addPritnersIntent, 0);
|
||||
if (!resolvedActivities.isEmpty()) {
|
||||
// The activity is a component name, therefore it is one or none.
|
||||
if (resolvedActivities.get(0).activityInfo.exported) {
|
||||
mAddPrintersTitle = addPrintersTitle;
|
||||
mAddPrintersIntent = addPritnersIntent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user