涉及到修改的文件:
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");
}
}
至此,设置中隐藏指定账户的功能已完成。