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

@@ -38,6 +38,8 @@ import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen;
@@ -590,4 +592,17 @@ public class TetherSettings extends SettingsPreferenceFragment
public int getHelpResource() {
return R.string.help_url_tether;
}
/**
* Checks whether this screen will have anything to show on this device. This is called by
* the shortcut picker for Settings shortcuts (home screen widget).
* @param context a context object for getting a system service.
* @return whether Tether & portable hotspot should be shown in the shortcuts picker.
*/
public static boolean showInShortcuts(Context context) {
final ConnectivityManager cm =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
return !isSecondaryUser && cm.isTetheringSupported();
}
}