// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/PhialErrorPlugins.java
// public class PhialErrorPlugins {
//     public interface ErrorHandler {
//         void onError(Throwable throwable);
//     }
// 
//     private static ErrorHandler handler;
// 
//     public static void setHandler(ErrorHandler handler) {
//         PhialErrorPlugins.handler = handler;
//     }
// 
//     public static void onError(Throwable throwable) {
//         if (handler != null) {
//             handler.onError(throwable);
//         }
//     }
// }
// 
// Path: phial-key-value/src/main/java/com/mindcoders/phial/keyvalue/Category.java
// public class Category {
//     private final String name;
//     private final List<Saver> savers;
// 
//     Category(String name, List<Saver> savers) {
//         this.name = name;
//         this.savers = savers;
//     }
// 
//     /**
//      * Sets a value to be associated with your debug data.
//      * Entry will be under the category set via {@link Phial#category(String)}
//      * <p>
//      * Note: setKey(key, null) will set associated value to null. In order to remove entry use {@link Phial#removeKey(String)}
//      *
//      * @param key   of the debug data
//      * @param value associated value
//      */
//     public Category setKey(@NonNull String key, String value) {
//         verifyKeyIsNotNull(key);
//         for (Saver saver : savers) {
//             saver.save(name, key, value);
//         }
//         return this;
//     }
// 
//     /**
//      * Sets a value to be associated with your debug data.
//      * Entry will be under the category set via {@link Phial#category(String)}
//      * <p>
//      * Note: setKey(key, null) will set associated value to null. In order to remove entry use {@link Phial#removeKey(String)}
//      *
//      * @param key   of the debug data
//      * @param value associated value
//      */
//     public Category setKey(@NonNull String key, Object value) {
//         verifyKeyIsNotNull(key);
//         for (Saver saver : savers) {
//             saver.save(name, key, String.valueOf(value));
//         }
//         return this;
//     }
// 
//     /**
//      * Removes entry with given key from debug data.
//      * <p>
//      * Note: Entry would be removed only from the category set via {@link Phial#category(String)}
//      *
//      * @param key to be removed.
//      */
//     public Category removeKey(@NonNull String key) {
//         verifyKeyIsNotNull(key);
//         for (Saver saver : savers) {
//             saver.remove(name, key);
//         }
//         return this;
//     }
// 
//     /**
//      * Clears all the keys associated with this category.
//      */
//     public void clear() {
//         for (Saver saver : savers) {
//             saver.remove(name);
//         }
//     }
// 
//     private void verifyKeyIsNotNull(String key) {
//         if (key == null) {
//             throw new IllegalArgumentException("key should not be null.");
//         }
//     }
// }


import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.support.annotation.Nullable;
import com.mindcoders.phial.internal.PhialErrorPlugins;
import com.mindcoders.phial.keyvalue.Category;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
package com.mindcoders.phial.internal.keyvalue;




/**
 * Created by rost on 10/30/17.
 */

public final class BuildInfoWriter extends InfoWriter {
    private final static String DATE_FORMAT = "d MMM yyyy HH:mm Z";
    @Nullable
    private final Long buildTime;
    @Nullable
    private final String buildCommit;

    public BuildInfoWriter(Context context) {
        this(context, null, null);
    }

    public BuildInfoWriter(Context context, @Nullable Long buildTime, @Nullable String buildCommit) {
        super(context, "Build");
        this.buildTime = buildTime;
        this.buildCommit = buildCommit;
    }

    @Override
    protected void writeInfo(Category category) {
        final String packageName = getContext().getPackageName();
        category.setKey("Package", packageName);

        try {
            final PackageInfo packageInfo = getContext().getPackageManager()
                    .getPackageInfo(packageName, PackageManager.GET_META_DATA);
            category.setKey("Version", packageInfo.versionName);
        } catch (PackageManager.NameNotFoundException e) {
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/PhialErrorPlugins.java
// public class PhialErrorPlugins {
//     public interface ErrorHandler {
//         void onError(Throwable throwable);
//     }
// 
//     private static ErrorHandler handler;
// 
//     public static void setHandler(ErrorHandler handler) {
//         PhialErrorPlugins.handler = handler;
//     }
// 
//     public static void onError(Throwable throwable) {
//         if (handler != null) {
//             handler.onError(throwable);
//         }
//     }
// }
// 
// Path: phial-key-value/src/main/java/com/mindcoders/phial/keyvalue/Category.java
// public class Category {
//     private final String name;
//     private final List<Saver> savers;
// 
//     Category(String name, List<Saver> savers) {
//         this.name = name;
//         this.savers = savers;
//     }
// 
//     /**
//      * Sets a value to be associated with your debug data.
//      * Entry will be under the category set via {@link Phial#category(String)}
//      * <p>
//      * Note: setKey(key, null) will set associated value to null. In order to remove entry use {@link Phial#removeKey(String)}
//      *
//      * @param key   of the debug data
//      * @param value associated value
//      */
//     public Category setKey(@NonNull String key, String value) {
//         verifyKeyIsNotNull(key);
//         for (Saver saver : savers) {
//             saver.save(name, key, value);
//         }
//         return this;
//     }
// 
//     /**
//      * Sets a value to be associated with your debug data.
//      * Entry will be under the category set via {@link Phial#category(String)}
//      * <p>
//      * Note: setKey(key, null) will set associated value to null. In order to remove entry use {@link Phial#removeKey(String)}
//      *
//      * @param key   of the debug data
//      * @param value associated value
//      */
//     public Category setKey(@NonNull String key, Object value) {
//         verifyKeyIsNotNull(key);
//         for (Saver saver : savers) {
//             saver.save(name, key, String.valueOf(value));
//         }
//         return this;
//     }
// 
//     /**
//      * Removes entry with given key from debug data.
//      * <p>
//      * Note: Entry would be removed only from the category set via {@link Phial#category(String)}
//      *
//      * @param key to be removed.
//      */
//     public Category removeKey(@NonNull String key) {
//         verifyKeyIsNotNull(key);
//         for (Saver saver : savers) {
//             saver.remove(name, key);
//         }
//         return this;
//     }
// 
//     /**
//      * Clears all the keys associated with this category.
//      */
//     public void clear() {
//         for (Saver saver : savers) {
//             saver.remove(name);
//         }
//     }
// 
//     private void verifyKeyIsNotNull(String key) {
//         if (key == null) {
//             throw new IllegalArgumentException("key should not be null.");
//         }
//     }
// }


// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/keyvalue/BuildInfoWriter.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.support.annotation.Nullable;
import com.mindcoders.phial.internal.PhialErrorPlugins;
import com.mindcoders.phial.keyvalue.Category;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

package com.mindcoders.phial.internal.keyvalue;




/**
 * Created by rost on 10/30/17.
 */

public final class BuildInfoWriter extends InfoWriter {
    private final static String DATE_FORMAT = "d MMM yyyy HH:mm Z";
    @Nullable
    private final Long buildTime;
    @Nullable
    private final String buildCommit;

    public BuildInfoWriter(Context context) {
        this(context, null, null);
    }

    public BuildInfoWriter(Context context, @Nullable Long buildTime, @Nullable String buildCommit) {
        super(context, "Build");
        this.buildTime = buildTime;
        this.buildCommit = buildCommit;
    }

    @Override
    protected void writeInfo(Category category) {
        final String packageName = getContext().getPackageName();
        category.setKey("Package", packageName);

        try {
            final PackageInfo packageInfo = getContext().getPackageManager()
                    .getPackageInfo(packageName, PackageManager.GET_META_DATA);
            category.setKey("Version", packageInfo.versionName);
        } catch (PackageManager.NameNotFoundException e) {
            PhialErrorPlugins.onError(e);