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:
Svetoslav
2013-09-13 18:40:00 -07:00
committed by Svetoslav Ganov
parent b8e39041a5
commit 17e72aa90b
3 changed files with 39 additions and 12 deletions

View File

@@ -3410,9 +3410,8 @@
<xliff:g id="service" example="My Print Service">%1$s</xliff:g>?</string> <xliff:g id="service" example="My Print Service">%1$s</xliff:g>?</string>
<!-- Summary for a warning message about security implications of enabling a print service, <!-- Summary for a warning message about security implications of enabling a print service,
displayed as a dialog message when the user selects to enable a print service. [CHAR LIMIT=NONE] --> displayed as a dialog message when the user selects to enable a print service. [CHAR LIMIT=NONE] -->
<string name="print_service_security_warning_summary"> <string name="print_service_security_warning_summary">Your document may pass through
<xliff:g id="print_service_name">%1$s</xliff:g> can receive documents you print. one or more servers on its way to the printer.</string>
Such documents may contain sensitive data.</string>
<!-- Title for the prompt shown as a placeholder if no print serivices are installed. [CHAR LIMIT=50] --> <!-- Title for the prompt shown as a placeholder if no print serivices are installed. [CHAR LIMIT=50] -->
<string name="print_no_services_installed">No services installed</string> <string name="print_no_services_installed">No services installed</string>
@@ -3437,8 +3436,14 @@
<!-- Title for the search action bar menu item. [CHAR LIMIT=20] --> <!-- Title for the search action bar menu item. [CHAR LIMIT=20] -->
<string name="print_menu_item_search">Search</string> <string name="print_menu_item_search">Search</string>
<!-- Title for the printer categoty showing a list of available printers. [CHAR LIMIT=25] --> <!-- Title for the prompt if no printers are available and the system is searching for such. [CHAR LIMIT=50] -->
<string name="category_printers">Printers</string> <string name="print_searching_for_printers">Searching for printers</string>
<!-- Title for the menu item to open the print jobs screen. [CHAR LIMIT=25] -->
<string name="print_print_jobs">Print jobs</string>
<!-- Title for the print jobs screen. [CHAR LIMIT=25] -->
<string name="print_active_print_jobs">Active print jobs</string>
<!-- App Fuel Gauge strings --> <!-- App Fuel Gauge strings -->
<skip /> <skip />

View File

@@ -20,6 +20,7 @@ import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@@ -41,6 +42,7 @@ import android.preference.PreferenceScreen;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextUtils.SimpleStringSplitter; import android.text.TextUtils.SimpleStringSplitter;
import android.util.Log;
import android.view.KeyCharacterMap; import android.view.KeyCharacterMap;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
@@ -66,6 +68,8 @@ import java.util.Set;
*/ */
public class AccessibilitySettings extends SettingsPreferenceFragment implements DialogCreatable, public class AccessibilitySettings extends SettingsPreferenceFragment implements DialogCreatable,
Preference.OnPreferenceChangeListener { Preference.OnPreferenceChangeListener {
private static final String LOG_TAG = "AccessibilitySettings";
private static final String DEFAULT_SCREENREADER_MARKET_LINK = private static final String DEFAULT_SCREENREADER_MARKET_LINK =
"market://search?q=pname:com.google.android.marvin.talkback"; "market://search?q=pname:com.google.android.marvin.talkback";
@@ -605,7 +609,12 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
Uri marketUri = Uri.parse(screenreaderMarketLink); Uri marketUri = Uri.parse(screenreaderMarketLink);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Intent marketIntent = new Intent(Intent.ACTION_VIEW,
marketUri); marketUri);
startActivity(marketIntent); try {
startActivity(marketIntent);
} catch (ActivityNotFoundException anfe) {
Log.w(LOG_TAG, "Couldn't start play store activity",
anfe);
}
} }
}) })
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)

View File

@@ -27,7 +27,10 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.Loader; import android.content.Loader;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.database.DataSetObserver; import android.database.DataSetObserver;
@@ -275,9 +278,14 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
if (!TextUtils.isEmpty(settingsTitle) && !TextUtils.isEmpty(settingsComponentName)) { if (!TextUtils.isEmpty(settingsTitle) && !TextUtils.isEmpty(settingsComponentName)) {
Intent settingsIntent = new Intent(Intent.ACTION_MAIN).setComponent( Intent settingsIntent = new Intent(Intent.ACTION_MAIN).setComponent(
ComponentName.unflattenFromString(settingsComponentName.toString())); ComponentName.unflattenFromString(settingsComponentName.toString()));
if (!getPackageManager().queryIntentActivities(settingsIntent, 0).isEmpty()) { List<ResolveInfo> resolvedActivities = getPackageManager().queryIntentActivities(
mSettingsTitle = settingsTitle; settingsIntent, 0);
mSettingsIntent = settingsIntent; 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)) { && !TextUtils.isEmpty(addPrintersComponentName)) {
Intent addPritnersIntent = new Intent(Intent.ACTION_MAIN).setComponent( Intent addPritnersIntent = new Intent(Intent.ACTION_MAIN).setComponent(
ComponentName.unflattenFromString(addPrintersComponentName.toString())); ComponentName.unflattenFromString(addPrintersComponentName.toString()));
if (!getPackageManager().queryIntentActivities(addPritnersIntent, 0).isEmpty()) { List<ResolveInfo> resolvedActivities = getPackageManager().queryIntentActivities(
mAddPrintersTitle = addPrintersTitle; addPritnersIntent, 0);
mAddPrintersIntent = addPritnersIntent; 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;
}
} }
} }