am 5e5b6b78: Merge "[FileEncap2] Remove mCanUpload instance variable"
* commit '5e5b6b78709b055ac5ed71153c0a696c63201a38': [FileEncap2] Remove mCanUpload instance variablemain
commit
dd5055862f
|
@ -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)) {
|
||||||
|
|
Loading…
Reference in New Issue