Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b5aa58d authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Don't show tether settings in shortcut picker"

parents 343bc617 394eaa21
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -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;
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -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();
    }
}