导航菜单

页面标题

页面副标题

xDrip+ v04633772025.07.16 - WakeLockTrampoline.java 源代码

正在查看: xDrip+ v04633772025.07.16 应用的 WakeLockTrampoline.java JAVA 源代码文件

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


package com.eveningoutpost.dexdrip.utils.framework;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.SparseArray;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.utilitymodels.ForegroundServiceStarter;
import com.eveningoutpost.dexdrip.xdrip;
import java.util.HashMap;
import java.util.Locale;

public class WakeLockTrampoline extends BroadcastReceiver {
    private static final HashMap<String, Class> cache = new HashMap<>();
    private static final SparseArray<String> collision = new SparseArray<>();

    @Override
    public void onReceive(Context context, Intent intent) {
        ComponentName startService;
        JoH.getWakeLock("WakeLockTrampoline", 1000);
        String stringExtra = intent.getStringExtra("SERVICE_PARAM");
        UserError.Log.d("WakeLockTrampoline", "Trampoline ignition for: " + stringExtra);
        if (stringExtra == null) {
            UserError.Log.wtf("WakeLockTrampoline", "Incorrectly passed pending intent with null service parameter!");
            return;
        }
        Class classFromName = getClassFromName(stringExtra);
        if (classFromName == null) {
            UserError.Log.wtf("WakeLockTrampoline", "Could not resolve service class for: " + stringExtra);
            return;
        }
        Intent intent2 = new Intent(context, (Class<?>) classFromName);
        String stringExtra2 = intent.getStringExtra("function");
        if (stringExtra2 != null) {
            intent2.putExtra("function", stringExtra2);
        }
        if (Build.VERSION.SDK_INT >= 26 && ForegroundServiceStarter.shouldRunCollectorInForeground()) {
            try {
                UserError.Log.d("WakeLockTrampoline", String.format("Starting oreo foreground service: %s", intent2.getComponent().getClassName()));
            } catch (NullPointerException unused) {
                UserError.Log.d("WakeLockTrampoline", "Null pointer exception in startServiceCompat");
            }
            startService = context.startForegroundService(intent2);
        } else {
            startService = context.startService(intent2);
        }
        UserError.Log.d("WakeLockTrampoline", "Start result: " + startService);
    }

    public static PendingIntent getPendingIntent(Class cls) {
        return getPendingIntent(cls, 0);
    }

    public static PendingIntent getPendingIntent(Class cls, int i) {
        return getPendingIntent(cls, i, null);
    }

    public static synchronized PendingIntent getPendingIntent(Class cls, int i, String str) {
        PendingIntent broadcast;
        synchronized (WakeLockTrampoline.class) {
            String canonicalName = cls.getCanonicalName();
            int hashCode = canonicalName.hashCode() + i;
            Intent putExtra = new Intent(xdrip.getAppContext(), (Class<?>) WakeLockTrampoline.class).putExtra("SERVICE_PARAM", canonicalName);
            if (str != null) {
                putExtra.putExtra("function", str);
            }
            cache.put(canonicalName, cls);
            Locale locale = Locale.US;
            UserError.Log.d("WakeLockTrampoline", String.format(locale, "Schedule %s ID: %d (%d)", canonicalName, Integer.valueOf(hashCode), Integer.valueOf(i)));
            SparseArray<String> sparseArray = collision;
            String str2 = sparseArray.get(hashCode);
            if (str2 == null) {
                sparseArray.put(hashCode, canonicalName);
                UserError.Log.d("WakeLockTrampoline", "New schedule id: " + hashCode + " for " + canonicalName);
            } else if (str2.equals(canonicalName)) {
                UserError.Log.d("WakeLockTrampoline", "Recurring schedule id: " + hashCode + " for " + str2);
            } else {
                UserError.Log.wtf("WakeLockTrampoline", String.format(locale, "Collision between: %s vs %s (%d) @ %d", str2, canonicalName, Integer.valueOf(i), Integer.valueOf(hashCode)));
            }
            broadcast = PendingIntent.getBroadcast(xdrip.getAppContext(), hashCode, putExtra, 134217728);
        }
        return broadcast;
    }

    private static Class getClassFromName(String str) {
        Class cls = cache.get(str);
        if (cls != null) {
            return cls;
        }
        try {
            return Class.forName(str);
        } catch (ClassNotFoundException unused) {
            return cls;
        }
    }
}