77
77
@ SuppressLint ("NewApi" )
78
78
public class GpiiActivity extends Activity {
79
79
80
+ private Context ctx ;
80
81
private boolean isSystemApp ;
81
82
private static String TAG = "Cloud4all" ;
82
83
private static String filepathgpii = Environment
@@ -92,6 +93,8 @@ public class GpiiActivity extends Activity {
92
93
93
94
private static String gpiiJS ;
94
95
private static String gpiiAPK ;
96
+ private static String uriUserListeners ;
97
+ private static String gpiiUserListenersAPK ;
95
98
96
99
private static String privSystemDir = "/system/priv-app" ;
97
100
private static String systemDir = "/system/app" ;
@@ -116,6 +119,7 @@ public class GpiiActivity extends Activity {
116
119
private Button downloadButton ;
117
120
private RelativeLayout gpiiInfo ;
118
121
private File file ;
122
+ private File userListenersFile ;
119
123
120
124
private long enqueue ;
121
125
private DownloadManager dm ;
@@ -215,23 +219,38 @@ public void onCreate(Bundle savedInstanceState) {
215
219
} catch (IOException ioe ) {
216
220
ioe .printStackTrace ();
217
221
}
222
+
223
+ userListenersFile = new File (Environment .getExternalStorageDirectory (),gpiiUserListenersAPK );
218
224
219
225
try {
220
226
tarIncluded =true ;
221
- Arrays .asList (getResources ().getAssets ().list ("" )).contains ("gpii-android.tar.gz " );
227
+ Arrays .asList (getResources ().getAssets ().list ("" )).contains ("gpii-android" );
222
228
} catch (IOException e1 ) {
223
229
224
230
tarIncluded =false ;
225
231
e1 .printStackTrace ();
226
232
}
227
233
228
- if (!gpiiApkInstalled ("cloud4all.UserListener.NFC" )){
234
+ if (!gpiiApkInstalled ("cloud4all.UserListener.NFC" )&&! userListenersFile . exists () ){
229
235
installGPIIUserListeners ();
230
236
userListenersInstalled = false ;
231
237
installationUserListenersEnabled =true ;
232
238
233
239
} else {
234
240
241
+ if (userListenersFile .exists ()){
242
+ userListenersInstalled =true ;
243
+ userListenersNotInstalledDialog (gpiiUserListenersAPK );
244
+ }
245
+
246
+ if (tarIncluded &&!file .exists ()){
247
+ wm .addView (progressView , progressparams );
248
+ downloadButton .setVisibility (View .GONE );
249
+ installationButton .setVisibility (View .VISIBLE );
250
+
251
+ new ExtractGpiiZipFileSystem ().execute ();
252
+ }
253
+
235
254
if (file .exists ()) {
236
255
downloadButton .setVisibility (View .GONE );
237
256
installationButton .setVisibility (View .VISIBLE );
@@ -550,20 +569,17 @@ protected void gunzip(File tarFile, File dest) {
550
569
new BufferedInputStream (new FileInputStream (tarFile ))));
551
570
552
571
TarArchiveEntry tarEntry = tarIn .getNextTarEntry ();
553
- // tarIn is a TarArchiveInputStream
572
+
554
573
while (tarEntry != null ) {
555
- // create a file with the same name as the
556
- // tarEntry
574
+
557
575
File destPath = new File (dest , tarEntry .getName ());
558
576
System .out .println ("working: " + destPath .getCanonicalPath ());
559
577
if (tarEntry .isDirectory ()) {
560
578
destPath .mkdirs ();
561
579
} else {
562
580
destPath .createNewFile ();
563
- // byte [] btoRead = new byte[(int)tarEntry.getSize()];
564
581
byte [] btoRead = new byte [1024 ];
565
- // FileInputStream fin
566
- // = new FileInputStream(destPath.getCanonicalPath());
582
+
567
583
BufferedOutputStream bout =
568
584
new BufferedOutputStream (new FileOutputStream (destPath ));
569
585
int len = 0 ;
@@ -713,11 +729,23 @@ protected void onPostExecute(Void result) {
713
729
@ Override
714
730
protected Void doInBackground (Void ... params ) {
715
731
716
- File fileTar = new File (filepathgpii + gpiiJS );
732
+ File fileTar = new File (filepathgpii + gpiiJS );;
733
+ if (tarIncluded ){
734
+
735
+ try {
736
+ InputStream inputStream = ctx .getResources ().getAssets ().open ("gpii-android" );
737
+ fileTar = createFileFromInputStream (inputStream ,fileTar );
738
+ } catch (Exception e ) {
739
+ e .printStackTrace ();
740
+ }
741
+ } else {
742
+ fileTar = new File (filepathgpii + gpiiJS );
743
+ }
717
744
File fileDest = new File (filepathgpii );
718
745
719
- gunzip (fileTar , fileDest );
720
-
746
+ if (fileTar !=null ){
747
+ gunzip (fileTar , fileDest );
748
+ }
721
749
return null ;
722
750
}
723
751
0 commit comments