Browse Source

1、优化ysdk Androidx的引用
2、代码优化

fluty 4 years ago
parent
commit
f23b556662
42 changed files with 2150 additions and 27 deletions
  1. 1 0
      app_dev/.gitignore
  2. 47 0
      app_dev/build.gradle
  3. BIN
      app_dev/fq_bytjz_gdt.jks
  4. BIN
      app_dev/fqgamesdkkeystore.jks
  5. 21 0
      app_dev/proguard-rules.pro
  6. 32 0
      app_dev/src/main/AndroidManifest.xml
  7. 353 0
      app_dev/src/main/java/com/funcheer/channel/sdk/MainActivity.java
  8. 19 0
      app_dev/src/main/java/com/funcheer/channel/sdk/MainApp.java
  9. 11 0
      app_dev/src/main/java/com/tencent/tmgp/xzsjjby/wxapi/WXEntryActivity.java
  10. 170 0
      app_dev/src/main/res/drawable/ic_launcher_background.xml
  11. 176 0
      app_dev/src/main/res/layout/fq_activity_main.xml
  12. BIN
      app_dev/src/main/res/mipmap-hdpi/ic_launcher.png
  13. BIN
      app_dev/src/main/res/mipmap-hdpi/ic_launcher_round.png
  14. BIN
      app_dev/src/main/res/mipmap-mdpi/ic_launcher.png
  15. BIN
      app_dev/src/main/res/mipmap-mdpi/ic_launcher_round.png
  16. BIN
      app_dev/src/main/res/mipmap-xhdpi/ic_launcher.png
  17. BIN
      app_dev/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  18. BIN
      app_dev/src/main/res/mipmap-xxhdpi/ic_launcher.png
  19. BIN
      app_dev/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  20. BIN
      app_dev/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  21. BIN
      app_dev/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  22. 11 0
      app_dev/src/main/res/values/colors.xml
  23. 25 0
      app_dev/src/main/res/values/strings.xml
  24. 8 0
      app_dev/src/main/res/values/styles.xml
  25. 1 0
      app_dev_lib/.gitignore
  26. 33 0
      app_dev_lib/build.gradle
  27. 0 0
      app_dev_lib/consumer-rules.pro
  28. 21 0
      app_dev_lib/proguard-rules.pro
  29. 27 0
      app_dev_lib/src/androidTest/java/com/example/app_dev_lib/ExampleInstrumentedTest.java
  30. 2 0
      app_dev_lib/src/main/AndroidManifest.xml
  31. 3 0
      app_dev_lib/src/main/res/values/strings.xml
  32. 17 0
      app_dev_lib/src/test/java/com/example/app_dev_lib/ExampleUnitTest.java
  33. 835 0
      fq_channel_ysdk/src/main/java/androidx/core/content/FileProvider.java
  34. 318 0
      fq_channel_ysdk/src/main/java/androidx/localbroadcastmanager/content/LocalBroadcastManager.java
  35. 7 8
      fq_plugin_api/src/main/java/com/fq/channel/sdk/api/FqGame.java
  36. 2 5
      fq_plugin_api/src/main/java/com/fq/channel/sdk/api/FqGameHander.java
  37. 1 2
      fq_plugin_base/build.gradle
  38. BIN
      fq_plugin_base/libs/android-support-v4.jar
  39. 2 3
      fq_plugin_base/src/main/java/com/fq/channel/sdk/base/permission/PermissionManager.java
  40. 6 7
      fq_plugin_base/src/main/java/com/fq/channel/sdk/base/utils/Utils.java
  41. 0 2
      gradle.properties
  42. 1 0
      settings.gradle

+ 1 - 0
app_dev/.gitignore

@@ -0,0 +1 @@
+/build

+ 47 - 0
app_dev/build.gradle

@@ -0,0 +1,47 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 29
+    defaultConfig {
+        applicationId "com.tencent.tmgp.xzsjjby"
+        minSdkVersion 15
+        targetSdkVersion 29
+        versionCode 1
+        versionName "1.0"
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        signingConfig signingConfigs.debug
+    }
+
+    signingConfigs {
+
+//        debug {
+//            storeFile file("./fqgamesdkkeystore.jks")
+//            storePassword '201868'
+//            keyPassword '201868'
+//            keyAlias 'fqgamesdkkeystore.jks'
+//        }
+//        ysdk
+        debug{
+            storeFile file('./fq_bytjz_gdt.jks')
+            storePassword '201999'
+            keyPassword '201999'
+            keyAlias 'fq_bytjz_gdt.jks'
+        }
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            signingConfig signingConfigs.debug
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+        debug{
+            signingConfig signingConfigs.debug
+        }
+    }
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+    api project(':fq_plugin_api')
+}

BIN
app_dev/fq_bytjz_gdt.jks


BIN
app_dev/fqgamesdkkeystore.jks


+ 21 - 0
app_dev/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 32 - 0
app_dev/src/main/AndroidManifest.xml

@@ -0,0 +1,32 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.fqchannelsdk">
+    <!-- 访问网络 -->
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:supportsRtl="true"
+        android:name="com.funcheer.channel.sdk.MainApp"
+        android:theme="@style/fq_AppTheme" >
+
+
+    <activity android:name="com.funcheer.channel.sdk.MainActivity"
+        android:configChanges="orientation|keyboardHidden|screenSize"
+        android:launchMode="singleTop"
+        android:screenOrientation="portrait"
+        android:theme="@style/fq_AppTheme"
+        >
+        <intent-filter>
+            <action android:name="android.intent.action.MAIN" />
+            <category android:name="android.intent.category.LAUNCHER" />
+        </intent-filter>
+    </activity>
+
+
+    </application>
+</manifest>

+ 353 - 0
app_dev/src/main/java/com/funcheer/channel/sdk/MainActivity.java

@@ -0,0 +1,353 @@
+package com.funcheer.channel.sdk;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.example.fqchannelsdk.R;
+import com.fq.channel.sdk.api.FqGame;
+import com.fq.channel.sdk.api.IExit;
+import com.fq.channel.sdk.api.ILogout;
+import com.fq.channel.sdk.api.IResult;
+import com.fq.channel.sdk.base.bean.LoginInfo;
+import com.fq.channel.sdk.base.bean.PaymentInfo;
+import com.fq.channel.sdk.base.constants.ConstSet;
+import com.fq.channel.sdk.base.utils.FqLog;
+
+/**
+ * @Description: 描述
+ * @Author: FLuty
+ * @CreateDate: 2020/3/24 09:49
+ */
+public class MainActivity extends Activity implements View.OnClickListener {
+    private static final String TAG = MainActivity.class.getSimpleName();
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.fq_activity_main);
+        FqLog.i(TAG, "onCreate: ");
+        initUI();
+        initSDK();
+        FqGame.onCreate(this,savedInstanceState);
+    }
+
+    //跟游戏的主Activity走
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        FqGame.onSaveInstanceState(outState);
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        FqGame.onNewIntent(intent);
+        super.onNewIntent(intent);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        FqGame.onActivityResult(requestCode, resultCode, data);
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+    @Override
+    protected void onRestart() {
+        super.onRestart();
+        FqLog.i(TAG, "onRestart: ");
+        FqGame.onRestart(this);
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        FqLog.i(TAG, "onStart: ");
+        FqGame.onStart(this);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        FqLog.i(TAG, "onResume: ");
+        FqGame.onResume(this);
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        FqLog.i(TAG, "onPause: ");
+        FqGame.onPause(this);
+
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        FqLog.i(TAG, "onStop: ");
+        FqGame.onStop(this);
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        FqLog.i(TAG, "onDestroy: ");
+        FqGame.onDestroy(this);
+    }
+
+    private void initUI() {
+        findViewById(getResourceId("fq_login", "id")).setOnClickListener(this);
+        findViewById(getResourceId("fq_logout", "id")).setOnClickListener(this);
+        findViewById(getResourceId("fq_change_account", "id")).setOnClickListener(this);
+        findViewById(getResourceId("fq_charge", "id")).setOnClickListener(this);
+        findViewById(getResourceId("fq_report_data", "id")).setOnClickListener(this);
+        findViewById(getResourceId("fq_exit", "id")).setOnClickListener(this);
+
+    }
+
+    @Override
+    public void onClick(View v) {
+        int id = v.getId();
+        switch (id) {
+            case R.id.fq_login:
+                login();
+                break;
+
+            case R.id.fq_logout:
+                logout();
+                break;
+
+            case R.id.fq_change_account:
+                changeAccount();
+                break;
+
+            case R.id.fq_report_data:
+                dataReport();
+                break;
+
+            case R.id.fq_charge:
+                charge();
+                break;
+
+            case R.id.fq_exit:
+                exit();
+                break;
+
+            default:
+                break;
+        }
+    }
+
+    private int getResourceId(String name, String defType) {
+        return this.getResources().getIdentifier(name, defType, this.getPackageName());
+    }
+
+    private void initSDK() {
+        FqGame.init(MainActivity.this, new IResult<String>() {
+            @Override
+            public void onSuccess(String s) {
+                FqLog.i(TAG, "init success: " + s);
+            }
+
+            @Override
+            public void onFail(String failMsg) {
+                FqLog.i(TAG, "init fail:" + failMsg);
+            }
+        });
+    }
+
+    private void login() {
+        FqGame.login(MainActivity.this, new IResult<LoginInfo>() {
+            @Override
+            public void onSuccess(LoginInfo s) {
+                FqLog.i(TAG, "login success: " + s.getUid());
+            }
+
+            @Override
+            public void onFail(String failMsg) {
+                FqLog.i(TAG, "login fail:" + failMsg);
+            }
+        });
+    }
+
+    public void charge() {
+
+        //get price
+        String priceString = ((EditText)findViewById(getResourceId("fq_charge_price",
+                "id"))).getText().toString();
+        if (TextUtils.isEmpty(priceString)){
+            showResult("请先填入价格");
+            return;
+        }
+        priceString = "0.1";
+        FqLog.i(TAG,"price : "+priceString);
+//        priceString = "0.01";
+        PaymentInfo paymentInfo = new PaymentInfo();
+        paymentInfo.setPrice(priceString);//订单金额
+        paymentInfo.setCpOrderId("cp"+System.currentTimeMillis());  //CP订单号
+        paymentInfo.setServerId("1");   //区服ID String的形式带入,值为int类型字符串
+        paymentInfo.setExtralInfo("FqGameSdk");  //扩展信息
+        paymentInfo.setRemark("remark");  //订单备注 透传信息
+        paymentInfo.setProductId("1");//商品ID,String类型
+        paymentInfo.setProductName("60金币"); //商品名称
+        paymentInfo.setProductDes("Fq"); //商品描述,值为String类型
+        paymentInfo.setProductUnit("金币"); //货币单位,值为String类型, 例:金币/钻石等且不可带量词
+        paymentInfo.setRate("10"); //兑换比例,String的形式带入,值为int类型,默认值为1
+        paymentInfo.setChargeId("pay123");  //计费ID 没有可不传
+        FqGame.pay(MainActivity.this,paymentInfo, new IResult<String>() {
+            @Override
+            public void onSuccess(String s) {
+                FqLog.i(TAG,"pay success: "+s);
+            }
+
+            @Override
+            public void onFail(String failMsg) {
+                FqLog.i(TAG,"pay fail:"+failMsg);
+            }
+        });
+    }
+
+    private void exit() {// 退出接口
+        FqGame.exit(MainActivity.this, new IExit() {
+            @Override
+            public void onExit() {
+                //退出游戏
+                System.exit(0);
+            }
+
+            @Override
+            public void onNoConfirmDialogExit() {
+                //渠道不存在退出界面,此处游戏必须弹出自己的退出确认框。
+                showGameExitView();
+            }
+        });
+    }
+
+    private void showGameExitView() {
+        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
+        builder.setTitle("游戏自带退出界面");
+        builder.setCancelable(false);
+        builder.setPositiveButton("退出",
+                new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog,
+                                        int which) {
+
+
+                        exitAppProcess(MainActivity.this);
+                    }
+                });
+        builder.show();
+    }
+
+    private void dataReport() {
+        //get report data type
+        String dataReportTypeString = ((EditText) findViewById(getResourceId("fq_report_type",
+                "id"))).getText().toString();
+        if (TextUtils.isEmpty(dataReportTypeString)) {
+            showResult("请先填入上报类型");
+            return;
+        }
+
+        int dataReportType = Integer.parseInt(dataReportTypeString);
+
+        /**设置统计参数的方法,游戏在参数发出变化时都需要调用接口设置参数*/
+        /**====================================================
+         * ConstSet.DATA_KEY_ROLE_ID 当前登录的玩家角色ID
+         * ConstSet.DATA_KEY_ROLE_NAME 当前登录的玩家角色名
+         * ConstSet.DATA_KEY_ROLE_LEVEL 当前登录的玩家角色等级
+         * ConstSet.DATA_KEY_ROLE_TYPE 角色类型,例如:战士,魔法师,弓箭手
+         * ConstSet.DATA_KEY_SERVER_ID 当前登录的游戏区服ID
+         * ConstSet.DATA_KEY_SERVER_NAME 当前登录的游戏区服名称
+         * ConstSet.DATA_KEY_BALANCE 当前用户游戏币余额
+         * ConstSet.DATA_KEY_VIP_LEVEL 当前用户VIP等级
+         * ConstSet.DATA_KEY_PARTY_NAME 当前用户所属帮派
+         * ConstSet.DATA_KEY_ROLE_CREATE_TIME 角色创建时间(单位:秒),该时间请务必传入服务端真实角色创建时间。
+         * ConstSet.DATA_KEY_ROLE_LEVEL_TIME 角色等级变化时间(单位:秒),该时间请务必传入服务端真实角色升级时间。
+         *
+         * ConstSet.DATA_KEY_DATA_TYPE 数据统计类型,以下所有统计点必接):
+         * 1、创建角色,data type为0;
+         * 2、角色升级,data type为1;
+         * 3、上传区服信息,data type为2;
+         * 4、登录,data type为3;
+         * 5、进入游戏,data type为4;
+         * 6、支付,data type为5;
+         * 7、选择服务器,data type为6;
+         * 8、退出游戏,data type为7;
+         =======================================================*/
+        Bundle staticsData = new Bundle();
+        staticsData.putString(ConstSet.DATA_KEY_ROLE_ID, "111");
+        staticsData.putString(ConstSet.DATA_KEY_ROLE_NAME, "战士");
+        staticsData.putString(ConstSet.DATA_KEY_ROLE_TYPE, "战士");
+        staticsData.putString(ConstSet.DATA_KEY_ROLE_LEVEL, "65");
+        staticsData.putString(ConstSet.DATA_KEY_SERVER_ID, "11");
+        staticsData.putString(ConstSet.DATA_KEY_SERVER_NAME, "服务器");
+        staticsData.putString(ConstSet.DATA_KEY_BALANCE, "102");
+        staticsData.putString(ConstSet.DATA_KEY_VIP_LEVEL, "2");
+        staticsData.putString(ConstSet.DATA_KEY_PARTY_NAME, "水果派");
+        staticsData.putLong(ConstSet.DATA_KEY_ROLE_CREATE_TIME, System.currentTimeMillis() / 1000);
+        staticsData.putLong(ConstSet.DATA_KEY_ROLE_LEVEL_TIME, System.currentTimeMillis() / 1000);
+        staticsData.putString(ConstSet.DATA_KEY_ZONE_ID, "1");
+        staticsData.putString(ConstSet.DATA_KEY_ZONE_NAME, "阿狸一区");
+        staticsData.putInt(ConstSet.DATA_KEY_DATA_TYPE, dataReportType);
+        FqGame.setRoleInfo(staticsData);
+    }
+
+    private void logout() {
+        FqGame.logout(this, new ILogout() {
+            @Override
+            public void onLogout() {
+                // 重新登录
+                FqLog.i(TAG,"onLogout");
+            }
+        });
+    }
+
+    private void changeAccount() {
+        FqLog.i(TAG,"changeAccount");
+        FqGame.changeAccount(this);
+    }
+
+    private void showResult(String message) {
+        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
+    }
+
+    private void exitAppProcess(Activity activity) {
+        if (!activity.isFinishing()) {
+            activity.finish();
+        }
+        android.os.Process.killProcess(android.os.Process.myPid());
+        System.exit(0);
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        boolean isConsume = super.onKeyDown(keyCode, event);
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_BACK:
+                isConsume = true;
+                exit();
+                break;
+        }
+
+        return isConsume;
+    }
+
+    @Override
+    public void onBackPressed() {
+        exit();
+    }
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[]
+            grantResults) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+        FqGame.onRequestPermissionsResult(requestCode, permissions, grantResults);
+    }
+}

+ 19 - 0
app_dev/src/main/java/com/funcheer/channel/sdk/MainApp.java

@@ -0,0 +1,19 @@
+package com.funcheer.channel.sdk;
+
+import android.content.Context;
+
+import com.fq.channel.sdk.FQApplication;
+
+
+public class MainApp extends FQApplication {
+
+    @Override
+    public void attachBaseContext(Context base) {
+        super.attachBaseContext(base);
+    }
+
+    @Override
+    public void onCreate(){
+        super.onCreate();
+    }
+}

+ 11 - 0
app_dev/src/main/java/com/tencent/tmgp/xzsjjby/wxapi/WXEntryActivity.java

@@ -0,0 +1,11 @@
+package com.tencent.tmgp.xzsjjby.wxapi;
+
+import com.fq.channel.sdk.WXCallBackActivity;
+
+/**
+ * @Description: 描述
+ * @Author: FLuty
+ * @CreateDate: 2020/4/21 15:58
+ */
+public class WXEntryActivity extends WXCallBackActivity {
+}

+ 170 - 0
app_dev/src/main/res/drawable/ic_launcher_background.xml

@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="108dp"
+    android:height="108dp"
+    android:viewportWidth="108"
+    android:viewportHeight="108">
+    <path
+        android:fillColor="#008577"
+        android:pathData="M0,0h108v108h-108z" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M9,0L9,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,0L19,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,0L29,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,0L39,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,0L49,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,0L59,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,0L69,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,0L79,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M89,0L89,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M99,0L99,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,9L108,9"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,19L108,19"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,29L108,29"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,39L108,39"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,49L108,49"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,59L108,59"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,69L108,69"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,79L108,79"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,89L108,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,99L108,99"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,29L89,29"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,39L89,39"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,49L89,49"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,59L89,59"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,69L89,69"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,79L89,79"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,19L29,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,19L39,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,19L49,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,19L59,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,19L69,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,19L79,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+</vector>

+ 176 - 0
app_dev/src/main/res/layout/fq_activity_main.xml

@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:padding="20dp"
+    android:background="@color/fq_gray"
+    tools:context="com.funcheer.channel.sdk.MainActivity"    >
+
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+
+            <LinearLayout
+                android:id="@+id/fq_user_module"
+                android:layout_alignParentTop="true"
+                android:layout_centerInParent="true"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="@color/fq_white"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/fq_user_tv"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:background="@color/fq_white"
+                    android:gravity="center"
+                    android:text="@string/fq_user" />
+
+                <Button
+                    android:id="@+id/fq_login"
+                    android:layout_marginTop="5dp"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/fq_login" />
+
+                <Button
+                    android:id="@+id/fq_logout"
+                    android:layout_marginTop="5dp"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/fq_logout" />
+                <Button
+                    android:id="@+id/fq_change_account"
+                    android:layout_marginTop="5dp"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/fq_change_account" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/fq_charge_module"
+                android:layout_width="match_parent"
+                android:layout_marginTop="20dp"
+                android:layout_centerInParent="true"
+                android:background="@color/fq_white"
+                android:layout_below="@+id/fq_user_module"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/fq_charge_module_tv"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:background="@color/fq_white"
+                    android:gravity="center"
+                    android:text="@string/fq_charge_module" />
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="horizontal">
+
+                    <TextView
+                        android:id="@+id/fq_input_price"
+                        android:layout_marginTop="10dp"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:background="@color/fq_white"
+                        android:gravity="center"
+                        android:text="@string/fq_input_price" />
+
+                    <EditText
+                        android:id="@+id/fq_charge_price"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:text="1"
+                        />
+
+                </LinearLayout>
+
+                <Button
+                    android:id="@+id/fq_charge"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="5dp"
+                    android:layout_below="@+id/fq_charge_module"
+                    android:layout_centerInParent="true"
+                    android:text="@string/fq_charge" />
+
+            </LinearLayout>
+
+
+            <LinearLayout
+                android:id="@+id/fq_data_report_module"
+                android:layout_width="match_parent"
+                android:layout_marginTop="20dp"
+                android:layout_centerInParent="true"
+                android:background="@color/fq_white"
+                android:layout_below="@+id/fq_user_module"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/fq_data_report_module_tv"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:background="@color/fq_white"
+                    android:gravity="center"
+                    android:text="@string/fq_data_report_module_tv" />
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="horizontal">
+
+                    <TextView
+                        android:id="@+id/fq_input_report_type"
+                        android:layout_marginTop="10dp"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:background="@color/fq_white"
+                        android:gravity="center"
+                        android:text="@string/fq_input_report_type" />
+
+                    <EditText
+                        android:id="@+id/fq_report_type"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:text="4"
+                        />
+
+                </LinearLayout>
+
+                <Button
+                    android:id="@+id/fq_report_data"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="5dp"
+                    android:layout_below="@+id/fq_charge_module"
+                    android:layout_centerInParent="true"
+                    android:text="@string/fq_report_data" />
+
+            </LinearLayout>
+
+
+            <Button
+                android:id="@+id/fq_exit"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:layout_centerInParent="true"
+                android:text="@string/fq_exit" />
+
+        </LinearLayout>
+
+    </ScrollView>
+
+</RelativeLayout>

BIN
app_dev/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app_dev/src/main/res/mipmap-hdpi/ic_launcher_round.png


BIN
app_dev/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
app_dev/src/main/res/mipmap-mdpi/ic_launcher_round.png


BIN
app_dev/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
app_dev/src/main/res/mipmap-xhdpi/ic_launcher_round.png


BIN
app_dev/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
app_dev/src/main/res/mipmap-xxhdpi/ic_launcher_round.png


BIN
app_dev/src/main/res/mipmap-xxxhdpi/ic_launcher.png


BIN
app_dev/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png


+ 11 - 0
app_dev/src/main/res/values/colors.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#008577</color>
+    <color name="colorPrimaryDark">#00574B</color>
+    <color name="colorAccent">#D81B60</color>
+    <color name="fq_colorPrimary">#3F51B5</color>
+    <color name="fq_colorPrimaryDark">#303F9F</color>
+    <color name="fq_colorAccent">#FF4081</color>
+    <color name="fq_white">#FFFFFF</color>
+    <color name="fq_gray">#F1F1F1</color>
+</resources>

+ 25 - 0
app_dev/src/main/res/values/strings.xml

@@ -0,0 +1,25 @@
+<resources>
+    <string name="app_name">FQChannel-YSDK</string>
+    <string name="fq_result">result...</string>
+
+    <string name="fq_user">用户</string>
+    <string name="fq_login">登录</string>
+    <string name="fq_logout">注销</string>
+    <string name="fq_change_account">切换账号</string>
+
+    <string name="fq_charge_module">支付</string>
+    <string name="fq_input_price">输入价格:</string>
+    <string name="fq_charge">支付</string>
+
+    <string name="fq_data_report_module_tv">数据上报</string>
+    <string name="fq_input_report_type">输入数据上报类型:</string>
+    <string name="fq_report_data">上报数据</string>
+
+    <string name="fq_show_float_view">显示浮层</string>
+    <string name="fq_hide_float_view">隐藏浮层</string>
+
+    <string name="fq_get_channel_id">获取渠道号</string>
+    <string name="fq_share">分享</string>
+
+    <string name="fq_exit">退出</string>
+</resources>

+ 8 - 0
app_dev/src/main/res/values/styles.xml

@@ -0,0 +1,8 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="fq_AppTheme" parent="@android:style/Theme.NoTitleBar">
+        <item name="android:windowIsTranslucent">false</item>
+        <item name="android:windowDisablePreview">true</item>
+    </style>
+</resources>

+ 1 - 0
app_dev_lib/.gitignore

@@ -0,0 +1 @@
+/build

+ 33 - 0
app_dev_lib/build.gradle

@@ -0,0 +1,33 @@
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion 29
+
+
+    defaultConfig {
+        minSdkVersion 15
+        targetSdkVersion 29
+        versionCode 1
+        versionName "1.0"
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        consumerProguardFiles 'consumer-rules.pro'
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+
+    implementation 'androidx.appcompat:appcompat:1.1.0'
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation 'androidx.test:runner:1.2.0'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+}

+ 0 - 0
app_dev_lib/consumer-rules.pro


+ 21 - 0
app_dev_lib/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 27 - 0
app_dev_lib/src/androidTest/java/com/example/app_dev_lib/ExampleInstrumentedTest.java

@@ -0,0 +1,27 @@
+package com.example.app_dev_lib;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+        assertEquals("com.example.app_dev_lib.test", appContext.getPackageName());
+    }
+}

+ 2 - 0
app_dev_lib/src/main/AndroidManifest.xml

@@ -0,0 +1,2 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.app_dev_lib" />

+ 3 - 0
app_dev_lib/src/main/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+    <string name="app_name">app_dev_lib</string>
+</resources>

+ 17 - 0
app_dev_lib/src/test/java/com/example/app_dev_lib/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package com.example.app_dev_lib;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() {
+        assertEquals(4, 2 + 2);
+    }
+}

+ 835 - 0
fq_channel_ysdk/src/main/java/androidx/core/content/FileProvider.java

@@ -0,0 +1,835 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.core.content;
+
+import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
+import static org.xmlpull.v1.XmlPullParser.START_TAG;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ProviderInfo;
+import android.content.res.XmlResourceParser;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Environment;
+import android.os.ParcelFileDescriptor;
+import android.provider.OpenableColumns;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.content.ContextCompat;
+import android.text.TextUtils;
+import android.webkit.MimeTypeMap;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.concurrent.GuardedBy;
+
+/**
+ * FileProvider is a special subclass of {@link ContentProvider} that facilitates secure sharing
+ * of files associated with an app by creating a <code>content://</code> {@link Uri} for a file
+ * instead of a <code>file:///</code> {@link Uri}.
+ * <p>
+ * A content URI allows you to grant read and write access using
+ * temporary access permissions. When you create an {@link Intent} containing
+ * a content URI, in order to send the content URI
+ * to a client app, you can also call {@link Intent#setFlags(int) Intent.setFlags()} to add
+ * permissions. These permissions are available to the client app for as long as the stack for
+ * a receiving {@link android.app.Activity} is active. For an {@link Intent} going to a
+ * {@link android.app.Service}, the permissions are available as long as the
+ * {@link android.app.Service} is running.
+ * <p>
+ * In comparison, to control access to a <code>file:///</code> {@link Uri} you have to modify the
+ * file system permissions of the underlying file. The permissions you provide become available to
+ * <em>any</em> app, and remain in effect until you change them. This level of access is
+ * fundamentally insecure.
+ * <p>
+ * The increased level of file access security offered by a content URI
+ * makes FileProvider a key part of Android's security infrastructure.
+ * <p>
+ * This overview of FileProvider includes the following topics:
+ * </p>
+ * <ol>
+ *     <li><a href="#ProviderDefinition">Defining a FileProvider</a></li>
+ *     <li><a href="#SpecifyFiles">Specifying Available Files</a></li>
+ *     <li><a href="#GetUri">Retrieving the Content URI for a File</li>
+ *     <li><a href="#Permissions">Granting Temporary Permissions to a URI</a></li>
+ *     <li><a href="#ServeUri">Serving a Content URI to Another App</a></li>
+ * </ol>
+ * <h3 id="ProviderDefinition">Defining a FileProvider</h3>
+ * <p>
+ * Since the default functionality of FileProvider includes content URI generation for files, you
+ * don't need to define a subclass in code. Instead, you can include a FileProvider in your app
+ * by specifying it entirely in XML. To specify the FileProvider component itself, add a
+ * <code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code>
+ * element to your app manifest. Set the <code>android:name</code> attribute to
+ * <code>FileProvider</code>. Set the <code>android:authorities</code>
+ * attribute to a URI authority based on a domain you control; for example, if you control the
+ * domain <code>mydomain.com</code> you should use the authority
+ * <code>com.mydomain.fileprovider</code>. Set the <code>android:exported</code> attribute to
+ * <code>false</code>; the FileProvider does not need to be public. Set the
+ * <a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn"
+ * >android:grantUriPermissions</a> attribute to <code>true</code>, to allow you
+ * to grant temporary access to files. For example:
+ * <pre class="prettyprint">
+ *&lt;manifest&gt;
+ *    ...
+ *    &lt;application&gt;
+ *        ...
+ *        &lt;provider
+ *            android:name="FileProvider"
+ *            android:authorities="com.mydomain.fileprovider"
+ *            android:exported="false"
+ *            android:grantUriPermissions="true"&gt;
+ *            ...
+ *        &lt;/provider&gt;
+ *        ...
+ *    &lt;/application&gt;
+ *&lt;/manifest&gt;</pre>
+ * <p>
+ * If you want to override any of the default behavior of FileProvider methods, extend
+ * the FileProvider class and use the fully-qualified class name in the <code>android:name</code>
+ * attribute of the <code>&lt;provider&gt;</code> element.
+ * <h3 id="SpecifyFiles">Specifying Available Files</h3>
+ * A FileProvider can only generate a content URI for files in directories that you specify
+ * beforehand. To specify a directory, specify the its storage area and path in XML, using child
+ * elements of the <code>&lt;paths&gt;</code> element.
+ * For example, the following <code>paths</code> element tells FileProvider that you intend to
+ * request content URIs for the <code>images/</code> subdirectory of your private file area.
+ * <pre class="prettyprint">
+ *&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
+ *    &lt;files-path name="my_images" path="images/"/&gt;
+ *    ...
+ *&lt;/paths&gt;
+ *</pre>
+ * <p>
+ * The <code>&lt;paths&gt;</code> element must contain one or more of the following child elements:
+ * </p>
+ * <dl>
+ *     <dt>
+ * <pre class="prettyprint">
+ *&lt;files-path name="<i>name</i>" path="<i>path</i>" /&gt;
+ *</pre>
+ *     </dt>
+ *     <dd>
+ *     Represents files in the <code>files/</code> subdirectory of your app's internal storage
+ *     area. This subdirectory is the same as the value returned by {@link Context#getFilesDir()
+ *     Context.getFilesDir()}.
+ *     </dd>
+ *     <dt>
+ * <pre>
+ *&lt;cache-path name="<i>name</i>" path="<i>path</i>" /&gt;
+ *</pre>
+ *     <dt>
+ *     <dd>
+ *     Represents files in the cache subdirectory of your app's internal storage area. The root path
+ *     of this subdirectory is the same as the value returned by {@link Context#getCacheDir()
+ *     getCacheDir()}.
+ *     </dd>
+ *     <dt>
+ * <pre class="prettyprint">
+ *&lt;external-path name="<i>name</i>" path="<i>path</i>" /&gt;
+ *</pre>
+ *     </dt>
+ *     <dd>
+ *     Represents files in the root of the external storage area. The root path of this subdirectory
+ *     is the same as the value returned by
+ *     {@link Environment#getExternalStorageDirectory() Environment.getExternalStorageDirectory()}.
+ *     </dd>
+ *     <dt>
+ * <pre class="prettyprint">
+ *&lt;external-files-path name="<i>name</i>" path="<i>path</i>" /&gt;
+ *</pre>
+ *     </dt>
+ *     <dd>
+ *     Represents files in the root of your app's external storage area. The root path of this
+ *     subdirectory is the same as the value returned by
+ *     {@code Context#getExternalFilesDir(String) Context.getExternalFilesDir(null)}.
+ *     </dd>
+ *     <dt>
+ * <pre class="prettyprint">
+ *&lt;external-cache-path name="<i>name</i>" path="<i>path</i>" /&gt;
+ *</pre>
+ *     </dt>
+ *     <dd>
+ *     Represents files in the root of your app's external cache area. The root path of this
+ *     subdirectory is the same as the value returned by
+ *     {@link Context#getExternalCacheDir() Context.getExternalCacheDir()}.
+ *     </dd>
+ *     <dt>
+ * <pre class="prettyprint">
+ *&lt;external-media-path name="<i>name</i>" path="<i>path</i>" /&gt;
+ *</pre>
+ *     </dt>
+ *     <dd>
+ *     Represents files in the root of your app's external media area. The root path of this
+ *     subdirectory is the same as the value returned by the first result of
+ *     {@link Context#getExternalMediaDirs() Context.getExternalMediaDirs()}.
+ *     <p><strong>Note:</strong> this directory is only available on API 21+ devices.</p>
+ *     </dd>
+ * </dl>
+ * <p>
+ *     These child elements all use the same attributes:
+ * </p>
+ * <dl>
+ *     <dt>
+ *         <code>name="<i>name</i>"</code>
+ *     </dt>
+ *     <dd>
+ *         A URI path segment. To enforce security, this value hides the name of the subdirectory
+ *         you're sharing. The subdirectory name for this value is contained in the
+ *         <code>path</code> attribute.
+ *     </dd>
+ *     <dt>
+ *         <code>path="<i>path</i>"</code>
+ *     </dt>
+ *     <dd>
+ *         The subdirectory you're sharing. While the <code>name</code> attribute is a URI path
+ *         segment, the <code>path</code> value is an actual subdirectory name. Notice that the
+ *         value refers to a <b>subdirectory</b>, not an individual file or files. You can't
+ *         share a single file by its file name, nor can you specify a subset of files using
+ *         wildcards.
+ *     </dd>
+ * </dl>
+ * <p>
+ * You must specify a child element of <code>&lt;paths&gt;</code> for each directory that contains
+ * files for which you want content URIs. For example, these XML elements specify two directories:
+ * <pre class="prettyprint">
+ *&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
+ *    &lt;files-path name="my_images" path="images/"/&gt;
+ *    &lt;files-path name="my_docs" path="docs/"/&gt;
+ *&lt;/paths&gt;
+ *</pre>
+ * <p>
+ * Put the <code>&lt;paths&gt;</code> element and its children in an XML file in your project.
+ * For example, you can add them to a new file called <code>res/xml/file_paths.xml</code>.
+ * To link this file to the FileProvider, add a
+ * <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a> element
+ * as a child of the <code>&lt;provider&gt;</code> element that defines the FileProvider. Set the
+ * <code>&lt;meta-data&gt;</code> element's "android:name" attribute to
+ * <code>android.support.FILE_PROVIDER_PATHS</code>. Set the element's "android:resource" attribute
+ * to <code>&#64;xml/file_paths</code> (notice that you don't specify the <code>.xml</code>
+ * extension). For example:
+ * <pre class="prettyprint">
+ *&lt;provider
+ *    android:name="FileProvider"
+ *    android:authorities="com.mydomain.fileprovider"
+ *    android:exported="false"
+ *    android:grantUriPermissions="true"&gt;
+ *    &lt;meta-data
+ *        android:name="android.support.FILE_PROVIDER_PATHS"
+ *        android:resource="&#64;xml/file_paths" /&gt;
+ *&lt;/provider&gt;
+ *</pre>
+ * <h3 id="GetUri">Generating the Content URI for a File</h3>
+ * <p>
+ * To share a file with another app using a content URI, your app has to generate the content URI.
+ * To generate the content URI, create a new {@link File} for the file, then pass the {@link File}
+ * to {@link #getUriForFile(Context, String, File) getUriForFile()}. You can send the content URI
+ * returned by {@link #getUriForFile(Context, String, File) getUriForFile()} to another app in an
+ * {@link Intent}. The client app that receives the content URI can open the file
+ * and access its contents by calling
+ * {@link android.content.ContentResolver#openFileDescriptor(Uri, String)
+ * ContentResolver.openFileDescriptor} to get a {@link ParcelFileDescriptor}.
+ * <p>
+ * For example, suppose your app is offering files to other apps with a FileProvider that has the
+ * authority <code>com.mydomain.fileprovider</code>. To get a content URI for the file
+ * <code>default_image.jpg</code> in the <code>images/</code> subdirectory of your internal storage
+ * add the following code:
+ * <pre class="prettyprint">
+ *File imagePath = new File(Context.getFilesDir(), "images");
+ *File newFile = new File(imagePath, "default_image.jpg");
+ *Uri contentUri = getUriForFile(getContext(), "com.mydomain.fileprovider", newFile);
+ *</pre>
+ * As a result of the previous snippet,
+ * {@link #getUriForFile(Context, String, File) getUriForFile()} returns the content URI
+ * <code>content://com.mydomain.fileprovider/my_images/default_image.jpg</code>.
+ * <h3 id="Permissions">Granting Temporary Permissions to a URI</h3>
+ * To grant an access permission to a content URI returned from
+ * {@link #getUriForFile(Context, String, File) getUriForFile()}, do one of the following:
+ * <ul>
+ * <li>
+ *     Call the method
+ *     {@link Context#grantUriPermission(String, Uri, int)
+ *     Context.grantUriPermission(package, Uri, mode_flags)} for the <code>content://</code>
+ *     {@link Uri}, using the desired mode flags. This grants temporary access permission for the
+ *     content URI to the specified package, according to the value of the
+ *     the <code>mode_flags</code> parameter, which you can set to
+ *     {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}, {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}
+ *     or both. The permission remains in effect until you revoke it by calling
+ *     {@link Context#revokeUriPermission(Uri, int) revokeUriPermission()} or until the device
+ *     reboots.
+ * </li>
+ * <li>
+ *     Put the content URI in an {@link Intent} by calling {@link Intent#setData(Uri) setData()}.
+ * </li>
+ * <li>
+ *     Next, call the method {@link Intent#setFlags(int) Intent.setFlags()} with either
+ *     {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} or
+ *     {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION} or both.
+ * </li>
+ * <li>
+ *     Finally, send the {@link Intent} to
+ *     another app. Most often, you do this by calling
+ *     {@link android.app.Activity#setResult(int, Intent) setResult()}.
+ *     <p>
+ *     Permissions granted in an {@link Intent} remain in effect while the stack of the receiving
+ *     {@link android.app.Activity} is active. When the stack finishes, the permissions are
+ *     automatically removed. Permissions granted to one {@link android.app.Activity} in a client
+ *     app are automatically extended to other components of that app.
+ *     </p>
+ * </li>
+ * </ul>
+ * <h3 id="ServeUri">Serving a Content URI to Another App</h3>
+ * <p>
+ * There are a variety of ways to serve the content URI for a file to a client app. One common way
+ * is for the client app to start your app by calling
+ * {@link android.app.Activity#startActivityForResult(Intent, int, Bundle) startActivityResult()},
+ * which sends an {@link Intent} to your app to start an {@link android.app.Activity} in your app.
+ * In response, your app can immediately return a content URI to the client app or present a user
+ * interface that allows the user to pick a file. In the latter case, once the user picks the file
+ * your app can return its content URI. In both cases, your app returns the content URI in an
+ * {@link Intent} sent via {@link android.app.Activity#setResult(int, Intent) setResult()}.
+ * </p>
+ * <p>
+ *  You can also put the content URI in a {@link android.content.ClipData} object and then add the
+ *  object to an {@link Intent} you send to a client app. To do this, call
+ *  {@link Intent#setClipData(ClipData) Intent.setClipData()}. When you use this approach, you can
+ *  add multiple {@link android.content.ClipData} objects to the {@link Intent}, each with its own
+ *  content URI. When you call {@link Intent#setFlags(int) Intent.setFlags()} on the {@link Intent}
+ *  to set temporary access permissions, the same permissions are applied to all of the content
+ *  URIs.
+ * </p>
+ * <p class="note">
+ *  <strong>Note:</strong> The {@link Intent#setClipData(ClipData) Intent.setClipData()} method is
+ *  only available in platform version 16 (Android 4.1) and later. If you want to maintain
+ *  compatibility with previous versions, you should send one content URI at a time in the
+ *  {@link Intent}. Set the action to {@link Intent#ACTION_SEND} and put the URI in data by calling
+ *  {@link Intent#setData setData()}.
+ * </p>
+ * <h3 id="">More Information</h3>
+ * <p>
+ *    To learn more about FileProvider, see the Android training class
+ *    <a href="{@docRoot}training/secure-file-sharing/index.html">Sharing Files Securely with URIs</a>.
+ * </p>
+ */
+public class FileProvider extends ContentProvider {
+    private static final String[] COLUMNS = {
+            OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE };
+
+    private static final String
+            META_DATA_FILE_PROVIDER_PATHS = "android.support.FILE_PROVIDER_PATHS";
+
+    private static final String TAG_ROOT_PATH = "root-path";
+    private static final String TAG_FILES_PATH = "files-path";
+    private static final String TAG_CACHE_PATH = "cache-path";
+    private static final String TAG_EXTERNAL = "external-path";
+    private static final String TAG_EXTERNAL_FILES = "external-files-path";
+    private static final String TAG_EXTERNAL_CACHE = "external-cache-path";
+    private static final String TAG_EXTERNAL_MEDIA = "external-media-path";
+
+    private static final String ATTR_NAME = "name";
+    private static final String ATTR_PATH = "path";
+
+    private static final File DEVICE_ROOT = new File("/");
+
+    @GuardedBy("sCache")
+    private static HashMap<String, PathStrategy> sCache = new HashMap<String, PathStrategy>();
+
+    private PathStrategy mStrategy;
+
+    /**
+     * The default FileProvider implementation does not need to be initialized. If you want to
+     * override this method, you must provide your own subclass of FileProvider.
+     */
+    @Override
+    public boolean onCreate() {
+        return true;
+    }
+
+    /**
+     * After the FileProvider is instantiated, this method is called to provide the system with
+     * information about the provider.
+     *
+     * @param context A {@link Context} for the current component.
+     * @param info A {@link ProviderInfo} for the new provider.
+     */
+    @Override
+    public void attachInfo(@NonNull Context context, @NonNull ProviderInfo info) {
+        super.attachInfo(context, info);
+
+        // Sanity check our security
+        if (info.exported) {
+            throw new SecurityException("Provider must not be exported");
+        }
+        if (!info.grantUriPermissions) {
+            throw new SecurityException("Provider must grant uri permissions");
+        }
+
+        mStrategy = getPathStrategy(context, info.authority);
+    }
+
+    /**
+     * Return a content URI for a given {@link File}. Specific temporary
+     * permissions for the content URI can be set with
+     * {@link Context#grantUriPermission(String, Uri, int)}, or added
+     * to an {@link Intent} by calling {@link Intent#setData(Uri) setData()} and then
+     * {@link Intent#setFlags(int) setFlags()}; in both cases, the applicable flags are
+     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} and
+     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}. A FileProvider can only return a
+     * <code>content</code> {@link Uri} for file paths defined in their <code>&lt;paths&gt;</code>
+     * meta-data element. See the Class Overview for more information.
+     *
+     * @param context A {@link Context} for the current component.
+     * @param authority The authority of a {@link FileProvider} defined in a
+     *            {@code <provider>} element in your app's manifest.
+     * @param file A {@link File} pointing to the filename for which you want a
+     * <code>content</code> {@link Uri}.
+     * @return A content URI for the file.
+     * @throws IllegalArgumentException When the given {@link File} is outside
+     * the paths supported by the provider.
+     */
+    public static Uri getUriForFile(@NonNull Context context, @NonNull String authority,
+                                    @NonNull File file) {
+        final PathStrategy strategy = getPathStrategy(context, authority);
+        return strategy.getUriForFile(file);
+    }
+
+    /**
+     * Use a content URI returned by
+     * {@link #getUriForFile(Context, String, File) getUriForFile()} to get information about a file
+     * managed by the FileProvider.
+     * FileProvider reports the column names defined in {@link OpenableColumns}:
+     * <ul>
+     * <li>{@link OpenableColumns#DISPLAY_NAME}</li>
+     * <li>{@link OpenableColumns#SIZE}</li>
+     * </ul>
+     * For more information, see
+     * {@link ContentProvider#query(Uri, String[], String, String[], String)
+     * ContentProvider.query()}.
+     *
+     * @param uri A content URI returned by {@link #getUriForFile}.
+     * @param projection The list of columns to put into the {@link Cursor}. If null all columns are
+     * included.
+     * @param selection Selection criteria to apply. If null then all data that matches the content
+     * URI is returned.
+     * @param selectionArgs An array of {@link String}, containing arguments to bind to
+     * the <i>selection</i> parameter. The <i>query</i> method scans <i>selection</i> from left to
+     * right and iterates through <i>selectionArgs</i>, replacing the current "?" character in
+     * <i>selection</i> with the value at the current position in <i>selectionArgs</i>. The
+     * values are bound to <i>selection</i> as {@link String} values.
+     * @param sortOrder A {@link String} containing the column name(s) on which to sort
+     * the resulting {@link Cursor}.
+     * @return A {@link Cursor} containing the results of the query.
+     *
+     */
+    @Override
+    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
+                        @Nullable String[] selectionArgs,
+                        @Nullable String sortOrder) {
+        // ContentProvider has already checked granted permissions
+        final File file = mStrategy.getFileForUri(uri);
+
+        if (projection == null) {
+            projection = COLUMNS;
+        }
+
+        String[] cols = new String[projection.length];
+        Object[] values = new Object[projection.length];
+        int i = 0;
+        for (String col : projection) {
+            if (OpenableColumns.DISPLAY_NAME.equals(col)) {
+                cols[i] = OpenableColumns.DISPLAY_NAME;
+                values[i++] = file.getName();
+            } else if (OpenableColumns.SIZE.equals(col)) {
+                cols[i] = OpenableColumns.SIZE;
+                values[i++] = file.length();
+            }
+        }
+
+        cols = copyOf(cols, i);
+        values = copyOf(values, i);
+
+        final MatrixCursor cursor = new MatrixCursor(cols, 1);
+        cursor.addRow(values);
+        return cursor;
+    }
+
+    /**
+     * Returns the MIME type of a content URI returned by
+     * {@link #getUriForFile(Context, String, File) getUriForFile()}.
+     *
+     * @param uri A content URI returned by
+     * {@link #getUriForFile(Context, String, File) getUriForFile()}.
+     * @return If the associated file has an extension, the MIME type associated with that
+     * extension; otherwise <code>application/octet-stream</code>.
+     */
+    @Override
+    public String getType(@NonNull Uri uri) {
+        // ContentProvider has already checked granted permissions
+        final File file = mStrategy.getFileForUri(uri);
+
+        final int lastDot = file.getName().lastIndexOf('.');
+        if (lastDot >= 0) {
+            final String extension = file.getName().substring(lastDot + 1);
+            final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
+            if (mime != null) {
+                return mime;
+            }
+        }
+
+        return "application/octet-stream";
+    }
+
+    /**
+     * By default, this method throws an {@link UnsupportedOperationException}. You must
+     * subclass FileProvider if you want to provide different functionality.
+     */
+    @Override
+    public Uri insert(@NonNull Uri uri, ContentValues values) {
+        throw new UnsupportedOperationException("No external inserts");
+    }
+
+    /**
+     * By default, this method throws an {@link UnsupportedOperationException}. You must
+     * subclass FileProvider if you want to provide different functionality.
+     */
+    @Override
+    public int update(@NonNull Uri uri, ContentValues values, @Nullable String selection,
+                      @Nullable String[] selectionArgs) {
+        throw new UnsupportedOperationException("No external updates");
+    }
+
+    /**
+     * Deletes the file associated with the specified content URI, as
+     * returned by {@link #getUriForFile(Context, String, File) getUriForFile()}. Notice that this
+     * method does <b>not</b> throw an {@link IOException}; you must check its return value.
+     *
+     * @param uri A content URI for a file, as returned by
+     * {@link #getUriForFile(Context, String, File) getUriForFile()}.
+     * @param selection Ignored. Set to {@code null}.
+     * @param selectionArgs Ignored. Set to {@code null}.
+     * @return 1 if the delete succeeds; otherwise, 0.
+     */
+    @Override
+    public int delete(@NonNull Uri uri, @Nullable String selection,
+                      @Nullable String[] selectionArgs) {
+        // ContentProvider has already checked granted permissions
+        final File file = mStrategy.getFileForUri(uri);
+        return file.delete() ? 1 : 0;
+    }
+
+    /**
+     * By default, FileProvider automatically returns the
+     * {@link ParcelFileDescriptor} for a file associated with a <code>content://</code>
+     * {@link Uri}. To get the {@link ParcelFileDescriptor}, call
+     * {@link android.content.ContentResolver#openFileDescriptor(Uri, String)
+     * ContentResolver.openFileDescriptor}.
+     *
+     * To override this method, you must provide your own subclass of FileProvider.
+     *
+     * @param uri A content URI associated with a file, as returned by
+     * {@link #getUriForFile(Context, String, File) getUriForFile()}.
+     * @param mode Access mode for the file. May be "r" for read-only access, "rw" for read and
+     * write access, or "rwt" for read and write access that truncates any existing file.
+     * @return A new {@link ParcelFileDescriptor} with which you can access the file.
+     */
+    @Override
+    public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode)
+            throws FileNotFoundException {
+        // ContentProvider has already checked granted permissions
+        final File file = mStrategy.getFileForUri(uri);
+        final int fileMode = modeToMode(mode);
+        return ParcelFileDescriptor.open(file, fileMode);
+    }
+
+    /**
+     * Return {@link PathStrategy} for given authority, either by parsing or
+     * returning from cache.
+     */
+    private static PathStrategy getPathStrategy(Context context, String authority) {
+        PathStrategy strat;
+        synchronized (sCache) {
+            strat = sCache.get(authority);
+            if (strat == null) {
+                try {
+                    strat = parsePathStrategy(context, authority);
+                } catch (IOException e) {
+                    throw new IllegalArgumentException(
+                            "Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
+                } catch (XmlPullParserException e) {
+                    throw new IllegalArgumentException(
+                            "Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
+                }
+                sCache.put(authority, strat);
+            }
+        }
+        return strat;
+    }
+
+    /**
+     * Parse and return {@link PathStrategy} for given authority as defined in
+     * {@link #META_DATA_FILE_PROVIDER_PATHS} {@code <meta-data>}.
+     *
+     * @see #getPathStrategy(Context, String)
+     */
+    private static PathStrategy parsePathStrategy(Context context, String authority)
+            throws IOException, XmlPullParserException {
+        final SimplePathStrategy strat = new SimplePathStrategy(authority);
+
+        final ProviderInfo info = context.getPackageManager()
+                .resolveContentProvider(authority, PackageManager.GET_META_DATA);
+        final XmlResourceParser in = info.loadXmlMetaData(
+                context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
+        if (in == null) {
+            throw new IllegalArgumentException(
+                    "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
+        }
+
+        int type;
+        while ((type = in.next()) != END_DOCUMENT) {
+            if (type == START_TAG) {
+                final String tag = in.getName();
+
+                final String name = in.getAttributeValue(null, ATTR_NAME);
+                String path = in.getAttributeValue(null, ATTR_PATH);
+
+                File target = null;
+                if (TAG_ROOT_PATH.equals(tag)) {
+                    target = DEVICE_ROOT;
+                } else if (TAG_FILES_PATH.equals(tag)) {
+                    target = context.getFilesDir();
+                } else if (TAG_CACHE_PATH.equals(tag)) {
+                    target = context.getCacheDir();
+                } else if (TAG_EXTERNAL.equals(tag)) {
+                    target = Environment.getExternalStorageDirectory();
+                } else if (TAG_EXTERNAL_FILES.equals(tag)) {
+                    File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null);
+                    if (externalFilesDirs.length > 0) {
+                        target = externalFilesDirs[0];
+                    }
+                } else if (TAG_EXTERNAL_CACHE.equals(tag)) {
+                    File[] externalCacheDirs = ContextCompat.getExternalCacheDirs(context);
+                    if (externalCacheDirs.length > 0) {
+                        target = externalCacheDirs[0];
+                    }
+                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
+                        && TAG_EXTERNAL_MEDIA.equals(tag)) {
+                    File[] externalMediaDirs = context.getExternalMediaDirs();
+                    if (externalMediaDirs.length > 0) {
+                        target = externalMediaDirs[0];
+                    }
+                }
+
+                if (target != null) {
+                    strat.addRoot(name, buildPath(target, path));
+                }
+            }
+        }
+
+        return strat;
+    }
+
+    /**
+     * Strategy for mapping between {@link File} and {@link Uri}.
+     * <p>
+     * Strategies must be symmetric so that mapping a {@link File} to a
+     * {@link Uri} and then back to a {@link File} points at the original
+     * target.
+     * <p>
+     * Strategies must remain consistent across app launches, and not rely on
+     * dynamic state. This ensures that any generated {@link Uri} can still be
+     * resolved if your process is killed and later restarted.
+     *
+     * @see SimplePathStrategy
+     */
+    interface PathStrategy {
+        /**
+         * Return a {@link Uri} that represents the given {@link File}.
+         */
+        Uri getUriForFile(File file);
+
+        /**
+         * Return a {@link File} that represents the given {@link Uri}.
+         */
+        File getFileForUri(Uri uri);
+    }
+
+    /**
+     * Strategy that provides access to files living under a narrow whitelist of
+     * filesystem roots. It will throw {@link SecurityException} if callers try
+     * accessing files outside the configured roots.
+     * <p>
+     * For example, if configured with
+     * {@code addRoot("myfiles", context.getFilesDir())}, then
+     * {@code context.getFileStreamPath("foo.txt")} would map to
+     * {@code content://myauthority/myfiles/foo.txt}.
+     */
+    static class SimplePathStrategy implements PathStrategy {
+        private final String mAuthority;
+        private final HashMap<String, File> mRoots = new HashMap<String, File>();
+
+        SimplePathStrategy(String authority) {
+            mAuthority = authority;
+        }
+
+        /**
+         * Add a mapping from a name to a filesystem root. The provider only offers
+         * access to files that live under configured roots.
+         */
+        void addRoot(String name, File root) {
+            if (TextUtils.isEmpty(name)) {
+                throw new IllegalArgumentException("Name must not be empty");
+            }
+
+            try {
+                // Resolve to canonical path to keep path checking fast
+                root = root.getCanonicalFile();
+            } catch (IOException e) {
+                throw new IllegalArgumentException(
+                        "Failed to resolve canonical path for " + root, e);
+            }
+
+            mRoots.put(name, root);
+        }
+
+        @Override
+        public Uri getUriForFile(File file) {
+            String path;
+            try {
+                path = file.getCanonicalPath();
+            } catch (IOException e) {
+                throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
+            }
+
+            // Find the most-specific root path
+            Map.Entry<String, File> mostSpecific = null;
+            for (Map.Entry<String, File> root : mRoots.entrySet()) {
+                final String rootPath = root.getValue().getPath();
+                if (path.startsWith(rootPath) && (mostSpecific == null
+                        || rootPath.length() > mostSpecific.getValue().getPath().length())) {
+                    mostSpecific = root;
+                }
+            }
+
+            if (mostSpecific == null) {
+                throw new IllegalArgumentException(
+                        "Failed to find configured root that contains " + path);
+            }
+
+            // Start at first char of path under root
+            final String rootPath = mostSpecific.getValue().getPath();
+            if (rootPath.endsWith("/")) {
+                path = path.substring(rootPath.length());
+            } else {
+                path = path.substring(rootPath.length() + 1);
+            }
+
+            // Encode the tag and path separately
+            path = Uri.encode(mostSpecific.getKey()) + '/' + Uri.encode(path, "/");
+            return new Uri.Builder().scheme("content")
+                    .authority(mAuthority).encodedPath(path).build();
+        }
+
+        @Override
+        public File getFileForUri(Uri uri) {
+            String path = uri.getEncodedPath();
+
+            final int splitIndex = path.indexOf('/', 1);
+            final String tag = Uri.decode(path.substring(1, splitIndex));
+            path = Uri.decode(path.substring(splitIndex + 1));
+
+            final File root = mRoots.get(tag);
+            if (root == null) {
+                throw new IllegalArgumentException("Unable to find configured root for " + uri);
+            }
+
+            File file = new File(root, path);
+            try {
+                file = file.getCanonicalFile();
+            } catch (IOException e) {
+                throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
+            }
+
+            if (!file.getPath().startsWith(root.getPath())) {
+                throw new SecurityException("Resolved path jumped beyond configured root");
+            }
+
+            return file;
+        }
+    }
+
+    /**
+     * Copied from ContentResolver.java
+     */
+    private static int modeToMode(String mode) {
+        int modeBits;
+        if ("r".equals(mode)) {
+            modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
+        } else if ("w".equals(mode) || "wt".equals(mode)) {
+            modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
+                    | ParcelFileDescriptor.MODE_CREATE
+                    | ParcelFileDescriptor.MODE_TRUNCATE;
+        } else if ("wa".equals(mode)) {
+            modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
+                    | ParcelFileDescriptor.MODE_CREATE
+                    | ParcelFileDescriptor.MODE_APPEND;
+        } else if ("rw".equals(mode)) {
+            modeBits = ParcelFileDescriptor.MODE_READ_WRITE
+                    | ParcelFileDescriptor.MODE_CREATE;
+        } else if ("rwt".equals(mode)) {
+            modeBits = ParcelFileDescriptor.MODE_READ_WRITE
+                    | ParcelFileDescriptor.MODE_CREATE
+                    | ParcelFileDescriptor.MODE_TRUNCATE;
+        } else {
+            throw new IllegalArgumentException("Invalid mode: " + mode);
+        }
+        return modeBits;
+    }
+
+    private static File buildPath(File base, String... segments) {
+        File cur = base;
+        for (String segment : segments) {
+            if (segment != null) {
+                cur = new File(cur, segment);
+            }
+        }
+        return cur;
+    }
+
+    private static String[] copyOf(String[] original, int newLength) {
+        final String[] result = new String[newLength];
+        System.arraycopy(original, 0, result, 0, newLength);
+        return result;
+    }
+
+    private static Object[] copyOf(Object[] original, int newLength) {
+        final Object[] result = new Object[newLength];
+        System.arraycopy(original, 0, result, 0, newLength);
+        return result;
+    }
+}

+ 318 - 0
fq_channel_ysdk/src/main/java/androidx/localbroadcastmanager/content/LocalBroadcastManager.java

@@ -0,0 +1,318 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.localbroadcastmanager.content;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.Message;
+import android.support.annotation.NonNull;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * Helper to register for and send broadcasts of Intents to local objects
+ * within your process.  This has a number of advantages over sending
+ * global broadcasts with {@link Context#sendBroadcast}:
+ * <ul>
+ * <li> You know that the data you are broadcasting won't leave your app, so
+ * don't need to worry about leaking private data.
+ * <li> It is not possible for other applications to send these broadcasts to
+ * your app, so you don't need to worry about having security holes they can
+ * exploit.
+ * <li> It is more efficient than sending a global broadcast through the
+ * system.
+ * </ul>
+ */
+public final class LocalBroadcastManager {
+    private static final class ReceiverRecord {
+        final IntentFilter filter;
+        final BroadcastReceiver receiver;
+        boolean broadcasting;
+        boolean dead;
+
+        ReceiverRecord(IntentFilter _filter, BroadcastReceiver _receiver) {
+            filter = _filter;
+            receiver = _receiver;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder(128);
+            builder.append("Receiver{");
+            builder.append(receiver);
+            builder.append(" filter=");
+            builder.append(filter);
+            if (dead) {
+                builder.append(" DEAD");
+            }
+            builder.append("}");
+            return builder.toString();
+        }
+    }
+
+    private static final class BroadcastRecord {
+        final Intent intent;
+        final ArrayList<ReceiverRecord> receivers;
+
+        BroadcastRecord(Intent _intent, ArrayList<ReceiverRecord> _receivers) {
+            intent = _intent;
+            receivers = _receivers;
+        }
+    }
+
+    private static final String TAG = "LocalBroadcastManager";
+    private static final boolean DEBUG = false;
+
+    private final Context mAppContext;
+
+    private final HashMap<BroadcastReceiver, ArrayList<ReceiverRecord>> mReceivers
+            = new HashMap<>();
+    private final HashMap<String, ArrayList<ReceiverRecord>> mActions = new HashMap<>();
+
+    private final ArrayList<BroadcastRecord> mPendingBroadcasts = new ArrayList<>();
+
+    static final int MSG_EXEC_PENDING_BROADCASTS = 1;
+
+    private final Handler mHandler;
+
+    private static final Object mLock = new Object();
+    private static LocalBroadcastManager mInstance;
+
+    @NonNull
+    public static LocalBroadcastManager getInstance(@NonNull Context context) {
+        synchronized (mLock) {
+            if (mInstance == null) {
+                mInstance = new LocalBroadcastManager(context.getApplicationContext());
+            }
+            return mInstance;
+        }
+    }
+
+    private LocalBroadcastManager(Context context) {
+        mAppContext = context;
+        mHandler = new Handler(context.getMainLooper()) {
+
+            @Override
+            public void handleMessage(Message msg) {
+                switch (msg.what) {
+                    case MSG_EXEC_PENDING_BROADCASTS:
+                        executePendingBroadcasts();
+                        break;
+                    default:
+                        super.handleMessage(msg);
+                }
+            }
+        };
+    }
+
+    /**
+     * Register a receive for any local broadcasts that match the given IntentFilter.
+     *
+     * @param receiver The BroadcastReceiver to handle the broadcast.
+     * @param filter Selects the Intent broadcasts to be received.
+     *
+     * @see #unregisterReceiver
+     */
+    public void registerReceiver(@NonNull BroadcastReceiver receiver,
+                                 @NonNull IntentFilter filter) {
+        synchronized (mReceivers) {
+            ReceiverRecord entry = new ReceiverRecord(filter, receiver);
+            ArrayList<ReceiverRecord> filters = mReceivers.get(receiver);
+            if (filters == null) {
+                filters = new ArrayList<>(1);
+                mReceivers.put(receiver, filters);
+            }
+            filters.add(entry);
+            for (int i=0; i<filter.countActions(); i++) {
+                String action = filter.getAction(i);
+                ArrayList<ReceiverRecord> entries = mActions.get(action);
+                if (entries == null) {
+                    entries = new ArrayList<ReceiverRecord>(1);
+                    mActions.put(action, entries);
+                }
+                entries.add(entry);
+            }
+        }
+    }
+
+    /**
+     * Unregister a previously registered BroadcastReceiver.  <em>All</em>
+     * filters that have been registered for this BroadcastReceiver will be
+     * removed.
+     *
+     * @param receiver The BroadcastReceiver to unregister.
+     *
+     * @see #registerReceiver
+     */
+    public void unregisterReceiver(@NonNull BroadcastReceiver receiver) {
+        synchronized (mReceivers) {
+            final ArrayList<ReceiverRecord> filters = mReceivers.remove(receiver);
+            if (filters == null) {
+                return;
+            }
+            for (int i=filters.size()-1; i>=0; i--) {
+                final ReceiverRecord filter = filters.get(i);
+                filter.dead = true;
+                for (int j=0; j<filter.filter.countActions(); j++) {
+                    final String action = filter.filter.getAction(j);
+                    final ArrayList<ReceiverRecord> receivers = mActions.get(action);
+                    if (receivers != null) {
+                        for (int k=receivers.size()-1; k>=0; k--) {
+                            final ReceiverRecord rec = receivers.get(k);
+                            if (rec.receiver == receiver) {
+                                rec.dead = true;
+                                receivers.remove(k);
+                            }
+                        }
+                        if (receivers.size() <= 0) {
+                            mActions.remove(action);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Broadcast the given intent to all interested BroadcastReceivers.  This
+     * call is asynchronous; it returns immediately, and you will continue
+     * executing while the receivers are run.
+     *
+     * @param intent The Intent to broadcast; all receivers matching this
+     *     Intent will receive the broadcast.
+     *
+     * @see #registerReceiver
+     *
+     * @return Returns true if the intent has been scheduled for delivery to one or more
+     * broadcast receivers.  (Note tha delivery may not ultimately take place if one of those
+     * receivers is unregistered before it is dispatched.)
+     */
+    public boolean sendBroadcast(@NonNull Intent intent) {
+        synchronized (mReceivers) {
+            final String action = intent.getAction();
+            final String type = intent.resolveTypeIfNeeded(
+                    mAppContext.getContentResolver());
+            final Uri data = intent.getData();
+            final String scheme = intent.getScheme();
+            final Set<String> categories = intent.getCategories();
+
+            final boolean debug = DEBUG ||
+                    ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
+            if (debug) Log.v(
+                    TAG, "Resolving type " + type + " scheme " + scheme
+                            + " of intent " + intent);
+
+            ArrayList<ReceiverRecord> entries = mActions.get(intent.getAction());
+            if (entries != null) {
+                if (debug) Log.v(TAG, "Action list: " + entries);
+
+                ArrayList<ReceiverRecord> receivers = null;
+                for (int i=0; i<entries.size(); i++) {
+                    ReceiverRecord receiver = entries.get(i);
+                    if (debug) Log.v(TAG, "Matching against filter " + receiver.filter);
+
+                    if (receiver.broadcasting) {
+                        if (debug) {
+                            Log.v(TAG, "  Filter's target already added");
+                        }
+                        continue;
+                    }
+
+                    int match = receiver.filter.match(action, type, scheme, data,
+                            categories, "LocalBroadcastManager");
+                    if (match >= 0) {
+                        if (debug) Log.v(TAG, "  Filter matched!  match=0x" +
+                                Integer.toHexString(match));
+                        if (receivers == null) {
+                            receivers = new ArrayList<ReceiverRecord>();
+                        }
+                        receivers.add(receiver);
+                        receiver.broadcasting = true;
+                    } else {
+                        if (debug) {
+                            String reason;
+                            switch (match) {
+                                case IntentFilter.NO_MATCH_ACTION: reason = "action"; break;
+                                case IntentFilter.NO_MATCH_CATEGORY: reason = "category"; break;
+                                case IntentFilter.NO_MATCH_DATA: reason = "data"; break;
+                                case IntentFilter.NO_MATCH_TYPE: reason = "type"; break;
+                                default: reason = "unknown reason"; break;
+                            }
+                            Log.v(TAG, "  Filter did not match: " + reason);
+                        }
+                    }
+                }
+
+                if (receivers != null) {
+                    for (int i=0; i<receivers.size(); i++) {
+                        receivers.get(i).broadcasting = false;
+                    }
+                    mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));
+                    if (!mHandler.hasMessages(MSG_EXEC_PENDING_BROADCASTS)) {
+                        mHandler.sendEmptyMessage(MSG_EXEC_PENDING_BROADCASTS);
+                    }
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Like {@link #sendBroadcast(Intent)}, but if there are any receivers for
+     * the Intent this function will block and immediately dispatch them before
+     * returning.
+     */
+    public void sendBroadcastSync(@NonNull Intent intent) {
+        if (sendBroadcast(intent)) {
+            executePendingBroadcasts();
+        }
+    }
+
+    @SuppressWarnings("WeakerAccess") /* synthetic access */
+    void executePendingBroadcasts() {
+        while (true) {
+            final BroadcastRecord[] brs;
+            synchronized (mReceivers) {
+                final int N = mPendingBroadcasts.size();
+                if (N <= 0) {
+                    return;
+                }
+                brs = new BroadcastRecord[N];
+                mPendingBroadcasts.toArray(brs);
+                mPendingBroadcasts.clear();
+            }
+            for (int i=0; i<brs.length; i++) {
+                final BroadcastRecord br = brs[i];
+                final int nbr = br.receivers.size();
+                for (int j=0; j<nbr; j++) {
+                    final ReceiverRecord rec = br.receivers.get(j);
+                    if (!rec.dead) {
+                        rec.receiver.onReceive(mAppContext, br.intent);
+                    }
+                }
+            }
+        }
+    }
+}

+ 7 - 8
fq_plugin_api/src/main/java/com/fq/channel/sdk/api/FqGame.java

@@ -5,8 +5,6 @@ import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 
-import androidx.annotation.NonNull;
-
 import com.fq.channel.sdk.base.bean.LoginInfo;
 import com.fq.channel.sdk.base.bean.PaymentInfo;
 import com.fq.channel.sdk.base.utils.FqLog;
@@ -28,7 +26,7 @@ public class FqGame {
      * @param activity
      * @param resultInit
      */
-    public static void init(@NonNull Activity activity, final IResult<String> resultInit) {
+    public static void init(Activity activity, final IResult<String> resultInit) {
         FqLog.i(TAG, "init");
         FqGameHander.init(activity, resultInit);
     }
@@ -38,7 +36,7 @@ public class FqGame {
      *
      * @param activity
      */
-    public static void login(@NonNull Activity activity, final IResult<LoginInfo> resultLoginInfo) {
+    public static void login(Activity activity, final IResult<LoginInfo> resultLoginInfo) {
         FqLog.i(TAG, "login");
         FqGameHander.login(activity, resultLoginInfo);
     }
@@ -50,7 +48,7 @@ public class FqGame {
      * @param paymentInfo CP传入的订单信息
      * @param resultPay
      */
-    public static void pay(@NonNull Activity activity, @NonNull final PaymentInfo paymentInfo, final IResult<String> resultPay) {
+    public static void pay(Activity activity, final PaymentInfo paymentInfo, final IResult<String> resultPay) {
         FqLog.i(TAG, "pay");
         FqGameHander.pay(activity, paymentInfo, resultPay);
     }
@@ -70,15 +68,16 @@ public class FqGame {
      *
      * @param activity
      */
-    public static void changeAccount(@NonNull Context activity){
+    public static void changeAccount(Context activity) {
         FqGameHander.changeAccount((Activity) activity);
     }
+
     /**
      * 提供给CP调用的登出接口
      *
      * @param activity
      */
-    public static void logout(@NonNull Activity activity,ILogout logout){
+    public static void logout(Activity activity, ILogout logout) {
         FqGameHander.logout(activity, logout);
     }
 
@@ -102,7 +101,7 @@ public class FqGame {
 
     public static void onCreate(Activity activity, Bundle savedInstanceState) {
         FqLog.i(TAG, "onCreate: ");
-        ApiPlugin.getInstace().onCreate(activity,savedInstanceState);
+        ApiPlugin.getInstace().onCreate(activity, savedInstanceState);
     }
 
     public static void onRestart(Activity activity) {

+ 2 - 5
fq_plugin_api/src/main/java/com/fq/channel/sdk/api/FqGameHander.java

@@ -1,9 +1,6 @@
 package com.fq.channel.sdk.api;
 
 import android.app.Activity;
-import android.content.Context;
-
-import androidx.annotation.NonNull;
 
 import com.fq.channel.sdk.base.bean.LoginInfo;
 import com.fq.channel.sdk.base.bean.PaymentInfo;
@@ -98,7 +95,7 @@ public class FqGameHander {
         });
     }
 
-    public static void login(@NonNull Activity activity, final IResult<LoginInfo> iResult) {
+    public static void login(Activity activity, final IResult<LoginInfo> iResult) {
         JointManager.getInstance().login(activity, new PluginResultHandler() {
             @Override
             public void onHandlePluginResult(PluginResult result) {
@@ -123,7 +120,7 @@ public class FqGameHander {
         });
     }
 
-    public static void pay(@NonNull Activity activity, @NonNull final PaymentInfo paymentInfo, final IResult<String> resultPay) {
+    public static void pay(Activity activity, final PaymentInfo paymentInfo, final IResult<String> resultPay) {
         try {
             Map map = Utils.getObjectToMap(paymentInfo);
             if (map == null) {

+ 1 - 2
fq_plugin_base/build.gradle

@@ -25,6 +25,5 @@ android {
 
 dependencies {
     api fileTree(dir: 'libs', include: ['*.jar'])
-    api 'androidx.legacy:legacy-support-v4:1.0.0'
-    api 'androidx.appcompat:appcompat:1.0.2'
+
 }

BIN
fq_plugin_base/libs/android-support-v4.jar


+ 2 - 3
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/permission/PermissionManager.java

@@ -5,9 +5,8 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.Build;
-
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.ContextCompat;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
 
 import com.fq.channel.sdk.base.interfaces.IPermissionRequestCallback;
 

+ 6 - 7
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/utils/Utils.java

@@ -10,15 +10,14 @@ import android.content.pm.PackageManager;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.net.Uri;
+import android.support.annotation.ColorRes;
+import android.support.annotation.DimenRes;
+import android.support.annotation.IntegerRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.StringRes;
+import android.support.v4.content.ContextCompat;
 import android.text.TextUtils;
 
-import androidx.annotation.ColorRes;
-import androidx.annotation.DimenRes;
-import androidx.annotation.IntegerRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.StringRes;
-import androidx.core.content.ContextCompat;
-
 import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;

+ 0 - 2
gradle.properties

@@ -20,7 +20,5 @@ org.gradle.jvmargs=-Xmx1536m
 ## Kotlin code style for this project: "official" or "obsolete":
 #kotlin.code.style=official
 #android.injected.testOnly=false
-android.useAndroidX=true
-android.enableJetifier=true
 
 

+ 1 - 0
settings.gradle

@@ -1,3 +1,4 @@
 include ':app', ':fq_plugin_api', ':fq_plugin_core', ':fq_plugin_base', ':fq_channel_mubao', ':fq_channel_oppo', ':fq_channel_ysdk'
 //include ':fq_channel_huawei'
+//include ':app_dev',':app_dev_lib'
 rootProject.name='FQChannelSDK'