/
OpenCL.java
638 lines (603 loc) · 21.3 KB
/
OpenCL.java
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/*
* Copyright (C) <2014> <Dries Goossens / driesgoossens93@gmail.com , Koen Daelman / koendaelman@gmail.com >
*
*Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
*The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.denayer.ovsr;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8U;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacpp.opencv_imgproc;
import org.bytedeco.javacpp.opencv_core.IplImage;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
public class OpenCL extends Object {
private Context mContext; //<-- declare a Context reference
Bitmap bmpOrig, bmpOpenCL;
static float saturatie=-1;
public ImageView outputButton;
final int info[] = new int[3]; // Width, Height, Execution time (ms)
static boolean sfoundLibrary = true;
String kernelName = "";
private OnUpdateProcessBar mGUIUpdater = null;
static int dev_type;
static LogFile LogFileObject;
/*! \brief The OpenCL constructor.
*
* The constructor takes two arguments. Loads the available OpenCL library
* and the self generated libOVSR where all the native functions are defined.
* It takes two arguments. The context is needed to make the mainwindow accessable from this class.
* The imageView is the output imageview on the mainwindow.
* @param context is the context of MainActivity
* @param imageView is the ImageView to put the result in
*/
public OpenCL(Context context, ImageView imageView) {
mContext = context;
outputButton = imageView;
LogFileObject = new LogFile(mContext);
try {
//Odroid lib
System.load("/system/vendor/lib/libPVROCL.so");
Log.i("Debug", "libPVROCL Loaded");
}
catch (UnsatisfiedLinkError e) {
sfoundLibrary = false;
}
if(sfoundLibrary==false)
{
try {
System.load("/system/vendor/lib/egl/libGLES_mali.so");
Log.i("Debug", "libGLES_mali loaded");
sfoundLibrary=true;
}
catch (UnsatisfiedLinkError e) {
sfoundLibrary = false;
}
}
if(sfoundLibrary==false)
{
try {
System.load("/system/lib/libOpenCL.so");
Log.i("Debug", "libOpenCL Qualcomm loaded");
sfoundLibrary=true;
}
catch (UnsatisfiedLinkError e) {
sfoundLibrary = false;
}
}
try {
System.loadLibrary("OVSR");
Log.i("Debug","My Lib Loaded!");
}
catch (UnsatisfiedLinkError e) {
Log.e("Debug", "Error log", e);
}
}
public OpenCL (Context context, ImageView imageView, OnUpdateProcessBar listener) {
mContext = context;
outputButton = imageView;
mGUIUpdater = listener;
LogFileObject = new LogFile(mContext);
}
/*! \brief Returns a boolean to be able to check OpenCL support in the main code
*
* @return sFoundLibrary is true if OpenCL is supported
*/
public boolean getOpenCLSupport(){
return sfoundLibrary;
}
/*! \brief Setter function for the input bitmap.
*
* The setBitmap function creates a copy of the argument (bmpOrigJava) and creates a 2th bitmap.
* @param bmpOrigJava is the bitmap that has to be copied and processed.
*/
public void setBitmap(Bitmap bmpOrigJava)
{
bmpOrig = bmpOrigJava;
info[0] = bmpOrig.getWidth();
info[1] = bmpOrig.getHeight();
bmpOpenCL = Bitmap.createBitmap(info[0], info[1], Bitmap.Config.ARGB_8888);
}
/*! \brief Getter function to get the resulting bitmap from one of the OpenCL functions.
*
* It has no arguments and returns a bitmap
* @return bmpOpenCL The resulting bitmap
*/
public Bitmap getBitmap()
{
return bmpOpenCL;
}
/*! \brief Connection between Java and Native code.
*
* The initOpenCL function needs a kernel name and initialises the OpenCL environment.
* @param kernelName is the kernel name of the kernel that has to be excecuted later
*/
private native void initOpenCL (String kernelName,int dev_type);
/*! \brief Connection between Java and Native code.
*
* The initOpenCLFromInput function needs a kernel name and the OpenCL code.
* This function initialises the OpenCL environment for the code from the input field in mainwindow.
* @param OpenCLCode is a String that contains the OpenCL code
* @param kernelName is a String that contains the kernel name from the OpenCLCode
*/
private native void initOpenCLFromInput (String OpenCLCode, String kernelName,int dev_type);
/*! \brief Connection between Java and Native code.
*
* The nativeBasicOpenCL function needs an input and output bitmap and executes the kernel initialized in initOpenCL.
* @param inputBitmap is the bitmap to be processed
* @param outputBitmap is the resulting bitmap
*/
private native void nativeBasicOpenCL (
Bitmap inputBitmap,
Bitmap outputBitmap
);
/*! \brief Connection between Java and Native code.
*
* The nativeImage2DOpenCL function needs an input and output bitmap and executes the kernel initialized in initOpenCL.
* The difference with nativeBasicOpenCL is that this function uses image2d_t in it's kernels.
* @param inputBitmap is the bitmap to be processed
* @param outputBitmap is the resulting bitmap
*/
private native void nativeImage2DOpenCL(
Bitmap inputBitmap,
Bitmap outputBitmap
);
/*! \brief Connection between Java and Native code.
*
* The nativeSaturatieImage2DOpenCL function needs an input and output bitmap and executes the kernel initialized in initOpenCL.
* This function als needs a saturation value (saturatie). This value will be between 0 (under saturation) and 200 (over saturation).
* The difference with nativeImage2DOpenCL is that this function is ONLY able to do the saturation filter.
* @param inputBitmap is the bitmap to be processed
* @param outputBitmap is the resulting bitmap
* @param saturatie is a float between 0 and 200
*/
private native void nativeSaturatieImage2DOpenCL(
Bitmap inputBitmap,
Bitmap outputBitmap,
float saturatie
);
/*! \brief Connection between Java and Native code.
*
* The shutdownOpenCL function removes all OpenCL allocations.
*/
private native void shutdownOpenCL ();
/*! \brief This function will be called when the Edge button is clicked.
*
* It will execute all steps to apply the OpenCL edge filter onto the image, gets the execution time and has a check to make sure the bitmap is valid.
*/
public void OpenCLEdge ()
{
if(bmpOrig == null)
return;
copyFile("edge.cl");
String kernelName="edge";
long startTime = System.nanoTime();
initOpenCL(kernelName,dev_type);
nativeImage2DOpenCL(
bmpOrig,
bmpOpenCL
);
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Edge",estimatedTime);
}
/*! \brief This function will be called when the Inverse button is clicked.
*
* It will execute all steps to apply the OpenCL inverse filter onto the image, gets the execution time and has a check to make sure the bitmap is valid.
*/
public void OpenCLInverse ()
{
if(bmpOrig == null)
return;
copyFile("inverse.cl");
String kernelName="inverse";
long startTime = System.nanoTime();
initOpenCL(kernelName,dev_type);
nativeImage2DOpenCL(
bmpOrig,
bmpOpenCL
);
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Inverse",estimatedTime);
}
/*! \brief This function will be called when the Sharpen button is clicked.
*
* It will execute all steps to apply the OpenCL sharpen filter onto the image, gets the execution time and has a check to make sure the bitmap is valid.
*/
public void OpenCLSharpen ()
{
if(bmpOrig == null)
return;
copyFile("sharpen.cl");
String kernelName="sharpen";
long startTime = System.nanoTime();
initOpenCL(kernelName,dev_type);
nativeImage2DOpenCL(
bmpOrig,
bmpOpenCL
);
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Sharpen",estimatedTime);
}
/*! \brief This function will be called when the mediaan button is clicked.
*
* It will execute all steps to apply the OpenCL mediaan filter onto the image, gets the execution time and has a check to make sure the bitmap is valid.
*/
public void OpenCLMediaan ()
{
if(bmpOrig == null)
return;
copyFile("mediaan.cl");
String kernelName="mediaan";
long startTime = System.nanoTime();
initOpenCL(kernelName,dev_type);
nativeImage2DOpenCL(
bmpOrig,
bmpOpenCL
);
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Median",estimatedTime);
}
/*! \brief This function will be called when the Blur button is clicked.
*
* It will execute all steps to apply the OpenCL blur filter onto the image, gets the execution time and has a check to make sure the bitmap is valid.
*/
public void OpenCLBlur ()
{
if(bmpOrig == null)
return;
copyFile("blur.cl");
String kernelName="blur";
long startTime = System.nanoTime();
initOpenCL(kernelName,dev_type);
nativeImage2DOpenCL(
bmpOrig,
bmpOpenCL
);
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Blur",estimatedTime);
}
/*! \brief This function will be called when the saturatie button is clicked.
*
* It will execute all steps to apply the OpenCL saturation filter onto the image, gets the execution time and has a check to make sure the bitmap is valid.
* This function will also show a pop up window with a slider bar to select the saturation value between 0 and 200.
*/
public void OpenCLSaturatie ()
{
if(bmpOrig == null)
return;
Log.i("DEBUG","OPENCLSATURATIE");
if(saturatie==-1) {
final TextView progressView = new TextView(mContext);
final SeekBar MySeekBar = new SeekBar(mContext);
MySeekBar.setMax(200);
MySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// Auto-generated method stub
progressView.setText(String.valueOf(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Auto-generated method stub
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setMessage("saturation value")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
saturatie = MySeekBar.getProgress();
saturate();
outputButton.setImageBitmap(bmpOpenCL);
saturatie = -1;
}
});
progressView.setGravity(1 | 0x10);
// Create the AlertDialog object and return it
AlertDialog dialog = builder.create();
LinearLayout ll=new LinearLayout(mContext);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(MySeekBar);
ll.addView(progressView);
dialog.setView(ll);
dialog.show();
} else {
saturate();
}
}
/*! \brief This function will be called when OpenCLsaturatie's pop up windows is closed.
*
* It will execute all steps to apply the OpenCL saturation filter onto the image, gets the execution time and has a check to make sure the bitmap is valid.
*/
private void saturate()
{
copyFile("saturatie.cl");
String kernelName="saturatie";
long startTime = System.nanoTime();
initOpenCL(kernelName,dev_type);
nativeSaturatieImage2DOpenCL(
bmpOrig,
bmpOpenCL,
saturatie
);
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Saturation",estimatedTime);
}
/*! \brief This function will copy a file from the assets folder specified by the argument to the execdir of the application.
*
* The argument is the file name and must be located inside the assets folder. It copies the file to make sure the OpenCL code can acces it.
* @param f is the name of the file that has to be copied
*/
private void copyFile(final String f) {
InputStream in;
try {
in = mContext.getAssets().open(f);
final File of = new File(mContext.getDir("execdir",Context.MODE_PRIVATE), f);
final OutputStream out = new FileOutputStream(of);
final byte b[] = new byte[65535];
int sz = 0;
while ((sz = in.read(b)) > 0) {
out.write(b, 0, sz);
}
in.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/*! \brief The setTimeFromJNI function allows the native code to set a value to the GUI in the log window.
*
*@param time is the time that has to be placed in the log field
*/
public void setTimeFromJNI(float time)
{
Log.i("setTimeFromJNI","Time set on " + String.valueOf(time));
//time = (float) (Math.round(time*1000.0) / 1000.0);
time = time *1000;
View rootView = ((Activity)mContext).getWindow().getDecorView().findViewById(android.R.id.content);
TextView v = (TextView) rootView.findViewById(R.id.timeview);
v.setText(String.valueOf(time) + " ms");
}
/*! \brief The setTimeToLog function sets a value to the GUI in the log window.
*
*@param time is the time that has to be placed in the log field
*/
public void setTimeToLog(long time)
{
View rootView = ((Activity)mContext).getWindow().getDecorView().findViewById(android.R.id.content);
TextView v = (TextView) rootView.findViewById(R.id.timeview);
v.setText(String.valueOf(time) + " ms");
}
/*! \brief The setTimeToLog function adds a line with information to the history file
*
*@param filterName the name of the executed filter
*@param time the time needed to execute the filter
*/
public void setHistory(String filterName,long time)
{
String Method="RenderScript";
SimpleDateFormat formatter = new SimpleDateFormat("yyMMddHHmmss");
Date now = new Date();
String fileName = "RenderScript/" + filterName + formatter.format(now);
LogFileObject.writeToFile("\n" + Method + " : " + fileName + " : " + String.valueOf(time) + " ms", "LogFile.txt",false);
}
/*! \brief The setConsoleOutput function allows the native code to set a value to the GUI in the console window.
*
*@param ErrorLog is the error log that has to be placed in the console view.
*/
public void setConsoleOutput(String ErrorLog)
{
View rootView = ((Activity)mContext).getWindow().getDecorView().findViewById(android.R.id.content);
TextView v = (TextView) rootView.findViewById(R.id.ConsoleView);
v.setText(ErrorLog);
}
/*! \brief Gets the template from the assets file and returns it.
*
*@return template is a string that contains the standard template for OpenCL
*/
public String getTemplate()
{
String template = null;
try {
InputStream in = mContext.getAssets().open("templateOpenCL.txt");
InputStreamReader inputStreamReader = new InputStreamReader(in);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String receiveString = "";
StringBuilder stringBuilder = new StringBuilder();
while ( (receiveString = bufferedReader.readLine()) != null ) {
stringBuilder.append(receiveString).append("\n");
}
in.close();
template = stringBuilder.toString();
} catch (IOException e) {
Log.e("login activity", "Can not read file: " + e.toString());
e.printStackTrace();
}
return template;
}
/*! \brief This function gives the kernelName a value.
*
*@param name contains the kernel name to be set
*/
public void setKernelName(String name) {
kernelName = name;
}
/*! \brief This function calls all the need OpenCL function to compile OpenCL code from text input.
*
*@param code is the OpenCL code that needs to be compiled
*/
public void codeFromFile(final String code)
{
long startTime = System.nanoTime();
initOpenCLFromInput(code, kernelName,dev_type);
nativeImage2DOpenCL(
bmpOrig,
bmpOpenCL
);
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Run time compiled",estimatedTime);
}
public void OpenCLVideo(String[] arg)
{
int LengthInFrames = 0;
int counter = 0;
long startTime = System.nanoTime();
try{
mGUIUpdater.updateProcessBar("Load");
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("/sdcard/DCIM/small.mp4");
grabber.start();
while(true)
{
if(grabber.grab()==null) break;
LengthInFrames++;
}
mGUIUpdater.updateProcessBar("Start" + " " + String.valueOf(LengthInFrames));
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("/sdcard/DCIM/saved_images/smallTesting.mp4", grabber.getImageWidth(), grabber.getImageHeight());
recorder.setFormat("mp4");
recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);
recorder.setVideoBitrate(33000);
recorder.setFrameRate(grabber.getFrameRate());
IplImage image = IplImage.create(grabber.getImageWidth(), grabber.getImageHeight(), IPL_DEPTH_8U, 4);
IplImage frame2 = IplImage.create(image.width(), image.height(), IPL_DEPTH_8U, 4);
Bitmap MyBitmap = Bitmap.createBitmap(frame2.width(), frame2.height(), Bitmap.Config.ARGB_8888);
Bitmap MyBitmap2 = Bitmap.createBitmap(frame2.width(), frame2.height(), Bitmap.Config.ARGB_8888);
recorder.start();
String kernelName=arg[0];
if(!arg[1].equals("runtime"))
{
copyFile( arg[0] +".cl");
initOpenCL(kernelName,dev_type);
}
else
{
Log.d("Kernel code",arg[2]);
Log.d("Kernel Name",kernelName);
initOpenCLFromInput(arg[2], kernelName,dev_type);
}
grabber.setFrameNumber(0);
while(true)
{
image = grabber.grab();
if(image==null)
{
break;
}
opencv_imgproc.cvCvtColor(image, frame2, opencv_imgproc.CV_BGR2RGBA);
MyBitmap.copyPixelsFromBuffer(frame2.getByteBuffer());
if(kernelName.equals("saturatie"))
{
nativeSaturatieImage2DOpenCL(
MyBitmap,
MyBitmap2,
saturatie
);
}
else
{
nativeImage2DOpenCL(
MyBitmap,
MyBitmap2
);
}
MyBitmap2.copyPixelsToBuffer(frame2.getByteBuffer());
opencv_imgproc.cvCvtColor(frame2, image, opencv_imgproc.CV_RGBA2BGR);
recorder.record(image);
counter++;
mGUIUpdater.updateProcessBar(String.valueOf(counter));
}
shutdownOpenCL();
recorder.stop();
grabber.stop();
mGUIUpdater.updateProcessBar("Done");
}catch(Exception e){
e.printStackTrace();
}
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
Log.d("Time:",Long.toString(estimatedTime));
setTimeToLog(estimatedTime);
}
public interface OnUpdateProcessBar {
public void updateProcessBar(String message);
}
/*! \brief Returns the source code of the specified filter
*
* @param filtername The name of the filter
* @return code The code of the specified filter
*/
public String getFilterCode(String filterName)
{
String code = "";
String file = filterName + ".cl";
try {
InputStream in = mContext.getAssets().open(file);
InputStreamReader inputStreamReader = new InputStreamReader(in);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String receiveString = "";
StringBuilder stringBuilder = new StringBuilder();
while ( (receiveString = bufferedReader.readLine()) != null ) {
stringBuilder.append(receiveString).append("\n");
}
in.close();
code = stringBuilder.toString();
} catch (IOException e) {
Log.e("login activity", "Can not read file: " + e.toString());
e.printStackTrace();
}
return code;
}
public void setDeviceType(int device)
{
dev_type = device;
}
}