去除Duo Preview(设备在添加帐户设置中点击"Duo预览"选项,提示不支持)

[Test Steps]
1. Go to Settings > Accounts > Add Account > click on "Duo Preview".
转到设置>帐户>添加帐户>单击"Duo预览"。
2. Observe pop-up "Duo Preview accounts aren't supported yet".
观察弹出窗口"还不支持Duo预览帐户"
[Actual results]Device gives "Duo Preview" option in Add Account settings which is not supported/设备在添加帐户设置中提供"Duo预览"选项,但不支持此选项
[Expected results] No such option should be shown in settings which is not supported in the device.不应在设备不支持的设置中显示此选项。

 

在Settings accounts相关类ChooseAccountActivity.java中添加过滤,增加对"com.android.sim","com.android.localphone","com.google.android.gms.matchstick" 的过滤,在其onAuthDescriptionsUpdated() 中addAccountPref = false;如此则不会走mProviderList.add(new ProviderEntry(providerName, accountType));

packages/apps/Settings/src/com/android/settings/accounts/ChooseAccountActivity.java

public class ChooseAccountActivity extends SettingsPreferenceFragment {

    private static final String TAG = "ChooseAccountActivity";

    private static final String TAG_ACCOUNTTYPE = "com.android.sim";

    private static final String PHONE_ACCOUNTTYPE = "com.android.localphone";

    private static final String DUO_PRE_ACCOUNTTYPE = "com.google.android.gms.matchstick";

    private EnterprisePrivacyFeatureProvider mFeatureProvider;

    private FooterPreference mEnterpriseDisclosurePreference = null;

扫描二维码关注公众号,回复: 10849618 查看本文章

 

    private String[] mAuthorities;

    private PreferenceGroup mAddAccountGroup;

    private final ArrayList<ProviderEntry> mProviderList = new ArrayList<ProviderEntry>();

    public HashSet<String> mAccountTypesFilter;

    private AuthenticatorDescription[] mAuthDescs;

    private HashMap<String, ArrayList<String>> mAccountTypeToAuthorities = null;

    private Map<String, AuthenticatorDescription> mTypeToAuthDescription

            = new HashMap<String, AuthenticatorDescription>();

    // The UserHandle of the user we are choosing an account for

    private UserHandle mUserHandle;

    private UserManager mUm;

 

    private static class ProviderEntry implements Comparable<ProviderEntry> {

        private final CharSequence name;

        private final String type;

        ProviderEntry(CharSequence providerName, String accountType) {

            name = providerName;

            type = accountType;

        }

 

        public int compareTo(ProviderEntry another) {

            if (name == null) {

                return -1;

            }

            if (another.name == null) {

                return +1;

            }

            return CharSequences.compareToIgnoreCase(name, another.name);

        }

    }

 

    @Override

    public int getMetricsCategory() {

        return MetricsEvent.ACCOUNTS_CHOOSE_ACCOUNT_ACTIVITY;

    }

 

    @Override

    public void onCreate(Bundle icicle) {

        super.onCreate(icicle);

 

        final Activity activity = getActivity();

        mFeatureProvider = FeatureFactory.getFactory(activity)

                .getEnterprisePrivacyFeatureProvider(activity);

 

        addPreferencesFromResource(R.xml.add_account_settings);

        mAuthorities = getIntent().getStringArrayExtra(

                AccountPreferenceBase.AUTHORITIES_FILTER_KEY);

        String[] accountTypesFilter = getIntent().getStringArrayExtra(

                AccountPreferenceBase.ACCOUNT_TYPES_FILTER_KEY);

        if (accountTypesFilter != null) {

            mAccountTypesFilter = new HashSet<String>();

            for (String accountType : accountTypesFilter) {

                mAccountTypesFilter.add(accountType);

            }

        }

        mAddAccountGroup = getPreferenceScreen();

        mUm = UserManager.get(getContext());

        mUserHandle = Utils.getSecureTargetUser(getActivity().getActivityToken(), mUm,

                null /* arguments */, getIntent().getExtras());

        updateAuthDescriptions();

    }

 

    /**

     * Updates provider icons. Subclasses should call this in onCreate()

     * and update any UI that depends on AuthenticatorDescriptions in onAuthDescriptionsUpdated().

     */

    private void updateAuthDescriptions() {

        mAuthDescs = AccountManager.get(getContext()).getAuthenticatorTypesAsUser(

                mUserHandle.getIdentifier());

        for (int i = 0; i < mAuthDescs.length; i++) {

            mTypeToAuthDescription.put(mAuthDescs[i].type, mAuthDescs[i]);

        }

        onAuthDescriptionsUpdated();

    }

 

    private void onAuthDescriptionsUpdated() {

        // Create list of providers to show on preference screen

        for (int i = 0; i < mAuthDescs.length; i++) {

            String accountType = mAuthDescs[i].type;

            CharSequence providerName = getLabelForType(accountType);

 

            // Skip preferences for authorities not specified. If no authorities specified,

            // then include them all.

            ArrayList<String> accountAuths = getAuthoritiesForAccountType(accountType);

            boolean addAccountPref = true;

            if (mAuthorities != null && mAuthorities.length > 0 && accountAuths != null) {

                addAccountPref = false;

                for (int k = 0; k < mAuthorities.length; k++) {

                    if (accountAuths.contains(mAuthorities[k])) {

                        addAccountPref = true;

                        break;

                    }

                }

            }

            if (addAccountPref && mAccountTypesFilter != null

                    && !mAccountTypesFilter.contains(accountType)

                    || TAG_ACCOUNTTYPE.equals(accountType)

                    || PHONE_ACCOUNTTYPE.equals(accountType)

                    || DUO_PRE_ACCOUNTTYPE.equals(accountType)) {

                addAccountPref = false;

            }

            if (addAccountPref) {

                mProviderList.add(new ProviderEntry(providerName, accountType));

            } else {

                if (Log.isLoggable(TAG, Log.VERBOSE)) {

                    Log.v(TAG, "Skipped pref " + providerName + ": has no authority we need");

                }

            }

 

        }

 

附录另一个bug,将system_dashboard_summary字串显示更改为:语言、时间、备份

packages/apps/Settings/res/values/strings.xml

    <!-- Summary text for system preference tile, showing important setting items under system setting [CHAR LIMIT=NONE]-->

    <string name="system_dashboard_summary">Languages, time, backup, updates</string>

修改为:

    <string name="system_dashboard_summary">Languages, time, backup</string>

 

packages/apps/Settings/res/values-zh-rCN/strings.xml

    <string name="system_dashboard_summary" msgid="5797743225249766685">"语言、时间、备份、更新"</string>

修改为:

    <string name="system_dashboard_summary" msgid="5797743225249766685">"语言、时间、备份"</string>

发布了31 篇原创文章 · 获赞 6 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/u012824529/article/details/103777029