package com.applovin.impl.adview.activity; import android.app.Service; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import com.applovin.adview.AppLovinFullscreenActivity; import com.applovin.impl.gc; import com.applovin.impl.sdk.n; import com.applovin.impl.tb; import com.applovin.impl.yp; /* loaded from: classes.dex */ public class FullscreenAdService extends Service { public static final String DATA_KEY_RAW_FULL_AD_RESPONSE = "raw_full_ad_response"; private static final String TAG = "FullscreenAdService"; public static class b extends Handler { private b() { } @Override // android.os.Handler public void handleMessage(Message message) { try { tb tbVar = AppLovinFullscreenActivity.parentInterstitialWrapper; if (tbVar == null) { if (!yp.a(1.0d)) { super.handleMessage(message); return; } throw new RuntimeException("parentWrapper is null for " + message.what); } com.applovin.impl.sdk.ad.b f = tbVar.f(); int i = message.what; c cVar = c.AD; if (i == cVar.b()) { Bundle bundle = new Bundle(); bundle.putString(FullscreenAdService.DATA_KEY_RAW_FULL_AD_RESPONSE, f.getRawFullResponse()); Message obtain = Message.obtain((Handler) null, cVar.b()); obtain.setData(bundle); try { message.replyTo.send(obtain); return; } catch (RemoteException e) { n.c(FullscreenAdService.TAG, "Failed to respond to Fullscreen Activity in another process with ad", e); return; } } if (message.what == c.AD_DISPLAYED.b()) { gc.a(tbVar.c(), f); return; } if (message.what == c.AD_CLICKED.b()) { gc.a(tbVar.b(), f); return; } if (message.what == c.AD_VIDEO_STARTED.b()) { gc.a(tbVar.d(), f); return; } if (message.what == c.AD_VIDEO_ENDED.b()) { Bundle data = message.getData(); gc.a(tbVar.d(), f, data.getDouble("percent_viewed"), data.getBoolean("fully_watched")); return; } if (message.what == c.AD_HIDDEN.b()) { gc.b(tbVar.c(), f); } else { super.handleMessage(message); } } catch (Throwable unused) { } } } public enum c { AD(0), AD_DISPLAYED(1), AD_CLICKED(2), AD_VIDEO_STARTED(3), AD_VIDEO_ENDED(4), AD_HIDDEN(5); private final int a; c(int i2) { this.a = i2; } public int b() { return this.a; } } @Override // android.app.Service public IBinder onBind(Intent intent) { return new Messenger(new b()).getBinder(); } }