Remove "view" button for .apk attachments

We don't need to allow users to install applications directly from the email
client. Instead, application installation is a two step process; the user
must first save the APK and then find it on the filesystem.

If the user does not want to allow installation of applications from unknown
sources, we don't provide the ability to save.

NOTE: After saving, we still try to open the APK which generates an error
toast. We will be removing the auto-open-after-save feature in a separate CL.

bug 3351137

Change-Id: I0eb1bc8224a154792fe852757e4b23a3059f4392
This commit is contained in:
Todd Kennedy 2011-01-14 16:05:48 -08:00
parent d0e795af73
commit 91a1cf1db0
2 changed files with 22 additions and 0 deletions

View File

@ -136,6 +136,15 @@ public class Email extends Application {
"zip", "gz", "z", "tar", "tgz", "bz2",
};
/**
* Filename extensions of attachments that can be installed.
* Entries in this list are compared to the end of the lower-cased filename, so they must
* be lower case, and should not include a "."
*/
public static final String[] INSTALLABLE_ATTACHMENT_EXTENSIONS = new String[] {
"apk",
};
/**
* Specifies how many messages will be shown in a folder by default. This number is set
* on each new folder and can be incremented with "Load more messages..." by the

View File

@ -60,6 +60,7 @@ import android.os.Environment;
import android.os.Handler;
import android.provider.ContactsContract;
import android.provider.ContactsContract.QuickContact;
import android.provider.Settings;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.format.DateUtils;
@ -1172,6 +1173,18 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
attachmentInfo.allowSave = false;
}
// Check for installable attachments by filename extension; hide both buttons
extension = AttachmentProvider.getFilenameExtension(attachmentInfo.name);
if (!TextUtils.isEmpty(extension) &&
Utility.arrayContains(Email.INSTALLABLE_ATTACHMENT_EXTENSIONS, extension)) {
int sideloadEnabled;
sideloadEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0 /* sideload disabled */);
// TODO Allow showing an "install" button
attachmentInfo.allowView = false;
attachmentInfo.allowSave = (sideloadEnabled == 1);
}
// File size exceeded; Hide both buttons
// The size limit is overridden when on a wifi connection - any size is OK
if (attachmentInfo.size > Email.MAX_ATTACHMENT_DOWNLOAD_SIZE) {