client_Hale
2020-08-27 45859ac805c06307385fdc7ada14b565ed57e039
0312 补充接口逻辑
7个文件已修改
230 ■■■■■ 已修改文件
ChannelDiff/Android/xmyjgame/libs/qk_sdk-game_qk-release.aar 补丁 | 查看 | 原始文档 | blame | 历史
Project/qk_sdk/build.gradle 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Project/qk_sdk/src/game_qk/java/com/secondworld/universalsdk/H2EngineSDK.java 94 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Project/qk_sdk/src/game_qk/java/com/secondworld/universalsdk/QuickPlatformUtil.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Project/qk_sdk/src/main/AndroidManifest.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Project/qk_sdk/src/main/java/com/secondworld/universalsdk/CodeA2U.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Project/qk_sdk/src/main/java/com/secondworld/universalsdk/MainActivity.java 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ChannelDiff/Android/xmyjgame/libs/qk_sdk-game_qk-release.aar
Binary files differ
Project/qk_sdk/build.gradle
@@ -24,10 +24,10 @@
    flavorDimensions "default"
    productFlavors {
        // 思璞SDK
        // quickSDK
        game_qk{
            dimension "default"
            manifestPlaceholders.put("appId", "com.zyxhgame.mxd")
            manifestPlaceholders.put("appId", "com.xfzc.yj.quick")
            manifestPlaceholders.put("TrackAppID", "5ae23b6b905f98d9b8bd542debf35678")
            manifestPlaceholders.put("TrackChannelID", "_default_")
            manifestPlaceholders.put("JpushAppKey", "22186239fee975f883198cf4")
Project/qk_sdk/src/game_qk/java/com/secondworld/universalsdk/H2EngineSDK.java
@@ -19,6 +19,7 @@
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.text.method.QwertyKeyListener;
import android.util.Log;
import android.widget.Toast;
import com.quicksdk.QuickSDK;
@@ -45,8 +46,8 @@
public class H2EngineSDK
{
    private static final String TAG = "H2EngineSDK";
    private static boolean PushEnable = true;
    private static String APP_ID = "";
    private static boolean PushEnable = false;
    public static void HandleUnityMessage(String json)
    {
@@ -60,6 +61,7 @@
            switch (_code)
            {
                case CodeU2A.Init:
                    APP_ID = _json.getString("appID");
                    init(_activity);
                    break;
                case CodeU2A.CopyOneAsset:
@@ -108,8 +110,13 @@
                case CodeU2A.FreePlatformPay:
                    JSONObject _extraData = new JSONObject();
                    String _yjAppID = UniversalUtil.getMetaString(_activity, "yj_appid");
                    _extraData.put("appid", _yjAppID);
                    String _appid = com.quicksdk.Extend.getInstance().getExtrasConfig("zfappid");
                    if (_appid == "")
                    {
                        //没有打包的自定义参数则取配置表
                        _appid = APP_ID;
                    }
                    _extraData.put("appid", _appid);
                    _extraData.put("cpinfo", _json.getString("cpInfo"));
                    _extraData.put("cporderid", _json.getString("orderId"));
                    try
@@ -145,17 +152,13 @@
                        GameRoleInfo roleInfo3 = new GameRoleInfo();
                        roleInfo3.setServerID(_json.getString("sid"));
                        roleInfo3.setServerName(_json.getString("serverName"));
                        roleInfo3.setGameRoleName(_json.getString("roleName").trim().replace(" ",
                                                                                             ""));
                        roleInfo3.setGameRoleName(_json.getString("roleName").trim().replace(" ", ""));
                        roleInfo3.setGameRoleID(_json.getString("roleID"));
                        roleInfo3.setGameBalance(_json.getString("money"));
                        roleInfo3.setVipLevel(_json.getString(
                                "vipLevel"));  //设置当前用户vip等级,必须为数字整型字符串,请勿传"vip1"等类似字符串
                        roleInfo3.setVipLevel(_json.getString("vipLevel"));  //设置当前用户vip等级,必须为数字整型字符串,请勿传"vip1"等类似字符串
                        roleInfo3.setGameUserLevel(_json.getString("level"));//设置游戏角色等级
                        roleInfo3.setPartyName(_json.getString("familyName").trim().replace(" ",
                                                                                            ""));//设置帮派名称
                        roleInfo3.setRoleCreateTime(
                                _json.getString("createTime")); //UC,当乐与1881,TT渠道必传,值为10位数时间戳
                        roleInfo3.setPartyName(_json.getString("familyName").trim().replace(" ", ""));//设置帮派名称
                        roleInfo3.setRoleCreateTime(_json.getString("createTime")); //UC,当乐与1881,TT渠道必传,值为10位数时间戳
                        roleInfo3.setPartyId("1100"); //360渠道参数,设置帮派id,必须为整型字符串
                        roleInfo3.setGameRolePower("38"); //360,TT语音渠道参数,设置角色战力,必须为整型字符串
@@ -259,6 +262,7 @@
//                                                                    .replace(" ", ""),
//                                                            _json.getString("vipLevel"),
//                                                            _json.getString("money"));
                    verifyRealName(_activity);
                    break;
                case CodeU2A.RoleLevelUp:
                    GameRoleInfo roleInfo2 = new GameRoleInfo();
@@ -464,7 +468,7 @@
            return;
        }
        PushEnable = activity.getPackageName().equals("com.xjaz.sp");
        //PushEnable = activity.getPackageName().equals("com.xjaz.sp");
        new Thread(new Runnable()
        {
@@ -523,12 +527,17 @@
                _msgStruct.clear();
                _msgStruct.put("code", CodeA2U.SdkInitComplete);
                _msgStruct.put("channelPlatform", "yj");
                String _appid = UniversalUtil.getMetaString(activity, "yj_appid");
                _msgStruct.put("channelPlatform", "quick");
                //根据appid是否相同和后台配置 可调整混服和专服
                //打包工具可添加自定义参数
                String _appid = com.quicksdk.Extend.getInstance().getExtrasConfig("zfappid");
                if (_appid == "")
                {
                    //没有打包的自定义参数则取配置表
                    _appid = APP_ID;
                }
                _msgStruct.put("yj_appid", _appid);
                _msgStruct.put("yj_spid", UniversalUtil.getMetaString(activity, "yj_spid"));
                _msgStruct.put("yj_branch", UniversalUtil.getMetaInt(activity, "yj_branch"));
                _msgStruct.put("banhao", activity.getResources().getString(R.string.banhao));
                _msgStruct.put("yj_spid", com.quicksdk.Extend.getInstance().getChannelType());
                UniversalUtil.sendMessageToUnity(_msgStruct);
                LogUtil.i(TAG, "初始化执行完毕");
@@ -539,7 +548,6 @@
    public static void onCreate(Activity activity, Bundle savedInstanceState)
    {
        QuickSDK.getInstance().setIsLandScape(true);
        Sdk.getInstance().onCreate(activity);
        try {
            // check权限
@@ -552,12 +560,13 @@
                        Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1);
            } else {
                QuickPlatformUtil.getInstance().onCreate();
                Sdk.getInstance().init(activity,"88049844578484520615487574815873", "82414864");
                Sdk.getInstance().init(activity,"96065423134516611008224414549989", "69623854");
            }
        } catch (Exception e) {
            QuickPlatformUtil.getInstance().onCreate();
            Sdk.getInstance().init(activity, "88049844578484520615487574815873", "82414864");
            Sdk.getInstance().init(activity, "96065423134516611008224414549989", "69623854");
        }
        QuickSDK.getInstance().setIsLandScape(true);
    }
    private static boolean m_IsFocus = true;
@@ -622,4 +631,47 @@
    {
        Sdk.getInstance().onDestroy(activity);
    }
    private static void verifyRealName(final Activity activity) {
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                // 判断渠道是否支持实名认证功能
                if (com.quicksdk.Extend.getInstance().isFunctionSupported(com.quicksdk.FuncType.REAL_NAME_REGISTER)) {
                    com.quicksdk.Extend.getInstance().callFunctionWithParamsCallBack(activity, com.quicksdk.FuncType.REAL_NAME_REGISTER, new com.quicksdk.BaseCallBack() {
                        @Override
                        public void onSuccess(Object... arg0) {
                            if (arg0 != null && arg0.length > 0) {
                                JSONObject jsonObject = (JSONObject) arg0[0];
                                Log.d("json", "==========" + jsonObject.toString());
                                try {
                                    // 用户id
                                    String uid = jsonObject.getString("uid");
                                    // 年龄, 如果渠道没返回默认为-1
                                    int age = jsonObject.getInt("age");
                                    // 是否已实名 true表示已实名
                                    // false表示未实名,如果渠道没返回默认为false
                                    boolean realName = jsonObject.getBoolean("realName");
                                    // oppo实名认证失败之后是否可以继续游戏 true表示可以
                                    // false表示不可以,如果渠道没返回默认为true
                                    boolean resumeGame = jsonObject.getBoolean("resumeGame");
                                    // 预留字段,如果渠道没返回默认为""的字符串
                                    String other = jsonObject.getString("other");
                                    // 游戏根据返回信息做对应的逻辑处理
                                } catch (JSONException e) {
                                }
                            }
                        }
                        @Override
                        public void onFailed(Object... arg0) {
                        }
                    });
                }
            }
        });
    }
}
Project/qk_sdk/src/game_qk/java/com/secondworld/universalsdk/QuickPlatformUtil.java
@@ -75,17 +75,15 @@
                USER = userInfo;
                //根据回调获取用户信息
                String timestamp = USER.getToken();
                String token = USER.getToken();
                String userId = USER.getUID();
                String userName = USER.getUserName();
                try
                {
                    JSONObject _info = new JSONObject();
                    _info.put("account", userName);
                    _info.put("account", userId);
                    _info.put("token", token);
                    _info.put("timeStamp", timestamp);
                    _info.put("account_id", userId);
                    _info.put("userName", userName);
                    m_Message.put("code", CodeA2U.FreePlatformLoginOk);
                    m_Message.put("info", _info);
                    UniversalUtil.sendMessageToUnity(m_Message);
@@ -133,17 +131,15 @@
                USER = userInfo;
                //根据回调获取用户信息
                String timestamp = USER.getToken();
                String token = USER.getToken();
                String userId = USER.getUID();
                String userName = USER.getUserName();
                try
                {
                    JSONObject _info = new JSONObject();
                    _info.put("account", userName);
                    _info.put("userName", userName);
                    _info.put("token", token);
                    _info.put("timeStamp", timestamp);
                    _info.put("account_id", userId);
                    _info.put("account", userId);
                    m_Message.put("code", CodeA2U.FreePlatformSwitchAccountOk);
                    m_Message.put("info", _info);
                    UniversalUtil.sendMessageToUnity(m_Message);
@@ -205,7 +201,7 @@
            public void onSuccess() {
                //退出成功,游戏在此做自身的退出逻辑处理
                m_Message.clear();
                m_Message.put("code", CodeA2U.FreePlatformExit);
                m_Message.put("code", CodeA2U.ExitGame);
                UniversalUtil.sendMessageToUnity(m_Message);
                payProcessing = false;
            }
Project/qk_sdk/src/main/AndroidManifest.xml
@@ -88,6 +88,8 @@
                android:name="com.samsung.android.keepalive.density"
                android:value="true" />
            <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true"></meta-data>
        </activity>
    </application>
Project/qk_sdk/src/main/java/com/secondworld/universalsdk/CodeA2U.java
@@ -60,5 +60,4 @@
    public static final int FreePlatformPayFail = 19;
    public static final int FreePlatformPayCancel = 20;
    public static final int FreePlatformRegisterOk = 21;
    public static final int FreePlatformExit = 22;
}
Project/qk_sdk/src/main/java/com/secondworld/universalsdk/MainActivity.java
@@ -12,6 +12,7 @@
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.PermissionChecker;
import android.util.Log;
import android.view.KeyEvent;
@@ -82,7 +83,27 @@
        View unityView = mUnityPlayer.getView();
        _frameLayout.addView(unityView);
        H2EngineSDK.onCreate(this, savedInstanceState);
        //H2EngineSDK.onCreate(this, savedInstanceState);
        Sdk.getInstance().onCreate(this);
        try {
            // check权限
            if ((ContextCompat.checkSelfPermission(this,
                                                   Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED)
                    || (ContextCompat.checkSelfPermission(this,
                                                          Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
                // 没有 , 申请权限 权限数组
                ActivityCompat.requestPermissions(this, new String[] {
                        Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1);
            } else {
                QuickPlatformUtil.getInstance().onCreate();
                Sdk.getInstance().init(this,"96065423134516611008224414549989", "69623854");
            }
        } catch (Exception e) {
            QuickPlatformUtil.getInstance().onCreate();
            Sdk.getInstance().init(this, "96065423134516611008224414549989", "69623854");
        }
        QuickSDK.getInstance().setIsLandScape(true);
    }
    @Override
@@ -117,7 +138,7 @@
            // 申请成功
            QuickPlatformUtil.getInstance().onCreate();
            if (!QuickPlatformUtil.getInstance().isInited) {
                Sdk.getInstance().init(this, "88049844578484520615487574815873", "82414864");
                Sdk.getInstance().init(this, "96065423134516611008224414549989", "69623854");
            }
        } else {
            // 失败 这里逻辑以游戏为准 这里只是模拟申请失败 退出游戏 cp方可改为继续申请 或者其他逻辑
@@ -140,7 +161,7 @@
                        intent.setData(uri);
                        startActivityForResult(intent, REQUEST_RECORD_PERMISSION_SETTING);
                        QuickPlatformUtil.getInstance().onCreate();
                        Sdk.getInstance().init(UnityPlayer.currentActivity, "88049844578484520615487574815873", "82414864");
                        Sdk.getInstance().init(UnityPlayer.currentActivity, "96065423134516611008224414549989", "69623854");
                    }
                });
                normalDialog.setNegativeButton("关闭", new DialogInterface.OnClickListener() {
@@ -148,7 +169,7 @@
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(UnityPlayer.currentActivity, "权限被拒绝", Toast.LENGTH_SHORT).show();
                        QuickPlatformUtil.getInstance().onCreate();
                        Sdk.getInstance().init(UnityPlayer.currentActivity, "88049844578484520615487574815873", "82414864");
                        Sdk.getInstance().init(UnityPlayer.currentActivity, "96065423134516611008224414549989", "69623854");
                    }
                });
                // 显示
@@ -197,48 +218,48 @@
        super.onResume();
        // 检测本地存储权限是否有, 没有的话要提示用户
        if (PermissionChecker.checkPermission(this,
                                              Manifest.permission.WRITE_EXTERNAL_STORAGE,
                                              Process.myPid(), Process.myUid(),
                                              getPackageName()) != PackageManager.PERMISSION_GRANTED
                || PermissionChecker.checkPermission(this,
                                                     Manifest.permission.READ_EXTERNAL_STORAGE,
                                                     Process.myPid(), Process.myUid(),
                                                     getPackageName()) != PackageManager.PERMISSION_GRANTED)
        {
            new AlertDialog.Builder(this)
                    .setMessage("应用没有存储读取权限,点击确定至设置中开启,否则无法继续游戏.")
                    .setCancelable(false)
                    .setPositiveButton("确定",
                                       new DialogInterface.OnClickListener()
                                       {
                                           @Override
                                           public void onClick(DialogInterface dialogInterface,
                                                               int i)
                                           {
                                               UniversalUtil.hasGoToSetting = true;
                                               Intent intent = new Intent(
                                                       Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                                               intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                               Uri uri = Uri.fromParts("package",
                                                                       getPackageName(),
                                                                       null);
                                               intent.setData(uri);
                                               startActivity(intent);
                                           }
                                       })
                    .setNegativeButton("拒绝",
                                       new DialogInterface.OnClickListener()
                                       {
                                           @Override
                                           public void onClick(DialogInterface dialogInterface,
                                                               int i)
                                           {
                                               finish();
                                           }
                                       })
                    .show();
        }
//        if (PermissionChecker.checkPermission(this,
//                                              Manifest.permission.WRITE_EXTERNAL_STORAGE,
//                                              Process.myPid(), Process.myUid(),
//                                              getPackageName()) != PackageManager.PERMISSION_GRANTED
//                || PermissionChecker.checkPermission(this,
//                                                     Manifest.permission.READ_EXTERNAL_STORAGE,
//                                                     Process.myPid(), Process.myUid(),
//                                                     getPackageName()) != PackageManager.PERMISSION_GRANTED)
//        {
//            new AlertDialog.Builder(this)
//                    .setMessage("应用没有存储读取权限,点击确定至设置中开启,否则无法继续游戏.")
//                    .setCancelable(false)
//                    .setPositiveButton("确定",
//                                       new DialogInterface.OnClickListener()
//                                       {
//                                           @Override
//                                           public void onClick(DialogInterface dialogInterface,
//                                                               int i)
//                                           {
//                                               UniversalUtil.hasGoToSetting = true;
//                                               Intent intent = new Intent(
//                                                       Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
//                                               intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//                                               Uri uri = Uri.fromParts("package",
//                                                                       getPackageName(),
//                                                                       null);
//                                               intent.setData(uri);
//                                               startActivity(intent);
//                                           }
//                                       })
//                    .setNegativeButton("拒绝",
//                                       new DialogInterface.OnClickListener()
//                                       {
//                                           @Override
//                                           public void onClick(DialogInterface dialogInterface,
//                                                               int i)
//                                           {
//                                               finish();
//                                           }
//                                       })
//                    .show();
//        }
    }
    @Override
@@ -287,4 +308,6 @@
        }
        return super.onKeyDown(i, keyEvent);
    }
}