/** * Go through each of the APK Expansion files defined in the structure above and determine if the * files are present and match the required size. Free applications should definitely consider * doing this, as this allows the application to be launched for the first time without having a * network connection present. Paid applications that use LVL should probably do at least one LVL * check that requires the network to be present, so this is not as necessary. * * @return true if they are present. */ boolean expansionFilesDelivered() { for (XAPKFile xf : xAPKS) { String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion); File fileForNewFile = new File(Helpers.generateSaveFileName(this, fileName)); if (!fileForNewFile.exists()) { return false; } } return true; }
boolean onlySingleExpansionFileFound() { for (OBBData.XAPKFile xf : OBBData.xAPKS) { String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion); GameActivity.Log.debug("Checking for file : " + fileName); String fileForNewFile = Helpers.generateSaveFileName(this, fileName); String fileForDevFile = Helpers.generateSaveFileNameDevelopment(this, fileName); if (Helpers.doesFileExist(this, fileName, xf.mFileSize, false) && Helpers.doesFileExistDev(this, fileName, xf.mFileSize, false)) return false; } return true; }
/** * Go through each of the APK Expansion files defined in the structure above and determine if the * files are present and match the required size. Free applications should definitely consider * doing this, as this allows the application to be launched for the first time without having a * network connection present. Paid applications that use LVL should probably do at least one LVL * check that requires the network to be present, so this is not as necessary. * * @return true if they are present. */ boolean expansionFilesDelivered() { for (OBBData.XAPKFile xf : OBBData.xAPKS) { String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion); GameActivity.Log.debug("Checking for file : " + fileName); String fileForNewFile = Helpers.generateSaveFileName(this, fileName); String fileForDevFile = Helpers.generateSaveFileNameDevelopment(this, fileName); GameActivity.Log.debug( "which is really being resolved to : " + fileForNewFile + "\n Or : " + fileForDevFile); if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false) && !Helpers.doesFileExistDev(this, fileName, xf.mFileSize, false)) return false; } return true; }
boolean expansionFilesUptoData() { File cacheFile = getFileDetailsCacheFile(); // Read data into an array or something... Map<String, Long> fileDetailsMap = new HashMap<String, Long>(); if (cacheFile.exists()) { try { FileReader fileCache = new FileReader(cacheFile); BufferedReader bufferedFileCache = new BufferedReader(fileCache); List<String> lines = new ArrayList<String>(); String line = null; while ((line = bufferedFileCache.readLine()) != null) { lines.add(line); } bufferedFileCache.close(); for (String dataLine : lines) { GameActivity.Log.debug("Splitting dataLine => " + dataLine); String[] parts = dataLine.split(","); fileDetailsMap.put(parts[0], Long.parseLong(parts[1])); } } catch (Exception e) { GameActivity.Log.debug("Exception thrown during file details reading."); e.printStackTrace(); fileDetailsMap.clear(); } } for (OBBData.XAPKFile xf : OBBData.xAPKS) { String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion); String fileForNewFile = Helpers.generateSaveFileName(this, fileName); String fileForDevFile = Helpers.generateSaveFileNameDevelopment(this, fileName); // check to see if time/data on files match cached version // if not return false File srcFile = new File(fileForNewFile); File srcDevFile = new File(fileForDevFile); long lastModified = srcFile.lastModified(); long lastModifiedDev = srcDevFile.lastModified(); if (!(srcFile.exists() && fileDetailsMap.containsKey(fileName) && lastModified == fileDetailsMap.get(fileName)) && !(srcDevFile.exists() && fileDetailsMap.containsKey(fileName) && lastModifiedDev == fileDetailsMap.get(fileName))) return false; } return true; }
private static void RemoveOBBFile(int OBBToDelete) { for (OBBData.XAPKFile xf : OBBData.xAPKS) { String fileName = Helpers.getExpansionAPKFileName( DownloaderActivity._download, xf.mIsMain, xf.mFileVersion); switch (OBBToDelete) { case 0: String fileForNewFile = Helpers.generateSaveFileName(DownloaderActivity._download, fileName); File srcFile = new File(fileForNewFile); srcFile.delete(); break; case 1: String fileForDevFile = Helpers.generateSaveFileNameDevelopment(DownloaderActivity._download, fileName); File srcDevFile = new File(fileForDevFile); srcDevFile.delete(); break; } } }