导航菜单

页面标题

页面副标题

Aptoide v9.22.5.3 - InstalledIntentService.java 源代码

正在查看: Aptoide v9.22.5.3 应用的 InstalledIntentService.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package cm.aptoide.pt.install;

import android.app.IntentService;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import cm.aptoide.pt.AptoideApplication;
import cm.aptoide.pt.ads.MinimalAdMapper;
import cm.aptoide.pt.app.CampaignAnalytics;
import cm.aptoide.pt.app.aptoideinstall.AptoideInstallManager;
import cm.aptoide.pt.app.migration.AppcMigrationManager;
import cm.aptoide.pt.crashreports.CrashReport;
import cm.aptoide.pt.database.RoomStoredMinimalAdPersistence;
import cm.aptoide.pt.database.room.RoomInstalled;
import cm.aptoide.pt.database.room.RoomStoredMinimalAd;
import cm.aptoide.pt.dataprovider.ads.AdNetworkUtils;
import cm.aptoide.pt.logger.Logger;
import cm.aptoide.pt.preferences.managed.ManagerPreferences;
import cm.aptoide.pt.root.RootAvailabilityManager;
import cm.aptoide.pt.updates.UpdateRepository;
import cm.aptoide.pt.util.ReferrerUtils;
import cm.aptoide.pt.utils.AptoideUtils;
import cm.aptoide.pt.utils.FileUtils;
import java.util.concurrent.Callable;
import javax.inject.Inject;
import rx.schedulers.Schedulers;

public class InstalledIntentService extends IntentService {
    private static final String TAG = InstalledIntentService.class.getName();
    private MinimalAdMapper adMapper;

    @Inject
    AppcMigrationManager appcMigrationManager;

    @Inject
    AptoideInstallManager aptoideInstallManager;

    @Inject
    CampaignAnalytics campaignAnalytics;

    @Inject
    FileUtils fileUtils;

    @Inject
    InstallAnalytics installAnalytics;
    private InstallManager installManager;
    private PackageManager packageManager;

    @Inject
    RoomStoredMinimalAdPersistence roomStoredMinimalAdPersistence;
    private RootAvailabilityManager rootAvailabilityManager;
    private SharedPreferences sharedPreferences;
    private rx.t.b subscriptions;

    @Inject
    UpdateRepository updatesRepository;

    public InstalledIntentService() {
        super("InstalledIntentService");
    }

    private void checkAndBroadcastReferrer(final String str) {
        this.subscriptions.a(this.roomStoredMinimalAdPersistence.get(str).j0(Schedulers.io()).H(new rx.m.e() {
            @Override
            public final Object call(Object obj) {
                return InstalledIntentService.this.a(str, (RoomStoredMinimalAd) obj);
            }
        }).H0(new rx.m.b() {
            @Override
            public final void call(Object obj) {
                InstalledIntentService.lambda$checkAndBroadcastReferrer$3((RoomStoredMinimalAd) obj);
            }
        }, new rx.m.b() {
            @Override
            public final void call(Object obj) {
                CrashReport.getInstance().log((Throwable) obj);
            }
        }));
    }

    private boolean checkAndLogNullPackageInfo(PackageInfo packageInfo, String str) {
        if (packageInfo != null) {
            return false;
        }
        CrashReport.getInstance().log(new IllegalArgumentException("PackageName null for package " + str));
        return true;
    }

    private PackageInfo databaseOnPackageAdded(String str) {
        PackageInfo packageInfo = AptoideUtils.SystemU.getPackageInfo(str, getPackageManager());
        if (checkAndLogNullPackageInfo(packageInfo, str)) {
            return packageInfo;
        }
        this.installManager.onAppInstalled(new RoomInstalled(packageInfo, this.packageManager, this.fileUtils)).I(new rx.m.a() {
            @Override
            public final void call() {
                InstalledIntentService.lambda$databaseOnPackageAdded$0();
            }
        }, new rx.m.b() {
            @Override
            public final void call(Object obj) {
                CrashReport.getInstance().log((Throwable) obj);
            }
        });
        return packageInfo;
    }

    private void databaseOnPackageRemoved(final String str) {
        this.installManager.onAppRemoved(str).a(this.updatesRepository.remove(str)).I(new rx.m.a() {
            @Override
            public final void call() {
                Logger.getInstance().d(InstalledIntentService.TAG, "databaseOnPackageRemoved: " + str);
            }
        }, new rx.m.b() {
            @Override
            public final void call(Object obj) {
                CrashReport.getInstance().log((Throwable) obj);
            }
        });
    }

    private PackageInfo databaseOnPackageReplaced(final String str) {
        PackageInfo packageInfo = AptoideUtils.SystemU.getPackageInfo(str, getPackageManager());
        if (checkAndLogNullPackageInfo(packageInfo, str)) {
            return packageInfo;
        }
        this.installManager.onUpdateConfirmed(new RoomInstalled(packageInfo, this.packageManager, this.fileUtils)).a(this.updatesRepository.remove(str)).I(new rx.m.a() {
            @Override
            public final void call() {
                Logger.getInstance().d(InstalledIntentService.TAG, "databaseOnPackageReplaced: " + str);
            }
        }, new rx.m.b() {
            @Override
            public final void call(Object obj) {
                CrashReport.getInstance().log((Throwable) obj);
            }
        });
        return packageInfo;
    }

    private rx.b knockCpi(final String str, final RoomStoredMinimalAdPersistence roomStoredMinimalAdPersistence, final RoomStoredMinimalAd roomStoredMinimalAd) {
        return rx.b.u(new Callable() {
            @Override
            public final Object call() {
                InstalledIntentService.this.b(str, roomStoredMinimalAd, roomStoredMinimalAdPersistence);
                return null;
            }
        });
    }

    public rx.b a(String str, RoomStoredMinimalAd roomStoredMinimalAd) {
        if (roomStoredMinimalAd != null) {
            return knockCpi(str, this.roomStoredMinimalAdPersistence, roomStoredMinimalAd);
        }
        return null;
    }

    static void lambda$checkAndBroadcastReferrer$3(RoomStoredMinimalAd roomStoredMinimalAd) {
    }

    static void lambda$databaseOnPackageAdded$0() {
    }

    private Object lambda$knockCpi$9(String str, RoomStoredMinimalAd roomStoredMinimalAd, RoomStoredMinimalAdPersistence roomStoredMinimalAdPersistence) throws Exception {
        ReferrerUtils.broadcastReferrer(str, roomStoredMinimalAd.getReferrer(), getApplicationContext());
        AdNetworkUtils.knockCpi(this.adMapper.map(roomStoredMinimalAd));
        roomStoredMinimalAdPersistence.remove(roomStoredMinimalAd);
        return null;
    }

    private void reportPackageInfoNullEvent() {
        CrashReport.getInstance().log(new NullPointerException("PackageInfo is null."));
    }

    private void sendCampaignConversion(String str, PackageInfo packageInfo) {
        if (packageInfo != null) {
            this.campaignAnalytics.convertCampaignEvent(str, packageInfo.versionCode);
        } else {
            reportPackageInfoNullEvent();
        }
    }

    private void sendInstallEvent(String str, PackageInfo packageInfo) {
        if (packageInfo != null) {
            this.installAnalytics.installCompleted(str, packageInfo.versionCode, ((Boolean) this.rootAvailabilityManager.isRootAvailable().y().b()).booleanValue(), ManagerPreferences.allowRootInstallation(this.sharedPreferences));
        } else {
            reportPackageInfoNullEvent();
        }
    }

    private void sendUninstallEvent(String str) {
        this.installAnalytics.uninstallCompleted(str);
    }

    public Object b(String str, RoomStoredMinimalAd roomStoredMinimalAd, RoomStoredMinimalAdPersistence roomStoredMinimalAdPersistence) {
        lambda$knockCpi$9(str, roomStoredMinimalAd, roomStoredMinimalAdPersistence);
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        ((AptoideApplication) getApplicationContext()).getApplicationComponent().inject(this);
        this.adMapper = new MinimalAdMapper();
        this.sharedPreferences = ((AptoideApplication) getApplicationContext()).getDefaultSharedPreferences();
        ((AptoideApplication) getApplicationContext()).getDefaultSharedPreferences();
        this.subscriptions = new rx.t.b();
        this.installManager = ((AptoideApplication) getApplicationContext()).getInstallManager();
        this.rootAvailabilityManager = ((AptoideApplication) getApplicationContext()).getRootAvailabilityManager();
        this.packageManager = getPackageManager();
    }

    @Override
    protected void onHandleIntent(android.content.Intent r6) {
        throw new UnsupportedOperationException("Method not decompiled: cm.aptoide.pt.install.InstalledIntentService.onHandleIntent(android.content.Intent):void");
    }

    protected void onPackageAdded(String str) {
        Logger.getInstance().d(TAG, "Package added: " + str);
        PackageInfo databaseOnPackageAdded = databaseOnPackageAdded(str);
        checkAndBroadcastReferrer(str);
        sendInstallEvent(str, databaseOnPackageAdded);
        sendCampaignConversion(str, databaseOnPackageAdded);
        this.appcMigrationManager.persistCandidate(str);
        this.aptoideInstallManager.persistCandidate(str);
    }

    protected void onPackageRemoved(String str) {
        Logger.getInstance().d(TAG, "Packaged removed: " + str);
        sendUninstallEvent(str);
        databaseOnPackageRemoved(str);
    }

    protected void onPackageReplaced(String str) {
        Logger.getInstance().d(TAG, "Packaged replaced: " + str);
        PackageInfo databaseOnPackageReplaced = databaseOnPackageReplaced(str);
        sendInstallEvent(str, databaseOnPackageReplaced);
        sendCampaignConversion(str, databaseOnPackageReplaced);
        this.aptoideInstallManager.persistCandidate(str);
    }
}