1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Don't use the "owner name" as default value for the email name

Get rid of Contacts.getOwnerName() and associated permissions.

Fixes issue 3331
This commit is contained in:
cketti 2011-05-14 04:53:17 +02:00
parent 59fe251318
commit 969e2d93fd
5 changed files with 6 additions and 63 deletions

View File

@ -18,10 +18,6 @@
<uses-permission android:name="android.permission.READ_CONTACTS"/> <uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/> <uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<!-- Needed to get the owner name which is used when the first mail account is created -->
<uses-permission android:name="android.permission.READ_OWNER_DATA"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<!-- Needed to mark a contact as contacted --> <!-- Needed to mark a contact as contacted -->
<uses-permission android:name="android.permission.WRITE_CONTACTS"/> <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
@ -319,7 +315,7 @@
android:enabled="true" android:enabled="true"
> >
<intent-filter> <intent-filter>
<!-- <!--
android.intent.action.MEDIA_MOUNTED android.intent.action.MEDIA_MOUNTED
* Broadcast Action: External media is present and mounted at its mount point. * Broadcast Action: External media is present and mounted at its mount point.
@ -329,9 +325,9 @@ android.intent.action.MEDIA_MOUNTED
--> -->
<action android:name="android.intent.action.MEDIA_MOUNTED"/> <action android:name="android.intent.action.MEDIA_MOUNTED"/>
<!-- <!--
MEDIA_EJECT and MEDIA_UNMOUNTED are not defined here: they have to be dynamically registered MEDIA_EJECT and MEDIA_UNMOUNTED are not defined here: they have to be dynamically registered
otherwise it would make K-9 start at the wrong time otherwise it would make K-9 start at the wrong time
--> -->

View File

@ -18,7 +18,6 @@ import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import com.fsck.k9.*; import com.fsck.k9.*;
import com.fsck.k9.activity.K9Activity; import com.fsck.k9.activity.K9Activity;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.Utility; import com.fsck.k9.helper.Utility;
import java.io.Serializable; import java.io.Serializable;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -134,17 +133,11 @@ public class AccountSetupBasics extends K9Activity
private String getOwnerName() { private String getOwnerName() {
String name = null; String name = null;
try { try {
name = Contacts.getInstance(this).getOwnerName(); name = getDefaultAccountName();
} catch (Exception e) { } catch (Exception e) {
Log.e(K9.LOG_TAG, "Could not get owner name, using default account name", e); Log.e(K9.LOG_TAG, "Could not get default account name", e);
}
if (name == null || name.length() == 0) {
try {
name = getDefaultAccountName();
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Could not get default account name", e);
}
} }
if (name == null) { if (name == null) {
name = ""; name = "";
} }

View File

@ -97,13 +97,6 @@ public abstract class Contacts {
mContentResolver = context.getContentResolver(); mContentResolver = context.getContentResolver();
} }
/**
* Get the name of the device's owner.
*
* @return The name of the owner if available. <tt>null</tt>, otherwise.
*/
public abstract String getOwnerName();
/** /**
* Start the activity to add information to an existing contact or add a * Start the activity to add information to an existing contact or add a
* new one. * new one.

View File

@ -85,27 +85,6 @@ public class ContactsSdk3_4 extends com.fsck.k9.helper.Contacts {
mContext.startActivity(contactIntent); mContext.startActivity(contactIntent);
} }
@Override
public String getOwnerName() {
String name = null;
final Cursor c = mContentResolver.query(
Uri.withAppendedPath(Contacts.People.CONTENT_URI, "owner"),
new String[] {Contacts.ContactMethods.DISPLAY_NAME},
null,
null,
null);
if (c != null) {
if (c.getCount() > 0) {
c.moveToFirst();
name = c.getString(0); // owner's display name
}
c.close();
}
return name;
}
@Override @Override
public boolean isInContacts(final String emailAddress) { public boolean isInContacts(final String emailAddress) {
boolean result = false; boolean result = false;

View File

@ -1,7 +1,5 @@
package com.fsck.k9.helper; package com.fsck.k9.helper;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
@ -87,22 +85,6 @@ public class ContactsSdk5 extends com.fsck.k9.helper.Contacts {
mContext.startActivity(contactIntent); mContext.startActivity(contactIntent);
} }
@Override
public String getOwnerName() {
String name = null;
// Get the name of the first account that has one.
Account[] accounts = AccountManager.get(mContext).getAccounts();
for (final Account account : accounts) {
if (account.name != null) {
name = account.name;
break;
}
}
return name;
}
@Override @Override
public boolean isInContacts(final String emailAddress) { public boolean isInContacts(final String emailAddress) {
boolean result = false; boolean result = false;