-
Notifications
You must be signed in to change notification settings - Fork 13
Sense SMS observer implemented. #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ApurvJain123
wants to merge
1
commit into
master
Choose a base branch
from
smsobserve
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,48 @@ | ||
| /* AUTO-GENERATED FILE. DO NOT MODIFY. | ||
| * | ||
| * This class was automatically generated by the | ||
| * aapt tool from the resource data it found. It | ||
| * should not be modified by hand. | ||
| */ | ||
| package org.scorelab.sense; | ||
| public final class R { | ||
| public static final class attr { | ||
| } | ||
| public static final class drawable { | ||
| public static final int ic_launcher=0x7f020000; | ||
| public static final int icon=0x7f020001; | ||
| } | ||
| public static final class string { | ||
| public static final int app_name=0x7f030000; | ||
| } | ||
| public static final class style { | ||
| /** | ||
| Base application theme, dependent on API level. This theme is replaced | ||
| by AppBaseTheme from res/values-vXX/styles.xml on newer devices. | ||
| Theme customizations available in newer API levels can go in | ||
| res/values-vXX/styles.xml, while customizations related to | ||
| backward-compatibility can go here. | ||
| Base application theme for API 11+. This theme completely replaces | ||
| AppBaseTheme from res/values/styles.xml on API 11+ devices. | ||
| API 11 theme customizations can go here. | ||
| Base application theme for API 14+. This theme completely replaces | ||
| AppBaseTheme from BOTH res/values/styles.xml and | ||
| res/values-v11/styles.xml on API 14+ devices. | ||
| API 14 theme customizations can go here. | ||
| */ | ||
| public static final int AppBaseTheme=0x7f040000; | ||
| /** Application theme. | ||
| All customizations that are NOT specific to a particular API-level can go here. | ||
| */ | ||
| public static final int AppTheme=0x7f040001; | ||
| } | ||
| } | ||
| /* AUTO-GENERATED FILE. DO NOT MODIFY. | ||
| * | ||
| * This class was automatically generated by the | ||
| * aapt tool from the resource data it found. It | ||
| * should not be modified by hand. | ||
| */ | ||
|
|
||
| package org.scorelab.sense; | ||
|
|
||
| public final class R { | ||
| public static final class attr { | ||
| } | ||
| public static final class drawable { | ||
| public static final int ic_launcher=0x7f020000; | ||
| public static final int icon=0x7f020001; | ||
| } | ||
| public static final class string { | ||
| public static final int app_name=0x7f030000; | ||
| } | ||
| public static final class style { | ||
| /** | ||
| Base application theme, dependent on API level. This theme is replaced | ||
| by AppBaseTheme from res/values-vXX/styles.xml on newer devices. | ||
|
|
||
|
|
||
| Theme customizations available in newer API levels can go in | ||
| res/values-vXX/styles.xml, while customizations related to | ||
| backward-compatibility can go here. | ||
|
|
||
|
|
||
| Base application theme for API 11+. This theme completely replaces | ||
| AppBaseTheme from res/values/styles.xml on API 11+ devices. | ||
|
|
||
| API 11 theme customizations can go here. | ||
|
|
||
| Base application theme for API 14+. This theme completely replaces | ||
| AppBaseTheme from BOTH res/values/styles.xml and | ||
| res/values-v11/styles.xml on API 14+ devices. | ||
|
|
||
| API 14 theme customizations can go here. | ||
| */ | ||
| public static final int AppBaseTheme=0x7f040000; | ||
| /** Application theme. | ||
| All customizations that are NOT specific to a particular API-level can go here. | ||
| */ | ||
| public static final int AppTheme=0x7f040001; | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/org/scorelab/sense/dataCollector/sms/observe/SmsObserveData.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.scorelab.sense.dataCollector.sms.observe; | ||
|
|
||
| import org.scorelab.sense.annotation.Attributes; | ||
|
|
||
| public class SmsObserveData { | ||
| @Attributes(primaryKey = true) | ||
| public String toAddress; | ||
| public String messageLength; | ||
| public String messageTimestamp; | ||
| @Attributes(primaryKey = true) | ||
| public String timestamp; | ||
| public String collectTimestamp; | ||
|
|
||
| public SmsObserveData(String toAddress, String messageLength, String messageTimestamp){ | ||
|
|
||
| } | ||
| } |
60 changes: 60 additions & 0 deletions
60
src/org/scorelab/sense/dataCollector/sms/observe/SmsObserveDataReader.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package org.scorelab.sense.dataCollector.sms.observe; | ||
|
|
||
| import java.math.BigInteger; | ||
| import java.security.MessageDigest; | ||
| import java.security.NoSuchAlgorithmException; | ||
|
|
||
| import org.scorelab.sense.util.SenseLog; | ||
|
|
||
| import android.content.Context; | ||
| import android.database.ContentObserver; | ||
| import android.database.Cursor; | ||
| import android.net.Uri; | ||
| import android.os.Handler; | ||
|
|
||
| public class SmsObserveDataReader extends ContentObserver { | ||
|
|
||
| private MessageDigest sensMessageDigest; | ||
| Context context; | ||
|
|
||
| public SmsObserveDataReader(Handler handler) { | ||
| super(handler); | ||
| } | ||
|
|
||
| @Override | ||
| public void onChange(boolean selfChange) { | ||
| super.onChange(selfChange); | ||
|
|
||
| try { | ||
| sensMessageDigest = MessageDigest.getInstance("MD5"); | ||
| } catch (NoSuchAlgorithmException e) { | ||
| SenseLog.w("NoSuchAlgorithmException Throws"); | ||
| } | ||
|
|
||
| Uri sMSURI = Uri.parse("content://sms/"); | ||
|
|
||
| Cursor cursor = context.getContentResolver().query(sMSURI, null, null, | ||
| null, null); | ||
|
|
||
| while (cursor.moveToNext()) { | ||
|
|
||
| String toAddress = cursor.getString(cursor | ||
| .getColumnIndex("address")); | ||
| int messageLength = cursor.getString(cursor.getColumnIndex("body")) | ||
| .length(); | ||
| long messageTimestamp = cursor.getLong(cursor | ||
| .getColumnIndex("date")); | ||
|
|
||
| sensMessageDigest.reset(); | ||
| byte[] fromAdressDigest = sensMessageDigest.digest(toAddress | ||
| .getBytes()); | ||
| BigInteger bigIntegerOfFromAdress = new BigInteger(1, | ||
| fromAdressDigest); | ||
| String fromAddressHash = bigIntegerOfFromAdress.toString(); | ||
| } | ||
|
|
||
| ; | ||
|
|
||
| } | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have proper indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohk @rehrumesh