Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SMSWakeUpService extends SMSIntentService
- {
- private static final int MSG_DELETE_SMS = 5291453;
- private static final String TAG = "SMSWakupService";
- private Context context;
- final Handler hndSMSDelete = new Handler()
- {
- int retVal;
- public void handleMessage(Message paramMessage)
- {
- if (paramMessage.what == 5291453)
- {
- Uri localUri = Uri.parse("content://sms/");
- String str = (String)paramMessage.obj;
- Log.d("SMSWakupService", "SMS message proccessed.. deleting from inbox sms=" + str);
- ContentResolver localContentResolver = SMSWakeUpService.this.context.getContentResolver();
- String[] arrayOfString = new String[1];
- arrayOfString[0] = str;
- this.retVal = localContentResolver.delete(localUri, "body like ?", arrayOfString);
- if (this.retVal < 1)
- Log.w("SMSWakupService", "Could NOT delete sms from inbox =" + str);
- }
- }
- };
- private SMSDBAdapter smsDbAdapter;
- public SMSWakeUpService()
- {
- super("SMSWakupService");
- }
- protected void checkSMSPrefix(Intent paramIntent)
- {
- String str1 = paramIntent.getStringExtra("SMS_FILTERING");
- if ((str1 != null) && (str1.contains(":")))
- {
- StringTokenizer localStringTokenizer = new StringTokenizer(str1, ":");
- while (true)
- {
- String str3;
- try
- {
- String str2 = localStringTokenizer.nextToken();
- Log.d("SMSWakupService", "smsPrefix = " + str2);
- if (!str2.startsWith("//VZW"))
- break;
- str3 = str2 + ":";
- if (this.smsDbAdapter != null)
- continue;
- Log.e("SMSWakupService", "smsDbAdapter == NULL");
- SQLiteDatabase localSQLiteDatabase = this.smsDbAdapter.openDBforRead();
- Cursor localCursor = null;
- if (localSQLiteDatabase == null)
- continue;
- localCursor = this.smsDbAdapter.getAppNameBySmsPrefix(str3, localSQLiteDatabase);
- if (localCursor != null)
- continue;
- Log.w("SMSWakupService", "curAppNames == null ");
- if ((localCursor != null) && (localCursor.getCount() > 0))
- {
- String str4 = str3 + "%";
- this.hndSMSDelete.sendMessageDelayed(this.hndSMSDelete.obtainMessage(5291453, str4), 2000L);
- if (localCursor.moveToNext())
- continue;
- if (localCursor == null)
- break;
- localCursor.close();
- this.smsDbAdapter.closeDBforRead(localSQLiteDatabase);
- break;
- String str5 = localCursor.getString(2);
- try
- {
- Intent localIntent = new Intent(str5);
- localIntent.putExtra("WAKE_UP_SMS_MSG", str1);
- Log.d("SMSWakupService", "sending broadcast to:" + str5);
- this.context.sendBroadcast(localIntent);
- }
- catch (Exception localException)
- {
- Log.e("SMSWakupService", localException.getMessage());
- }
- continue;
- }
- }
- catch (NoSuchElementException localNoSuchElementException)
- {
- Log.w("SMSWakupService", "Invalid SMS");
- }
- Log.d("SMSWakupService", "No matching prefix found: smsPrefix = " + str3);
- }
- }
- }
- public void onCreate()
- {
- this.context = getApplicationContext();
- this.smsDbAdapter = new SMSDBAdapter(this.context);
- super.onCreate();
- }
- public void onDestroy()
- {
- this.smsDbAdapter.close();
- super.onDestroy();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement