Android 9.0 如何在设置中隐藏sim和phone账户

涉及到修改的文件:

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

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

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

一、AccountDashboardFragment.java 的setListening方法中作如下修改:

 // Show up to 3 account types, ignore any null value
                    int accountToAdd = Math.min(3, types.length);

                    for (int i = 0; i < types.length && accountToAdd > 0; i++) {
                        //hpe add start
			if(types[i].equals("com.android.sim") || types[i].equals("com.android.localphone")){
			    Log.i("hpe-account","do not show, type= " + types[i]);
			    continue;
			}
                        //hpe add end
                        final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
                        if (TextUtils.isEmpty(label)) {
                            continue;
                        }
                        if (summary == null) {
                            summary = bidiFormatter.unicodeWrap(label);
                        } else {
			    
                            summary = mContext.getString(R.string.join_many_items_middle, summary,
                                    bidiFormatter.unicodeWrap(label));
                        }
                        accountToAdd--;
                    }

二、AccountPreferenceController.java 的getAccountTypePreferences方法中修改如下:

 // Add a preference row for each individual account
            for (Account account : accounts) {
                final AccountTypePreference preference =
                        preferenceToRemove.remove(AccountTypePreference.buildKey(account));
                if (preference != null) {
                    accountTypePreferences.add(preference);
                    continue;
                }
                final ArrayList<String> auths =
                    helper.getAuthoritiesForAccountType(account.type);
                if (!AccountRestrictionHelper.showAccount(mAuthorities, auths)) {
                    continue;
                }
                //hpe add start
		if(account.type.equals("com.android.sim") || account.type.equals("com.android.localphone")){
		    Log.i("hpe-account","do not show, account.type= " + account.type + ", titleResPackageName= " + titleResPackageName);
		    continue;
		}
                //hpe add end
                final Bundle fragmentArguments = new Bundle();
                fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT,
                    account);
                fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
                    userHandle);

三、ChooseAccountActivity.java的onAuthDescriptionsUpdated 方法中修改如下:

 if (addAccountPref && mAccountTypesFilter != null
                    && !mAccountTypesFilter.contains(accountType)) {
                addAccountPref = false;
            }
            if (addAccountPref) {
                //hpe modify start    
		if(accountType.equals("com.android.localphone") || accountType.equals("com.android.sim")){
	  	    Log.i("hpe-account","do not add to list to show on preference screen. " + "providerName = "+ providerName +", accountType= " + accountType);
		}else{
		    Log.i("hpe-account","providerName= " + providerName + ", accountType= " + accountType);
		    mProviderList.add(new ProviderEntry(providerName, accountType));	
		}
                //hpe modify end
            } else {
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log.v(TAG, "Skipped pref " + providerName + ": has no authority we need");
                }
            }

至此,设置中隐藏指定账户的功能已完成。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值