Merge pull request 'Some Bug Fix' (#59) from Fix_Security_Exception into master

Reviewed-on: https://codeberg.org/Schoumi/PeerTubeLive/pulls/59
This commit is contained in:
Schoumi 2024-05-28 23:36:23 +00:00
commit a804a36f9e
2 changed files with 29 additions and 8 deletions

View File

@ -148,17 +148,10 @@ class StreamActivity : AppCompatActivity() {
if (intent?.action.equals(Intent.ACTION_SCREEN_OFF)){ if (intent?.action.equals(Intent.ACTION_SCREEN_OFF)){
setResult(LOCK) setResult(LOCK)
finish() finish()
} else if (intent?.action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)){
val reason = intent?.getStringExtra("reason")
if(reason.equals("homekey")){
setResult(BACKGROUND)
finish()
}
} }
} }
} }
val filter = IntentFilter(Intent.ACTION_SCREEN_OFF) val filter = IntentFilter(Intent.ACTION_SCREEN_OFF)
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
registerReceiver(lockReceiver, filter) registerReceiver(lockReceiver, filter)
} }

View File

@ -21,6 +21,7 @@ import android.os.Bundle
import fr.mobdev.peertubelive.BuildConfig import fr.mobdev.peertubelive.BuildConfig
import fr.mobdev.peertubelive.R import fr.mobdev.peertubelive.R
import fr.mobdev.peertubelive.objects.OAuthData import fr.mobdev.peertubelive.objects.OAuthData
import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import java.io.BufferedReader import java.io.BufferedReader
import java.io.InputStream import java.io.InputStream
@ -177,6 +178,10 @@ class OAuthManager {
return return
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace() e.printStackTrace()
if (connection.errorStream == null) {
message.listener?.onError(InstanceManager.INTERNAL_ERROR, message.context.getString(R.string.unknwon_error))
return
}
inputStream = connection.errorStream inputStream = connection.errorStream
inError = true inError = true
} }
@ -184,7 +189,14 @@ class OAuthManager {
val response = readInputStream(inputStream) val response = readInputStream(inputStream)
if(!inError) { if(!inError) {
if(response.isNotEmpty()) { if(response.isNotEmpty()) {
val rootObj = JSONObject(response) val rootObj: JSONObject
try {
rootObj = JSONObject(response)
} catch (e: JSONException) {
message.listener?.onError(InstanceManager.INTERNAL_ERROR, message.context.getString(R.string.json_error))
return
}
val clientId = rootObj.getString("client_id") val clientId = rootObj.getString("client_id")
val clientSecret = rootObj.getString("client_secret") val clientSecret = rootObj.getString("client_secret")
@ -252,6 +264,10 @@ class OAuthManager {
return return
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace() e.printStackTrace()
if (connection.errorStream == null) {
message.listener?.onError(InstanceManager.INTERNAL_ERROR, message.context.getString(R.string.unknwon_error))
return
}
inputStream = connection.errorStream inputStream = connection.errorStream
inError = true inError = true
} }
@ -324,6 +340,10 @@ class OAuthManager {
return return
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace() e.printStackTrace()
if (connection.errorStream == null) {
message.listener?.onError(InstanceManager.INTERNAL_ERROR, message.context.getString(R.string.unknwon_error))
return
}
inputStream = connection.errorStream inputStream = connection.errorStream
inError = true inError = true
} }
@ -392,6 +412,10 @@ class OAuthManager {
return return
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace() e.printStackTrace()
if (connection.errorStream == null) {
message.listener?.onError(InstanceManager.INTERNAL_ERROR, message.context.getString(R.string.unknwon_error))
return
}
inError = true inError = true
inputStream = connection.errorStream inputStream = connection.errorStream
} }
@ -454,6 +478,10 @@ class OAuthManager {
return return
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace() e.printStackTrace()
if (connection.errorStream == null) {
message.listener?.onError(InstanceManager.INTERNAL_ERROR, message.context.getString(R.string.unknwon_error))
return
}
inputStream = connection.errorStream inputStream = connection.errorStream
inError = true inError = true
} }