package j7;

import android.content.ClipData;
import android.content.ClipboardManager;
import kotlin.jvm.internal.t;

/* loaded from: classes.dex */
public final class a implements c {

    /* renamed from: a, reason: collision with root package name */
    private final t7.c f23975a;

    public a(t7.c contextService) {
        t.g(contextService, "contextService");
        this.f23975a = contextService;
    }

    @Override // j7.c
    public void a(String str, String str2) {
        Object systemService = this.f23975a.a().getSystemService("clipboard");
        t.e(systemService, "null cannot be cast to non-null type android.content.ClipboardManager");
        ((ClipboardManager) systemService).setPrimaryClip(ClipData.newPlainText(str, str2));
    }

    @Override // j7.c
    public String b() {
        CharSequence text;
        Object systemService = this.f23975a.a().getSystemService("clipboard");
        t.e(systemService, "null cannot be cast to non-null type android.content.ClipboardManager");
        try {
            ClipData primaryClip = ((ClipboardManager) systemService).getPrimaryClip();
            if (primaryClip == null || primaryClip.getItemCount() <= 0 || (text = primaryClip.getItemAt(0).getText()) == null) {
                return null;
            }
            return text.toString();
        } catch (Exception e10) {
            tr.a.f36618a.d(e10, e10.getMessage(), new Object[0]);
        }
        return null;
    }
}
