package X3;

import android.content.ContentResolver;
import android.provider.Settings;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import r4.AbstractC0983h;

/* JADX INFO: loaded from: classes.dex */
public final class a implements FlutterPlugin, MethodChannel.MethodCallHandler {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public MethodChannel f3304k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public ContentResolver f3305l;

    @Override // io.flutter.embedding.engine.plugins.FlutterPlugin
    public final void onAttachedToEngine(FlutterPlugin.FlutterPluginBinding flutterPluginBinding) {
        AbstractC0983h.e("flutterPluginBinding", flutterPluginBinding);
        this.f3305l = flutterPluginBinding.getApplicationContext().getContentResolver();
        MethodChannel methodChannel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "android_id");
        this.f3304k = methodChannel;
        methodChannel.setMethodCallHandler(this);
    }

    @Override // io.flutter.embedding.engine.plugins.FlutterPlugin
    public final void onDetachedFromEngine(FlutterPlugin.FlutterPluginBinding flutterPluginBinding) {
        AbstractC0983h.e("binding", flutterPluginBinding);
        MethodChannel methodChannel = this.f3304k;
        if (methodChannel != null) {
            methodChannel.setMethodCallHandler(null);
        } else {
            AbstractC0983h.i("channel");
            throw null;
        }
    }

    @Override // io.flutter.plugin.common.MethodChannel.MethodCallHandler
    public final void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
        AbstractC0983h.e("call", methodCall);
        AbstractC0983h.e("result", result);
        if (!AbstractC0983h.a(methodCall.method, "getId")) {
            result.notImplemented();
            return;
        }
        try {
            ContentResolver contentResolver = this.f3305l;
            if (contentResolver != null) {
                result.success(Settings.Secure.getString(contentResolver, "android_id"));
            } else {
                AbstractC0983h.i("contentResolver");
                throw null;
            }
        } catch (Exception e2) {
            result.error("ERROR_GETTING_ID", "Failed to get Android ID", e2.getLocalizedMessage());
        }
    }
}
