导航菜单

页面标题

页面副标题

Chaupal v3.2 - MediaDownloadService.java 源代码

正在查看: Chaupal v3.2 应用的 MediaDownloadService.java JAVA 源代码文件

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


package com.yupptv.ott.player.offlinedownload;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.SparseArray;
import androidx.core.app.m;
import androidx.core.app.w;
import com.google.android.exoplayer2.offline.Download;
import com.google.android.exoplayer2.offline.DownloadManager;
import com.google.android.exoplayer2.offline.DownloadService;
import com.google.android.exoplayer2.scheduler.PlatformScheduler;
import com.google.android.exoplayer2.scheduler.Requirements;
import com.google.android.exoplayer2.ui.DownloadNotificationHelper;
import com.google.android.exoplayer2.util.NotificationUtil;
import com.google.android.exoplayer2.util.Util;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.razorpay.R;
import com.yupptv.ott.MainActivity;
import com.yupptv.ott.OTTApplication;
import com.yupptv.ottsdk.model.User;
import hd.a;
import hd.d;
import hd.e0;
import hd.h;
import hd.r;
import java.util.List;

public class MediaDownloadService extends DownloadService {
    public static int d = 3;
    private static final SparseArray<OfflineDownloadData> e = new SparseArray<>();
    private static int f;
    private DownloadNotificationHelper a;
    private m.i c;

    class a implements DownloadManager.Listener {
        a() {
        }

        public void onDownloadChanged(DownloadManager downloadManager, Download download, Exception exc) {
            int i = download.state;
            if (i == 3) {
                if (hd.a.a.g(OTTApplication.o()).getLoggedUser() != null) {
                    MediaDownloadService.g(MediaDownloadService.this, Util.fromUtf8Bytes(download.request.data), download.request.uri);
                }
            } else if (i == 4) {
                NotificationUtil.setNotification(MediaDownloadService.this, MediaDownloadService.b(), MediaDownloadService.this.a.buildDownloadFailedNotification(MediaDownloadService.this, 2131231600, (PendingIntent) null, Util.fromUtf8Bytes(download.request.data)));
            }
        }

        public void onDownloadRemoved(DownloadManager downloadManager, Download download) {
            com.google.android.exoplayer2.offline.m.b(this, downloadManager, download);
        }

        public void onDownloadsPausedChanged(DownloadManager downloadManager, boolean z) {
            com.google.android.exoplayer2.offline.m.c(this, downloadManager, z);
        }

        public void onIdle(DownloadManager downloadManager) {
            com.google.android.exoplayer2.offline.m.d(this, downloadManager);
        }

        public void onInitialized(DownloadManager downloadManager) {
            com.google.android.exoplayer2.offline.m.e(this, downloadManager);
        }

        public void onRequirementsStateChanged(DownloadManager downloadManager, Requirements requirements, int i) {
            com.google.android.exoplayer2.offline.m.f(this, downloadManager, requirements, i);
        }

        public void onWaitingForRequirementsChanged(DownloadManager downloadManager, boolean z) {
            com.google.android.exoplayer2.offline.m.g(this, downloadManager, z);
        }
    }

    public MediaDownloadService() {
        super(1, 1000L, "download_channel", 2131952170, 0);
        f = 2;
    }

    static int b() {
        int i = f;
        f = i + 1;
        return i;
    }

    public static Notification c(Context context, int i, String str, PendingIntent pendingIntent, List<Download> list) {
        int i2;
        boolean z;
        Download download;
        Uri uri;
        Uri uri2;
        list.size();
        float f2 = BitmapDescriptorFactory.HUE_RED;
        boolean z2 = false;
        boolean z3 = false;
        int i3 = 0;
        boolean z4 = true;
        boolean z5 = false;
        for (int i4 = 0; i4 < list.size(); i4++) {
            Download download2 = list.get(i4);
            int i5 = download2.state;
            if (i5 == 5) {
                z3 = true;
            } else if (i5 == 7 || i5 == 2) {
                float percentDownloaded = download2.getPercentDownloaded();
                if (percentDownloaded != -1.0f) {
                    f2 += percentDownloaded;
                    z4 = false;
                }
                z5 |= download2.getBytesDownloaded() > 0;
                i3++;
                z2 = true;
            }
        }
        int i6 = z2 ? 2131952168 : z3 ? 2131952174 : 0;
        if (z2) {
            int i10 = (int) (f2 / i3);
            boolean z10 = z4 && z5;
            i2 = i10;
            z = z10;
        } else {
            i2 = 0;
            z = true;
        }
        if (z2) {
            try {
                download = list.get(0);
                uri = null;
                for (int i11 = 0; i11 < list.size(); i11++) {
                    try {
                        Download download3 = list.get(i11);
                        if (download3.state != 0) {
                            uri = download3.request.uri;
                        }
                        SparseArray<OfflineDownloadData> sparseArray = e;
                        OfflineDownloadData offlineDownloadData = sparseArray.get(download3.request.uri.hashCode());
                        if (sparseArray.size() != 0 && offlineDownloadData != null) {
                            OfflineDownloadData offlineDownloadData2 = sparseArray.get(download3.request.uri.hashCode());
                            if (offlineDownloadData2 != null) {
                                offlineDownloadData2.z(e0.e(download3.getBytesDownloaded()));
                                offlineDownloadData2.C("" + e0.L(Float.valueOf(download3.getPercentDownloaded())));
                                offlineDownloadData2.D(System.currentTimeMillis() + d.n);
                                offlineDownloadData2.A(Boolean.TRUE);
                                e0.f0(offlineDownloadData2);
                            }
                        }
                        new e0.v("MediaDownloadService", uri, download3).execute(new Void[0]);
                    } catch (Exception unused) {
                    }
                }
            } catch (Exception unused2) {
                download = null;
                uri = null;
            }
            uri2 = uri;
        } else {
            download = null;
            uri2 = null;
        }
        String fromUtf8Bytes = download != null ? Util.fromUtf8Bytes(download.request.data) : "";
        m.i f3 = f(context, i, str, pendingIntent, fromUtf8Bytes, i6);
        f3.U(100, i2, z);
        f3.R(true);
        f3.Y(false);
        f3.T(2);
        f3.l0(0L);
        w g = w.g(context);
        g.f(MainActivity.class);
        Intent intent = new Intent(context, (Class<?>) CancelDownloadBroadCastReceiver.class);
        intent.addFlags(67108864);
        intent.addFlags(268468224);
        if (uri2 != null) {
            intent.putExtra("FOREGROUND_URI", uri2.toString());
        }
        intent.putExtra("title", fromUtf8Bytes);
        h.a("Offline_Download>>7", "title::" + fromUtf8Bytes);
        intent.putExtra("FOREGROUND_NOTIFICATION_ID", 1);
        Bundle bundle = new Bundle();
        if (uri2 != null) {
            bundle.putParcelable(r.R1, e.get(uri2.hashCode()));
        }
        bundle.putBoolean("SERVICES_COMING_CANCEL_NOTIFICATION", true);
        a.C0133a c0133a = hd.a.a;
        User loggedUser = (c0133a.g(OTTApplication.o()) == null || c0133a.g(OTTApplication.o()).getLoggedUser() == null) ? null : c0133a.g(OTTApplication.o()).getLoggedUser();
        if (loggedUser != null) {
            bundle.putString("USER_ID", loggedUser.getUserId().toString());
        }
        intent.putExtra("NOTIFICATION_DATA", bundle);
        int currentTimeMillis = (int) System.currentTimeMillis();
        g.b(intent);
        int i12 = Build.VERSION.SDK_INT < 31 ? 134217728 : 67108864;
        f3.a(2131231551, "Cancel", PendingIntent.getBroadcast(context, currentTimeMillis, intent, i12));
        Intent intent2 = new Intent(context, (Class<?>) MainActivity.class);
        Bundle bundle2 = new Bundle();
        if (uri2 != null) {
            bundle2.putParcelable(r.R1, e.get(uri2.hashCode()));
        }
        bundle2.putBoolean("SERVICES_COMING_NOTIFICATION", true);
        if (c0133a.g(OTTApplication.o()) != null && c0133a.g(OTTApplication.o()).getLoggedUser() != null) {
            loggedUser = c0133a.g(OTTApplication.o()).getLoggedUser();
        }
        if (loggedUser != null) {
            bundle2.putString("USER_ID", loggedUser.getUserId().toString());
        }
        intent2.putExtra("NOTIFICATION_DATA", bundle2);
        intent2.addFlags(335577088);
        f3.B(PendingIntent.getActivity(context, currentTimeMillis, intent2, i12));
        return f3.g();
    }

    public static void d(String str) {
        SparseArray<OfflineDownloadData> sparseArray = e;
        if (sparseArray.get(str.hashCode()) != null) {
            sparseArray.remove(str.hashCode());
        }
    }

    private static m.i f(Context context, int i, String str, PendingIntent pendingIntent, String str2, int i2) {
        m.i Z;
        NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
        if (Build.VERSION.SDK_INT >= 26) {
            String string = context.getResources().getString(R.string.app_name);
            notificationManager.createNotificationChannel(new NotificationChannel(string, string, 2));
            Z = new m.i(context, string).Z(i);
        } else {
            Z = new m.i(context, context.getResources().getString(R.string.app_name)).Z(i);
        }
        if (i2 != 0) {
            Z.D(context.getResources().getString(i2));
            Z.C(str2);
        }
        if (pendingIntent != null) {
            Z.B(pendingIntent);
        }
        if (str2 != null) {
            Z.e0(new m.g().y(str2));
        }
        return Z;
    }

    public static void g(Context context, String str, Uri uri) {
        m.i iVar;
        NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
        Intent intent = new Intent(context, (Class<?>) MainActivity.class);
        intent.addFlags(67108864);
        intent.addFlags(268468224);
        Bundle bundle = new Bundle();
        bundle.putParcelable(r.R1, e.get(uri.hashCode()));
        bundle.putBoolean("SERVICES_COMING_NOTIFICATION", true);
        a.C0133a c0133a = hd.a.a;
        User loggedUser = (c0133a.g(OTTApplication.o()) == null || c0133a.g(OTTApplication.o()).getLoggedUser() == null) ? null : c0133a.g(OTTApplication.o()).getLoggedUser();
        if (loggedUser != null) {
            bundle.putString("USER_ID", loggedUser.getUserId().toString());
        }
        intent.putExtra("NOTIFICATION_DATA", bundle);
        w g = w.g(context);
        g.f(MainActivity.class);
        g.b(intent);
        int currentTimeMillis = (int) System.currentTimeMillis();
        int i = Build.VERSION.SDK_INT;
        PendingIntent h = g.h(currentTimeMillis, i < 31 ? 134217728 : 67108864);
        if (i >= 26) {
            String string = context.getResources().getString(R.string.app_name);
            notificationManager.createNotificationChannel(new NotificationChannel(string, string, 4));
            iVar = new m.i(context, string);
        } else {
            iVar = new m.i(context, context.getResources().getString(R.string.app_name));
        }
        iVar.D(str).G(1).B(h).s(true).Z(2131231203).g();
        notificationManager.notify(2, iVar.g());
    }

    public static void h(String str, OfflineDownloadData offlineDownloadData) {
        e.put(str.hashCode(), offlineDownloadData);
    }

    public static void i(int i, Download download, OfflineDownloadData offlineDownloadData) {
        e.put(i, offlineDownloadData);
        if (offlineDownloadData != null) {
            offlineDownloadData.z(e0.e(download.getBytesDownloaded()));
            offlineDownloadData.C("" + e0.L(Float.valueOf(download.getPercentDownloaded())));
            offlineDownloadData.D(System.currentTimeMillis() + d.n);
            offlineDownloadData.A(Boolean.TRUE);
            e0.f0(offlineDownloadData);
        }
    }

    public PlatformScheduler getScheduler() {
        if (Util.SDK_INT >= 21) {
            return new PlatformScheduler(this, 1);
        }
        return null;
    }

    protected DownloadManager getDownloadManager() {
        DownloadManager s = ((OTTApplication) getApplication()).s();
        s.addListener(new a());
        return s;
    }

    protected Notification getForegroundNotification(List<Download> list, int i) {
        h.a("Offline_Download>>6", "getForegroundNotification :::" + i);
        return c(this, 2131231869, "download_channel", null, list);
    }

    public void onCreate() {
        super.onCreate();
        this.a = new DownloadNotificationHelper(this, "download_channel");
        this.c = new m.i(this, "download_channel");
    }
}