Skip to content

Commit

Permalink
Merge pull request #5 from simonchius/Simon
Browse files Browse the repository at this point in the history
SIM slot detection is added
  • Loading branch information
Simon Chius authored Jul 4, 2019
2 parents 0085432 + 8b0d0dc commit c9dbd2e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ Sample Payload :
"msg": "Play Rummy FREE! Rs.5,000 as Welcome Bonus http://1kx.in/KEbVbX Win Real Money!",
"sourceNumber": "BT-WINWIN",
"timestamp": 1561098395896,
"userIdentifier" : "Simon-Android-S8_plus:987654526367"
"userIdentifier" : "Simon-Android-S8_plus:987654526367",
"simSlot": "SIM 2",
},
{
"id": "8380",
"msg": "Dear Customer, This Number Available In Vodafone Postpaid For Instant Activation Dial",
"sourceNumber": "+919876543210",
"timestamp": 1561095428631,
"userIdentifier" : "Simon-Android-S8_plus:987654526367"
"userIdentifier" : "Simon-Android-S8_plus:987654526367",
"simSlot": "SIM 1",
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SMSHelper {
val lUserIdentifier = PreferenceHelper(mContext).getPreference().getString(PreferenceHelper.USER_IDENTIFIER,"")
var lSmsList = mutableListOf<SMS>()
val lSMSUri : Uri = Uri.parse("content://sms/inbox")
val lCursor: Cursor = mContext.contentResolver.query(lSMSUri, arrayOf("_id","body","address","date"), "date > $mLastMessageTime", null, "date DESC")
val lCursor: Cursor = mContext.contentResolver.query(lSMSUri, arrayOf("_id","body","address","date","sim_slot"), "date > $mLastMessageTime", null, "date DESC")
if(lCursor.moveToFirst()){
do{
lSmsList.add(
Expand All @@ -20,7 +20,8 @@ class SMSHelper {
lCursor.getString(1),
lCursor.getString(2),
lCursor.getLong(3),
lUserIdentifier
lUserIdentifier,
"SIM ${lCursor.getInt(4)+1}"
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package com.simonmisles.powerbackup.Http

import com.simonmisles.powerbackup.BuildConfig
import java.io.*
import java.lang.StringBuilder
import java.net.HttpURLConnection
import java.net.HttpURLConnection.HTTP_CREATED
import java.net.HttpURLConnection.HTTP_OK
import java.net.URL

class HttpURLFetcher(val mUserAgent: String = "Android : ${BuildConfig.APPLICATION_ID} ${BuildConfig.VERSION_NAME} Version ${BuildConfig.VERSION_CODE}") {
val TAG = "HttpURLFetcher"
fun doFetch(mRequest: HttpRequest): HttpResponse {

val lTimeOut = if (mRequest.mTimeOut > 0) mRequest.mTimeOut else 30
Expand Down Expand Up @@ -35,22 +38,22 @@ class HttpURLFetcher(val mUserAgent: String = "Android : ${BuildConfig.APPLICATI
}
}

var lResponseStringBuffer: StringBuffer? = null
var lResponseStringBuffer: StringBuilder? = null
var lInputStream: InputStream? = null
val lResponseCode = lHttpURLConnection.responseCode

try {
lInputStream = lHttpURLConnection.inputStream
} catch (ioe: IOException) {
if (lResponseCode != HTTP_OK) {
if (lResponseCode != HTTP_OK && lResponseCode != HTTP_CREATED) {
lInputStream = lHttpURLConnection.errorStream
}
}

if (lInputStream != null) {
lResponseStringBuffer = StringBuffer()
lResponseStringBuffer = StringBuilder()
val mReader = BufferedReader(InputStreamReader(lInputStream))
mReader.readLine().forEach { lResponseStringBuffer.append(it) }
mReader.forEachLine { lResponseStringBuffer.append(it) }
lInputStream.close()
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/simonmisles/powerbackup/Pojo/SMS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ data class SMS(

var timestamp: Long,

val userIdentifier: String
val userIdentifier: String,

val simSlot: String
) : Serializable,
Comparable<SMS> {
override fun compareTo(other: SMS): Int {
Expand Down

0 comments on commit c9dbd2e

Please sign in to comment.