am 256e51d3
: Merge "Ignore print service settings activities if they are not exported." into klp-dev
* commit '256e51d328ac28594a6057de829190ffe4fa593f': Ignore print service settings activities if they are not exported.
This commit is contained in:
@@ -20,6 +20,7 @@ import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@@ -41,6 +42,7 @@ import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextUtils.SimpleStringSplitter;
|
||||
import android.util.Log;
|
||||
import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@@ -66,6 +68,8 @@ import java.util.Set;
|
||||
*/
|
||||
public class AccessibilitySettings extends SettingsPreferenceFragment implements DialogCreatable,
|
||||
Preference.OnPreferenceChangeListener {
|
||||
private static final String LOG_TAG = "AccessibilitySettings";
|
||||
|
||||
private static final String DEFAULT_SCREENREADER_MARKET_LINK =
|
||||
"market://search?q=pname:com.google.android.marvin.talkback";
|
||||
|
||||
@@ -605,7 +609,12 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
Uri marketUri = Uri.parse(screenreaderMarketLink);
|
||||
Intent marketIntent = new Intent(Intent.ACTION_VIEW,
|
||||
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)
|
||||
|
@@ -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