wakelocks
This commit is contained in:
parent
d6aebf45b8
commit
f5b0fba58d
7 changed files with 153 additions and 23 deletions
20
app/release/output-metadata.json
Normal file
20
app/release/output-metadata.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "asgardius.page.s3manager",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 10,
|
||||
"versionName": "0.1.8",
|
||||
"outputFile": "s3-manager-0.1.8-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
BIN
app/release/s3-manager-0.1.8-release.aab
Normal file
BIN
app/release/s3-manager-0.1.8-release.aab
Normal file
Binary file not shown.
BIN
app/release/s3-manager-0.1.8-release.apk
Normal file
BIN
app/release/s3-manager-0.1.8-release.apk
Normal file
Binary file not shown.
|
@ -7,6 +7,7 @@
|
|||
<uses-permission
|
||||
android:name="android.permission.READ_PHONE_STATE"
|
||||
tools:node="remove" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
|
|
@ -10,7 +10,9 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -37,28 +39,29 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
|
||||
public class Downloader extends AppCompatActivity {
|
||||
String username, password, endpoint, bucket, filekey, filename, prefix, location, fkey;
|
||||
boolean isfolder;
|
||||
int progress;
|
||||
Uri fileuri, folder, uri;
|
||||
EditText fprefix;
|
||||
String username, password, endpoint, bucket, filename, prefix, location;
|
||||
Uri fileuri;
|
||||
Region region;
|
||||
S3ClientOptions s3ClientOptions;
|
||||
AWSCredentials myCredentials;
|
||||
AmazonS3 s3client;
|
||||
ProgressBar simpleProgressBar;
|
||||
File dfile;
|
||||
Intent intent;
|
||||
Button fileDownload;
|
||||
Thread downloadFile;
|
||||
S3Object object;
|
||||
InputStream in;
|
||||
OutputStream out;
|
||||
private WifiManager.WifiLock mWifiLock;
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
private PowerManager powerManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_downloader);
|
||||
// create Wifi and wake locks
|
||||
mWifiLock = ((WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Transistor:wifi_lock");
|
||||
powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Transistor:wake_lock");
|
||||
filename = getIntent().getStringExtra("filename");
|
||||
endpoint = getIntent().getStringExtra("endpoint");
|
||||
username = getIntent().getStringExtra("username");
|
||||
|
@ -85,6 +88,15 @@ public class Downloader extends AppCompatActivity {
|
|||
simpleProgressBar.setVisibility(View.VISIBLE);
|
||||
fileDownload.setEnabled(false);
|
||||
fileDownload.setText(getResources().getString(R.string.download_in_progress));
|
||||
//Acquiring WakeLock and WifiLock if not held
|
||||
if (!mWifiLock.isHeld()) {
|
||||
mWifiLock.acquire();
|
||||
//System.out.println("WifiLock acquired");
|
||||
}
|
||||
if (!mWakeLock.isHeld()) {
|
||||
mWakeLock.acquire();
|
||||
//System.out.println("WakeLock acquired");
|
||||
}
|
||||
downloadFile = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
|
@ -100,6 +112,15 @@ public class Downloader extends AppCompatActivity {
|
|||
@Override
|
||||
public void run() {
|
||||
//simpleProgressBar.setProgress(100);
|
||||
//Releasing WifiLock and WakeLock if held
|
||||
if (mWifiLock.isHeld()) {
|
||||
mWifiLock.release();
|
||||
//System.out.println("WifiLock released");
|
||||
}
|
||||
if (mWakeLock.isHeld()) {
|
||||
mWakeLock.release();
|
||||
//System.out.println("WakeLock released");
|
||||
}
|
||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||
fileDownload.setText(getResources().getString(R.string.download_success));
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.download_success), Toast.LENGTH_SHORT).show();
|
||||
|
@ -115,6 +136,15 @@ public class Downloader extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
//Releasing WifiLock and WakeLock if held
|
||||
if (mWifiLock.isHeld()) {
|
||||
mWifiLock.release();
|
||||
//System.out.println("WifiLock released");
|
||||
}
|
||||
if (mWakeLock.isHeld()) {
|
||||
mWakeLock.release();
|
||||
//System.out.println("WakeLock released");
|
||||
}
|
||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||
fileDownload.setText(getResources().getString(R.string.download_failed));
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
@ -5,10 +5,13 @@ import static android.content.ContentValues.TAG;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
@ -57,11 +60,18 @@ public class Uploader extends AppCompatActivity {
|
|||
Button fileUpload;
|
||||
Thread uploadFile;
|
||||
private static final long MAX_SINGLE_PART_UPLOAD_BYTES = 5 * 1024 * 1024;
|
||||
private WifiManager.WifiLock mWifiLock;
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
private PowerManager powerManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_uploader);
|
||||
// create Wifi and wake locks
|
||||
mWifiLock = ((WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Transistor:wifi_lock");
|
||||
powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Transistor:wake_lock");
|
||||
endpoint = getIntent().getStringExtra("endpoint");
|
||||
username = getIntent().getStringExtra("username");
|
||||
password = getIntent().getStringExtra("password");
|
||||
|
@ -83,11 +93,6 @@ public class Uploader extends AppCompatActivity {
|
|||
//Toast.makeText(Uploader.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||
performFileSearch("Select file to upload");
|
||||
fprefix.setText(prefix);
|
||||
/*if (isfolder) {
|
||||
folder = uploadFolder();
|
||||
} else {
|
||||
file = uploadFile();
|
||||
}*/
|
||||
fileUpload.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -95,8 +100,15 @@ public class Uploader extends AppCompatActivity {
|
|||
if (fileuri == null && folder == null) {
|
||||
Toast.makeText(Uploader.this, getResources().getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
//Toast.makeText(CreateBucket.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||
//System.out.println(file.getPath());
|
||||
//Acquiring WakeLock and WifiLock if not held
|
||||
if (!mWifiLock.isHeld()) {
|
||||
mWifiLock.acquire();
|
||||
//System.out.println("WifiLock acquired");
|
||||
}
|
||||
if (!mWakeLock.isHeld()) {
|
||||
mWakeLock.acquire();
|
||||
//System.out.println("WakeLock acquired");
|
||||
}
|
||||
simpleProgressBar.setVisibility(View.VISIBLE);
|
||||
fileUpload.setEnabled(false);
|
||||
fileUpload.setText(getResources().getString(R.string.upload_in_progress));
|
||||
|
@ -125,6 +137,15 @@ public class Uploader extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
//Releasing WifiLock and WakeLock if held
|
||||
if (mWifiLock.isHeld()) {
|
||||
mWifiLock.release();
|
||||
//System.out.println("WifiLock released");
|
||||
}
|
||||
if (mWakeLock.isHeld()) {
|
||||
mWakeLock.release();
|
||||
//System.out.println("WakeLock released");
|
||||
}
|
||||
//simpleProgressBar.setProgress(100);
|
||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||
fileUpload.setText(getResources().getString(R.string.upload_success));
|
||||
|
@ -141,6 +162,15 @@ public class Uploader extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
//Releasing WifiLock and WakeLock if held
|
||||
if (mWifiLock.isHeld()) {
|
||||
mWifiLock.release();
|
||||
//System.out.println("WifiLock released");
|
||||
}
|
||||
if (mWakeLock.isHeld()) {
|
||||
mWakeLock.release();
|
||||
//System.out.println("WakeLock released");
|
||||
}
|
||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||
fileUpload.setEnabled(true);
|
||||
fileUpload.setText(getResources().getString(R.string.retry));
|
||||
|
|
|
@ -2,7 +2,10 @@ package asgardius.page.s3manager;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -21,10 +24,9 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
|
||||
// creating a variable for exoplayerview.
|
||||
protected StyledPlayerView playerView;
|
||||
|
||||
|
||||
// url of video which we are loading.
|
||||
//String videoURL = "https://video.asgardius.company/download/videos/41780585-a935-4d53-84c8-45ce97141231-480.mp4";
|
||||
private WifiManager.WifiLock mWifiLock;
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
private PowerManager powerManager;
|
||||
|
||||
ExoPlayer player;
|
||||
|
||||
|
@ -32,6 +34,10 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_video_player);
|
||||
// create Wifi and wake locks
|
||||
mWifiLock = ((WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Transistor:wifi_lock");
|
||||
powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Transistor:wake_lock");
|
||||
//Get media url
|
||||
String videoURL = getIntent().getStringExtra("video_url");
|
||||
playerView = findViewById(R.id.player_view);
|
||||
|
@ -57,12 +63,11 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
if (cause instanceof HttpDataSource.HttpDataSourceException) {
|
||||
// An HTTP error occurred.
|
||||
//System.out.println("Playback error F");
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_conn_fail), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.media_conn_fail), Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
// An HTTP error occurred.
|
||||
//System.out.println("Playback error F");
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_wrong_type), Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.media_wrong_type), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
player.release();
|
||||
finish();
|
||||
|
@ -70,6 +75,50 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
|
||||
|
||||
});
|
||||
|
||||
player.addListener(new Player.Listener() {
|
||||
@Override
|
||||
public void onPlaybackStateChanged(@Player.State int state) {
|
||||
if (state == 3) {
|
||||
// Active playback.
|
||||
//Acquiring WakeLock and WifiLock if not held
|
||||
if (!mWifiLock.isHeld()) {
|
||||
mWifiLock.acquire();
|
||||
//System.out.println("WifiLock acquired");
|
||||
}
|
||||
if (!mWakeLock.isHeld()) {
|
||||
mWakeLock.acquire();
|
||||
//System.out.println("WakeLock acquired");
|
||||
}
|
||||
} else if (state == 2) {
|
||||
// Buffering.
|
||||
//Acquiring WakeLock and WifiLock if not held
|
||||
if (!mWifiLock.isHeld()) {
|
||||
mWifiLock.acquire();
|
||||
//System.out.println("WifiLock acquired");
|
||||
}
|
||||
if (!mWakeLock.isHeld()) {
|
||||
mWakeLock.acquire();
|
||||
//System.out.println("WakeLock acquired");
|
||||
}
|
||||
} else {
|
||||
//Player inactive
|
||||
//Releasing WifiLock and WakeLock if held
|
||||
if (mWifiLock.isHeld()) {
|
||||
mWifiLock.release();
|
||||
//System.out.println("WifiLock released");
|
||||
}
|
||||
if (mWakeLock.isHeld()) {
|
||||
mWakeLock.release();
|
||||
//System.out.println("WakeLock released");
|
||||
}
|
||||
// Not playing because playback is paused, ended, suppressed, or the player
|
||||
// is buffering, stopped or failed. Check player.getPlayWhenReady,
|
||||
// player.getPlaybackState, player.getPlaybackSuppressionReason and
|
||||
// player.getPlaybackError for details.
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue