Don't show tether settings in shortcut picker

On devices that don't have tethering options, don't allow user
to create a shortcut to the tether settings.

Bug: 6865610
Change-Id: I2ebbd6ef98391ef3fe74130570bd9b70108a2aa9
This commit is contained in:
Amith Yamasani
2013-06-11 11:04:44 -07:00
parent ee53d98c93
commit 394eaa21e7
2 changed files with 38 additions and 0 deletions

View File

@@ -18,10 +18,15 @@ package com.android.settings;
import android.app.LauncherActivity;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import com.android.settings.Settings.TetherSettingsActivity;
import java.util.List;
public class CreateShortcut extends LauncherActivity {
@Override
@@ -49,4 +54,22 @@ public class CreateShortcut extends LauncherActivity {
protected boolean onEvaluateShowIcons() {
return false;
}
/**
* Perform query on package manager for list items. The default
* implementation queries for activities.
*/
protected List<ResolveInfo> onQueryPackageManager(Intent queryIntent) {
List<ResolveInfo> activities = super.onQueryPackageManager(queryIntent);
if (activities == null) return null;
for (int i = activities.size() - 1; i >= 0; i--) {
ResolveInfo info = activities.get(i);
if (info.activityInfo.name.endsWith(TetherSettingsActivity.class.getSimpleName())) {
if (!TetherSettings.showInShortcuts(this)) {
activities.remove(i);
}
}
}
return activities;
}
}