导航菜单

页面标题

页面副标题

Jurassic World v1.83.4 - PlayServicesErrorActivity.java 源代码

正在查看: Jurassic World v1.83.4 应用的 PlayServicesErrorActivity.java JAVA 源代码文件

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


package com.urbanairship.google;

import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import com.google.android.gms.common.GoogleApiAvailability;
import com.urbanairship.Logger;
import com.urbanairship.UAirship;

public class PlayServicesErrorActivity extends FragmentActivity {
    private static final String DIALOG_TAG = "error_dialog";
    private static final int REQUEST_RESOLVE_ERROR = 1000;

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1000) {
            if (resultCode == -1) {
                Logger.debug("Google Play services resolution received result ok.", new Object[0]);
                checkPlayServices();
            } else {
                Logger.debug("Google Play services resolution canceled.", new Object[0]);
                finish();
            }
        }
    }

    protected void onStart() {
        super.onStart();
        if (getSupportFragmentManager().findFragmentByTag(DIALOG_TAG) == null) {
            checkPlayServices();
        }
    }

    protected void onStop() {
        super.onStop();
        if (isFinishing() && GooglePlayServicesUtilWrapper.isGooglePlayServicesAvailable(this) == 0 && UAirship.shared().getPushManager().isPushEnabled()) {
            UAirship.shared().getChannel().updateRegistration();
        }
    }

    private void checkPlayServices() {
        Logger.info("Checking Google Play services.", new Object[0]);
        int isGooglePlayServicesAvailable = GooglePlayServicesUtilWrapper.isGooglePlayServicesAvailable(this);
        if (isGooglePlayServicesAvailable == 0) {
            Logger.debug("Google Play services available!", new Object[0]);
            finish();
        } else if (GooglePlayServicesUtilWrapper.isUserRecoverableError(isGooglePlayServicesAvailable)) {
            Logger.debug("Google Play services recoverable error: %s", Integer.valueOf(isGooglePlayServicesAvailable));
            ErrorDialogFragment.createInstance(isGooglePlayServicesAvailable).show(getSupportFragmentManager(), DIALOG_TAG);
        } else {
            Logger.error("Unrecoverable Google Play services error: %s", Integer.valueOf(isGooglePlayServicesAvailable));
            finish();
        }
    }

    public static class ErrorDialogFragment extends DialogFragment {
        private static final String DIALOG_ERROR = "dialog_error";

        public static ErrorDialogFragment createInstance(int error) {
            ErrorDialogFragment errorDialogFragment = new ErrorDialogFragment();
            Bundle bundle = new Bundle();
            bundle.putInt(DIALOG_ERROR, error);
            errorDialogFragment.setArguments(bundle);
            return errorDialogFragment;
        }

        public Dialog onCreateDialog(Bundle savedInstanceState) {
            return GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), getArguments() != null ? getArguments().getInt(DIALOG_ERROR) : 0, 1000);
        }

        public void onCancel(DialogInterface dialog) {
            super.onCancel(dialog);
            if (getActivity() != null) {
                getActivity().finish();
            }
        }
    }
}