package com.kakao.util.apicompatibility;

import android.content.Intent;
import android.os.Bundle;
import android.telephony.gsm.SmsMessage;
import com.bytedance.covode.number.Covode;
import com.kakao.util.helper.log.Logger;

public class APILevel9Compatibility extends APICompatibility {
    static {
        Covode.recordClassIndex(45985);
    }

    public static Bundle INVOKEVIRTUAL_com_kakao_util_apicompatibility_APILevel9Compatibility_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras(Intent intent) {
        try {
            return intent.getExtras();
        } catch (Exception unused) {
            return null;
        }
    }

    public String getSmsMessage(Intent intent) {
        Object[] objArr = (Object[]) INVOKEVIRTUAL_com_kakao_util_apicompatibility_APILevel9Compatibility_com_ss_android_ugc_aweme_lancet_IntentLancet_get(INVOKEVIRTUAL_com_kakao_util_apicompatibility_APILevel9Compatibility_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras(intent), "pdus");
        int length = objArr.length;
        String str = null;
        int i = 0;
        while (true) {
            if (i >= length) {
                break;
            }
            Object obj = objArr[i];
            Logger.d("legacy SMS implementation (before KitKat)");
            SmsMessage createFromPdu = SmsMessage.createFromPdu((byte[]) obj);
            if (createFromPdu == null) {
                Logger.e("SMS message is null -- ABORT");
                break;
            }
            str = createFromPdu.getDisplayMessageBody();
            i++;
        }
        return str;
    }

    public static Object INVOKEVIRTUAL_com_kakao_util_apicompatibility_APILevel9Compatibility_com_ss_android_ugc_aweme_lancet_IntentLancet_get(Bundle bundle, String str) {
        try {
            return bundle.get(str);
        } catch (Exception | OutOfMemoryError unused) {
            return null;
        }
    }
}
