Skip to content

Commit ea287c4

Browse files
committed
Changes added to GpiiActivity to fix some bugs
1 parent d7a883f commit ea287c4

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

platform/app/src/net/gpii/app/GpiiActivity.java

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
@SuppressLint("NewApi")
7878
public class GpiiActivity extends Activity {
7979

80+
private Context ctx;
8081
private boolean isSystemApp;
8182
private static String TAG = "Cloud4all";
8283
private static String filepathgpii = Environment
@@ -92,6 +93,8 @@ public class GpiiActivity extends Activity {
9293

9394
private static String gpiiJS;
9495
private static String gpiiAPK;
96+
private static String uriUserListeners;
97+
private static String gpiiUserListenersAPK;
9598

9699
private static String privSystemDir = "/system/priv-app";
97100
private static String systemDir = "/system/app";
@@ -116,6 +119,7 @@ public class GpiiActivity extends Activity {
116119
private Button downloadButton;
117120
private RelativeLayout gpiiInfo;
118121
private File file;
122+
private File userListenersFile;
119123

120124
private long enqueue;
121125
private DownloadManager dm;
@@ -215,23 +219,38 @@ public void onCreate(Bundle savedInstanceState) {
215219
} catch (IOException ioe) {
216220
ioe.printStackTrace();
217221
}
222+
223+
userListenersFile = new File(Environment.getExternalStorageDirectory(),gpiiUserListenersAPK);
218224

219225
try {
220226
tarIncluded=true;
221-
Arrays.asList(getResources().getAssets().list("")).contains("gpii-android.tar.gz");
227+
Arrays.asList(getResources().getAssets().list("")).contains("gpii-android");
222228
} catch (IOException e1) {
223229

224230
tarIncluded=false;
225231
e1.printStackTrace();
226232
}
227233

228-
if(!gpiiApkInstalled("cloud4all.UserListener.NFC")){
234+
if(!gpiiApkInstalled("cloud4all.UserListener.NFC")&&!userListenersFile.exists()){
229235
installGPIIUserListeners();
230236
userListenersInstalled = false;
231237
installationUserListenersEnabled=true;
232238

233239
} else {
234240

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+
235254
if (file.exists()) {
236255
downloadButton.setVisibility(View.GONE);
237256
installationButton.setVisibility(View.VISIBLE);
@@ -550,20 +569,17 @@ protected void gunzip(File tarFile, File dest) {
550569
new BufferedInputStream(new FileInputStream(tarFile))));
551570

552571
TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
553-
// tarIn is a TarArchiveInputStream
572+
554573
while (tarEntry != null) {
555-
// create a file with the same name as the
556-
// tarEntry
574+
557575
File destPath = new File(dest, tarEntry.getName());
558576
System.out.println("working: " + destPath.getCanonicalPath());
559577
if (tarEntry.isDirectory()) {
560578
destPath.mkdirs();
561579
} else {
562580
destPath.createNewFile();
563-
// byte [] btoRead = new byte[(int)tarEntry.getSize()];
564581
byte[] btoRead = new byte[1024];
565-
// FileInputStream fin
566-
// = new FileInputStream(destPath.getCanonicalPath());
582+
567583
BufferedOutputStream bout =
568584
new BufferedOutputStream(new FileOutputStream(destPath));
569585
int len = 0;
@@ -713,11 +729,23 @@ protected void onPostExecute(Void result) {
713729
@Override
714730
protected Void doInBackground(Void... params) {
715731

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+
}
717744
File fileDest = new File(filepathgpii);
718745

719-
gunzip(fileTar, fileDest);
720-
746+
if(fileTar!=null){
747+
gunzip(fileTar, fileDest);
748+
}
721749
return null;
722750
}
723751

0 commit comments

Comments
 (0)