├── README.md └── app └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── gsdroid │ └── smsantitheft │ ├── Background.java │ ├── Client.java │ ├── DatabaseHelper.java │ ├── DeviceAdmin.java │ ├── GCMListenerService.java │ ├── MainMenu.java │ ├── Message.java │ ├── MyInstanceIDListenerService.java │ ├── Receiver.java │ ├── SmsReceiver.java │ └── Welcome.java └── res ├── drawable └── lock.png ├── layout ├── app_help.xml ├── client_app.xml ├── home_menu.xml ├── item_layout.xml ├── list.xml ├── login_app.xml ├── main_menu.xml ├── settings.xml ├── side_menu_layout.xml ├── test.xml ├── welcome.xml ├── welcome_device_admin.xml ├── welcome_gcm.xml ├── welcome_password.xml └── welcome_phone.xml ├── mipmap-hdpi ├── ic_account_box_black_18dp.png ├── ic_cloud_done_white_24dp.png ├── ic_contact_phone_white_24dp.png ├── ic_fingerprint_white_24dp.png ├── ic_format_paint_black_18dp.png ├── ic_help_outline_white_24dp.png ├── ic_launcher.png ├── ic_library_books_white_24dp.png ├── ic_security_white_24dp.png ├── ic_settings_white_24dp.png ├── ic_textsms_white_24dp.png └── icon.png ├── mipmap-mdpi ├── ic_account_box_black_18dp.png ├── ic_cloud_done_white_24dp.png ├── ic_contact_phone_white_24dp.png ├── ic_fingerprint_white_24dp.png ├── ic_format_paint_black_18dp.png ├── ic_help_outline_white_24dp.png ├── ic_launcher.png ├── ic_library_books_white_24dp.png ├── ic_security_white_24dp.png ├── ic_settings_white_24dp.png ├── ic_textsms_white_24dp.png └── icon.png ├── mipmap-xhdpi ├── ic_account_box_black_18dp.png ├── ic_cloud_done_white_24dp.png ├── ic_contact_phone_white_24dp.png ├── ic_fingerprint_white_24dp.png ├── ic_format_paint_black_18dp.png ├── ic_help_outline_white_24dp.png ├── ic_launcher.png ├── ic_library_books_white_24dp.png ├── ic_security_white_24dp.png ├── ic_settings_white_24dp.png ├── ic_textsms_white_24dp.png └── icon.png ├── mipmap-xxhdpi ├── ic_account_box_black_18dp.png ├── ic_cloud_done_white_24dp.png ├── ic_contact_phone_white_24dp.png ├── ic_fingerprint_white_24dp.png ├── ic_format_paint_black_18dp.png ├── ic_help_outline_white_24dp.png ├── ic_launcher.png ├── ic_library_books_white_24dp.png ├── ic_security_white_24dp.png ├── ic_settings_white_24dp.png ├── ic_textsms_white_24dp.png └── icon.png ├── mipmap-xxxhdpi ├── ic_account_box_black_18dp.png ├── ic_cloud_done_white_24dp.png ├── ic_contact_phone_white_24dp.png ├── ic_fingerprint_white_24dp.png ├── ic_format_paint_black_18dp.png ├── ic_help_outline_white_24dp.png ├── ic_launcher.png ├── ic_library_books_white_24dp.png ├── ic_security_white_24dp.png ├── ic_settings_white_24dp.png ├── ic_textsms_white_24dp.png └── icon.png ├── values ├── colors.xml ├── strings.xml └── styles.xml └── xml └── device_admin_sample.xml /README.md: -------------------------------------------------------------------------------- 1 |

SMS_AntiTheft

2 | 3 |

4 | 5 |

6 | 7 | Android Application perform these commands without internet (SMS): 8 | 9 | * `[ LOCK ]` 10 | * `[ ERASE ]` 11 | * `[ Wifi_ON ]` 12 | * `[ Wifi_OFF ]` 13 | * `[ Wifi_Details ]` 14 | * `[ Location ]` 15 | * `[ Silent_Mode ]` 16 | * `[ Normal_Mode ]` 17 | * `[ Bluetooth_ON ]` 18 | * `[ Bluetooth_OFF ]` 19 | * `[ Phone_Number ]` 20 | * `[ Display_Lock ]` 21 | * `[ SIM_Serial_Number ]` 22 | 23 | App is published on `Google Play`. You can download it for free from the following link: 24 | 25 | ``` 26 | URL_COMING_SOON 27 | ``` 28 | 29 |

Inbuilt Client Manager

30 | 31 |

Inbuilt client manager encrypts the command into a HMAC format and sends the command to the lost device and makes it unreadable

32 | 33 |

Unencrypted Command (For Emergency Purpose)

34 | 35 |

As an alternative way, user can also send a command without encrypting, in case of emergency. This method doesn’t require the client manager tool or app to be installed on an alternative device.

36 | 37 |

Commands


38 | 39 | ``` 40 | smstheft password silent 41 | smstheft password normal 42 | smstheft password lockdisplay 43 | smstheft password wifion 44 | smstheft password wifioff 45 | smstheft password wifiname 46 | smstheft password bluetoothon 47 | smstheft password bluetoothoff 48 | smstheft password location 49 | smstheft password siminfo 50 | smstheft password phonenumber 51 | 52 | ``` 53 |

Screenshots

54 |

55 | 56 |

57 |
58 | 59 |
60 | 61 |
62 | 63 |
64 | 65 |
66 | 67 |
68 | 69 |
70 | 71 |
72 | 73 |
74 | 75 |
76 | 77 |
78 | 79 | 80 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 73 | 74 | 75 | 76 | 77 | 78 | 81 | 82 | 83 | 84 | 85 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/Background.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.Manifest; 4 | import android.annotation.TargetApi; 5 | import android.app.Activity; 6 | import android.app.KeyguardManager; 7 | import android.app.Notification; 8 | import android.app.NotificationManager; 9 | import android.app.PendingIntent; 10 | import android.app.Service; 11 | import android.app.admin.DevicePolicyManager; 12 | import android.bluetooth.BluetoothAdapter; 13 | import android.content.BroadcastReceiver; 14 | import android.content.ComponentName; 15 | import android.content.Context; 16 | import android.content.Intent; 17 | import android.content.IntentFilter; 18 | import android.content.SharedPreferences; 19 | import android.content.pm.PackageManager; 20 | import android.database.Cursor; 21 | import android.graphics.Bitmap; 22 | import android.graphics.PixelFormat; 23 | import android.location.Criteria; 24 | import android.location.Location; 25 | import android.location.LocationListener; 26 | import android.location.LocationManager; 27 | import android.media.AudioManager; 28 | import android.media.MediaPlayer; 29 | import android.media.Ringtone; 30 | import android.media.RingtoneManager; 31 | import android.net.ConnectivityManager; 32 | import android.net.Uri; 33 | import android.net.wifi.WifiInfo; 34 | import android.net.wifi.WifiManager; 35 | import android.os.BatteryManager; 36 | import android.os.Build; 37 | import android.os.Bundle; 38 | import android.os.Environment; 39 | import android.os.IBinder; 40 | import android.provider.Settings; 41 | import android.support.annotation.Nullable; 42 | import android.support.v4.app.ActivityCompat; 43 | import android.telephony.SmsManager; 44 | import android.telephony.TelephonyManager; 45 | import android.util.Log; 46 | import android.view.View; 47 | import android.view.WindowManager; 48 | 49 | import com.google.android.gms.common.ConnectionResult; 50 | import com.google.android.gms.common.api.GoogleApiClient; 51 | import com.google.android.gms.location.LocationServices; 52 | 53 | import java.io.File; 54 | import java.io.FileOutputStream; 55 | import java.lang.reflect.InvocationTargetException; 56 | import java.lang.reflect.Method; 57 | import java.text.SimpleDateFormat; 58 | import java.util.Calendar; 59 | import java.util.Date; 60 | 61 | public class Background extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { 62 | 63 | public DatabaseHelper myDb; 64 | protected DevicePolicyManager dPM; 65 | protected ComponentName cn; 66 | private GoogleApiClient mGoogleApiClient; 67 | private String phoneForLoc; 68 | private Context mContext; 69 | private String batPhone, pNuSend; 70 | 71 | @Nullable 72 | @Override 73 | public IBinder onBind(Intent intent) { 74 | return null; 75 | } 76 | 77 | @Override 78 | public int onStartCommand(Intent intent, int flags, int startId) { 79 | 80 | myDb = new DatabaseHelper(getBaseContext()); 81 | cn = new ComponentName(getBaseContext(), DeviceAdmin.class); 82 | dPM = (DevicePolicyManager) getBaseContext().getSystemService(DEVICE_POLICY_SERVICE); 83 | 84 | if (intent.getStringExtra("id").equals("phone")) { 85 | String phone = intent.getStringExtra("num"); 86 | String message = intent.getStringExtra("message"); 87 | handleSMS(phone, message); 88 | Message.deviceLog(getBaseContext(), "SMS from: " + phone + " , Message:" + message); 89 | } else if(intent.getStringExtra("id").equals("sms")){ 90 | String message = intent.getStringExtra("message"); 91 | String phone = intent.getStringExtra("phone"); 92 | if(!phone.equals("null")){ 93 | sendSMS(phone,message); 94 | } 95 | } 96 | return START_NOT_STICKY; 97 | } 98 | 99 | public void handleSMS(String phone, String message) { 100 | String storedPhone1 = Message.GetSP(getBaseContext(), "Welcome_Phone", "secure_phone1", "NO"); 101 | String storedPhone2 = Message.GetSP(getBaseContext(), "Welcome_Phone", "secure_phone2", "NO"); 102 | 103 | if (phone.equals(storedPhone1) || phone.equals(storedPhone2)) { 104 | String[] split = message.split(" "); 105 | if (split.length == 4 || split.length == 5) { 106 | if (split[0].equals(getBaseContext().getResources().getString(R.string.command_1))) { 107 | String password = Message.GetSP(getBaseContext(), "Welcome_Password", "secure_pass", "NOPASS"); 108 | if (!password.equals("NOPASS")) { 109 | if (split[1].equals(Message.md5(password+split[2]))) { 110 | switchExecute(split, phone); 111 | }else { 112 | Message.tag("Secure Password and Received Password doesn't match"); 113 | } 114 | }else { 115 | Message.tag("Secure password is not set"); 116 | } 117 | } 118 | }else if(split.length == 3) { 119 | if(split[0].equals("smstheft")){ 120 | String password = Message.GetSP(getBaseContext(), "Welcome_Password", "secure_pass", "NOPASS"); 121 | if (!password.equals("NOPASS")) { 122 | if(split[1].equals(password)){ 123 | String[] strings = {split[0],split[1],"2",split[2]}; 124 | switchExecute(strings,phone); 125 | }else { 126 | Message.tag("Unencrypted secure password and received password doesn't match"); 127 | } 128 | }else{ 129 | Message.tag("Secure password is not set"); 130 | } 131 | 132 | } else { 133 | Message.tag("Invalid base command : " + split[0]); 134 | } 135 | }else { 136 | Message.tag("Command length is inappropriate for ("+split[0]+")"); 137 | } 138 | 139 | Message.tag(message); 140 | } else { 141 | Message.tag("Incorrect Phone"); 142 | } 143 | } 144 | 145 | protected void switchExecute(String[] word, String phone) { 146 | 147 | switch (word[3]) { 148 | 149 | case "lock": 150 | if(word[0].equals("smsanti")) { 151 | if (dPM.isAdminActive(cn)) { 152 | if (!word[4].trim().isEmpty()) { 153 | if (word[4].length() >= 4 && word[4].length() <= 10) { 154 | dPM.resetPassword(word[4], DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY); 155 | dPM.lockNow(); 156 | sendSMS(phone, "Password Changed : " + word[4]); 157 | } else { 158 | Message.deviceLog(getBaseContext(), "lock password length should be 4-10"); 159 | sendSMS(phone, "lock password length should be 4-10"); 160 | } 161 | 162 | } else { 163 | Message.deviceLog(getBaseContext(), "Unauthorized lock password type"); 164 | sendSMS(phone, "Unauthorized lock password type"); 165 | } 166 | 167 | } else { 168 | NoActiveAdmin(); 169 | } 170 | } 171 | break; 172 | 173 | case "erase": 174 | if(word[0].equals("smsanti")) { 175 | if (dPM.isAdminActive(cn)) { 176 | dPM.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE); 177 | } else { 178 | NoActiveAdmin(); 179 | } 180 | } 181 | break; 182 | 183 | case "lockdisplay": 184 | if (dPM.isAdminActive(cn)) { 185 | dPM.lockNow(); 186 | } else { 187 | NoActiveAdmin(); 188 | } 189 | break; 190 | 191 | case "silent": 192 | AudioManager am = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE); 193 | am.setRingerMode(AudioManager.RINGER_MODE_SILENT); 194 | sendSMS(phone, "Activated SILENT"); 195 | break; 196 | 197 | case "normal": 198 | AudioManager am1 = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE); 199 | am1.setRingerMode(AudioManager.RINGER_MODE_NORMAL); 200 | sendSMS(phone, "Activated NORMAL"); 201 | break; 202 | 203 | case "wifion": 204 | WifiManager wifiManager = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); 205 | wifiManager.setWifiEnabled(true); 206 | wifiManager.startScan(); 207 | break; 208 | 209 | case "wifioff": 210 | WifiManager wifiManager1 = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); 211 | wifiManager1.setWifiEnabled(false); 212 | break; 213 | 214 | case "bluetoothon": 215 | BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 216 | if (bluetoothAdapter.isEnabled()) { 217 | bluetoothAdapter.enable(); 218 | } 219 | break; 220 | 221 | case "bluetoothoff": 222 | BluetoothAdapter bluetoothAdapter1 = BluetoothAdapter.getDefaultAdapter(); 223 | bluetoothAdapter1.disable(); 224 | break; 225 | 226 | case "wifiname": 227 | WifiManager wifiManager2 = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); 228 | WifiInfo info = wifiManager2.getConnectionInfo(); 229 | if (info != null) { 230 | sendSMS(phone, "Your device wifi ssid : " + info.getSSID()); 231 | } else { 232 | sendSMS(phone, "Wifi Info not available"); 233 | } 234 | break; 235 | 236 | case "location": 237 | if (mGoogleApiClient == null) { 238 | mGoogleApiClient = new GoogleApiClient.Builder(this) 239 | .addConnectionCallbacks(this) 240 | .addOnConnectionFailedListener(this) 241 | .addApi(LocationServices.API) 242 | .build(); 243 | } 244 | mGoogleApiClient.connect(); 245 | phoneForLoc = phone; 246 | break; 247 | 248 | case "siminfo": 249 | TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); 250 | sendSMS(phone, "SIM Serial Number : " + tm.getSimSerialNumber() + ", SIM Network Operator : " + tm.getSimOperatorName()); 251 | break; 252 | 253 | case "phonenumber": 254 | String pNu = getPhoneNumber(); 255 | 256 | if(pNu.equals("")){ 257 | pNuSend = "Not Defined"; 258 | }else{ 259 | pNuSend = pNu; 260 | } 261 | sendSMS(phone,"Device Phone number :"+pNuSend); 262 | break; 263 | 264 | case "battery": 265 | mContext = getApplicationContext(); 266 | IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); 267 | mContext.registerReceiver(mBroadcastReceiver, iFilter); 268 | batPhone = phone; 269 | break; 270 | } 271 | onDestroy(); 272 | } 273 | 274 | 275 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { 276 | @Override 277 | public void onReceive(Context context, Intent intent) { 278 | int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE,-1); 279 | int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL,-1); 280 | float percentage = level/ (float) scale; 281 | sendSMS(batPhone,"Device battery level : "+String.valueOf(Math.round(percentage*100)+"%")); 282 | mContext.unregisterReceiver(mBroadcastReceiver); 283 | } 284 | }; 285 | 286 | public String getPhoneNumber(){ 287 | TelephonyManager tm1 = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 288 | return tm1.getLine1Number(); 289 | } 290 | 291 | public void NoActiveAdmin() { 292 | Message.adminLog(getBaseContext(), "Device Admin is not active on your device"); 293 | } 294 | 295 | 296 | @Override 297 | public void onDestroy() { 298 | super.onDestroy(); 299 | Message.tag("onDestroy Service"); 300 | } 301 | 302 | public void sendSMS(String phoneNo, String msg) { 303 | 304 | if(Message.GetSP(getBaseContext(),"Settings","Response","ON").equals("ON")) { 305 | try { 306 | SmsManager smsManager = SmsManager.getDefault(); 307 | smsManager.sendTextMessage(phoneNo, null, msg, null, null); 308 | Message.tag("Message Sent"+phoneNo); 309 | 310 | } catch (Exception ex) { 311 | Message.tag(ex.getMessage()); 312 | ex.printStackTrace(); 313 | } 314 | Message.tag("Reply : " + msg); 315 | }else{ 316 | Message.deviceLog(getBaseContext(), "SMS Response couldn't be sent, Turn on the service in settings option"); 317 | } 318 | } 319 | 320 | @Override 321 | public void onConnected(@Nullable Bundle bundle) { 322 | 323 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 324 | return; 325 | } 326 | Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); 327 | if(location != null){ 328 | sendSMS(phoneForLoc,"http://www.google.com/maps/place/"+location.getLatitude()+","+location.getLongitude()+"/@"+ 329 | location.getLatitude()+","+location.getLongitude()+",17z"); 330 | }else{ 331 | sendSMS(phoneForLoc,"Location Not Available, but phone is active. Try other commands"); 332 | } 333 | 334 | mGoogleApiClient.disconnect(); 335 | } 336 | 337 | @Override 338 | public void onConnectionSuspended(int i) { 339 | 340 | } 341 | 342 | @Override 343 | public void onConnectionFailed(ConnectionResult connectionResult) { 344 | Message.tag("Location Connection Failed"); 345 | } 346 | 347 | } 348 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/Client.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.app.Activity; 4 | import android.database.Cursor; 5 | import android.graphics.Typeface; 6 | import android.net.Uri; 7 | import android.os.Bundle; 8 | import android.support.v7.app.ActionBarActivity; 9 | import android.telephony.SmsManager; 10 | import android.util.Log; 11 | import android.view.View; 12 | import android.widget.AdapterView; 13 | import android.widget.ArrayAdapter; 14 | import android.widget.Button; 15 | import android.widget.EditText; 16 | import android.widget.Spinner; 17 | import android.widget.TextView; 18 | 19 | import java.math.BigInteger; 20 | import java.security.SecureRandom; 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | 25 | public class Client extends ActionBarActivity { 26 | 27 | private Button send; 28 | private TextView info, query; 29 | private EditText phone, password, optional; 30 | private Typeface tf; 31 | private String status; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.client_app); 37 | final Spinner spinner = (Spinner) findViewById(R.id.spinner); 38 | tf = Typeface.createFromAsset(getAssets(),"font.ttf"); 39 | phone = (EditText)findViewById(R.id.phone); 40 | password = (EditText)findViewById(R.id.password); 41 | optional = (EditText)findViewById(R.id.optional); 42 | info = (TextView)findViewById(R.id.client_info); 43 | query = (TextView)findViewById(R.id.client_query); 44 | send = (Button)findViewById(R.id.client_final_button); 45 | info.setTypeface(tf); 46 | query.setTypeface(tf); 47 | phone.setTypeface(tf); 48 | password.setTypeface(tf); 49 | optional.setTypeface(tf); 50 | optional.setVisibility(View.INVISIBLE); 51 | send.setTypeface(tf); 52 | 53 | // Spinner Drop down elements 54 | List categories = new ArrayList(); 55 | categories.add("Select Any Option"); 56 | categories.add("Lock"); 57 | categories.add("Erase"); 58 | categories.add("Display Lock"); 59 | categories.add("Silent Mode"); 60 | categories.add("Normal Mode"); 61 | categories.add("Wifi ON"); 62 | categories.add("Wifi OFF"); 63 | categories.add("Wifi Details"); 64 | categories.add("Bluetooth ON"); 65 | categories.add("Bluetooth OFF"); 66 | categories.add("Location"); 67 | categories.add("SIM Serial No"); 68 | categories.add("Phone Number"); 69 | 70 | // Creating adapter for spinner 71 | ArrayAdapter dataAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, categories); 72 | 73 | // Drop down layout style - list view with radio button 74 | dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 75 | 76 | // attaching data adapter to spinner 77 | spinner.setAdapter(dataAdapter); 78 | spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 79 | @Override 80 | public void onItemSelected(AdapterView parent, View view, int position, long id) { 81 | String item = parent.getItemAtPosition(position).toString(); 82 | 83 | switch (position) { 84 | case 1: 85 | status = "lock"; 86 | optional.setVisibility(View.VISIBLE); 87 | optional.setHint("Enter new password to lock"); 88 | 89 | break; 90 | 91 | case 2: 92 | status = "erase"; 93 | optional.setVisibility(View.INVISIBLE); 94 | break; 95 | 96 | case 3: 97 | status = "lockdisplay"; 98 | optional.setVisibility(View.INVISIBLE); 99 | break; 100 | 101 | case 4: 102 | status = "silent"; 103 | optional.setVisibility(View.INVISIBLE); 104 | break; 105 | 106 | case 5: 107 | status = "normal"; 108 | optional.setVisibility(View.INVISIBLE); 109 | break; 110 | 111 | case 6: 112 | status = "wifion"; 113 | optional.setVisibility(View.INVISIBLE); 114 | break; 115 | 116 | case 7: 117 | status = "wifioff"; 118 | optional.setVisibility(View.INVISIBLE); 119 | break; 120 | 121 | case 8: 122 | status = "wifiname"; 123 | optional.setVisibility(View.INVISIBLE); 124 | break; 125 | 126 | case 9: 127 | status = "bluetoothon"; 128 | optional.setVisibility(View.INVISIBLE); 129 | break; 130 | 131 | case 10: 132 | status = "bluetoothoff"; 133 | optional.setVisibility(View.INVISIBLE); 134 | break; 135 | 136 | case 11: 137 | status = "location"; 138 | optional.setVisibility(View.INVISIBLE); 139 | break; 140 | 141 | case 12: 142 | status = "siminfo"; 143 | optional.setVisibility(View.INVISIBLE); 144 | break; 145 | 146 | case 13: 147 | status = "phonenumber"; 148 | optional.setVisibility(View.INVISIBLE); 149 | break; 150 | 151 | } 152 | } 153 | 154 | @Override 155 | public void onNothingSelected(AdapterView parent) { 156 | 157 | } 158 | }); 159 | 160 | send.setOnClickListener(new View.OnClickListener() { 161 | @Override 162 | public void onClick(View v) { 163 | String ph = phone.getText().toString(); 164 | String pass = password.getText().toString(); 165 | if (ph.startsWith("+")) { 166 | if (ph.length() > 6 && ph.length() < 15) { 167 | if (pass.length() >= 5 && pass.length() <= 10) { 168 | if (status.equals("lock")) { 169 | String optnl = optional.getText().toString(); 170 | if (optnl.length() >= 5 && optnl.length() <= 10) { 171 | SecureRandom random = new SecureRandom(); 172 | String ranNum = new BigInteger(30, random).toString(); 173 | String command = "smsanti" + " " + Message.md5(pass + ranNum) + " " + ranNum + " " + status + " " + optnl; 174 | query.setText("Your SMS Command : " + command); 175 | sendSMS(ph, command); 176 | } else { 177 | Message.toast(getBaseContext(), "New password length is invalid"); 178 | } 179 | } else { 180 | SecureRandom random = new SecureRandom(); 181 | String ranNum = new BigInteger(30, random).toString(); 182 | String command = "smsanti" + " " + Message.md5(pass + ranNum) + " " + ranNum + " " + status; 183 | query.setText("Your SMS Command : " + command); 184 | sendSMS(ph, command); 185 | } 186 | } 187 | } else { 188 | Message.toast(getBaseContext(), "Phone number length is invalid"); 189 | } 190 | } else { 191 | Message.toast(getBaseContext(), "Enter your phone number with + and country code eg +44"); 192 | } 193 | } 194 | }); 195 | } 196 | 197 | public void sendSMS(String phone, String message){ 198 | Message.tag("Phone : "+phone+" Message : "+message); 199 | try { 200 | SmsManager smsManager = SmsManager.getDefault(); 201 | smsManager.sendTextMessage(phone, null, message, null, null); 202 | Message.toast(getBaseContext(),"Message Sent"); 203 | } catch (Exception ex) { 204 | Message.toast(getBaseContext(),"Message failed to send"); 205 | } 206 | } 207 | 208 | } 209 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/DatabaseHelper.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | 4 | import android.content.ContentValues; 5 | import android.content.Context; 6 | import android.database.Cursor; 7 | import android.database.sqlite.SQLiteDatabase; 8 | import android.database.sqlite.SQLiteOpenHelper; 9 | 10 | public class DatabaseHelper extends SQLiteOpenHelper{ 11 | 12 | public static final String DATABASE_NAME = "SMSAntiTheft.db"; 13 | public static final String TABLE_NAME = "ANTI"; 14 | public static final String COL_1 = "id"; 15 | public static final String COL_2 = "DATE"; 16 | public static final String COL_4 = "MESSAGE"; 17 | public Context c; 18 | 19 | public DatabaseHelper(Context context) { 20 | super(context, DATABASE_NAME, null, 1); 21 | c = context; 22 | } 23 | 24 | @Override 25 | public void onCreate(SQLiteDatabase db) { 26 | db.execSQL("create table " + TABLE_NAME + " (_id INTEGER PRIMARY KEY AUTOINCREMENT, DATE TEXT, MESSAGE TEXT)"); 27 | Message.toast(c, "Storage Setting Up..."); 28 | } 29 | 30 | @Override 31 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 32 | db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); 33 | onCreate(db); 34 | } 35 | 36 | public boolean insertData(String date, String Message){ 37 | SQLiteDatabase db = this.getWritableDatabase(); 38 | ContentValues contentValues = new ContentValues(); 39 | contentValues.put(COL_2, date); 40 | contentValues.put(COL_4, Message); 41 | long result = db.insert(TABLE_NAME, null, contentValues); 42 | if(result == -1) 43 | return false; 44 | else 45 | return true; 46 | 47 | } 48 | 49 | public Cursor getAllData(){ 50 | SQLiteDatabase db = this.getWritableDatabase(); 51 | Cursor res = db.rawQuery("select * from " + TABLE_NAME + " ORDER BY DATE DESC", null); 52 | return res; 53 | } 54 | 55 | 56 | public void deleteData(){ 57 | SQLiteDatabase db = this.getWritableDatabase(); 58 | db.execSQL("DROP TABLE "+TABLE_NAME); 59 | Message.toast(c,"Reset Complete..."); 60 | onCreate(db); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/DeviceAdmin.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.app.admin.DeviceAdminReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | 8 | public class DeviceAdmin extends DeviceAdminReceiver { 9 | 10 | @Override 11 | public void onPasswordChanged(Context context, Intent intent) { 12 | super.onPasswordChanged(context, intent); 13 | Message.adminLog(context, "Password Changed"); 14 | } 15 | 16 | @Override 17 | public void onPasswordFailed(Context context, Intent intent) { 18 | super.onPasswordFailed(context, intent); 19 | Message.deviceLog(context, "Device Login Attempt Failed"); 20 | } 21 | 22 | @Override 23 | public void onEnabled(Context context, Intent intent) { 24 | super.onEnabled(context, intent); 25 | Message.adminLog(context, "Device Admin Enabled"); 26 | } 27 | 28 | @Override 29 | public void onDisabled(Context context, Intent intent) { 30 | super.onDisabled(context, intent); 31 | Message.adminLog(context, "Device Admin Disabled"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/GCMListenerService.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.app.NotificationManager; 4 | import android.app.PendingIntent; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.media.RingtoneManager; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.support.v7.app.NotificationCompat; 11 | 12 | import com.google.android.gms.gcm.GcmListenerService; 13 | 14 | import java.text.SimpleDateFormat; 15 | import java.util.Date; 16 | 17 | public class GCMListenerService extends GcmListenerService { 18 | 19 | DatabaseHelper MyDb; 20 | @Override 21 | public void onMessageReceived(String from, Bundle data) { 22 | String message = data.getString("message"); 23 | MyDb = new DatabaseHelper(getBaseContext()); 24 | AddData(message); 25 | sendNotification(getBaseContext(), message, MainMenu.class); 26 | } 27 | 28 | public static void sendNotification(Context context,String Message, Class clas){ 29 | Intent intent = new Intent(context, clas); 30 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 31 | PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT); 32 | 33 | Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 34 | android.support.v4.app.NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) 35 | .setSmallIcon(R.mipmap.ic_launcher) 36 | .setContentTitle("SMSAntiTheft") 37 | .setAutoCancel(true) 38 | .setSound(defaultSoundUri) 39 | .setContentText(Message) 40 | .setStyle(new NotificationCompat.BigTextStyle().bigText(Message)) 41 | .setContentIntent(pendingIntent); 42 | 43 | NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); 44 | notificationManager.notify(0, notificationBuilder.build()); 45 | } 46 | 47 | public void AddData(String message){ 48 | 49 | SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); 50 | String currentDateandTime = sdf.format(new Date()); 51 | MyDb.insertData(currentDateandTime, message); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/MainMenu.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.Manifest; 4 | import android.app.ActionBar; 5 | import android.app.Activity; 6 | import android.app.FragmentManager; 7 | import android.app.FragmentTransaction; 8 | import android.content.Context; 9 | import android.content.Intent; 10 | import android.content.pm.PackageManager; 11 | import android.content.res.Configuration; 12 | import android.database.Cursor; 13 | import android.graphics.Typeface; 14 | import android.hardware.Camera; 15 | import android.net.ConnectivityManager; 16 | import android.net.Uri; 17 | import android.os.Bundle; 18 | import android.provider.Settings; 19 | import android.support.v4.app.ActivityCompat; 20 | import android.support.v4.content.ContextCompat; 21 | import android.support.v4.widget.DrawerLayout; 22 | import android.support.v7.app.ActionBarActivity; 23 | import android.support.v7.app.ActionBarDrawerToggle; 24 | import android.telephony.TelephonyManager; 25 | import android.view.LayoutInflater; 26 | import android.view.Menu; 27 | import android.view.MenuItem; 28 | import android.view.View; 29 | import android.view.ViewGroup; 30 | import android.widget.AdapterView; 31 | import android.widget.BaseAdapter; 32 | import android.widget.ImageView; 33 | import android.widget.ListView; 34 | 35 | 36 | public class MainMenu extends ActionBarActivity implements AdapterView.OnItemClickListener,Welcome.Communicator { 37 | 38 | private DrawerLayout drawerLayout; 39 | private ListView listview; 40 | private ActionBarDrawerToggle drawerListener; 41 | protected MyAdapter MyAdapter; 42 | 43 | @Override 44 | protected void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | setContentView(R.layout.main_menu); 47 | drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); 48 | 49 | listview = (ListView) findViewById(R.id.drawerList); 50 | MyAdapter = new MyAdapter(this); 51 | listview.setAdapter(MyAdapter); 52 | listview.setOnItemClickListener(this); 53 | 54 | drawerListener = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close) { 55 | @Override 56 | public void onDrawerOpened(View drawerView) { 57 | super.onDrawerOpened(drawerView); 58 | } 59 | 60 | @Override 61 | public void onDrawerClosed(View drawerView) { 62 | super.onDrawerClosed(drawerView); 63 | } 64 | }; 65 | 66 | String status = Message.GetSP(getBaseContext(), "ACT", "welcome", "DEFAULT"); 67 | if( Message.GetSP(getBaseContext(),"ACT","SimCH1","DONE").equals("OK")){ 68 | simInsert(); 69 | } 70 | if (status.equals("DEFAULT")) { 71 | Message.tag("onCreate DEFAULT"); 72 | Activate_Welcome("Welcome","W"); 73 | drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); 74 | }else { 75 | login(); 76 | try { 77 | getSupportActionBar().hide(); 78 | } catch (Exception e) { 79 | Message.toast(getBaseContext(), "Error: Contact Developer"); 80 | } 81 | } 82 | } 83 | 84 | //main initial 85 | public void Main(){ 86 | Message.tag("onCreate DEFAULT Else"); 87 | drawerLayout.setDrawerListener(drawerListener); 88 | getSupportActionBar().setHomeButtonEnabled(true); 89 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 90 | initial(); 91 | if(Message.GetSP(getBaseContext(),"Permission","SMS","OFF").equals("OFF")){ 92 | check(); 93 | }else{ 94 | Message.SetSP(getBaseContext(),"ACT","SimCH1","OK"); 95 | } 96 | Message.appLog(getBaseContext(), "App Opened"); 97 | try{ 98 | getSupportActionBar().show(); 99 | }catch (Exception e){ 100 | Message.toast(getBaseContext(),"Error: Contact Developer"); 101 | } 102 | } 103 | 104 | //check permission 105 | public void check(){ 106 | ActivityCompat.requestPermissions(MainMenu.this, new String[]{ 107 | Manifest.permission.READ_SMS, 108 | Manifest.permission.RECEIVE_SMS, 109 | Manifest.permission.SEND_SMS, 110 | Manifest.permission.ACCESS_COARSE_LOCATION, 111 | Manifest.permission.ACCESS_FINE_LOCATION, 112 | Manifest.permission.READ_PHONE_STATE}, 113 | 133); 114 | } 115 | 116 | public void simInsert(){ 117 | TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 118 | Message.SetSP(getBaseContext(), "Sim", "SimNo", tm.getSimSerialNumber()); 119 | // Message.tag(tm.getSimSerialNumber()); 120 | } 121 | 122 | @Override 123 | public void onRequestPermissionsResult(int requestCode, 124 | String permissions[], int[] grantResults) { 125 | switch (requestCode) { 126 | case 133: { 127 | 128 | if (grantResults.length > 0 129 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 130 | Message.SetSP(getBaseContext(),"Permission","SMS","ON"); 131 | } else { 132 | 133 | Message.SetSP(getBaseContext(), "Permission", "SMS", "OFF"); 134 | } 135 | return; 136 | } 137 | } 138 | } 139 | 140 | //Activate 141 | public void Activate_Welcome(String id, String where){ 142 | Welcome welcomeFrag = new Welcome(); 143 | Bundle bundle = new Bundle(); 144 | bundle.putString("id", id); 145 | bundle.putString("where", where); 146 | welcomeFrag.setArguments(bundle); 147 | FragmentManager FM = getFragmentManager(); 148 | FragmentTransaction FT = FM.beginTransaction(); 149 | 150 | FT.replace(R.id.relative_main, welcomeFrag); 151 | FT.commit(); 152 | } 153 | 154 | @Override 155 | public void onWelcome(String string) { 156 | Message.tag("onWelcome :" + string); 157 | if(string.equals("phone")){ 158 | Activate_Welcome("Phone", "W"); 159 | setTitle("Trusted Phone Number"); 160 | } 161 | else if(string.equals("password")){ 162 | Activate_Welcome("Password", "W"); 163 | setTitle("Password Setup"); 164 | } 165 | else if(string.equals("device_admin")){ 166 | Activate_Welcome("Device_Admin", "W"); 167 | setTitle("Device Admin Permission"); 168 | } 169 | else if(string.equals("send_gcm")){ 170 | Activate_Welcome("Send_Gcm","W"); 171 | setTitle("Completed"); 172 | }else if(string.equals("main")){ 173 | Main(); 174 | } 175 | } 176 | 177 | public void ifstatement(int num) 178 | { 179 | 180 | if(num == 0) 181 | { 182 | initial(); 183 | }else if(num == 1){ 184 | setTitle("Phone Number"); 185 | Activate_Welcome("Phone", "M"); 186 | }else if(num == 2){ 187 | setTitle("Password Setup"); 188 | Activate_Welcome("Password", "M"); 189 | }else if(num == 3){ 190 | setTitle("Device Administrator"); 191 | Activate_Welcome("Device_Admin", "M"); 192 | }else if(num == 4){ 193 | Activate_Welcome("Log", "M"); 194 | }else if(num == 5){ 195 | setTitle("Settings"); 196 | Activate_Welcome("Settings","M"); 197 | }else if(num == 6){ 198 | setTitle("Help"); 199 | Activate_Welcome("Help", "M"); 200 | } 201 | } 202 | 203 | 204 | 205 | public void initial(){ 206 | setTitle("Status"); 207 | Activate_Welcome("Status","M"); 208 | } 209 | 210 | public void login(){ 211 | Activate_Welcome("Login","M"); 212 | } 213 | 214 | @Override 215 | protected void onPostCreate(Bundle savedInstanceState) { 216 | super.onPostCreate(savedInstanceState); 217 | drawerListener.syncState(); 218 | } 219 | 220 | @Override 221 | public void onConfigurationChanged(Configuration newConfig) { 222 | super.onConfigurationChanged(newConfig); 223 | drawerListener.onConfigurationChanged(newConfig); 224 | } 225 | 226 | @Override 227 | public boolean onOptionsItemSelected(MenuItem item) { 228 | // Handle action bar item clicks here. The action bar will 229 | // automatically handle clicks on the Home/Up button, so long 230 | // as you specify a parent activity in AndroidManifest.xml. 231 | int id = item.getItemId(); 232 | 233 | //noinspection SimplifiableIfStatement 234 | if(drawerListener.onOptionsItemSelected(item)) 235 | { 236 | return true; 237 | } 238 | return super.onOptionsItemSelected(item); 239 | } 240 | 241 | @Override 242 | public void onItemClick(AdapterView parent, View view, int position, long id) { 243 | ifstatement(position); 244 | selectItem(position); 245 | drawerLayout.closeDrawers(); 246 | } 247 | 248 | public void selectItem(int position) { 249 | listview.setItemChecked(position, true); 250 | } 251 | public void setTitle(String title) 252 | { 253 | getSupportActionBar().setTitle(title); 254 | 255 | } 256 | 257 | } 258 | 259 | class MyAdapter extends BaseAdapter { 260 | 261 | private Context context; 262 | int[] images = {R.mipmap.ic_textsms_white_24dp, 263 | R.mipmap.ic_contact_phone_white_24dp, 264 | R.mipmap.ic_fingerprint_white_24dp, 265 | R.mipmap.ic_security_white_24dp, 266 | R.mipmap.ic_library_books_white_24dp, 267 | R.mipmap.ic_settings_white_24dp, 268 | R.mipmap.ic_help_outline_white_24dp}; 269 | 270 | public MyAdapter(Context context){ 271 | this.context = context; 272 | } 273 | 274 | @Override 275 | public int getCount() { 276 | return images.length; 277 | } 278 | 279 | @Override 280 | public Object getItem(int position) { 281 | return images[position]; 282 | } 283 | 284 | @Override 285 | public long getItemId(int position) { 286 | return position; 287 | } 288 | 289 | @Override 290 | public View getView(int position, View convertView, ViewGroup parent) { 291 | 292 | View row; 293 | if(convertView==null) 294 | { 295 | LayoutInflater inflater =(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 296 | row = inflater.inflate(R.layout.side_menu_layout, parent, false); 297 | 298 | }else{ 299 | row = convertView; 300 | } 301 | ImageView titleImageView = (ImageView)row.findViewById(R.id.imageview1); 302 | titleImageView.setImageResource(images[position]); 303 | 304 | return row; 305 | } 306 | } -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/Message.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.util.Log; 8 | import android.widget.Toast; 9 | 10 | import java.security.MessageDigest; 11 | import java.security.NoSuchAlgorithmException; 12 | import java.text.SimpleDateFormat; 13 | import java.util.Calendar; 14 | 15 | public class Message { 16 | 17 | public static void toast(Context c, String s){ 18 | Toast.makeText(c, s, Toast.LENGTH_LONG).show(); 19 | } 20 | 21 | public static String GetSP(Context context,String lib,String key, String defaults){ 22 | SharedPreferences sp = context.getSharedPreferences(lib, Context.MODE_PRIVATE); 23 | String s= sp.getString(key, defaults); 24 | return s; 25 | } 26 | 27 | public static void SetSP(Context context, String lib, String key, String value){ 28 | SharedPreferences sp = context.getSharedPreferences(lib, Context.MODE_PRIVATE); 29 | SharedPreferences.Editor editor = sp.edit(); 30 | editor.putString(key, value).apply(); 31 | } 32 | 33 | public static void tag(String s){ 34 | Log.i("TAG", s); 35 | } 36 | 37 | public static void log(Context context,String s){ 38 | Intent intent = new Intent(context,Background.class); 39 | intent.putExtra("id","log"); 40 | intent.putExtra("message",s); 41 | context.startService(intent); 42 | } 43 | 44 | public static String md5(final String s) { 45 | final String MD5 = "MD5"; 46 | try { 47 | // Create MD5 Hash 48 | MessageDigest digest = MessageDigest.getInstance(MD5); 49 | digest.update(s.getBytes()); 50 | byte messageDigest[] = digest.digest(); 51 | 52 | // Create Hex String 53 | StringBuilder hexString = new StringBuilder(); 54 | for (byte aMessageDigest : messageDigest) { 55 | String h = Integer.toHexString(0xFF & aMessageDigest); 56 | while (h.length() < 2) 57 | h = "0" + h; 58 | hexString.append(h); 59 | } 60 | return hexString.toString(); 61 | 62 | } catch (NoSuchAlgorithmException e) { 63 | e.printStackTrace(); 64 | } 65 | return null; 66 | } 67 | 68 | //log 69 | public static void deviceLog(Context context,String message) { 70 | if(Message.GetSP(context,"Settings","LogDevice","ON").equals("ON")) { 71 | DatabaseHelper myDb = new DatabaseHelper(context); 72 | myDb.insertData(Message.time(), message); 73 | } 74 | } 75 | 76 | public static void adminLog(Context context,String message) { 77 | if(Message.GetSP(context,"Settings","LogAdmin","ON").equals("ON")) { 78 | DatabaseHelper myDb = new DatabaseHelper(context); 79 | myDb.insertData(Message.time(), message); 80 | } 81 | } 82 | 83 | public static void appLog(Context context,String message) { 84 | if(Message.GetSP(context,"Settings","LogApp","ON").equals("ON")) { 85 | DatabaseHelper myDb = new DatabaseHelper(context); 86 | myDb.insertData(time(), message); 87 | } 88 | } 89 | 90 | public static String time() { 91 | String format = "dd-MM-yyyy HH:mm:ss"; 92 | Calendar c = Calendar.getInstance(); 93 | SimpleDateFormat sdf = new SimpleDateFormat(format); 94 | return sdf.format(c.getTime()); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/MyInstanceIDListenerService.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.content.Intent; 4 | 5 | import com.google.android.gms.iid.InstanceIDListenerService; 6 | 7 | /** 8 | * Created by Gajendran on 06/02/2016. 9 | */ 10 | public class MyInstanceIDListenerService extends InstanceIDListenerService { 11 | 12 | @Override 13 | public void onTokenRefresh() { 14 | Intent intent = new Intent(this, RegistrationIntentService.class); 15 | startActivity(intent); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/Receiver.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.telephony.TelephonyManager; 7 | 8 | 9 | public class Receiver extends BroadcastReceiver { 10 | @Override 11 | public void onReceive(Context context, Intent intent) { 12 | Message.tag("BOOT COMPLETE"); 13 | TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); 14 | if(Message.GetSP(context,"Sim","SimNo","null").equals(tm.getSimSerialNumber())){ 15 | Message.tag("SIM Number Match"); 16 | }else { 17 | Intent intent1 = new Intent(context,Background.class); 18 | intent1.putExtra("id","sms"); 19 | intent1.putExtra("message","Your sim card has been changed"); 20 | intent1.putExtra("phone",Message.GetSP(context,"Welcome_Phone","secure_phone1","null")); 21 | context.startService(intent1); 22 | Message.tag("SIM Number Doesn't Match"); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/SmsReceiver.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.telephony.SmsManager; 8 | import android.telephony.SmsMessage; 9 | import android.widget.Toast; 10 | 11 | public class SmsReceiver extends BroadcastReceiver { 12 | @Override 13 | public void onReceive(Context context, Intent intent) { 14 | Message.tag("SMS Broadcast on Recieve"); 15 | final Bundle bundle = intent.getExtras(); 16 | 17 | try { 18 | 19 | if (bundle != null) { 20 | 21 | final Object[] pdusObj = (Object[]) bundle.get("pdus"); 22 | 23 | for (int i = 0; i < pdusObj.length; i++) { 24 | SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]); 25 | String phoneNumber = currentMessage.getDisplayOriginatingAddress(); 26 | if(Message.GetSP(context,"Welcome_Phone","secure_phone1","null").equals(phoneNumber) || 27 | Message.GetSP(context,"Welcome_Phone","secure_phone2","null").equals(phoneNumber)){ 28 | String senderNum = phoneNumber; 29 | String message = currentMessage.getDisplayMessageBody(); 30 | Intent backgroundService = new Intent(context,Background.class); 31 | backgroundService.putExtra("id","phone"); 32 | backgroundService.putExtra("num",senderNum); 33 | backgroundService.putExtra("message",message); 34 | context.startService(backgroundService); 35 | } 36 | } // end for loop 37 | } // bundle is null 38 | 39 | } catch (Exception e) { 40 | Message.tag("Exception smsReceiver" + e); 41 | 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/gsdroid/smsantitheft/Welcome.java: -------------------------------------------------------------------------------- 1 | package com.gsdroid.smsantitheft; 2 | 3 | import android.app.Activity; 4 | import android.app.Fragment; 5 | import android.app.FragmentManager; 6 | import android.app.FragmentTransaction; 7 | import android.app.admin.DevicePolicyManager; 8 | import android.content.ComponentName; 9 | import android.content.Context; 10 | import android.content.Intent; 11 | import android.database.Cursor; 12 | import android.graphics.Typeface; 13 | import android.net.Uri; 14 | import android.os.Bundle; 15 | import android.provider.ContactsContract; 16 | import android.support.annotation.Nullable; 17 | import android.support.v4.widget.DrawerLayout; 18 | import android.text.Editable; 19 | import android.text.method.BaseKeyListener; 20 | import android.text.method.KeyListener; 21 | import android.util.Log; 22 | import android.view.KeyEvent; 23 | import android.view.LayoutInflater; 24 | import android.view.View; 25 | import android.view.ViewGroup; 26 | import android.widget.BaseAdapter; 27 | import android.widget.Button; 28 | import android.widget.CheckBox; 29 | import android.widget.CompoundButton; 30 | import android.widget.EditText; 31 | import android.widget.ImageButton; 32 | import android.widget.ListView; 33 | import android.widget.SimpleCursorAdapter; 34 | import android.widget.Switch; 35 | import android.widget.TextView; 36 | 37 | import java.util.ArrayList; 38 | import java.util.List; 39 | 40 | 41 | public class Welcome extends Fragment { 42 | 43 | View v; 44 | Communicator communicator; 45 | private Button btn; 46 | private String info,onActRet,where,pOnAct; 47 | private Typeface tf; 48 | private Context context; 49 | private EditText con1, con2, app, secure,login_pass; 50 | private DevicePolicyManager mDPM; 51 | private ComponentName mDeviceApp; 52 | private Switch switONOFF; 53 | public DatabaseHelper myDb; 54 | MyAdap myAdap; 55 | Cursor cursor; 56 | 57 | @Override 58 | public void onAttach(Activity activity) { 59 | super.onAttach(activity); 60 | communicator = (Communicator)activity; 61 | } 62 | 63 | @Nullable 64 | @Override 65 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 66 | 67 | Message.tag("onCreateView Frag"); 68 | tf = Typeface.createFromAsset(getActivity().getAssets(), "font.ttf"); 69 | String id = getArguments().getString("id"); 70 | where = getArguments().getString("where"); 71 | Message.tag("onCreateView Id : " + id); 72 | onActRet = "null"; 73 | 74 | mDPM = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE); 75 | mDeviceApp = new ComponentName(getActivity(),DeviceAdmin.class); 76 | 77 | if("Login".equals(id)){ 78 | v = inflater.inflate(R.layout.login_app,container,false); 79 | btn = (Button)v.findViewById(R.id.act_welcome_next_btn); 80 | login_pass = (EditText)v.findViewById(R.id.et_login); 81 | Button btnClient = (Button)v.findViewById(R.id.client_btn); 82 | login_pass.setTypeface(tf); 83 | context = v.getContext(); 84 | onActRet = "log-in"; 85 | //textTypeface 86 | TextView tv1 = (TextView)v.findViewById(R.id.login_text1); 87 | TextView tv2 = (TextView)v.findViewById(R.id.login_text2); 88 | tv1.setTypeface(tf); 89 | tv2.setTypeface(tf); 90 | btnClient.setTypeface(tf); 91 | btnClient.setOnClickListener(new View.OnClickListener() { 92 | @Override 93 | public void onClick(View v) { 94 | startActivity(new Intent(v.getContext(),Client.class)); 95 | } 96 | }); 97 | 98 | 99 | }else if("Welcome".equals(id)){ 100 | v = inflater.inflate(R.layout.welcome,container,false); 101 | btn = (Button)v.findViewById(R.id.act_welcome_next_btn); 102 | info = "phone"; 103 | int[] ids = {R.id.sub_welcome,R.id.sub_middle_text}; 104 | for(int i = 0; i 7 && con1.getText().length() < 15 && con1.getText().toString().startsWith("+")) { 460 | if (con2.getText().toString().isEmpty()) { 461 | Message.SetSP(context, "Welcome_Phone", "secure_phone1", con1.getText().toString()); 462 | if (!where.equals("M")) { 463 | communicator.onWelcome(info); 464 | } else { 465 | success(context); 466 | } 467 | } else { 468 | if (con2.getText().toString().length() > 7 && con2.getText().length() < 15 && con2.getText().toString().startsWith("+")) { 469 | Message.SetSP(context, "Welcome_Phone", "secure_phone1", con1.getText().toString()); 470 | Message.SetSP(context, "Welcome_Phone", "secure_phone2", con2.getText().toString()); 471 | if (where.equals("M")) { 472 | success(context); 473 | } else { 474 | communicator.onWelcome(info); 475 | } 476 | } else { 477 | Message.toast(context, "Your second phone number length is invalid, Enter with country code eg +44"); 478 | } 479 | } 480 | } else { 481 | Message.toast(context, "Your first phone number length is invalid, Enter with country code eg +44"); 482 | }//Phone number finish 483 | 484 | } else if (onActRet.equals("password")) { 485 | int num = app.getText().toString().length(); 486 | int num1 = secure.getText().toString().length(); 487 | if (num >= 5 && num <= 10) { 488 | if (num1 >= 5 && num1 <= 10) { 489 | Message.SetSP(context, "Welcome_Password", "app_pass", app.getText().toString()); 490 | Message.SetSP(context, "Welcome_Password", "secure_pass", secure.getText().toString()); 491 | if (where.equals("M")) { 492 | success(context); 493 | } else { 494 | communicator.onWelcome(info); 495 | } 496 | } else { 497 | Message.toast(context, "Secure password should be between 5 to 10 characters"); 498 | } 499 | } else { 500 | Message.toast(context, "App password should be between 5 to 10 characters"); 501 | } 502 | } else if (onActRet.equals("device_admin")) { 503 | if (isActiveAdmin()) { 504 | Message.SetSP(context, "DeviceAdmin", "Admin", "ON"); 505 | communicator.onWelcome(info); 506 | } else { 507 | communicator.onWelcome(info); 508 | Message.toast(context, "You can turn-on device admin later on settings option"); 509 | } 510 | } else if (onActRet.equals("finish")) { 511 | Message.SetSP(context, "ACT", "welcome", "DONE"); 512 | context.startService(new Intent(context, RegistrationIntentService.class)); 513 | startActivity(new Intent(context, MainMenu.class)); 514 | 515 | } else if (onActRet.equals("log-in")) { 516 | String pass = Message.GetSP(context, "Welcome_Password", "app_pass", "null"); 517 | if (!pass.equals("null")) { 518 | if (pass.equals(login_pass.getText().toString())) { 519 | communicator.onWelcome("main"); 520 | } else { 521 | Message.toast(context, "Incorrect Password"); 522 | } 523 | } 524 | } else { 525 | communicator.onWelcome(info); 526 | } 527 | } 528 | }); 529 | 530 | 531 | 532 | 533 | return v; 534 | } 535 | 536 | public void hideStatus(View vw){ 537 | int[] idarray = {R.id.act_welcome_status_1,R.id.act_welcome_status_2,R.id.act_welcome_status_3,R.id.act_welcome_status_4, 538 | R.id.act_welcome_status_5}; 539 | for(int i = 0; i= 1){ 619 | String[] FieldNames = new String[]{myDb.COL_2, myDb.COL_4}; 620 | int[] toViewIds = new int[]{R.id.item_layout_date, R.id.item_layout_message}; 621 | //SimpleCursorAdapter simpleCursorAdapter; 622 | //simpleCursorAdapter = new SimpleCursorAdapter(vv.getContext(), R.layout.item_layout,cursor,FieldNames, toViewIds, 0); 623 | myAdap.getValue(cursor); 624 | ListView listView = (ListView)vv.findViewById(R.id.lv); 625 | listView.setAdapter(ba); 626 | 627 | }else{ 628 | Message.tag("Something is wrong..!! Reinstall the app"); 629 | } 630 | } 631 | 632 | interface Communicator{ 633 | public void onWelcome(String string); 634 | } 635 | } 636 | 637 | class MyAdap extends BaseAdapter { 638 | 639 | String[] menuoptions; 640 | String[] menuTime; 641 | String date, msg; 642 | 643 | public void getValue(Cursor c){ 644 | menuoptions = new String[c.getCount()]; 645 | menuTime = new String[c.getCount()]; 646 | List list_msg = new ArrayList(); 647 | List list_tym = new ArrayList(); 648 | if (c != null ) { 649 | if (c.moveToFirst()) { 650 | do { 651 | date = c.getString(c.getColumnIndex("DATE")); 652 | msg = c.getString(c.getColumnIndex("MESSAGE")); 653 | list_msg.add(msg); 654 | list_tym.add(date); 655 | }while (c.moveToNext()); 656 | } 657 | } 658 | menuoptions = list_msg.toArray(menuoptions); 659 | menuTime = list_tym.toArray(menuTime); 660 | } 661 | 662 | 663 | private Context context; 664 | 665 | Typeface tf; 666 | public MyAdap(Context context){ 667 | this.context = context; 668 | tf = Typeface.createFromAsset(context.getAssets(), "font.ttf"); 669 | 670 | } 671 | 672 | @Override 673 | public int getCount() { 674 | return menuoptions.length; 675 | } 676 | 677 | @Override 678 | public Object getItem(int position) { 679 | return menuoptions[position]; 680 | } 681 | 682 | @Override 683 | public long getItemId(int position) { 684 | return position; 685 | } 686 | 687 | @Override 688 | public View getView(int position, View convertView, ViewGroup parent) { 689 | 690 | View row; 691 | if(convertView==null) 692 | { 693 | LayoutInflater inflater =(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 694 | row = inflater.inflate(R.layout.item_layout, parent, false); 695 | 696 | }else{ 697 | row = convertView; 698 | } 699 | TextView titleTextView = (TextView)row.findViewById(R.id.item_layout_message); 700 | TextView titleDate = (TextView)row.findViewById(R.id.item_layout_date); 701 | titleDate.setText(menuTime[position]); 702 | titleTextView.setText(menuoptions[position]); 703 | titleTextView.setTypeface(tf); 704 | titleDate.setTypeface(tf); 705 | 706 | return row; 707 | } 708 | } 709 | 710 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rgajendran/sms_antitheft/eb508c556182c3e2f116571f06bfaae52d704cee/app/src/main/res/drawable/lock.png -------------------------------------------------------------------------------- /app/src/main/res/layout/app_help.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 19 | 25 |