[FileEncap2] Remove mCanUpload instance variable

Change-Id: I62a100c4d73bb64a14a7994f7dd9af7b6946d064
This commit is contained in:
Kurt Partridge 2013-02-27 12:13:42 -08:00
parent 347b2ebebf
commit 466e665b3c

View file

@ -56,7 +56,6 @@ public final class UploaderService extends IntentService {
private static final int BUF_SIZE = 1024 * 8; private static final int BUF_SIZE = 1024 * 8;
protected static final int TIMEOUT_IN_MS = 1000 * 4; protected static final int TIMEOUT_IN_MS = 1000 * 4;
private boolean mCanUpload;
private File mFilesDir; private File mFilesDir;
private URL mUrl; private URL mUrl;
@ -68,7 +67,6 @@ public final class UploaderService extends IntentService {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
mCanUpload = false;
mFilesDir = null; mFilesDir = null;
mUrl = null; mUrl = null;
@ -83,12 +81,15 @@ public final class UploaderService extends IntentService {
} }
mFilesDir = getFilesDir(); mFilesDir = getFilesDir();
mUrl = new URL(urlString); mUrl = new URL(urlString);
mCanUpload = true;
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public boolean isPossibleToUpload() {
return hasUploadingPermission() && mUrl != null && !IS_INHIBITING_AUTO_UPLOAD;
}
private boolean hasUploadingPermission() { private boolean hasUploadingPermission() {
final PackageManager packageManager = getPackageManager(); final PackageManager packageManager = getPackageManager();
return packageManager.checkPermission(Manifest.permission.INTERNET, return packageManager.checkPermission(Manifest.permission.INTERNET,
@ -97,9 +98,7 @@ public final class UploaderService extends IntentService {
@Override @Override
protected void onHandleIntent(Intent intent) { protected void onHandleIntent(Intent intent) {
if (!mCanUpload) { if (!isPossibleToUpload()) return;
return;
}
boolean isUploadingUnconditionally = false; boolean isUploadingUnconditionally = false;
Bundle bundle = intent.getExtras(); Bundle bundle = intent.getExtras();
if (bundle != null && bundle.containsKey(EXTRA_UPLOAD_UNCONDITIONALLY)) { if (bundle != null && bundle.containsKey(EXTRA_UPLOAD_UNCONDITIONALLY)) {