// Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
// 
//     public class RomInfo {
// 
//         public int id;
//         public String filename;
//         public String path;
//         public String folder;
//         public String md5;
//         public String type;
//         public String description;
//         public int is_flashable;
//         public long modified;
//         public int downloads;
//         public int status;
//         public String additional_info;
//         public String short_url;
//         public int developer_id;
//         public String developerid;
//         public String board;
//         public String rom;
//         public long version;
//         public int gapps_package;
//         public int incremental_file;
//     }
// 
//     public static final String PROPERTY_DEVICE = "ro.product.device";
// 
//     public static interface UpdaterListener {
// 
//         public void versionFound(RomInfo info);
//         public void versionError(String error);
//     }
// 
//     public String getRomName();
// 
//     public int getRomVersion();
// 
//     public void searchVersion();
// 
//     public boolean isScanning();
// }
// 
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
// 
//     public static interface HttpStringReaderListener {
// 
//         public void onReadEnd(String buffer);
//         public void onReadError(Exception ex);
//     };
// 
//     private HttpStringReaderListener mListener;
//     private String mResponse;
//     private Exception mException;
//     
//     public HttpStringReader(HttpStringReaderListener listener) {
//         mListener = listener;
//     }
// 
//     @Override
//     protected Void doInBackground(String... urls) {
//         try {
//             HttpClient client = new DefaultHttpClient();
//             HttpGet get = new HttpGet(urls[0]);
//             HttpResponse r = client.execute(get);
//             int status = r.getStatusLine().getStatusCode();
//             HttpEntity e = r.getEntity();
//             if (status == 200) {
//                 mResponse = EntityUtils.toString(e);
//             } else {
//                 if (e != null) e.consumeContent();
//                 String error = "Server responded with error " + status;
//                 mException = new Exception(error);
//             }
//         } catch (Exception ex) {
//             ex.printStackTrace();
//             mException = ex;
//         }
//         return null;
//     }
// 
//     @Override
//     protected void onPostExecute(Void result) {
//         if (mListener != null) {
//             if (mException != null) {
//                 mListener.onReadError(mException);
//             } else {
//                 mListener.onReadEnd(mResponse);
//             }
//         }
//     }
// }
// 
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
// 
//     private static final int ALARM_ID = 122303221;
// 
//     public static String getProperty(String prop) {
//         try {
//             Process p = Runtime.getRuntime().exec("getprop " + prop);
//             p.waitFor();
//             BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
//             String line = input.readLine();
//             return "".equals(line) ? null : line;
//         } catch (Exception e) {
//             e.printStackTrace();
//             return null;
//         }
//     }
//     
//     public static boolean isNetworkAvailable(Context context) {
//         ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//         NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
//         return activeNetworkInfo != null && activeNetworkInfo.isConnected();
//     }
//     
//     public static void setAlarm(Context context, long time, boolean trigger) {
// 
//         Intent i = new Intent(context, NotificationAlarm.class);
//         i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 
//         PendingIntent pi = PendingIntent
//                 .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
// 
//         AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//         am.cancel(pi);
//         if (time > 0) {
//             am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
//         }
//     }
// 
//     public static boolean alarmExists(Context context) {
//         return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
//                 NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
//     }
// }


import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties;
/*
 * Copyright 2014 ZipInstaller Project
 *
 * This file is part of ZipInstaller.
 *
 * ZipInstaller is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ZipInstaller is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ZipInstaller.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.beerbong.zipinst.core.plugins.update.impl;




public class OUCUpdater implements Updater {

    public static final String URL = "https://www.otaupdatecenter.pro/pages/romupdate.php";
    public static final String PROPERTY_OTA_ID = "otaupdater.otaid";
    public static final String PROPERTY_OTA_VER = "otaupdater.otaver";
    public static final String PROPERTY_OTA_TIME = "otaupdater.otatime";

    private UpdaterListener mListener;
    private boolean mScanning = false;

    public OUCUpdater(UpdaterListener listener) {
        mListener = listener;
    }

    @Override
    public String getRomName() {
         return SystemProperties.getProperty(PROPERTY_OTA_ID);
    }

    @Override
    public int getRomVersion() {
// Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
// 
//     public class RomInfo {
// 
//         public int id;
//         public String filename;
//         public String path;
//         public String folder;
//         public String md5;
//         public String type;
//         public String description;
//         public int is_flashable;
//         public long modified;
//         public int downloads;
//         public int status;
//         public String additional_info;
//         public String short_url;
//         public int developer_id;
//         public String developerid;
//         public String board;
//         public String rom;
//         public long version;
//         public int gapps_package;
//         public int incremental_file;
//     }
// 
//     public static final String PROPERTY_DEVICE = "ro.product.device";
// 
//     public static interface UpdaterListener {
// 
//         public void versionFound(RomInfo info);
//         public void versionError(String error);
//     }
// 
//     public String getRomName();
// 
//     public int getRomVersion();
// 
//     public void searchVersion();
// 
//     public boolean isScanning();
// }
// 
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
// 
//     public static interface HttpStringReaderListener {
// 
//         public void onReadEnd(String buffer);
//         public void onReadError(Exception ex);
//     };
// 
//     private HttpStringReaderListener mListener;
//     private String mResponse;
//     private Exception mException;
//     
//     public HttpStringReader(HttpStringReaderListener listener) {
//         mListener = listener;
//     }
// 
//     @Override
//     protected Void doInBackground(String... urls) {
//         try {
//             HttpClient client = new DefaultHttpClient();
//             HttpGet get = new HttpGet(urls[0]);
//             HttpResponse r = client.execute(get);
//             int status = r.getStatusLine().getStatusCode();
//             HttpEntity e = r.getEntity();
//             if (status == 200) {
//                 mResponse = EntityUtils.toString(e);
//             } else {
//                 if (e != null) e.consumeContent();
//                 String error = "Server responded with error " + status;
//                 mException = new Exception(error);
//             }
//         } catch (Exception ex) {
//             ex.printStackTrace();
//             mException = ex;
//         }
//         return null;
//     }
// 
//     @Override
//     protected void onPostExecute(Void result) {
//         if (mListener != null) {
//             if (mException != null) {
//                 mListener.onReadError(mException);
//             } else {
//                 mListener.onReadEnd(mResponse);
//             }
//         }
//     }
// }
// 
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
// 
//     private static final int ALARM_ID = 122303221;
// 
//     public static String getProperty(String prop) {
//         try {
//             Process p = Runtime.getRuntime().exec("getprop " + prop);
//             p.waitFor();
//             BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
//             String line = input.readLine();
//             return "".equals(line) ? null : line;
//         } catch (Exception e) {
//             e.printStackTrace();
//             return null;
//         }
//     }
//     
//     public static boolean isNetworkAvailable(Context context) {
//         ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//         NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
//         return activeNetworkInfo != null && activeNetworkInfo.isConnected();
//     }
//     
//     public static void setAlarm(Context context, long time, boolean trigger) {
// 
//         Intent i = new Intent(context, NotificationAlarm.class);
//         i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 
//         PendingIntent pi = PendingIntent
//                 .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
// 
//         AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//         am.cancel(pi);
//         if (time > 0) {
//             am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
//         }
//     }
// 
//     public static boolean alarmExists(Context context) {
//         return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
//                 NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
//     }
// }


// Path: src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java
import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties;

/*
 * Copyright 2014 ZipInstaller Project
 *
 * This file is part of ZipInstaller.
 *
 * ZipInstaller is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ZipInstaller is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ZipInstaller.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.beerbong.zipinst.core.plugins.update.impl;




public class OUCUpdater implements Updater {

    public static final String URL = "https://www.otaupdatecenter.pro/pages/romupdate.php";
    public static final String PROPERTY_OTA_ID = "otaupdater.otaid";
    public static final String PROPERTY_OTA_VER = "otaupdater.otaver";
    public static final String PROPERTY_OTA_TIME = "otaupdater.otatime";

    private UpdaterListener mListener;
    private boolean mScanning = false;

    public OUCUpdater(UpdaterListener listener) {
        mListener = listener;
    }

    @Override
    public String getRomName() {
         return SystemProperties.getProperty(PROPERTY_OTA_ID);
    }

    @Override
    public int getRomVersion() {
        String version = SystemProperties.getProperty(PROPERTY_OTA_TIME);