Mad Aces v1.2.2.3版本的 MD5 值为:f29ebd7c5808053d9f3f3722a5db1688

以下内容为反编译后的 Manager.java 源代码,内容仅作参考


package com.heyzap.house;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Handler;
import android.os.Looper;
import com.heyzap.common.cache.FileCache;
import com.heyzap.common.concurrency.ExecutorPool;
import com.heyzap.common.concurrency.FutureUtils;
import com.heyzap.common.concurrency.SettableFuture;
import com.heyzap.common.net.APIClient;
import com.heyzap.house.abstr.AbstractActivity;
import com.heyzap.house.handler.AttributionHandler;
import com.heyzap.house.model.AdModel;
import com.heyzap.house.request.DisplayCache;
import com.heyzap.house.request.FetchRequest;
import com.heyzap.internal.Constants;
import com.heyzap.internal.ContextReference;
import com.heyzap.internal.Logger;
import com.heyzap.internal.PackageManager;
import com.heyzap.internal.Utils;
import com.heyzap.sdk.ads.HeyzapAds;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

public class Manager {
    public static final String ACTION_URL_PLACEHOLDER = "market://details?id=%s&referrer=%s";
    public static final String ACTION_URL_REFERRER = "utm_source%3Dheyzap%26utm_medium%3Dmobile%26utm_campaign%3Dheyzap_ad_network";
    public static final String FIRST_RUN_KEY = "HeyzapAdsFirstRun";
    public static final long MAX_CACHE_SIZE = 30000000;
    public static Context applicationContext;
    private static DisplayCache displayCache;
    private static FileCache fileCache;
    private static volatile Manager ref;
    public static long maxClickDifference = 1000;
    public static Boolean SLOW_CLOSE = false;
    public static String AD_SERVER = "http://ads.heyzap.com/in_game_api/ads";
    public static final Handler handler = new Handler(Looper.getMainLooper());
    public static Boolean started = false;
    public static AbstractActivity lastActivity = null;
    private static AtomicReference<SettableFuture> initializationFutureRef = new AtomicReference<>();
    public long lastClickedTime = 0;
    private int flags = 0;
    private ContextReference contextRef = null;

    private Manager(ContextReference contextReference, String str) {
        setPublisherId(str);
        setContextRef(contextReference);
        clearAndCreateImageFileCache();
        displayCache = new DisplayCache();
        fileCache = new FileCache(ExecutorPool.getInstance(), new File(Utils.getCacheDirAbsolutePath(contextReference.getApp())), Long.valueOf(MAX_CACHE_SIZE));
    }

    public static void runOnUiThread(Runnable runnable) {
        new Handler(Looper.getMainLooper()).post(runnable);
    }

    public static Boolean isStarted() {
        return started;
    }

    public static SettableFuture start(ContextReference contextReference, String str) {
        if (initializationFutureRef.compareAndSet(null, SettableFuture.create())) {
            if (contextReference.getApp() == null) {
                throw new IllegalArgumentException();
            }
            applicationContext = contextReference.getApp();
            ref = new Manager(contextReference, str);
            SharedPreferences sharedPreferences = contextReference.getApp().getSharedPreferences(Constants.PREFERENCES_KEY, 0);
            SharedPreferences.Editor edit = sharedPreferences.edit();
            if (sharedPreferences.getBoolean("ran_once", false) ? false : true) {
                Logger.log("Running first run tasks");
                AttributionHandler.getInstance().doSelfInstall(applicationContext);
                edit.putBoolean("ran_once", true);
                edit.commit();
            }
            PackageManager.checkInstalledPackages(contextReference.getApp());
            SettableFuture<Boolean> open = ref.getFileCache().open();
            open.addListener(new Runnable() {
                @Override
                public void run() {
                    Manager.ref.getFileCache().flush();
                }
            }, ExecutorPool.getInstance());
            FutureUtils.bind(open, initializationFutureRef.get(), ExecutorPool.getInstance());
            initializationFutureRef.get().addListener(new Runnable() {
                @Override
                public void run() {
                    Manager.started = true;
                    Logger.log("Heyzap Ad Manager started.");
                }
            }, ExecutorPool.getInstance());
        }
        return initializationFutureRef.get();
    }

    public DisplayCache getDisplayCache() {
        return displayCache;
    }

    public FileCache getFileCache() {
        return fileCache;
    }

    public List<String> getLocalPackages() {
        if (applicationContext == null) {
            return null;
        }
        List<PackageInfo> installedPackages = applicationContext.getPackageManager().getInstalledPackages(0);
        ArrayList arrayList = new ArrayList();
        for (PackageInfo packageInfo : installedPackages) {
            if (!packageInfo.packageName.startsWith("android.") && !packageInfo.packageName.startsWith("com.google.android") && !packageInfo.packageName.startsWith("com.android") && !packageInfo.packageName.startsWith("com.htc") && !packageInfo.packageName.startsWith("com.samsung") && !packageInfo.packageName.startsWith("com.sec") && !packageInfo.packageName.startsWith("com.monotype") && !packageInfo.packageName.startsWith("com.verizon") && !packageInfo.packageName.startsWith("com.qualcomm") && !packageInfo.packageName.startsWith("com.vzw")) {
                arrayList.add(packageInfo.packageName);
            }
        }
        return arrayList;
    }

    public void installHeyzap(AdModel adModel) {
    }

    public void clearAndCreateFileCache() {
        String cacheDirAbsolutePath = Utils.getCacheDirAbsolutePath(applicationContext);
        try {
            if (new File(cacheDirAbsolutePath).exists()) {
                Utils.deleteDirectory(new File(cacheDirAbsolutePath));
            }
            new File(cacheDirAbsolutePath).mkdirs();
        } catch (Exception e) {
            Logger.trace((Throwable) e);
        }
    }

    public void clearAndCreateImageFileCache() {
        String imageCacheDirAbsolutePath = Utils.getImageCacheDirAbsolutePath(applicationContext);
        try {
            if (new File(imageCacheDirAbsolutePath).exists()) {
                Utils.deleteDirectory(new File(imageCacheDirAbsolutePath));
            }
            new File(imageCacheDirAbsolutePath).mkdirs();
        } catch (Exception e) {
            Logger.trace((Throwable) e);
        }
    }

    public void setPublisherId(String str) {
        HeyzapAds.config.publisherId = str;
    }

    public String getPublisherId() {
        return HeyzapAds.config.publisherId;
    }

    public void setContextRef(ContextReference contextReference) {
        this.contextRef = contextReference;
    }

    public void setFlags(int i) {
        this.flags = i;
    }

    public Boolean isFlagEnabled(int i) {
        return Boolean.valueOf((this.flags & i) == i);
    }

    public static synchronized Manager getInstance() {
        Manager manager;
        synchronized (Manager.class) {
            if (ref == null) {
                throw new RuntimeException("Heyzap has not been started yet! Start Heyzap by calling HeyzapAds.start(<your-publisher-id>) in your launch Activity.");
            }
            manager = ref;
        }
        return manager;
    }

    public Object clone() {
        return null;
    }

    public static void setAdsHost(String str) {
        FetchRequest.setDefaultHost(str);
        APIClient.DOMAIN = str;
        AD_SERVER = "http://" + str + "/in_game_api/ads";
    }
}