use of android.accounts.AuthenticatorDescription in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManageAccountsSettings method isSafeIntent.
/**
* Determines if the supplied Intent is safe. A safe intent is one that is
* will launch a exported=true activity or owned by the same uid as the
* authenticator supplying the intent.
*/
private boolean isSafeIntent(PackageManager pm, Intent intent) {
AuthenticatorDescription authDesc = mAuthenticatorHelper.getAccountTypeDescription(mAccountType);
ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
if (resolveInfo == null) {
return false;
}
ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo;
ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo;
try {
ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0);
return resolvedActivityInfo.exported || resolvedAppInfo.uid == authenticatorAppInf.uid;
} catch (NameNotFoundException e) {
Log.e(TAG, "Intent considered unsafe due to exception.", e);
return false;
}
}
use of android.accounts.AuthenticatorDescription in project ETSMobile-Android2 by ApplETS.
the class ContactAdderFragment method onAccountsUpdated.
/**
* Updates account list spinner when the list of Accounts on the system
* changes. Satisfies OnAccountsUpdateListener implementation.
*/
@Override
public void onAccountsUpdated(Account[] a) {
Log.i(TAG, "Account list update detected");
// Clear out any old data to prevent duplicates
mAccounts.clear();
// Get account data from system
final AuthenticatorDescription[] accountTypes = AccountManager.get(getActivity()).getAuthenticatorTypes();
// Populate tables
for (final Account element : a) {
// The user may have multiple accounts with the same name, so we
// need to construct a
// meaningful display name for each.
final String systemAccountType = element.type;
final AuthenticatorDescription ad = getAuthenticatorDescription(systemAccountType, accountTypes);
final AccountData data = new AccountData(element.name, ad);
mAccounts.add(data);
}
// Update the account spinner
mAccountAdapter.notifyDataSetChanged();
}
use of android.accounts.AuthenticatorDescription in project VirtualApp by asLody.
the class VAccountManagerService method parseAuthenticatorDescription.
private static AuthenticatorDescription parseAuthenticatorDescription(Resources resources, String packageName, AttributeSet attributeSet) {
TypedArray array = resources.obtainAttributes(attributeSet, R_Hide.styleable.AccountAuthenticator.get());
try {
String accountType = array.getString(R_Hide.styleable.AccountAuthenticator_accountType.get());
int label = array.getResourceId(R_Hide.styleable.AccountAuthenticator_label.get(), 0);
int icon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_icon.get(), 0);
int smallIcon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_smallIcon.get(), 0);
int accountPreferences = array.getResourceId(R_Hide.styleable.AccountAuthenticator_accountPreferences.get(), 0);
boolean customTokens = array.getBoolean(R_Hide.styleable.AccountAuthenticator_customTokens.get(), false);
if (TextUtils.isEmpty(accountType)) {
return null;
}
return new AuthenticatorDescription(accountType, packageName, label, icon, smallIcon, accountPreferences, customTokens);
} finally {
array.recycle();
}
}
use of android.accounts.AuthenticatorDescription in project VirtualApp by asLody.
the class VAccountManagerService method generateServicesMap.
private void generateServicesMap(List<ResolveInfo> services, Map<String, AuthenticatorInfo> map, IAccountParser accountParser) {
for (ResolveInfo info : services) {
XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo, AccountManager.AUTHENTICATOR_META_DATA_NAME);
if (parser != null) {
try {
AttributeSet attributeSet = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
// Nothing to do
}
if (AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME.equals(parser.getName())) {
AuthenticatorDescription desc = parseAuthenticatorDescription(accountParser.getResources(mContext, info.serviceInfo.applicationInfo), info.serviceInfo.packageName, attributeSet);
if (desc != null) {
map.put(desc.type, new AuthenticatorInfo(desc, info.serviceInfo));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of android.accounts.AuthenticatorDescription in project Android-AccountChooser by frakbot.
the class ChooseAccountTypeActivity method buildTypeToAuthDescriptionMap.
private void buildTypeToAuthDescriptionMap() {
for (AuthenticatorDescription desc : AccountManager.get(this).getAuthenticatorTypes()) {
String name = null;
Drawable icon = null;
try {
Context authContext = createPackageContext(desc.packageName, 0);
icon = authContext.getResources().getDrawable(desc.iconId);
final CharSequence sequence = authContext.getResources().getText(desc.labelId);
if (sequence != null) {
name = sequence.toString();
}
name = sequence.toString();
} catch (PackageManager.NameNotFoundException e) {
// Nothing we can do much here, just log
if (Log.isLoggable(TAG, Log.WARN)) {
Log.w(TAG, "No icon name for account type " + desc.type);
}
} catch (Resources.NotFoundException e) {
// Nothing we can do much here, just log
if (Log.isLoggable(TAG, Log.WARN)) {
Log.w(TAG, "No icon resource for account type " + desc.type);
}
}
AuthInfo authInfo = new AuthInfo(desc, name, icon);
mTypeToAuthenticatorInfo.put(desc.type, authInfo);
}
}
Aggregations