├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ghost
│ │ └── thunder
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── ghost
│ │ │ └── thunder
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── ghost
│ └── thunder
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── thunder
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── ghost
│ └── thunder
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── xunlei
│ │ └── downloadlib
│ │ ├── BlockingItem.java
│ │ ├── Daemon.java
│ │ ├── LinuxFileCommand.java
│ │ ├── XLAppKeyChecker.java
│ │ ├── XLDownloadManager.java
│ │ ├── XLLoader.java
│ │ ├── XLTaskHelper.java
│ │ ├── android
│ │ ├── LogConfig.java
│ │ ├── LogLevel.java
│ │ ├── XLLog.java
│ │ ├── XLLogInternal.java
│ │ └── XLUtil.java
│ │ └── parameter
│ │ ├── BtIndexSet.java
│ │ ├── BtSubTaskDetail.java
│ │ ├── BtTaskParam.java
│ │ ├── BtTaskStatus.java
│ │ ├── CIDTaskParam.java
│ │ ├── EmuleTaskParam.java
│ │ ├── ErrorCodeToMsg.java
│ │ ├── GetDownloadHead.java
│ │ ├── GetDownloadLibVersion.java
│ │ ├── GetFileName.java
│ │ ├── GetTaskId.java
│ │ ├── InitParam.java
│ │ ├── MagnetTaskParam.java
│ │ ├── MaxDownloadSpeedParam.java
│ │ ├── P2spTaskParam.java
│ │ ├── PeerResourceParam.java
│ │ ├── ServerResourceParam.java
│ │ ├── ThunderUrlInfo.java
│ │ ├── TorrentFileInfo.java
│ │ ├── TorrentInfo.java
│ │ ├── UrlQuickInfo.java
│ │ ├── XLConstant.java
│ │ ├── XLProductInfo.java
│ │ ├── XLSessionInfo.java
│ │ ├── XLTaskInfo.java
│ │ ├── XLTaskInfoEx.java
│ │ └── XLTaskLocalUrl.java
├── jniLibs
│ └── armeabi
│ │ ├── libxl_stat.so
│ │ ├── libxl_thunder_iface.so
│ │ ├── libxl_thunder_sdk.so
│ │ └── libxluagc.so
└── res
│ └── values
│ └── strings.xml
└── test
└── java
└── com
└── ghost
└── thunder
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | *.jks
45 |
46 | # External native build folder generated in Android Studio 2.2 and later
47 | .externalNativeBuild
48 |
49 | # Google Services (e.g. APIs or Firebase)
50 | google-services.json
51 |
52 | # Freeline
53 | freeline.py
54 | freeline/
55 | freeline_project_description.json
56 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
19 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MiniThunder
2 | android迷你版迅雷,支持thunder:// ftp:// http:// ed2k:// 磁力链 种子文件的下载
3 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.ghost.thunder.demo"
8 | minSdkVersion 15
9 | targetSdkVersion 21
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.3.1'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | compile project(':thunder')
31 | }
32 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Applications/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ghost/thunder/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.ghost.thunder;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.ghost.thunder", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ghost/thunder/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.ghost.thunder;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 | import android.os.Message;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.text.TextUtils;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.TextView;
13 | import com.ghost.thunder.demo.R;
14 |
15 | import com.xunlei.downloadlib.XLTaskHelper;
16 | import com.xunlei.downloadlib.parameter.XLTaskInfo;
17 |
18 | public class MainActivity extends AppCompatActivity {
19 | EditText inputUrl;
20 | Button btnDownload;
21 | TextView tvStatus;
22 | Handler handler = new Handler(Looper.getMainLooper()){
23 | @Override
24 | public void handleMessage(Message msg) {
25 | super.handleMessage(msg);
26 | if(msg.what == 0) {
27 | long taskId = (long) msg.obj;
28 | XLTaskInfo taskInfo = XLTaskHelper.instance().getTaskInfo(taskId);
29 | tvStatus.setText(
30 | "fileSize:" + taskInfo.mFileSize
31 | + " downSize:" + taskInfo.mDownloadSize
32 | + " speed:" + convertFileSize(taskInfo.mDownloadSpeed)
33 | + "/s dcdnSoeed:" + convertFileSize(taskInfo.mAdditionalResDCDNSpeed)
34 | + "/s filePath:" + "/sdcard/" + XLTaskHelper.instance().getFileName(inputUrl.getText().toString())
35 | );
36 | handler.sendMessageDelayed(handler.obtainMessage(0,taskId),1000);
37 | }
38 | }
39 | };
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_main);
44 | XLTaskHelper.init(getApplicationContext());
45 | inputUrl = (EditText) findViewById(R.id.input_url);
46 | btnDownload = (Button) findViewById(R.id.btn_down);
47 | tvStatus = (TextView) findViewById(R.id.tv_status);
48 | btnDownload.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View v) {
51 | if(!TextUtils.isEmpty(inputUrl.getText())) {
52 | long taskId = XLTaskHelper.instance().addThunderTask(inputUrl.getText().toString(),"/sdcard/",null);
53 | handler.sendMessage(handler.obtainMessage(0,taskId));
54 | }
55 | }
56 | });
57 | }
58 | public static String convertFileSize(long size) {
59 | long kb = 1024;
60 | long mb = kb * 1024;
61 | long gb = mb * 1024;
62 |
63 | if (size >= gb) {
64 | return String.format("%.1f GB", (float) size / gb);
65 | } else if (size >= mb) {
66 | float f = (float) size / mb;
67 | return String.format(f > 100 ? "%.0f M" : "%.1f M", f);
68 | } else if (size >= kb) {
69 | float f = (float) size / kb;
70 | return String.format(f > 100 ? "%.0f K" : "%.1f K", f);
71 | } else
72 | return String.format("%d B", size);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
22 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MiniThunder
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/ghost/thunder/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.ghost.thunder;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Aug 10 11:23:14 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':thunder'
2 |
--------------------------------------------------------------------------------
/thunder/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/thunder/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
26 | exclude group: 'com.android.support', module: 'support-annotations'
27 | })
28 | compile 'com.android.support:appcompat-v7:25.3.1'
29 | compile 'io.reactivex:rxandroid:1.1.0'
30 | compile 'io.reactivex:rxjava:1.1.0'
31 | testCompile 'junit:junit:4.12'
32 | }
33 |
--------------------------------------------------------------------------------
/thunder/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Applications/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/thunder/src/androidTest/java/com/ghost/thunder/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.ghost.thunder;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.ghost.thunder.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/thunder/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/BlockingItem.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib;
2 |
3 | import java.util.concurrent.TimeUnit;
4 | import java.util.concurrent.locks.Condition;
5 | import java.util.concurrent.locks.Lock;
6 | import java.util.concurrent.locks.ReentrantLock;
7 |
8 | public class BlockingItem {
9 | final Lock lock = new ReentrantLock();
10 | final Condition notEmpty = lock.newCondition();
11 |
12 | private volatile T item;
13 |
14 | public void put(T x) {
15 | lock.lock();
16 | try {
17 | item = x;
18 | if (x != null)
19 | notEmpty.signal();
20 | } finally {
21 | lock.unlock();
22 | }
23 | }
24 |
25 | public T take() throws InterruptedException {
26 | lock.lock();
27 | try {
28 | while (item == null)
29 | notEmpty.await();
30 | T t = item;
31 | item = null;
32 | return t;
33 | } finally {
34 | lock.unlock();
35 | }
36 | }
37 |
38 | public T tryTake(long waitMs) throws InterruptedException {
39 | lock.lock();
40 | try {
41 | while (item == null)
42 | if (!notEmpty.await(waitMs, TimeUnit.MILLISECONDS))
43 | return null;
44 | T t = item;
45 | item = null;
46 | return t;
47 | } finally {
48 | lock.unlock();
49 | }
50 | }
51 |
52 | public T peek() {
53 | return item;
54 | }
55 | }
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/Daemon.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib;
2 |
3 | import android.os.Looper;
4 |
5 | /**
6 | * 常驻的后台线程,用于处理一个消息循环
7 | *
8 | * 一般用于处理运算密集型任务、磁盘IO任务等执行时间小于1秒的任务
9 | *
10 | */
11 | public class Daemon {
12 | private static volatile boolean shouldStop;
13 | private static Thread thread = null;
14 | private static Looper looper = null;
15 |
16 | public static synchronized void start() {
17 | if (thread == null) {
18 | final BlockingItem bl = new BlockingItem();
19 | thread = new Thread(new Runnable() {
20 | @Override
21 | public void run() {
22 | Looper.prepare();
23 | Looper l = Looper.myLooper();
24 | bl.put(l);
25 |
26 | while (!shouldStop) {
27 | try {
28 | Looper.loop();
29 | } catch (Exception e) {
30 | }
31 | }
32 | }
33 | }, "daemon");
34 |
35 | shouldStop = false;
36 | thread.start();
37 | try {
38 | looper = bl.take();
39 | } catch (InterruptedException e) {
40 | }
41 | }
42 | }
43 |
44 | public static synchronized void stop() {
45 | shouldStop = true;
46 |
47 | if (thread != null && looper != null) {
48 | looper.quit();
49 | try {
50 | thread.join();
51 | } catch (Exception e) {
52 | }
53 | thread = null;
54 | looper = null;
55 | }
56 | }
57 |
58 | public static Looper looper() {
59 | if (looper == null) {
60 | start();
61 | }
62 | return looper == null ? Looper.getMainLooper() : looper;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/LinuxFileCommand.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * File operators. Like: delete, create, move...
7 | * Use linux shell to implement these operators.
8 | * So, only for linux like operator system.
9 | * All return the execute process, and if the requested program can not be executed,
10 | * may throws IOException.
11 | * And all files or diretorys String parameters are absolute path.
12 | * The return new {@code Process} object that represents the native process.
13 | * */
14 | public class LinuxFileCommand {
15 | public final Runtime shell;
16 | //private static final int c = 0;
17 | /**
18 | * Constructor. /data/busybox/
19 | * @param
20 | * */
21 | public LinuxFileCommand(Runtime runtime) {
22 | // TODO Auto-generated constructor stub
23 | shell = runtime;
24 | }
25 |
26 | /** Delete {@code file} file, nerver prompt*/
27 | public final Process deleteFile(String file) throws IOException{
28 | String[] cmds = {"rm", file};
29 | return shell.exec(cmds);
30 | }
31 |
32 | public final Process delete(String file) throws IOException {
33 | String[] cmds = {"rm", "-r", file};
34 | return shell.exec(cmds);
35 | }
36 |
37 | public final Process deleteMult(String[] cmds) throws IOException{
38 | return shell.exec(cmds);
39 | }
40 |
41 | /** Delete {@code dire} directory, nerver prompt*/
42 | public final Process deleteDirectory(String dire) throws IOException{
43 | String[] cmds = {"rm", "-r", dire};
44 | return shell.exec(cmds);
45 | }
46 |
47 | /** Create {@code file} file, if file has already exist, update the
48 | * file access and modification time to current time.
49 | * @throws IOException
50 | * */
51 | public final Process createFile(String file) throws IOException {
52 | String[] cmds = {"touch", file};
53 | return shell.exec(cmds);
54 | }
55 |
56 | /** Create directory. If parent path is not existed, also create parent directory
57 | * @throws IOException */
58 | public final Process createDirectory(String dire) throws IOException{
59 | String[] cmds = {"mkdir", dire};
60 | return shell.exec(cmds);
61 | }
62 |
63 | /** Move or rename(if they in the same directory) file or directory
64 | * @throws IOException */
65 | public final Process moveFile(String src, String dir) throws IOException{
66 | String[] cmds = {"mv", src, dir};
67 | return shell.exec(cmds);
68 | }
69 |
70 | /** Copy file
71 | * @throws IOException */
72 | public final Process copyFile(String src, String dir) throws IOException{
73 | String[] cmds = {"cp", "-r", src, dir};
74 | return shell.exec(cmds);
75 | }
76 |
77 | /**`
78 | * File soft Link
79 | * @throws IOException
80 | * */
81 | public final Process linkFile(String src, String dir) throws IOException{
82 | String[] cmds = {"ln", "-l", src, dir};
83 | return shell.exec(cmds);
84 | }
85 |
86 |
87 | public final Process du_s(String file) throws IOException{
88 | String[] cmds = {"du", "-s", file};
89 | return shell.exec(cmds);
90 | }
91 |
92 | public final Process ls_lhd(String file) throws IOException{
93 | String[] cmds = {"ls", "-l", file};
94 | return shell.exec(cmds);
95 | }
96 |
97 | public final Process ls_Directory(String directory) throws IOException{
98 | if (directory.equals("/"))
99 | directory = "";
100 | String[] cmds = {"ls", "-a", directory};
101 | return shell.exec(cmds);
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/XLAppKeyChecker.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib;
2 |
3 | import android.content.Context;
4 | import android.util.Base64;
5 | import com.xunlei.downloadlib.android.XLLog;
6 | import com.xunlei.downloadlib.android.XLUtil;
7 | import java.io.UnsupportedEncodingException;
8 | import java.text.ParseException;
9 | import java.text.SimpleDateFormat;
10 | import java.util.Calendar;
11 | import java.util.Date;
12 | import java.util.Locale;
13 |
14 | public class XLAppKeyChecker {
15 | private static final byte APPTYPE_PRODUCT = (byte) 1;
16 | private static final String TAG = "XLAppKeyChecker";
17 | private short mAppId = (short) 0;
18 | private String mAppKey = "";
19 | private Context mContext = null;
20 | private String mPackageName = "";
21 |
22 | private class AppKeyEntity {
23 | private String MD5;
24 | private RawItemsEntity mItemsEntity;
25 | private String mRawItems;
26 |
27 | private AppKeyEntity() {
28 | this.mRawItems = "";
29 | this.MD5 = "";
30 | this.mItemsEntity = null;
31 | }
32 |
33 | public RawItemsEntity getmItemsEntity() {
34 | return this.mItemsEntity;
35 | }
36 |
37 | public void setmItemsEntity(RawItemsEntity rawItemsEntity) {
38 | this.mItemsEntity = rawItemsEntity;
39 | }
40 |
41 | public String getMD5() {
42 | return this.MD5;
43 | }
44 |
45 | public void setMD5(String str) {
46 | this.MD5 = str;
47 | }
48 |
49 | public String getmRawItems() {
50 | return this.mRawItems;
51 | }
52 |
53 | public void setmRawItems(String str) {
54 | this.mRawItems = str;
55 | }
56 | }
57 |
58 | public class KeyFormateException extends Exception {
59 | private static final long serialVersionUID = 13923744320L;
60 |
61 | public KeyFormateException(String str) {
62 | super(str);
63 | }
64 | }
65 |
66 | private class RawItemsEntity {
67 | private short mAppId;
68 | private Date mExpired;
69 |
70 | private RawItemsEntity() {
71 | this.mAppId = (short) 0;
72 | this.mExpired = null;
73 | }
74 |
75 | public short getAppId() {
76 | return this.mAppId;
77 | }
78 |
79 | public void setAppId(short s) {
80 | this.mAppId = s;
81 | }
82 |
83 | public Date getExpired() {
84 | return this.mExpired;
85 | }
86 |
87 | public void setExpired(Date date) {
88 | this.mExpired = date;
89 | }
90 | }
91 |
92 | public XLAppKeyChecker(Context context, String str) {
93 | this.mContext = context;
94 | this.mAppKey = str;
95 | }
96 |
97 | public boolean verify() {
98 | try {
99 | AppKeyEntity keyEntity = getKeyEntity();
100 | this.mPackageName = "com.xunlei.downloadprovider";
101 | if (!verifyAppKeyMD5(keyEntity, this.mPackageName)) {
102 | XLLog.i(TAG, "appkey MD5 invalid.");
103 | return false;
104 | } else if (!verifyAppKeyExpired(keyEntity)) {
105 | return true;
106 | } else {
107 | XLLog.i(TAG, "appkey expired.");
108 | return false;
109 | }
110 | } catch (KeyFormateException e) {
111 | return false;
112 | }
113 | }
114 |
115 | private boolean verifyAppKeyMD5(AppKeyEntity appKeyEntity, String str) {
116 | String str2 = appKeyEntity.getmRawItems() + ";" + str;
117 | XLLog.i(TAG, "totalContent:" + str2);
118 | str2 = XLUtil.getMd5(str2).toLowerCase().replace('b', '^').replace('9', 'b');
119 | XLLog.i(TAG, "keyEntity getMD5 MD5:" + appKeyEntity.getMD5());
120 | if (str2.compareTo(appKeyEntity.getMD5()) == 0) {
121 | return true;
122 | }
123 | return false;
124 | }
125 |
126 | private boolean verifyAppKeyExpired(AppKeyEntity appKeyEntity) {
127 | Date expired = appKeyEntity.getmItemsEntity().getExpired();
128 | if (expired == null) {
129 | return false;
130 | }
131 | return expired.before(Calendar.getInstance().getTime());
132 | }
133 |
134 | public String getSoAppKey() {
135 | return XLUtil.generateAppKey("com.xunlei.downloadprovider", this.mAppId, (byte) 1);
136 | }
137 |
138 | private AppKeyEntity getKeyEntity() throws KeyFormateException {
139 | String[] split = this.mAppKey.split("==");
140 | if (split.length != 2) {
141 | XLLog.i(TAG, "keyPair length invalid");
142 | throw new KeyFormateException("error");
143 | }
144 | AppKeyEntity appKeyEntity = new AppKeyEntity();
145 | appKeyEntity.setMD5(split[1]);
146 | try {
147 | String replace = split[0].replace('^', '=');
148 | String str = new String(Base64.decode(replace.substring(2, replace.length() - 2), 0), "UTF-8");
149 | appKeyEntity.setmRawItems(str);
150 | XLLog.i(TAG, "items:" + str);
151 | appKeyEntity.setmItemsEntity(getRawItemsEntity(str));
152 | return appKeyEntity;
153 | } catch (UnsupportedEncodingException e) {
154 | throw new KeyFormateException("error");
155 | }
156 | }
157 |
158 | private RawItemsEntity getRawItemsEntity(String str) throws KeyFormateException {
159 | String[] split = str.split(";");
160 | RawItemsEntity rawItemsEntity = new RawItemsEntity();
161 | if (split.length <= 0 || split.length > 2) {
162 | throw new KeyFormateException("raw item length invalid.");
163 | }
164 | try {
165 | this.mAppId = Short.parseShort(split[0]);
166 | rawItemsEntity.setAppId(this.mAppId);
167 | if (split.length == 2) {
168 | try {
169 | rawItemsEntity.setExpired(new SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(split[1]));
170 | } catch (ParseException e) {
171 | throw new KeyFormateException("expired field formate error.");
172 | }
173 | }
174 | return rawItemsEntity;
175 | } catch (NumberFormatException e2) {
176 | XLLog.i(TAG, "appId invalid");
177 | e2.printStackTrace();
178 | throw new KeyFormateException("app id format error.");
179 | }
180 | }
181 | }
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/XLDownloadManager.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 | import android.os.Build;
8 | import android.os.Environment;
9 | import android.text.TextUtils;
10 | import android.util.Base64;
11 | import com.xunlei.downloadlib.android.XLLog;
12 | import com.xunlei.downloadlib.android.XLUtil;
13 | import com.xunlei.downloadlib.android.XLUtil.GUID_TYPE;
14 | import com.xunlei.downloadlib.android.XLUtil.GuidInfo;
15 | import com.xunlei.downloadlib.parameter.BtIndexSet;
16 | import com.xunlei.downloadlib.parameter.BtSubTaskDetail;
17 | import com.xunlei.downloadlib.parameter.BtTaskParam;
18 | import com.xunlei.downloadlib.parameter.BtTaskStatus;
19 | import com.xunlei.downloadlib.parameter.CIDTaskParam;
20 | import com.xunlei.downloadlib.parameter.EmuleTaskParam;
21 | import com.xunlei.downloadlib.parameter.GetDownloadHead;
22 | import com.xunlei.downloadlib.parameter.GetDownloadLibVersion;
23 | import com.xunlei.downloadlib.parameter.GetFileName;
24 | import com.xunlei.downloadlib.parameter.GetTaskId;
25 | import com.xunlei.downloadlib.parameter.InitParam;
26 | import com.xunlei.downloadlib.parameter.MagnetTaskParam;
27 | import com.xunlei.downloadlib.parameter.MaxDownloadSpeedParam;
28 | import com.xunlei.downloadlib.parameter.P2spTaskParam;
29 | import com.xunlei.downloadlib.parameter.PeerResourceParam;
30 | import com.xunlei.downloadlib.parameter.ServerResourceParam;
31 | import com.xunlei.downloadlib.parameter.ThunderUrlInfo;
32 | import com.xunlei.downloadlib.parameter.TorrentInfo;
33 | import com.xunlei.downloadlib.parameter.UrlQuickInfo;
34 | import com.xunlei.downloadlib.parameter.XLConstant.XLManagerStatus;
35 | import com.xunlei.downloadlib.parameter.XLProductInfo;
36 | import com.xunlei.downloadlib.parameter.XLSessionInfo;
37 | import com.xunlei.downloadlib.parameter.XLTaskInfo;
38 | import com.xunlei.downloadlib.parameter.XLTaskInfoEx;
39 | import com.xunlei.downloadlib.parameter.XLTaskLocalUrl;
40 | import java.io.File;
41 | import java.util.Map;
42 | import java.util.Timer;
43 | import java.util.TimerTask;
44 |
45 | public class XLDownloadManager {
46 | private static final int GET_GUID_FIRST_TIME = 5000;
47 | private static final int GET_GUID_INTERVAL_TIME = 60000;
48 | private static final int QUERY_GUID_COUNT = 5;
49 | private static final String TAG = "XLDownloadManager";
50 | private static boolean mAllowExecution = true;
51 | public static XLManagerStatus mDownloadManagerState = XLManagerStatus.MANAGER_UNINIT;
52 | private static Map mErrcodeStringMap = null;
53 | private static XLDownloadManager mInstance = null;
54 | private static boolean mIsLoadErrcodeMsg = false;
55 | private static int mRunningRefCount = 0;
56 | private XLAppKeyChecker mAppkeyChecker;
57 | private Context mContext;
58 | private Timer mGetGuidTimer;
59 | private TimerTask mGetGuidTimerTask;
60 | private XLLoader mLoader;
61 | private int mQueryGuidCount;
62 | private NetworkChangeReceiver mReceiver;
63 |
64 | public static synchronized XLDownloadManager getInstance() {
65 | XLDownloadManager xLDownloadManager;
66 | synchronized (XLDownloadManager.class) {
67 | if (mInstance == null) {
68 | mInstance = new XLDownloadManager();
69 | }
70 | xLDownloadManager = mInstance;
71 | }
72 | return xLDownloadManager;
73 | }
74 |
75 | private XLDownloadManager() {
76 | this.mLoader = null;
77 | this.mContext = null;
78 | this.mReceiver = null;
79 | this.mAppkeyChecker = null;
80 | this.mQueryGuidCount = 0;
81 | this.mLoader = new XLLoader();
82 | XLLog.init(new File(Environment.getExternalStorageDirectory().getPath(), "xunlei_ds_log.ini").getPath());
83 | }
84 |
85 | public XLManagerStatus getManagerStatus() {
86 | return mDownloadManagerState;
87 | }
88 |
89 | private void doMonitorNetworkChange() {
90 | XLLog.i(TAG, "doMonitorNetworkChange()");
91 | if (this.mContext != null && this.mReceiver == null) {
92 | this.mReceiver = new NetworkChangeReceiver(this);
93 | IntentFilter intentFilter = new IntentFilter();
94 | intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
95 | XLLog.i(TAG, "register Receiver");
96 | this.mContext.registerReceiver(this.mReceiver, intentFilter);
97 | }
98 | }
99 |
100 | private void undoMonitorNetworkChange() {
101 | XLLog.i(TAG, "undoMonitorNetworkChange()");
102 | if (this.mContext != null && this.mReceiver != null) {
103 | try {
104 | this.mContext.unregisterReceiver(this.mReceiver);
105 | XLLog.i(TAG, "unregister Receiver");
106 | } catch (IllegalArgumentException e) {
107 | XLLog.e(TAG, "Receiver not registered");
108 | }
109 | this.mReceiver = null;
110 | }
111 | }
112 |
113 | private synchronized void increRefCount() {
114 | mRunningRefCount++;
115 | }
116 |
117 | private synchronized void decreRefCount() {
118 | mRunningRefCount--;
119 | }
120 |
121 | public synchronized int init(Context context, InitParam initParam) {
122 | return init(context, initParam, true);
123 | }
124 |
125 | public synchronized int init(Context context, InitParam initParam, boolean z) {
126 | int i = 9900;
127 | int i2 = 0;
128 | synchronized (this) {
129 | if (!mIsLoadErrcodeMsg) {
130 | loadErrcodeString(context);
131 | mIsLoadErrcodeMsg = true;
132 | }
133 | if (!(context == null || initParam == null || !initParam.checkMemberVar())) {
134 | this.mContext = context;
135 | mAllowExecution = z;
136 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING) {
137 | XLLog.i(TAG, "XLDownloadManager is already init");
138 | } else if (this.mLoader != null) {
139 | this.mAppkeyChecker = new XLAppKeyChecker(context, initParam.mAppKey);
140 | if (this.mAppkeyChecker.verify()) {
141 | XLLog.i(TAG, "appKey check successful");
142 | String soAppKey = this.mAppkeyChecker.getSoAppKey();
143 | String peerid = getPeerid();
144 | String guid = getGuid();
145 | XLLog.i(TAG, "Peerid:" + new String(Base64.encode(peerid.getBytes(), 0)));
146 | XLLog.i(TAG, "Guid:" + new String(Base64.encode(guid.getBytes(), 0)));
147 | if (mAllowExecution) {
148 | i2 = XLUtil.getNetworkTypeComplete(context);
149 | }
150 | i = this.mLoader.init(soAppKey, "com.xunlei.downloadprovider", initParam.mAppVersion, "", peerid, guid, initParam.mStatSavePath, initParam.mStatCfgSavePath, i2, initParam.mPermissionLevel);
151 | if (i != 9000) {
152 | mDownloadManagerState = XLManagerStatus.MANAGER_INIT_FAIL;
153 | } else {
154 | mDownloadManagerState = XLManagerStatus.MANAGER_RUNNING;
155 | doMonitorNetworkChange();
156 | setLocalProperty("PhoneModel", Build.MODEL);
157 | }
158 | } else {
159 | XLLog.i(TAG, "appKey check failed");
160 | i = 9901;
161 | }
162 | }
163 | }
164 | }
165 | return i;
166 | }
167 |
168 | public synchronized int uninit() {
169 | int i = 9900;
170 | synchronized (this) {
171 | if (mRunningRefCount != 0) {
172 | XLLog.i(TAG, "some function of XLDownloadManager is running, uninit failed!");
173 | } else if (!(mDownloadManagerState == XLManagerStatus.MANAGER_UNINIT || this.mLoader == null)) {
174 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING) {
175 | undoMonitorNetworkChange();
176 | }
177 | stopGetGuidTimer();
178 | i = this.mLoader.unInit();
179 | mDownloadManagerState = XLManagerStatus.MANAGER_UNINIT;
180 | this.mContext = null;
181 | }
182 | }
183 | return i;
184 | }
185 |
186 | int notifyNetWorkType(int i, XLLoader xLLoader) {
187 | int i2 = 9900;
188 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && xLLoader != null) {
189 | try {
190 | i2 = xLLoader.notifyNetWorkType(i);
191 | } catch (Error e) {
192 | XLLog.e(TAG, "notifyNetWorkType failed," + e.getMessage());
193 | }
194 | }
195 | return i2;
196 | }
197 |
198 | public int createP2spTask(P2spTaskParam p2spTaskParam, GetTaskId getTaskId) {
199 | int i = 9900;
200 | if (!(p2spTaskParam == null || getTaskId == null || !p2spTaskParam.checkMemberVar())) {
201 | increRefCount();
202 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
203 | i = this.mLoader.createP2spTask(p2spTaskParam.mUrl, p2spTaskParam.mRefUrl, p2spTaskParam.mCookie, p2spTaskParam.mUser, p2spTaskParam.mPass, p2spTaskParam.mFilePath, p2spTaskParam.mFileName, p2spTaskParam.mCreateMode, p2spTaskParam.mSeqId, getTaskId);
204 | }
205 | decreRefCount();
206 | }
207 | return i;
208 | }
209 |
210 | public int releaseTask(long j) {
211 | int i = 9900;
212 | increRefCount();
213 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
214 | i = this.mLoader.releaseTask(j);
215 | }
216 | decreRefCount();
217 | return i;
218 | }
219 |
220 | int setTaskAppInfo(long j, String str, String str2, String str3) {
221 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null || str2 == null || str3 == null) {
222 | return 9900;
223 | }
224 | return this.mLoader.setTaskAppInfo(j, str, str2, str3);
225 | }
226 |
227 | public int setTaskAllowUseResource(long j, int i) {
228 | int i2 = 9900;
229 | increRefCount();
230 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
231 | i2 = this.mLoader.setTaskAllowUseResource(j, i);
232 | }
233 | decreRefCount();
234 | return i2;
235 | }
236 |
237 | public int setTaskUid(long j, int i) {
238 | int i2 = 9900;
239 | increRefCount();
240 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
241 | i2 = this.mLoader.setTaskUid(j, i);
242 | }
243 | decreRefCount();
244 | return i2;
245 | }
246 |
247 | public int startTask(long j, boolean z) {
248 | int i = 9900;
249 | increRefCount();
250 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
251 | i = this.mLoader.startTask(j, z);
252 | }
253 | decreRefCount();
254 | return i;
255 | }
256 |
257 | public int startTask(long j) {
258 | return startTask(j, false);
259 | }
260 |
261 | int switchOriginToAllResDownload(long j) {
262 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null) {
263 | return 9900;
264 | }
265 | return this.mLoader.switchOriginToAllResDownload(j);
266 | }
267 |
268 | public int stopTask(long j) {
269 | int i = 9900;
270 | increRefCount();
271 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
272 | i = this.mLoader.stopTask(j);
273 | }
274 | XLLog.i(TAG, "XLStopTask()----- ret=" + i);
275 | decreRefCount();
276 | return i;
277 | }
278 |
279 | public int stopTaskWithReason(long j, int i) {
280 | int i2 = 9900;
281 | increRefCount();
282 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
283 | i2 = this.mLoader.stopTaskWithReason(j, i);
284 | }
285 | XLLog.i(TAG, "XLStopTask()----- ret=" + i2);
286 | decreRefCount();
287 | return i2;
288 | }
289 |
290 | public int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo) {
291 | int i2 = 9900;
292 | increRefCount();
293 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || xLTaskInfo == null)) {
294 | i2 = this.mLoader.getTaskInfo(j, i, xLTaskInfo);
295 | }
296 | decreRefCount();
297 | return i2;
298 | }
299 |
300 | public int getTaskInfoEx(long j, XLTaskInfoEx xLTaskInfoEx) {
301 | int i = 9900;
302 | increRefCount();
303 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || xLTaskInfoEx == null)) {
304 | i = this.mLoader.getTaskInfoEx(j, xLTaskInfoEx);
305 | }
306 | decreRefCount();
307 | return i;
308 | }
309 |
310 | public int getLocalUrl(String str, XLTaskLocalUrl xLTaskLocalUrl) {
311 | int i = 9900;
312 | increRefCount();
313 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || xLTaskLocalUrl == null)) {
314 | i = this.mLoader.getLocalUrl(str, xLTaskLocalUrl);
315 | }
316 | decreRefCount();
317 | return i;
318 | }
319 |
320 | public int addServerResource(long j, ServerResourceParam serverResourceParam) {
321 | int i = 9900;
322 | if (serverResourceParam != null && serverResourceParam.checkMemberVar()) {
323 | increRefCount();
324 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
325 | XLLog.i(TAG, "respara.mUrl=" + serverResourceParam.mUrl);
326 | i = this.mLoader.addServerResource(j, serverResourceParam.mUrl, serverResourceParam.mRefUrl, serverResourceParam.mCookie, serverResourceParam.mResType, serverResourceParam.mStrategy);
327 | }
328 | decreRefCount();
329 | }
330 | return i;
331 | }
332 |
333 | public int addPeerResource(long j, PeerResourceParam peerResourceParam) {
334 | int i = 9900;
335 | if (peerResourceParam == null || !peerResourceParam.checkMemberVar()) {
336 | return 9900;
337 | }
338 | increRefCount();
339 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
340 | i = this.mLoader.addPeerResource(j, peerResourceParam.mPeerId, peerResourceParam.mUserId, peerResourceParam.mJmpKey, peerResourceParam.mVipCdnAuth, peerResourceParam.mInternalIp, peerResourceParam.mTcpPort, peerResourceParam.mUdpPort, peerResourceParam.mResLevel, peerResourceParam.mResPriority, peerResourceParam.mCapabilityFlag, peerResourceParam.mResType);
341 | }
342 | decreRefCount();
343 | return i;
344 | }
345 |
346 | public int removeServerResource(long j, int i) {
347 | int i2 = 9900;
348 | increRefCount();
349 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
350 | i2 = this.mLoader.removeAddedServerResource(j, i);
351 | }
352 | decreRefCount();
353 | return i2;
354 | }
355 |
356 | int requeryTaskIndex(long j) {
357 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null) {
358 | return 9900;
359 | }
360 | return this.mLoader.requeryIndex(j);
361 | }
362 |
363 | public int setOriginUserAgent(long j, String str) {
364 | int i = 9900;
365 | increRefCount();
366 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null)) {
367 | i = this.mLoader.setOriginUserAgent(j, str);
368 | }
369 | decreRefCount();
370 | return i;
371 | }
372 |
373 | public int setUserId(String str) {
374 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null) {
375 | return 9900;
376 | }
377 | return this.mLoader.setUserId(str);
378 | }
379 |
380 | public int getDownloadHeader(long j, GetDownloadHead getDownloadHead) {
381 | int i = 9900;
382 | increRefCount();
383 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || getDownloadHead == null)) {
384 | i = this.mLoader.getDownloadHeader(j, getDownloadHead);
385 | }
386 | decreRefCount();
387 | return i;
388 | }
389 |
390 | public int setFileName(long j, String str) {
391 | int i = 9900;
392 | increRefCount();
393 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null)) {
394 | i = this.mLoader.setFileName(j, str);
395 | }
396 | decreRefCount();
397 | return i;
398 | }
399 |
400 | int notifyNetWorkCarrier(int i) {
401 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null) {
402 | return 9900;
403 | }
404 | return this.mLoader.setNotifyNetWorkCarrier(i);
405 | }
406 |
407 | int notifyWifiBSSID(String str, XLLoader xLLoader) {
408 | int i = 9900;
409 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && xLLoader != null) {
410 | if (str == null || str.length() == 0 || str == "") {
411 | str = "";
412 | }
413 | try {
414 | i = xLLoader.setNotifyWifiBSSID(str);
415 | } catch (Error e) {
416 | XLLog.e(TAG, "setNotifyWifiBSSID failed," + e.getMessage());
417 | }
418 | }
419 | return i;
420 | }
421 |
422 | public int setDownloadTaskOrigin(long j, String str) {
423 | int i = 9900;
424 | increRefCount();
425 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null)) {
426 | i = this.mLoader.setDownloadTaskOrigin(j, str);
427 | }
428 | decreRefCount();
429 | return i;
430 | }
431 |
432 | int setMac(String str) {
433 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null) {
434 | return 9900;
435 | }
436 | return this.mLoader.setMac(str);
437 | }
438 |
439 | int setImei(String str) {
440 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null) {
441 | return 9900;
442 | }
443 | return this.mLoader.setImei(str);
444 | }
445 |
446 | private int setLocalProperty(String str, String str2) {
447 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null || str2 == null) {
448 | return 9900;
449 | }
450 | return this.mLoader.setLocalProperty(str, str2);
451 | }
452 |
453 | public int setOSVersion(String str) {
454 | int i = 9900;
455 | increRefCount();
456 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null)) {
457 | i = this.mLoader.setMiUiVersion(str);
458 | }
459 | decreRefCount();
460 | return i;
461 | }
462 |
463 | public int setHttpHeaderProperty(long j, String str, String str2) {
464 | int i = 9900;
465 | increRefCount();
466 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || str == null || str2 == null)) {
467 | i = this.mLoader.setHttpHeaderProperty(j, str, str2);
468 | }
469 | decreRefCount();
470 | return i;
471 | }
472 |
473 | public int getDownloadLibVersion(GetDownloadLibVersion getDownloadLibVersion) {
474 | int i = 9900;
475 | increRefCount();
476 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || getDownloadLibVersion == null)) {
477 | i = this.mLoader.getDownloadLibVersion(getDownloadLibVersion);
478 | }
479 | decreRefCount();
480 | return i;
481 | }
482 |
483 | public int getProductInfo(XLProductInfo xLProductInfo) {
484 | increRefCount();
485 | if (mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mContext == null || xLProductInfo == null) {
486 | decreRefCount();
487 | return 9900;
488 | }
489 | xLProductInfo.mProductKey = this.mAppkeyChecker.getSoAppKey();
490 | xLProductInfo.mProductName = this.mContext.getPackageName();
491 | return 9000;
492 | }
493 |
494 | private String getPeerid() {
495 | if (!mAllowExecution) {
496 | return "000000000000000V";
497 | }
498 | String peerid = XLUtil.getPeerid(this.mContext);
499 | if (peerid == null) {
500 | return "000000000000000V";
501 | }
502 | return peerid;
503 | }
504 |
505 | private String getGuid() {
506 | if (!mAllowExecution) {
507 | return "00000000000000_000000000000";
508 | }
509 | GuidInfo guidInfo = new GuidInfo();
510 | guidInfo = XLUtil.generateGuid(this.mContext);
511 | if (guidInfo.mType != GUID_TYPE.ALL) {
512 | XLLog.i(TAG, "Start the GetGuidTimer");
513 | startGetGuidTimer();
514 | }
515 | return guidInfo.mGuid;
516 | }
517 |
518 | private void startGetGuidTimer() {
519 | this.mGetGuidTimer = new Timer();
520 | this.mGetGuidTimerTask = new MyTimerTask(this);
521 | this.mGetGuidTimer.schedule(this.mGetGuidTimerTask, 5000, 60000);
522 | }
523 |
524 | private void stopGetGuidTimer() {
525 | if (this.mGetGuidTimer instanceof Timer) {
526 | this.mGetGuidTimer.cancel();
527 | this.mGetGuidTimer.purge();
528 | this.mGetGuidTimer = null;
529 | XLLog.i(TAG, "stopGetGuidTimer");
530 | }
531 | if (this.mGetGuidTimerTask instanceof TimerTask) {
532 | this.mGetGuidTimerTask.cancel();
533 | this.mGetGuidTimerTask = null;
534 | }
535 | }
536 |
537 | public int enterPrefetchMode(long j) {
538 | int i = 9900;
539 | increRefCount();
540 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
541 | i = this.mLoader.enterPrefetchMode(j);
542 | }
543 | decreRefCount();
544 | return i;
545 | }
546 |
547 | public int setTaskLxState(long j, int i, int i2) {
548 | int i3 = 9900;
549 | increRefCount();
550 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
551 | i3 = this.mLoader.setTaskLxState(j, i, i2);
552 | }
553 | decreRefCount();
554 | return i3;
555 | }
556 |
557 | public int setTaskGsState(long j, int i, int i2) {
558 | int i3 = 9900;
559 | increRefCount();
560 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
561 | i3 = this.mLoader.setTaskGsState(j, i, i2);
562 | }
563 | decreRefCount();
564 | return i3;
565 | }
566 |
567 | public int setReleaseLog(boolean z, String str, int i, int i2) {
568 | int i3 = 9900;
569 | increRefCount();
570 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
571 | i3 = z ? this.mLoader.setReleaseLog(1, str, i, i2) : this.mLoader.setReleaseLog(0, null, 0, 0);
572 | }
573 | decreRefCount();
574 | return i3;
575 | }
576 |
577 | public int setReleaseLog(boolean z, String str) {
578 | return setReleaseLog(z, str, 0, 0);
579 | }
580 |
581 | public boolean isLogTurnOn() {
582 | boolean z = false;
583 | increRefCount();
584 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
585 | z = this.mLoader.isLogTurnOn();
586 | }
587 | decreRefCount();
588 | return z;
589 | }
590 |
591 | public int setStatReportSwitch(boolean z) {
592 | int i = 9900;
593 | increRefCount();
594 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
595 | i = this.mLoader.setStatReportSwitch(z);
596 | }
597 | decreRefCount();
598 | return i;
599 | }
600 |
601 | public int createBtMagnetTask(MagnetTaskParam magnetTaskParam, GetTaskId getTaskId) {
602 | int i = 9900;
603 | if (!(magnetTaskParam == null || getTaskId == null || !magnetTaskParam.checkMemberVar())) {
604 | increRefCount();
605 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
606 | i = this.mLoader.createBtMagnetTask(magnetTaskParam.mUrl, magnetTaskParam.mFilePath, magnetTaskParam.mFileName, getTaskId);
607 | }
608 | decreRefCount();
609 | }
610 | return i;
611 | }
612 |
613 | public int createEmuleTask(EmuleTaskParam emuleTaskParam, GetTaskId getTaskId) {
614 | int i = 9900;
615 | if (!(emuleTaskParam == null || getTaskId == null || !emuleTaskParam.checkMemberVar())) {
616 | increRefCount();
617 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
618 | i = this.mLoader.createEmuleTask(emuleTaskParam.mUrl, emuleTaskParam.mFilePath, emuleTaskParam.mFileName, emuleTaskParam.mCreateMode, emuleTaskParam.mSeqId, getTaskId);
619 | }
620 | decreRefCount();
621 | }
622 | return i;
623 | }
624 |
625 | public int createBtTask(BtTaskParam btTaskParam, GetTaskId getTaskId) {
626 | int i = 9900;
627 | if (!(btTaskParam == null || getTaskId == null || !btTaskParam.checkMemberVar())) {
628 | increRefCount();
629 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
630 | i = this.mLoader.createBtTask(btTaskParam.mTorrentPath, btTaskParam.mFilePath, btTaskParam.mMaxConcurrent, btTaskParam.mCreateMode, btTaskParam.mSeqId, getTaskId);
631 | }
632 | decreRefCount();
633 | }
634 | return i;
635 | }
636 |
637 | public int getTorrentInfo(String str, TorrentInfo torrentInfo) {
638 | int i = 9900;
639 | increRefCount();
640 | if (!(this.mLoader == null || str == null || torrentInfo == null)) {
641 | i = this.mLoader.getTorrentInfo(str, torrentInfo);
642 | }
643 | decreRefCount();
644 | return i;
645 | }
646 |
647 | public int getBtSubTaskStatus(long j, BtTaskStatus btTaskStatus, int i, int i2) {
648 | int i3 = 9900;
649 | increRefCount();
650 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || btTaskStatus == null)) {
651 | i3 = this.mLoader.getBtSubTaskStatus(j, btTaskStatus, i, i2);
652 | }
653 | decreRefCount();
654 | return i3;
655 | }
656 |
657 | public int getBtSubTaskInfo(long j, int i, BtSubTaskDetail btSubTaskDetail) {
658 | int i2 = 9900;
659 | increRefCount();
660 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || btSubTaskDetail == null)) {
661 | i2 = this.mLoader.getBtSubTaskInfo(j, i, btSubTaskDetail);
662 | }
663 | decreRefCount();
664 | return i2;
665 | }
666 |
667 | public int selectBtSubTask(long j, BtIndexSet btIndexSet) {
668 | int i = 9900;
669 | increRefCount();
670 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || btIndexSet == null)) {
671 | i = this.mLoader.selectBtSubTask(j, btIndexSet);
672 | }
673 | decreRefCount();
674 | return i;
675 | }
676 |
677 | public int deselectBtSubTask(long j, BtIndexSet btIndexSet) {
678 | int i = 9900;
679 | increRefCount();
680 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || btIndexSet == null)) {
681 | i = this.mLoader.deselectBtSubTask(j, btIndexSet);
682 | }
683 | decreRefCount();
684 | return i;
685 | }
686 |
687 | public int btAddServerResource(long j, int i, ServerResourceParam serverResourceParam) {
688 | if (serverResourceParam == null) {
689 | XLLog.e(TAG, "btAddServerResource serverResPara is null, task=[" + j + ":" + i + "]");
690 | return 9112;
691 | }
692 | XLLog.d(TAG, "btAddServerResource beg, task=[" + j + ":" + i + "] mUrl=[" + serverResourceParam.mUrl + "] mRefUrl=[" + serverResourceParam.mRefUrl + "] mCookie=[" + serverResourceParam.mCookie + "] mResType=[" + serverResourceParam.mResType + "] mStrategy=[" + serverResourceParam.mStrategy + "]");
693 | if (serverResourceParam.checkMemberVar()) {
694 | try {
695 | increRefCount();
696 | if (this.mLoader == null) {
697 | XLLog.e(TAG, "btAddServerResource mLoader is null, task=[" + j + ":" + i + "]");
698 | return 9900;
699 | } else if (XLManagerStatus.MANAGER_RUNNING != mDownloadManagerState) {
700 | XLLog.e(TAG, "btAddServerResource mDownloadManagerState is invaild, task=[" + j + ":" + i + "] mDownloadManagerState=[" + mDownloadManagerState + "]");
701 | decreRefCount();
702 | return 9900;
703 | } else {
704 | int btAddServerResource = mLoader.btAddServerResource(j, i, serverResourceParam.mUrl, serverResourceParam.mRefUrl, serverResourceParam.mCookie, serverResourceParam.mResType, serverResourceParam.mStrategy);
705 | if (9000 != btAddServerResource) {
706 | XLLog.e(TAG, "btAddServerResource btAddServerResource failed, task=[" + j + ":" + i + "] errno=[" + btAddServerResource + "]");
707 | decreRefCount();
708 | return btAddServerResource;
709 | }
710 | String str = TAG;
711 | String str__ = "btAddServerResource end success, task=[" + j + ":" + i + "]";
712 | XLLog.d(str, str__);
713 | decreRefCount();
714 | return 9000;
715 | }
716 | } finally {
717 | decreRefCount();
718 | }
719 | } else {
720 | XLLog.e(TAG, "btAddServerResource checkMemberVar failed, task=[" + j + ":" + i + "] mUrl=[" + serverResourceParam.mUrl + "] mRefUrl=[" + serverResourceParam.mRefUrl + "] mCookie=[" + serverResourceParam.mCookie + "]");
721 | return 9112;
722 | }
723 | }
724 |
725 | public int btAddPeerResource(long j, int i, PeerResourceParam peerResourceParam) {
726 | if (peerResourceParam == null) {
727 | XLLog.e(TAG, "btAddPeerResource peerResPara is null, task=[" + j + ":" + i + "]");
728 | return 9112;
729 | }
730 | XLLog.d(TAG, "btAddPeerResource beg, task=[" + j + ":" + i + "] mPeerId=[" + peerResourceParam.mPeerId + "] mUserId=[" + peerResourceParam.mUserId + "] mJmpKey=[" + peerResourceParam.mJmpKey + "] mVipCdnAuth=[" + peerResourceParam.mVipCdnAuth + "] mInternalIp=[" + peerResourceParam.mInternalIp + "] mTcpPort=[" + peerResourceParam.mTcpPort + "] mUdpPort=[" + peerResourceParam.mUdpPort + "] mResLevel=[" + peerResourceParam.mResLevel + "] mResPriority=[" + peerResourceParam.mResPriority + "] mCapabilityFlag=[" + peerResourceParam.mCapabilityFlag + "] mResType=[" + peerResourceParam.mResType + "]");
731 | if (peerResourceParam.checkMemberVar()) {
732 | try {
733 | increRefCount();
734 | if (this.mLoader == null) {
735 | XLLog.e(TAG, "btAddPeerResource mLoader is null, task=[" + j + ":" + i + "]");
736 | return 9900;
737 | } else if (XLManagerStatus.MANAGER_RUNNING != mDownloadManagerState) {
738 | XLLog.e(TAG, "btAddPeerResource mDownloadManagerState is invaild, task=[" + j + ":" + i + "] mDownloadManagerState=[" + mDownloadManagerState + "]");
739 | decreRefCount();
740 | return 9900;
741 | } else {
742 | int btAddPeerResource = this.mLoader.btAddPeerResource(j, i, peerResourceParam.mPeerId, peerResourceParam.mUserId, peerResourceParam.mJmpKey, peerResourceParam.mVipCdnAuth, peerResourceParam.mInternalIp, peerResourceParam.mTcpPort, peerResourceParam.mUdpPort, peerResourceParam.mResLevel, peerResourceParam.mResPriority, peerResourceParam.mCapabilityFlag, peerResourceParam.mResType);
743 | if (9000 != btAddPeerResource) {
744 | XLLog.e(TAG, "btAddPeerResource btAddPeerResource failed, task=[" + j + ":" + i + "] errno=[" + btAddPeerResource + "]");
745 | decreRefCount();
746 | return btAddPeerResource;
747 | }
748 | XLLog.d(TAG, "btAddPeerResource end success, task=[" + j + ":" + i + "]");
749 | decreRefCount();
750 | return 9000;
751 | }
752 | } finally {
753 | decreRefCount();
754 | }
755 | } else {
756 | XLLog.e(TAG, "btAddPeerResource peerResPara checkMemberVar failed, task=[" + j + ":" + i + "]");
757 | return 9112;
758 | }
759 | }
760 |
761 | public int btRemoveAddedResource(long j, int i, int i2) {
762 | int i3 = 9900;
763 | increRefCount();
764 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
765 | i3 = this.mLoader.btRemoveAddedResource(j, i, i2);
766 | }
767 | decreRefCount();
768 | return i3;
769 | }
770 |
771 | private void loadErrcodeString(Context context) {
772 | if (context == null) {
773 | XLLog.e(TAG, "loadErrcodeString, context invalid");
774 | } else {
775 | mErrcodeStringMap = XLUtil.parseJSONString("{ \"9000\": \"XL_NO_ERRNO \" , \"9101\": \"XL_ALREADY_INIT \" , \"9102\": \"XL_SDK_NOT_INIT \" , \"9103\": \"XL_TASK_ALREADY_EXIST \" , \"9104\": \"XL_TASK_NOT_EXIST \" , \"9105\": \"XL_TASK_ALREADY_STOPPED \" , \"9106\": \"XL_TASK_ALREADY_RUNNING \" , \"9107\": \"XL_TASK_NOT_START \" , \"9108\": \"XL_TASK_STILL_RUNNING \" , \"9109\": \"XL_FILE_EXISTED \" , \"9110\": \"XL_DISK_FULL \" , \"9111\": \"XL_TOO_MUCH_TASK \" , \"9112\": \"XL_PARAM_ERROR \" , \"9113\": \"XL_SCHEMA_NOT_SUPPORT \" , \"9114\": \"XL_DYNAMIC_PARAM_FAIL \" , \"9115\": \"XL_CONTINUE_NO_NAME \" , \"9116\": \"XL_APPNAME_APPKEY_ERROR \" , \"9117\": \"XL_CREATE_THREAD_ERROR \" , \"9118\": \"XL_TASK_FINISH \" , \"9119\": \"XL_TASK_NOT_RUNNING \" , \"9120\": \"XL_TASK_NOT_IDLE \" , \"9121\": \"XL_TASK_TYPE_NOT_SUPPORT \" , \"9122\": \"XL_ADD_RESOURCE_ERROR \" , \"9123\": \"XL_TASK_LOADING_CFG \" , \"9301\": \"XL_NO_ENOUGH_BUFFER \" , \"9302\": \"XL_TORRENT_PARSE_ERROR \" , \"9303\": \"XL_INDEX_NOT_READY \" , \"9304\": \"XL_TORRENT_IMCOMPLETE \" , \"9900\": \"DOWNLOAD_MANAGER_ERROR \" , \"9901\": \"APPKEY_CHECKER_ERROR \" , \"111024\": \"COMMON_ERRCODE_BASE \" , \"111025\": \"TARGET_THREAD_STOPING \" , \"111026\": \"OUT_OF_MEMORY \" , \"111031\": \"TASK_USE_TOO_MUCH_MEM \" , \"111032\": \"OUT_OF_FIXED_MEMORY \" , \"111033\": \"QUEUE_NO_ROOM \" , \"111035\": \"MAP_UNINIT \" , \"111036\": \"MAP_DUPLICATE_KEY \" , \"111037\": \"MAP_KEY_NOT_FOUND \" , \"111038\": \"INVALID_ITERATOR \" , \"111039\": \"BUFFER_OVERFLOW \" , \"111041\": \"INVALID_ARGUMENT \" , \"111048\": \"INVALID_SOCKET_DESCRIPTOR \" , \"111050\": \"ERROR_INVALID_INADDR \" , \"111181\": \"REDIRECT_TOO_MUCH \" , \"111057\": \"NOT_IMPLEMENT \" , \"111074\": \"INVALID_TIMER_INDEX \" , \"111078\": \"DNS_INVALID_ADDR \" , \"111083\": \"BAD_DIR_PATH \" , \"111084\": \"FILE_CANNOT_TRUNCATE \" , \"111085\": \"INSUFFICIENT_DISK_SPACE \" , \"111086\": \"FILE_TOO_BIG \" , \"111118\": \"DISPATCHER_ERRCODE_BASE \" , \"111119\": \"DATA_MGR_ERRCODE_BASE \" , \"111120\": \"ALLOC_INVALID_SIZE \" , \"111121\": \"DATA_BUFFER_IS_FULL \" , \"111122\": \"BLOCK_NO_INVALID \" , \"111123\": \"CHECK_DATA_BUFFER_NOT_ENOUG \" , \"111124\": \"BCID_CHECK_FAIL \" , \"111125\": \"BCID_ONCE_CHECT_TOO_MUCH \" , \"111126\": \"READ_FILE_ERR \" , \"111127\": \"WRITE_FILE_ERR \" , \"111128\": \"OPEN_FILE_ERR \" , \"111129\": \"FILE_PATH_TOO_LONG \" , \"111130\": \"SD_INVALID_FILE_SIZE \" , \"111131\": \"FILE_CFG_MAGIC_ERROR \" , \"111132\": \"FILE_CFG_READ_ERROR \" , \"111133\": \"FILE_CFG_WRITE_ERROR \" , \"111134\": \"FILE_CFG_READ_HEADER_ERROR \" , \"111135\": \"FILE_CFG_RESOLVE_ERROR \" , \"111136\": \"TASK_FAILURE_NO_DATA_PIPE \" , \"111137\": \"NO_FILE_NAME \" , \"111138\": \"CANNOT_GET_FILE_NAME \" , \"111139\": \"CREATE_FILE_FAIL \" , \"111140\": \"OPEN_OLD_FILE_FAIL \" , \"111141\": \"FILE_SIZE_NOT_BELIEVE \" , \"111142\": \"FILE_SIZE_TOO_SMALL \" , \"111143\": \"FILE_NOT_EXIST \" , \"111144\": \"FILE_INVALID_PARA \" , \"111145\": \"FILE_CREATING \" , \"111146\": \"FIL_INFO_INVALID_DATA \" , \"111147\": \"FIL_INFO_RECVED_DATA \" , \"111159\": \"CONF_MGR_ERRCODE_BASE \" , \"111160\": \"SETTINGS_ERR_UNKNOWN \" , \"111161\": \"SETTINGS_ERR_INVALID_FILE_NAME \" , \"111162\": \"SETTINGS_ERR_CFG_FILE_NOT_EXIST \" , \"111163\": \"SETTINGS_ERR_INVALID_LINE \" , \"111164\": \"SETTINGS_ERR_INVALID_ITEM_NAME \" , \"111165\": \"SETTINGS_ERR_INVALID_ITEM_VALUE \" , \"111166\": \"SETTINGS_ERR_LIST_EMPTY \" , \"111167\": \"SETTINGS_ERR_ITEM_NOT_FOUND \" , \"111168\": \"NET_REACTOR_ERRCODE_BASE \" , \"111169\": \"NET_CONNECT_SSL_ERR \" , \"111170\": \"NET_BROKEN_PIPE \" , \"111171\": \"NET_CONNECTION_REFUSED \" , \"111172\": \"NET_SSL_GET_FD_ERROR \" , \"111173\": \"NET_OP_CANCEL \" , \"111174\": \"NET_UNKNOWN_ERROR \" , \"111175\": \"NET_NORMAL_CLOSE \" , \"111176\": \"TASK_FAIL_LONG_TIME_NO_RECV_DATA \" , \"111177\": \"TASK_FILE_SIZE_TOO_LARGE \" , \"111178\": \"TASK_RETRY_ALWAY_FAIL \" , \"111300\": \"ASYN_FILE_E_BASE \" , \"111301\": \"ASYN_FILE_E_OP_NONE \" , \"111302\": \"ASYN_FILE_E_OP_BUSY \" , \"111303\": \"ASYN_FILE_E_FILE_NOT_OPEN \" , \"111304\": \"ASYN_FILE_E_FILE_REOPEN \" , \"111305\": \"ASYN_FILE_E_EMPTY_FILE \" , \"111306\": \"ASYN_FILE_E_FILE_SIZE_LESS \" , \"111307\": \"ASYN_FILE_E_TOO_MUCH_DATA \" , \"111308\": \"ASYN_FILE_E_FILE_CLOSING \" , \"112400\": \"ERR_PTL_PROTOCOL_NOT_SUPPORT \" , \"112500\": \"ERR_PTL_PEER_OFFLINE \" , \"112600\": \"ERR_PTL_GET_PEERSN_FAILED \" , \"11300\": \"P2P_PIPE_ERRCODE_BASE\t\t\t \" , \"11301\": \"ERR_P2P_VERSION_NOT_SUPPORT\t\t \" , \"11302\": \"ERR_P2P_WAITING_CLOSE\t\t\t \" , \"11303\": \"ERR_P2P_HANDSHAKE_RESP_FAIL\t\t \" , \"11304\": \"ERR_P2P_REQUEST_RESP_FAIL\t\t \" , \"11305\": \"ERR_P2P_UPLOAD_OVER_MAX\t\t\t \" , \"11306\": \"ERR_P2P_REMOTE_UNKNOWN_MY_CMD\t \" , \"11307\": \"ERR_P2P_NOT_SUPPORT_UDT\t\t\t \" , \"11308\": \"ERR_P2P_BROKER_CONNECT\t\t\t \" , \"11309\": \"ERR_P2P_INVALID_COMMAND\t\t\t \" , \"11310\": \"ERR_P2P_INVALID_PARAM\t\t\t \" , \"11311\": \"ERR_P2P_CONNECT_FAILED\t\t\t \" , \"11312\": \"ERR_P2P_CONNECT_UPLOAD_SLOW\t \" , \"11313\": \"ERR_P2P_ALLOC_MEM_ERR \" , \"11314\": \"ERR_P2P_SEND_HANDSHAKE \" , \"114001\": \"TASK_FAILURE_QUERY_EMULE_HUB_FAILED\" , \"114101\": \"TASK_FAILURE_EMULE_NO_RECORD \" , \"114002\": \"TASK_FAILURE_SUBTASK_FAILED \" , \"114003\": \"TASK_FAILURE_CANNOT_START_SUBTASK \" , \"114004\": \"TASK_FAILURE_QUERY_BT_HUB_FAILED \" , \"114005\": \"TASK_FAILURE_PARSE_TORRENT_FAILED \" , \"114006\": \"TASK_FAILURE_GET_TORRENT_FAILED \" , \"114007\": \"TASK_FAILURE_SAVE_TORRENT_FAILED \" , \"115000\": \"RES_QUERY_E_BASE \" , \"115100\": \"HTTP_HUB_CLIENT_E_BASE \" , \"116000\": \"IP6_ERRCODE_BASE \" , \"116001\": \"ERR_INVALID_ADDRESS_FAMILY \" , \"116002\": \"IP6_INVALID_IN6ADDR \" , \"116003\": \"IP6_NOT_SUPPORT_SSL \" , \"117000\": \"PAUSE_TASK_WRITE_CFG_ERR \" , \"117001\": \"PAUSE_TASK_WRITE_DATA_TIMEOUT \" }");
776 | }
777 | }
778 |
779 | public String getErrorCodeMsg(int i) {
780 | String str = null;
781 | String num = Integer.toString(i);
782 | if (!(mErrcodeStringMap == null || num == null)) {
783 | Object obj = mErrcodeStringMap.get(num);
784 | if (obj != null) {
785 | str = obj.toString().trim();
786 | }
787 | XLLog.i(TAG, "errcode:" + i + ", errcodeMsg:" + str);
788 | }
789 | return str;
790 | }
791 |
792 | public int getUrlQuickInfo(long j, UrlQuickInfo urlQuickInfo) {
793 | int i = 9900;
794 | increRefCount();
795 | if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || urlQuickInfo == null)) {
796 | i = this.mLoader.getUrlQuickInfo(j, urlQuickInfo);
797 | }
798 | decreRefCount();
799 | return i;
800 | }
801 |
802 | public int createCIDTask(CIDTaskParam cIDTaskParam, GetTaskId getTaskId) {
803 | int i = 9900;
804 | if (!(cIDTaskParam == null || getTaskId == null || !cIDTaskParam.checkMemberVar())) {
805 | increRefCount();
806 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
807 | i = this.mLoader.createCIDTask(cIDTaskParam.mCid, cIDTaskParam.mGcid, cIDTaskParam.mBcid, cIDTaskParam.mFilePath, cIDTaskParam.mFileName, cIDTaskParam.mFileSize, cIDTaskParam.mCreateMode, cIDTaskParam.mSeqId, getTaskId);
808 | }
809 | decreRefCount();
810 | }
811 | return i;
812 | }
813 |
814 | public String parserThunderUrl(String str) {
815 | int i = 9900;
816 | ThunderUrlInfo thunderUrlInfo = new ThunderUrlInfo();
817 | if (!(this.mLoader == null || str == null)) {
818 | i = this.mLoader.parserThunderUrl(str, thunderUrlInfo);
819 | }
820 | if (9000 == i) {
821 | return thunderUrlInfo.mUrl;
822 | }
823 | return null;
824 | }
825 |
826 | public int getFileNameFromUrl(String str, GetFileName getFileName) {
827 | if (this.mLoader == null || str == null || getFileName == null) {
828 | return 9900;
829 | }
830 | return this.mLoader.getFileNameFromUrl(str, getFileName);
831 | }
832 |
833 | public int getNameFromUrl(String str, String str2) {
834 | if (this.mLoader == null || str == null || str2 == null) {
835 | return 9900;
836 | }
837 | return this.mLoader.getNameFromUrl(str, str2);
838 | }
839 |
840 | public int setSpeedLimit(long j, long j2) {
841 | XLLog.d(TAG, "debug: XLDownloadManager::setSpeedLimit beg, maxDownloadSpeed=[" + j + "] maxUploadSpeed=[" + j2 + "]");
842 | if (this.mLoader == null) {
843 | XLLog.e(TAG, "error: XLDownloadManager::setSpeedLimit mLoader is null, maxDownloadSpeed=[" + j + "] maxUploadSpeed=[" + j2 + "] ret=[9900]");
844 | return 9900;
845 | }
846 | int speedLimit = this.mLoader.setSpeedLimit(j, j2);
847 | XLLog.d(TAG, "debug: XLDownloadManager::setSpeedLimit end, maxDownloadSpeed=[" + j + "] maxUploadSpeed=[" + j2 + "] ret=[" + speedLimit + "]");
848 | return speedLimit;
849 | }
850 |
851 | public int setBtPriorSubTask(long j, int i) {
852 | XLLog.d(TAG, "XLDownloadManager::setBtPriorSubTask beg, taskId=[" + j + "] fileIndex=[" + i + "]");
853 | if (this.mLoader == null) {
854 | XLLog.e(TAG, "XLDownloadManager::setBtPriorSubTask mLoader is null, taskId=[" + j + "] fileIndex=[" + i + "]");
855 | return 9900;
856 | }
857 | int btPriorSubTask = this.mLoader.setBtPriorSubTask(j, i);
858 | if (9000 != btPriorSubTask) {
859 | XLLog.e(TAG, "XLDownloadManager::setBtPriorSubTask end, taskId=[" + j + "] fileIndex=[" + i + "] ret=[" + btPriorSubTask + "]");
860 | return btPriorSubTask;
861 | }
862 | XLLog.d(TAG, " XLDownloadManager::setBtPriorSubTask end, taskId=[" + j + "] fileIndex=[" + i + "]");
863 | return 9000;
864 | }
865 |
866 | public int getMaxDownloadSpeed(MaxDownloadSpeedParam maxDownloadSpeedParam) {
867 | if (this.mLoader == null) {
868 | XLLog.e(TAG, "XLDownloadManager::getMaxDownloadSpeed mLoader is null");
869 | return 9900;
870 | }
871 | int maxDownloadSpeed = this.mLoader.getMaxDownloadSpeed(maxDownloadSpeedParam);
872 | if (9000 != maxDownloadSpeed) {
873 | XLLog.e(TAG, "XLDownloadManager::getMaxDownloadSpeed end, ret=[" + maxDownloadSpeed + "]");
874 | return maxDownloadSpeed;
875 | }
876 | XLLog.d(TAG, "XLDownloadManager::getMaxDownloadSpeed end, speed=[" + maxDownloadSpeedParam.mSpeed + "] ret=[" + maxDownloadSpeed + "]");
877 | return maxDownloadSpeed;
878 | }
879 |
880 | public int statExternalInfo(long j, int i, String str, String str2) {
881 | XLLog.d(TAG, "XLDownloadManager::statExternalInfo beg, taskId=[" + j + "] fileIndex=[" + i + "] key=[" + str + "] value=[" + str2 + "]");
882 | if (this.mLoader == null) {
883 | XLLog.e(TAG, "XLDownloadManager::statExternalInfo mLoader is null, taskId=[" + j + "] fileIndex=[" + i + "]");
884 | return 9900;
885 | }
886 | int statExternalInfo = this.mLoader.statExternalInfo(j, i, str, str2);
887 | if (9000 != statExternalInfo) {
888 | XLLog.e(TAG, "XLDownloadManager::statExternalInfo end, taskId=[" + j + "] fileIndex=[" + i + "] ret=[" + statExternalInfo + "]");
889 | return statExternalInfo;
890 | }
891 | XLLog.d(TAG, "XLDownloadManager::statExternalInfo end, taskId=[" + j + "] fileIndex=[" + i + "] ret=[" + statExternalInfo + "]");
892 | return statExternalInfo;
893 | }
894 |
895 | public int statExternalInfo(long j, int i, String str, int i2) {
896 | return statExternalInfo(j, i, str, String.valueOf(i2));
897 | }
898 |
899 | public int clearTaskFile(String str) {
900 | XLLog.d(TAG, "XLDownloadManager::clearTaskFile filePath=[" + str + "]");
901 | if (TextUtils.isEmpty(str)) {
902 | return 9900;
903 | }
904 | if (this.mLoader == null) {
905 | XLLog.e(TAG, "XLDownloadManager::clearTaskFile mLoader is null");
906 | return 9900;
907 | }
908 | int clearTaskFile = this.mLoader.clearTaskFile(str);
909 | if (9000 == clearTaskFile) {
910 | return 9000;
911 | }
912 | XLLog.e(TAG, "XLDownloadManager::clearTaskFile end, ret=[" + clearTaskFile + "]");
913 | return clearTaskFile;
914 | }
915 |
916 | public int startDcdn(long j, int i, String str, String str2, String str3) {
917 | int i2 = 9900;
918 | increRefCount();
919 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
920 | i2 = this.mLoader.startDcdn(j, i, str, str2, str3);
921 | }
922 | decreRefCount();
923 | XLLog.d(TAG, String.format("XLDownloadManager::startDcdn ret=[%d] taskId=[%d] subIndex=[%d] sessionId=[%s] productType=[%s] verifyInfo=[%s]", new Object[]{Integer.valueOf(i2), Long.valueOf(j), Integer.valueOf(i), str, str2, str3}));
924 | return i2;
925 | }
926 |
927 | public int stopDcdn(long j, int i) {
928 | int i2 = 9900;
929 | increRefCount();
930 | if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
931 | i2 = this.mLoader.stopDcdn(j, i);
932 | }
933 | decreRefCount();
934 | XLLog.d(TAG, String.format("XLDownloadManager::stopDcdn ret=[%d] taskId=[%d] subIndex=[%d]", new Object[]{Integer.valueOf(i2), Long.valueOf(j), Integer.valueOf(i)}));
935 | return i2;
936 | }
937 |
938 | public int createShortVideoTask(String str, String str2, String str3, String str4, int i, int i2, int i3, GetTaskId getTaskId) {
939 | XLLog.d(TAG, "XLDownloadManager::createShortVideoTask beg, url=[" + str + "] path=[" + str2 + "] filename=[" + str3 + "] title=[" + str4 + "]");
940 | if (this.mLoader == null) {
941 | XLLog.e(TAG, "XLDownloadManager::createShortVideoTask mLoader is null");
942 | return 9900;
943 | }
944 | String str5;
945 | if (str4 == null) {
946 | str5 = "default Title";
947 | } else {
948 | str5 = str4;
949 | }
950 | int createShortVideoTask = this.mLoader.createShortVideoTask(str, str2, str3, str5, i, i2, i3, getTaskId);
951 | if (9000 != createShortVideoTask) {
952 | XLLog.e(TAG, "XLDownloadManager::createShortVideoTask end, ret=[" + createShortVideoTask + "]");
953 | return createShortVideoTask;
954 | }
955 | XLLog.d(TAG, "XLDownloadManager::createShortVideoTask end, taskId=[" + getTaskId.getTaskId() + "] ret=[" + createShortVideoTask + "]");
956 | return createShortVideoTask;
957 | }
958 |
959 | public int playShortVideoBegin(long j) {
960 | XLLog.d(TAG, "XLDownloadManager::playShortVideoBegin beg, taskId=[" + j + "]");
961 | if (this.mLoader == null) {
962 | XLLog.e(TAG, "XLDownloadManager::playShortVideoBegin mLoader is null");
963 | return 9900;
964 | }
965 | int playShortVideoBegin = this.mLoader.playShortVideoBegin(j);
966 | if (9000 != playShortVideoBegin) {
967 | XLLog.e(TAG, "XLDownloadManager::playShortVideoBegin end, ret=[" + playShortVideoBegin + "]");
968 | return playShortVideoBegin;
969 | }
970 | XLLog.d(TAG, "XLDownloadManager::playShortVideoBegin end, taskId=[" + j + "] ret=[" + playShortVideoBegin + "]");
971 | return playShortVideoBegin;
972 | }
973 |
974 | public int getSessionInfoByUrl(String str, XLSessionInfo xLSessionInfo) {
975 | if (this.mLoader == null) {
976 | XLLog.e(TAG, "XLDownloadManager::getSessionInfoByUrl mLoader is null");
977 | return 9900;
978 | }
979 | int sessionInfoByUrl = this.mLoader.getSessionInfoByUrl(str, xLSessionInfo);
980 | if (9000 == sessionInfoByUrl) {
981 | return sessionInfoByUrl;
982 | }
983 | XLLog.e(TAG, "XLDownloadManager::getSessionInfoByUrl end, ret=[" + sessionInfoByUrl + "]");
984 | return sessionInfoByUrl;
985 | }
986 |
987 |
988 |
989 | class NetworkChangeReceiver extends BroadcastReceiver {
990 | private static final String TAG = "TAG_DownloadReceiver";
991 | final /* synthetic */ XLDownloadManager this$0;
992 |
993 | public NetworkChangeReceiver(XLDownloadManager xLDownloadManager) {
994 | this.this$0 = xLDownloadManager;
995 | }
996 |
997 | public void onReceive(Context context, Intent intent) {
998 | String action = intent.getAction();
999 | if (action != null && action.equals("android.net.conn.CONNECTIVITY_CHANGE")) {
1000 | new Thread(new NetworkChangeHandlerThread(this.this$0, context, mLoader, mAllowExecution)).start();
1001 | }
1002 | }
1003 | }
1004 | class NetworkChangeHandlerThread implements Runnable {
1005 | private boolean m_allow_execution = true;
1006 | private Context m_context = null;
1007 | private XLLoader m_loader = null;
1008 | final /* synthetic */ XLDownloadManager this$0;
1009 |
1010 | public NetworkChangeHandlerThread(XLDownloadManager xLDownloadManager, Context context, XLLoader xLLoader, boolean z) {
1011 | this.this$0 = xLDownloadManager;
1012 | this.m_context = context;
1013 | this.m_loader = xLLoader;
1014 | this.m_allow_execution = z;
1015 | }
1016 |
1017 | public void run() {
1018 | if (this.m_allow_execution) {
1019 | int networkTypeComplete = XLUtil.getNetworkTypeComplete(this.m_context);
1020 | XLLog.d("XLDownloadManager", "NetworkChangeHandlerThread nettype=" + networkTypeComplete);
1021 | this.this$0.notifyNetWorkType(networkTypeComplete, this.m_loader);
1022 | String bssid = XLUtil.getBSSID(this.m_context);
1023 | XLLog.d("XLDownloadManager", "NetworkChangeHandlerThread bssid=" + bssid);
1024 | this.this$0.notifyWifiBSSID(bssid, this.m_loader);
1025 | XLUtil.NetWorkCarrier netWorkCarrier = XLUtil.getNetWorkCarrier(this.m_context);
1026 | XLLog.d("XLDownloadManager", "NetworkChangeHandlerThread NetWorkCarrier=" + netWorkCarrier);
1027 | this.this$0.notifyNetWorkCarrier(netWorkCarrier.ordinal());
1028 | }
1029 | }
1030 | }
1031 | class MyTimerTask extends TimerTask {
1032 | final /* synthetic */ XLDownloadManager this$0;
1033 |
1034 | MyTimerTask(XLDownloadManager xLDownloadManager) {
1035 | this.this$0 = xLDownloadManager;
1036 | }
1037 |
1038 | public void run() {
1039 | if (mQueryGuidCount < 5) {
1040 | // XLDownloadManager.access$208(this.this$0);
1041 | GuidInfo guidInfo = new GuidInfo();
1042 | guidInfo = XLUtil.generateGuid(mContext);
1043 | if (guidInfo.mType == GUID_TYPE.ALL) {
1044 | // XLDownloadManager.access$400(this.this$0);
1045 | }
1046 | if (guidInfo.mType != GUID_TYPE.DEFAULT) {
1047 | setLocalProperty("Guid", guidInfo.mGuid);
1048 | return;
1049 | }
1050 | return;
1051 | }
1052 | // XLDownloadManager.access$400(this.this$0);
1053 | }
1054 | }
1055 | }
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/XLLoader.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib;
2 |
3 | import android.content.Context;
4 | import com.xunlei.downloadlib.android.XLLog;
5 | import com.xunlei.downloadlib.parameter.BtIndexSet;
6 | import com.xunlei.downloadlib.parameter.BtSubTaskDetail;
7 | import com.xunlei.downloadlib.parameter.BtTaskStatus;
8 | import com.xunlei.downloadlib.parameter.GetDownloadHead;
9 | import com.xunlei.downloadlib.parameter.GetDownloadLibVersion;
10 | import com.xunlei.downloadlib.parameter.GetFileName;
11 | import com.xunlei.downloadlib.parameter.GetTaskId;
12 | import com.xunlei.downloadlib.parameter.MaxDownloadSpeedParam;
13 | import com.xunlei.downloadlib.parameter.ThunderUrlInfo;
14 | import com.xunlei.downloadlib.parameter.TorrentInfo;
15 | import com.xunlei.downloadlib.parameter.UrlQuickInfo;
16 | import com.xunlei.downloadlib.parameter.XLSessionInfo;
17 | import com.xunlei.downloadlib.parameter.XLTaskInfo;
18 | import com.xunlei.downloadlib.parameter.XLTaskInfoEx;
19 | import com.xunlei.downloadlib.parameter.XLTaskLocalUrl;
20 |
21 | class XLLoader {
22 | private static final String TAG = "XLLoader";
23 |
24 | public native int addPeerResource(long j, String str, long j2, String str2, String str3, int i, int i2, int i3, int i4, int i5, int i6, int i7);
25 |
26 | public native int addServerResource(long j, String str, String str2, String str3, int i, int i2);
27 |
28 | public native int btAddPeerResource(long j, int i, String str, long j2, String str2, String str3, int i2, int i3, int i4, int i5, int i6, int i7, int i8);
29 |
30 | public native int btAddServerResource(long j, int i, String str, String str2, String str3, int i2, int i3);
31 |
32 | public native int btRemoveAddedResource(long j, int i, int i2);
33 |
34 | public native int clearTaskFile(String str);
35 |
36 | public native int createBtMagnetTask(String str, String str2, String str3, GetTaskId getTaskId);
37 |
38 | public native int createBtTask(String str, String str2, int i, int i2, int i3, GetTaskId getTaskId);
39 |
40 | public native int createCIDTask(String str, String str2, String str3, String str4, String str5, long j, int i, int i2, GetTaskId getTaskId);
41 |
42 | public native int createEmuleTask(String str, String str2, String str3, int i, int i2, GetTaskId getTaskId);
43 |
44 | public native int createP2spTask(String str, String str2, String str3, String str4, String str5, String str6, String str7, int i, int i2, GetTaskId getTaskId);
45 |
46 | public native int createShortVideoTask(String str, String str2, String str3, String str4, int i, int i2, int i3, GetTaskId getTaskId);
47 |
48 | public native int deselectBtSubTask(long j, BtIndexSet btIndexSet);
49 |
50 | public native int enterPrefetchMode(long j);
51 |
52 | public native int getBtSubTaskInfo(long j, int i, BtSubTaskDetail btSubTaskDetail);
53 |
54 | public native int getBtSubTaskStatus(long j, BtTaskStatus btTaskStatus, int i, int i2);
55 |
56 | public native int getDownloadHeader(long j, GetDownloadHead getDownloadHead);
57 |
58 | public native int getDownloadLibVersion(GetDownloadLibVersion getDownloadLibVersion);
59 |
60 | public native int getFileNameFromUrl(String str, GetFileName getFileName);
61 |
62 | public native int getLocalUrl(String str, XLTaskLocalUrl xLTaskLocalUrl);
63 |
64 | public native int getMaxDownloadSpeed(MaxDownloadSpeedParam maxDownloadSpeedParam);
65 |
66 | public native int getNameFromUrl(String str, String str2);
67 |
68 | public native int getSessionInfoByUrl(String str, XLSessionInfo xLSessionInfo);
69 |
70 | public native int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo);
71 |
72 | public native int getTaskInfoEx(long j, XLTaskInfoEx xLTaskInfoEx);
73 |
74 | public native int getTorrentInfo(String str, TorrentInfo torrentInfo);
75 |
76 | public native int getUrlQuickInfo(long j, UrlQuickInfo urlQuickInfo);
77 |
78 | public native int init(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, int i, int i2);
79 |
80 | public native boolean isLogTurnOn();
81 |
82 | public native int notifyNetWorkType(int i);
83 |
84 | public native int parserThunderUrl(String str, ThunderUrlInfo thunderUrlInfo);
85 |
86 | public native int playShortVideoBegin(long j);
87 |
88 | public native int releaseTask(long j);
89 |
90 | public native int removeAddedServerResource(long j, int i);
91 |
92 | public native int requeryIndex(long j);
93 |
94 | public native int selectBtSubTask(long j, BtIndexSet btIndexSet);
95 |
96 | public native int setBtPriorSubTask(long j, int i);
97 |
98 | public native int setDownloadTaskOrigin(long j, String str);
99 |
100 | public native int setFileName(long j, String str);
101 |
102 | public native int setHttpHeaderProperty(long j, String str, String str2);
103 |
104 | public native int setImei(String str);
105 |
106 | public native int setLocalProperty(String str, String str2);
107 |
108 | public native int setMac(String str);
109 |
110 | public native int setMiUiVersion(String str);
111 |
112 | public native int setNotifyNetWorkCarrier(int i);
113 |
114 | public native int setNotifyWifiBSSID(String str);
115 |
116 | public native int setOriginUserAgent(long j, String str);
117 |
118 | public native int setReleaseLog(int i, String str, int i2, int i3);
119 |
120 | public native int setSpeedLimit(long j, long j2);
121 |
122 | public native int setStatReportSwitch(boolean z);
123 |
124 | public native int setTaskAllowUseResource(long j, int i);
125 |
126 | public native int setTaskAppInfo(long j, String str, String str2, String str3);
127 |
128 | public native int setTaskGsState(long j, int i, int i2);
129 |
130 | public native int setTaskLxState(long j, int i, int i2);
131 |
132 | public native int setTaskUid(long j, int i);
133 |
134 | public native int setUserId(String str);
135 |
136 | public native int startDcdn(long j, int i, String str, String str2, String str3);
137 |
138 | public native int startTask(long j, boolean z);
139 |
140 | public native int statExternalInfo(long j, int i, String str, String str2);
141 |
142 | public native int stopDcdn(long j, int i);
143 |
144 | public native int stopTask(long j);
145 |
146 | public native int stopTaskWithReason(long j, int i);
147 |
148 | public native int switchOriginToAllResDownload(long j);
149 |
150 | public native int unInit();
151 |
152 | public XLLoader() {
153 | System.loadLibrary("xl_stat");
154 | System.loadLibrary("xluagc");
155 | System.loadLibrary("xl_thunder_sdk");
156 | System.loadLibrary("xl_thunder_iface");
157 | }
158 | }
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/XLTaskHelper.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.os.Handler;
6 | import android.support.annotation.Nullable;
7 | import android.text.TextUtils;
8 |
9 | import com.xunlei.downloadlib.parameter.BtIndexSet;
10 | import com.xunlei.downloadlib.parameter.BtSubTaskDetail;
11 | import com.xunlei.downloadlib.parameter.BtTaskParam;
12 | import com.xunlei.downloadlib.parameter.EmuleTaskParam;
13 | import com.xunlei.downloadlib.parameter.GetFileName;
14 | import com.xunlei.downloadlib.parameter.GetTaskId;
15 | import com.xunlei.downloadlib.parameter.InitParam;
16 | import com.xunlei.downloadlib.parameter.MagnetTaskParam;
17 | import com.xunlei.downloadlib.parameter.P2spTaskParam;
18 | import com.xunlei.downloadlib.parameter.TorrentFileInfo;
19 | import com.xunlei.downloadlib.parameter.TorrentInfo;
20 | import com.xunlei.downloadlib.parameter.XLTaskInfo;
21 | import com.xunlei.downloadlib.parameter.XLTaskLocalUrl;
22 |
23 | import java.util.concurrent.atomic.AtomicInteger;
24 |
25 | /**
26 | * Created by oceanzhang on 2017/7/27.
27 | */
28 |
29 | public class XLTaskHelper {
30 | private static final String TAG = "XLTaskHelper";
31 |
32 | public static void init(Context context) {
33 | XLDownloadManager instance = XLDownloadManager.getInstance();
34 | InitParam initParam = new InitParam();
35 | initParam.mAppKey = "xzNjAwOQ^^yb==aa214316d5e0a63a5b58db24557fa2^e";
36 | initParam.mAppVersion = "5.41.2.4980";
37 | initParam.mStatSavePath = context.getFilesDir().getPath();
38 | initParam.mStatCfgSavePath = context.getFilesDir().getPath();
39 | initParam.mPermissionLevel = 2;
40 | instance.init(context, initParam);
41 | instance.setOSVersion(Build.VERSION.INCREMENTAL);
42 | instance.setSpeedLimit(-1, -1);
43 | XLDownloadManager.getInstance().setUserId("");
44 | }
45 |
46 | private AtomicInteger seq = new AtomicInteger(0);
47 |
48 | private XLTaskHelper() {
49 | }
50 |
51 | private static volatile XLTaskHelper instance = null;
52 |
53 | public static XLTaskHelper instance() {
54 | if (instance == null) {
55 | synchronized (XLTaskHelper.class) {
56 | if (instance == null) {
57 | instance = new XLTaskHelper();
58 | }
59 | }
60 |
61 | }
62 | return instance;
63 | }
64 |
65 |
66 | /**
67 | * 添加迅雷链接任务 支持thunder:// ftp:// ed2k:// http:// https:// 协议
68 | * @param url
69 | * @param savePath 下载文件保存路径
70 | * @param fileName 下载文件名 可以通过 getFileName(url) 获取到,为空默认为getFileName(url)的值
71 | * @return
72 | */
73 | public synchronized long addThunderTask(String url, String savePath, @Nullable String fileName) {
74 | if (url.startsWith("thunder://")) url = XLDownloadManager.getInstance().parserThunderUrl(url);
75 | final GetTaskId getTaskId = new GetTaskId();
76 | if(TextUtils.isEmpty(fileName)) {
77 | GetFileName getFileName = new GetFileName();
78 | XLDownloadManager.getInstance().getFileNameFromUrl(url, getFileName);
79 | fileName = getFileName.getFileName();
80 | }
81 | if (url.startsWith("ftp://") || url.startsWith("http://") || url.startsWith("https://")) {
82 | P2spTaskParam taskParam = new P2spTaskParam();
83 | taskParam.setCreateMode(1);
84 | taskParam.setFileName(fileName);
85 | taskParam.setFilePath(savePath);
86 | taskParam.setUrl(url);
87 | taskParam.setSeqId(seq.incrementAndGet());
88 | taskParam.setCookie("");
89 | taskParam.setRefUrl("");
90 | taskParam.setUser("");
91 | taskParam.setPass("");
92 | XLDownloadManager.getInstance().createP2spTask(taskParam, getTaskId);
93 | } else if (url.startsWith("ed2k://")) {
94 | EmuleTaskParam taskParam = new EmuleTaskParam();
95 | taskParam.setFilePath(savePath);
96 | taskParam.setFileName(fileName);
97 | taskParam.setUrl(url);
98 | taskParam.setSeqId(seq.incrementAndGet());
99 | taskParam.setCreateMode(1);
100 | XLDownloadManager.getInstance().createEmuleTask(taskParam, getTaskId);
101 | }
102 |
103 | XLDownloadManager.getInstance().setDownloadTaskOrigin(getTaskId.getTaskId(), "out_app/out_app_paste");
104 | XLDownloadManager.getInstance().setOriginUserAgent(getTaskId.getTaskId(), "AndroidDownloadManager/4.4.4 (Linux; U; Android 4.4.4; Build/KTU84Q)");
105 | XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false);
106 | XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1);
107 | XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), 0, "", "", "");
108 | return getTaskId.getTaskId();
109 | }
110 |
111 | /**
112 | * 通过链接获取文件名
113 | * @param url
114 | * @return
115 | */
116 | public synchronized String getFileName(String url) {
117 | if (url.startsWith("thunder://")) url = XLDownloadManager.getInstance().parserThunderUrl(url);
118 | GetFileName getFileName = new GetFileName();
119 | XLDownloadManager.getInstance().getFileNameFromUrl(url, getFileName);
120 | return getFileName.getFileName();
121 | }
122 |
123 | /**
124 | * 添加磁力链任务
125 | * @param url 磁力链接 magnet:? 开头
126 | * @param savePath
127 | * @param fileName
128 | * @return
129 | * @throws Exception
130 | */
131 | public synchronized long addMagentTask(final String url,final String savePath,String fileName) throws Exception {
132 | if (url.startsWith("magnet:?")) {
133 | if(TextUtils.isEmpty(fileName)) {
134 | final GetFileName getFileName = new GetFileName();
135 | XLDownloadManager.getInstance().getFileNameFromUrl(url, getFileName);
136 | fileName = getFileName.getFileName();
137 | }
138 | MagnetTaskParam magnetTaskParam = new MagnetTaskParam();
139 | magnetTaskParam.setFileName(fileName);
140 | magnetTaskParam.setFilePath(savePath);
141 | magnetTaskParam.setUrl(url);
142 | final GetTaskId getTaskId = new GetTaskId();
143 | XLDownloadManager.getInstance().createBtMagnetTask(magnetTaskParam, getTaskId);
144 |
145 | XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1);
146 | XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), 0, "", "", "");
147 | XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false);
148 | return getTaskId.getTaskId();
149 | } else {
150 | throw new Exception("url illegal.");
151 | }
152 | }
153 |
154 | /**
155 | * 获取种子详情
156 | * @param torrentPath
157 | * @return
158 | */
159 | public synchronized TorrentInfo getTorrentInfo(String torrentPath) {
160 | TorrentInfo torrentInfo = new TorrentInfo();
161 | XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo);
162 | return torrentInfo;
163 | }
164 |
165 | /**
166 | * 添加种子下载任务,如果是磁力链需要先通过addMagentTask将种子下载下来
167 | * @param torrentPath 种子地址
168 | * @param savePath 保存路径
169 | * @param indexs 需要下载的文件索引
170 | * @return
171 | * @throws Exception
172 | */
173 | public synchronized long addTorrentTask(String torrentPath,String savePath,int []indexs) throws Exception {
174 | TorrentInfo torrentInfo = new TorrentInfo();
175 | XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo);
176 | TorrentFileInfo[] fileInfos = torrentInfo.mSubFileInfo;
177 | BtTaskParam taskParam = new BtTaskParam();
178 | taskParam.setCreateMode(1);
179 | taskParam.setFilePath(savePath);
180 | taskParam.setMaxConcurrent(3);
181 | taskParam.setSeqId(seq.incrementAndGet());
182 | taskParam.setTorrentPath(torrentPath);
183 | GetTaskId getTaskId = new GetTaskId();
184 | XLDownloadManager.getInstance().createBtTask(taskParam,getTaskId);
185 | if(fileInfos.length > 1 && indexs != null && indexs.length > 0) {
186 | BtIndexSet btIndexSet = new BtIndexSet(indexs.length);
187 | int i = 0;
188 | for(int index : indexs) {
189 | btIndexSet.mIndexSet[i++] = index;
190 | }
191 | XLDownloadManager.getInstance().selectBtSubTask(getTaskId.getTaskId(),btIndexSet);
192 | }
193 | XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1);
194 | // XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), currentFileInfo.mRealIndex, "", "", "");
195 | XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false);
196 | // XLDownloadManager.getInstance().setBtPriorSubTask(getTaskId.getTaskId(),currentFileInfo.mRealIndex);
197 | // XLTaskLocalUrl localUrl = new XLTaskLocalUrl();
198 | // XLDownloadManager.getInstance().getLocalUrl(savePath+"/" +(TextUtils.isEmpty(currentFileInfo.mSubPath) ? "" : currentFileInfo.mSubPath+"/")+ currentFileInfo.mFileName,localUrl);
199 | // currentFileInfo.playUrl = localUrl.mStrUrl;
200 | // currentFileInfo.hash = torrentInfo.mInfoHash;
201 | // return currentFileInfo;
202 | return getTaskId.getTaskId();
203 | }
204 |
205 | /**
206 | * 获取某个文件的本地proxy url,如果是音视频文件可以实现变下边播
207 | * @param filePath
208 | * @return
209 | */
210 | public synchronized String getLoclUrl(String filePath) {
211 | XLTaskLocalUrl localUrl = new XLTaskLocalUrl();
212 | XLDownloadManager.getInstance().getLocalUrl(filePath,localUrl);
213 | return localUrl.mStrUrl;
214 | }
215 |
216 | /**
217 | * 删除一个任务,会把文件也删掉
218 | * @param taskId
219 | * @param savePath
220 | */
221 | public synchronized void deleteTask(long taskId,final String savePath) {
222 | stopTask(taskId);
223 | new Handler(Daemon.looper()).post(new Runnable() {
224 | @Override
225 | public void run() {
226 | try {
227 | new LinuxFileCommand(Runtime.getRuntime()).deleteDirectory(savePath);
228 | } catch (Exception e) {
229 | e.printStackTrace();
230 | }
231 | }
232 | });
233 | }
234 |
235 | /**
236 | * 停止任务 文件保留
237 | * @param taskId
238 | */
239 | public synchronized void stopTask(long taskId) {
240 | XLDownloadManager.getInstance().stopTask(taskId);
241 | XLDownloadManager.getInstance().releaseTask(taskId);
242 | }
243 |
244 | /**
245 | * 获取任务详情, 包含当前状态,下载进度,下载速度,文件大小
246 | * mDownloadSize:已下载大小 mDownloadSpeed:下载速度 mFileSize:文件总大小 mTaskStatus:当前状态,0连接中1下载中 2下载完成 3失败 mAdditionalResDCDNSpeed DCDN加速 速度
247 | * @param taskId
248 | * @return
249 | */
250 | public synchronized XLTaskInfo getTaskInfo(long taskId) {
251 | XLTaskInfo taskInfo = new XLTaskInfo();
252 | XLDownloadManager.getInstance().getTaskInfo(taskId,1,taskInfo);
253 | return taskInfo;
254 | }
255 |
256 | /**
257 | * 获取种子文件子任务的详情
258 | * @param taskId
259 | * @param fileIndex
260 | * @return
261 | */
262 | public synchronized BtSubTaskDetail getBtSubTaskInfo(long taskId,int fileIndex) {
263 | BtSubTaskDetail subTaskDetail = new BtSubTaskDetail();
264 | XLDownloadManager.getInstance().getBtSubTaskInfo(taskId,fileIndex,subTaskDetail);
265 | return subTaskDetail;
266 | }
267 |
268 | /**
269 | * 开启dcdn加速
270 | * @param taskId
271 | * @param btFileIndex
272 | */
273 | public synchronized void startDcdn(long taskId,int btFileIndex) {
274 | XLDownloadManager.getInstance().startDcdn(taskId, btFileIndex, "", "", "");
275 | }
276 |
277 | /**
278 | * 停止dcdn加速
279 | * @param taskId
280 | * @param btFileIndex
281 | */
282 | public synchronized void stopDcdn(long taskId,int btFileIndex) {
283 | XLDownloadManager.getInstance().stopDcdn(taskId,btFileIndex);
284 | }
285 | }
286 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/android/LogConfig.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.android;
2 |
3 | import android.text.TextUtils;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | /* compiled from: XLLog */
10 | final class LogConfig {
11 | private final int mDestinationType;
12 | final String mFileName;
13 | final LogLevel mLevel;
14 | final String mLogDir;
15 | final long mLogSize;
16 |
17 | public LogConfig(String str) {
18 | Map parseConfigFile = parseConfigFile(str);
19 | long parseLong = Long.parseLong(getOrDefault(parseConfigFile, "LOG_FILE_SIZE", "0"));
20 | if (parseLong == 0) {
21 | parseLong = 20971520;
22 | }
23 | this.mLogSize = parseLong;
24 | this.mLevel = LogLevel.parseLevel(getOrDefault(parseConfigFile, "LOG_LEVEL", "").toLowerCase());
25 | this.mFileName = getOrDefault(parseConfigFile, "LOG_FILE", "");
26 | this.mLogDir = getOrDefault(parseConfigFile, "LOG_DIR", "");
27 | if (TextUtils.isEmpty(this.mFileName) || TextUtils.isEmpty(this.mLogDir)) {
28 | this.mDestinationType = 0;
29 | return;
30 | }
31 | int parseInt = Integer.parseInt(getOrDefault(parseConfigFile, "LOG_DESTINATION_TYPE", "0"));
32 | if (parseInt > 0) {
33 | this.mDestinationType = parseInt;
34 | } else {
35 | this.mDestinationType = 3;
36 | }
37 | }
38 |
39 | public final boolean canLogToFile() {
40 | return (this.mDestinationType & 1) > 0;
41 | }
42 |
43 | public final boolean canLogToLogCat() {
44 | return (this.mDestinationType & 2) > 0;
45 | }
46 |
47 | private String getOrDefault(Map map, String str, String str2) {
48 | String str3 = (String) map.get(str);
49 | return str3 == null ? str2 : str3;
50 | }
51 |
52 | private Map parseConfigFile(String str) {
53 | File file = new File(str);
54 | Map hashMap = new HashMap();
55 | if (file.exists()) {
56 | try {
57 | FileInputStream fileInputStream = new FileInputStream(file);
58 | String str2 = "";
59 | StringBuilder stringBuilder = new StringBuilder();
60 | StringBuilder stringBuilder2 = new StringBuilder();
61 | while (true) {
62 | int read = fileInputStream.read();
63 | if (read != -1) {
64 | if (stringBuilder.length() == 0 && read == 35) {
65 | do {
66 | read = fileInputStream.read();
67 | if (read == -1 || read == 13) {
68 | break;
69 | }
70 | } while (read != 10);
71 | } else if (!(read == 32 || read == 9)) {
72 | if (read == 61) {
73 | str2 = stringBuilder.toString();
74 | } else if (read == 10 || read == 13) {
75 | if (stringBuilder.length() != 0) {
76 | hashMap.put(str2, stringBuilder2.toString());
77 | str2 = "";
78 | stringBuilder = new StringBuilder();
79 | stringBuilder2 = new StringBuilder();
80 | }
81 | } else if (str2.length() == 0) {
82 | stringBuilder.append((char) read);
83 | } else {
84 | stringBuilder2.append((char) read);
85 | }
86 | }
87 | } else {
88 | break;
89 | }
90 | }
91 | fileInputStream.close();
92 | } catch (Exception e) {
93 | e.printStackTrace();
94 | }
95 | }
96 | return hashMap;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/android/LogLevel.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.android;
2 |
3 |
4 | /* compiled from: XLLog */
5 | enum LogLevel {
6 | LOG_LEVEL_VERBOSE(2),
7 | LOG_LEVEL_DEBUG(3),
8 | LOG_LEVEL_INFO(4),
9 | LOG_LEVEL_WARN(5),
10 | LOG_LEVEL_ERROR(6);
11 |
12 | private final int logLevel;
13 |
14 | private LogLevel(int i) {
15 | this.logLevel = i;
16 | }
17 |
18 | static LogLevel parseLevel(String str) {
19 | if (str.equals("e") || str.equals("error")) {
20 | return LOG_LEVEL_ERROR;
21 | }
22 | if (str.equals("w") || str.equals("warn")) {
23 | return LOG_LEVEL_WARN;
24 | }
25 | if (str.equals("i") || str.equals("info")) {
26 | return LOG_LEVEL_INFO;
27 | }
28 | if (str.equals("d") || str.equals("debug")) {
29 | return LOG_LEVEL_DEBUG;
30 | }
31 | return LOG_LEVEL_VERBOSE;
32 | }
33 |
34 | public final int getValue() {
35 | return this.logLevel;
36 | }
37 |
38 | public final String toString() {
39 | return toString(true);
40 | }
41 |
42 | public final String toString(boolean z) {
43 | switch (this) {
44 | case LOG_LEVEL_DEBUG:
45 | return z ? "D" : "DEBUG";
46 | case LOG_LEVEL_INFO:
47 | return z ? "I" : "INFO";
48 | case LOG_LEVEL_WARN:
49 | return z ? "W" : "WARN";
50 | case LOG_LEVEL_ERROR:
51 | return z ? "E" : "ERROR";
52 | default:
53 | if (z) {
54 | return "V";
55 | }
56 | return "VERBOSE";
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/android/XLLog.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.android;
2 |
3 | import android.os.Environment;
4 | import android.util.Log;
5 | import java.io.File;
6 |
7 | public class XLLog {
8 | private static LogConfig mLogConfig = null;
9 | private static XLLogInternal mXLLogInternal;
10 |
11 | @Deprecated
12 | public static boolean init(String str) {
13 | return init();
14 | }
15 |
16 | public static synchronized boolean init() {
17 | synchronized (XLLog.class) {
18 | if (mLogConfig == null) {
19 | File file = new File(Environment.getExternalStorageDirectory().getPath(), "xunlei_ds_log.ini");
20 | if (file.exists()) {
21 | LogConfig logConfig = new LogConfig(file.getPath());
22 | mLogConfig = logConfig;
23 | if (logConfig.canLogToFile()) {
24 | mXLLogInternal = new XLLogInternal(mLogConfig);
25 | }
26 | }
27 | }
28 | }
29 | return true;
30 | }
31 |
32 | public static void i(String str, String str2) {
33 | log(LogLevel.LOG_LEVEL_INFO, str, str2);
34 | }
35 |
36 | public static void d(String str, String str2) {
37 | log(LogLevel.LOG_LEVEL_DEBUG, str, str2);
38 | }
39 |
40 | public static void w(String str, String str2) {
41 | log(LogLevel.LOG_LEVEL_WARN, str, str2);
42 | }
43 |
44 | public static void e(String str, String str2) {
45 | log(LogLevel.LOG_LEVEL_ERROR, str, str2);
46 | }
47 |
48 | public static void w(String str, String str2, Throwable th) {
49 | log(LogLevel.LOG_LEVEL_WARN, str, str2 + ": " + th);
50 | }
51 |
52 | public static void v(String str, String str2) {
53 | d(str, str2);
54 | }
55 |
56 | public static void wtf(String str, String str2, Throwable th) {
57 | log(LogLevel.LOG_LEVEL_WARN, str, str2 + ": " + th);
58 | }
59 |
60 | public static boolean canbeLog(LogLevel logLevel) {
61 | return mXLLogInternal != null;
62 | }
63 |
64 | static void log(LogLevel logLevel, String str, String str2) {
65 | Object obj = null;
66 | if (logLevel == LogLevel.LOG_LEVEL_ERROR || (mLogConfig != null && mLogConfig.canLogToLogCat())) {
67 | obj = 1;
68 | }
69 | if (obj != null || mXLLogInternal != null) {
70 | String formatMessage = formatMessage(logLevel, str, str2);
71 | if (obj != null) {
72 | Log.println(logLevel.getValue(), str, formatMessage);
73 | }
74 | if (mXLLogInternal != null) {
75 | mXLLogInternal.log(logLevel, str, formatMessage);
76 | }
77 | }
78 | }
79 |
80 | public static void printStackTrace(Throwable th) {
81 | if (mXLLogInternal != null) {
82 | mXLLogInternal.printStackTrace(th);
83 | }
84 | }
85 |
86 | private static String formatMessage(LogLevel logLevel, String str, String str2) {
87 | StringBuilder stringBuilder = new StringBuilder(str2 + "\t");
88 | try {
89 | StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
90 | if (stackTrace.length > 5) {
91 | StackTraceElement stackTraceElement = stackTrace[5];
92 | stringBuilder.append("[" + stackTraceElement.getFileName() + ":");
93 | stringBuilder.append(stackTraceElement.getLineNumber() + "]");
94 | } else {
95 | stringBuilder.append("[stack=" + stackTrace.length + "]");
96 | }
97 | } catch (Exception e) {
98 | }
99 | return stringBuilder.toString();
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/android/XLLogInternal.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.android;
2 |
3 | import android.os.Environment;
4 | import android.os.Handler;
5 | import android.os.HandlerThread;
6 | import java.io.BufferedWriter;
7 | import java.io.File;
8 | import java.io.FileInputStream;
9 | import java.io.FileWriter;
10 | import java.io.IOException;
11 | import java.io.PrintWriter;
12 | import java.io.Writer;
13 | import java.text.SimpleDateFormat;
14 | import java.util.Date;
15 |
16 | /* compiled from: XLLog */
17 | final class XLLogInternal {
18 | private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
19 | private File mFile;
20 | private final Handler mHandler;
21 | private final LogConfig mLogConfig;
22 | private int mNext;
23 | private int mRun;
24 |
25 | XLLogInternal(LogConfig logConfig) {
26 | this.mLogConfig = logConfig;
27 | HandlerThread handlerThread = new HandlerThread("DownloadLib-XLLog");
28 | handlerThread.start();
29 | this.mHandler = new Handler(handlerThread.getLooper());
30 | }
31 |
32 | final void log(final LogLevel logLevel, final String str, String str2) {
33 | final String appendHeader = appendHeader(logLevel, str, str2);
34 | if (logLevel.getValue() >= this.mLogConfig.mLevel.getValue() && this.mLogConfig.canLogToFile()) {
35 | this.mHandler.post(new Runnable() {
36 | public void run() {
37 | XLLogInternal.this.logfile(logLevel, str, appendHeader);
38 | }
39 | });
40 | }
41 | }
42 |
43 | public final void printStackTrace(final Throwable th) {
44 | this.mHandler.post(new Runnable() {
45 | public void run() {
46 | try {
47 | Writer fileWriter = new FileWriter(XLLogInternal.this.getLogFile(), true);
48 | Writer bufferedWriter = new BufferedWriter(fileWriter);
49 | th.printStackTrace(new PrintWriter(bufferedWriter));
50 | bufferedWriter.write("\n");
51 | bufferedWriter.close();
52 | fileWriter.close();
53 | } catch (IOException e) {
54 | e.printStackTrace();
55 | }
56 | }
57 | });
58 | }
59 |
60 | private static String appendHeader(LogLevel logLevel, String str, String str2) {
61 | StringBuilder stringBuilder = new StringBuilder();
62 | stringBuilder.append(DATEFORMAT.format(new Date()) + ": " + logLevel.toString());
63 | stringBuilder.append("/" + str + "(" + Thread.currentThread().getId() + "):\t");
64 | stringBuilder.append(str2);
65 | stringBuilder.append("\r\n");
66 | return stringBuilder.toString();
67 | }
68 |
69 | private void logfile(LogLevel logLevel, String str, String str2) {
70 | try {
71 | Writer fileWriter = new FileWriter(getLogFile(), true);
72 | BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
73 | bufferedWriter.write(str2);
74 | bufferedWriter.newLine();
75 | bufferedWriter.close();
76 | fileWriter.close();
77 | } catch (Exception e) {
78 | }
79 | }
80 |
81 | private File getLogFile() {
82 | if ("mounted".equalsIgnoreCase(Environment.getExternalStorageState())) {
83 | File file = new File(Environment.getExternalStorageDirectory().getPath() + File.separator + this.mLogConfig.mLogDir);
84 | if (!file.exists()) {
85 | file.mkdirs();
86 | }
87 | while (this.mFile == null) {
88 | this.mFile = new File(file.getPath() + File.separator + new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".R" + this.mRun + ".0." + this.mLogConfig.mFileName);
89 | if (!this.mFile.exists()) {
90 | break;
91 | }
92 | this.mRun++;
93 | this.mFile = null;
94 | }
95 | if (getLogFileSize() >= this.mLogConfig.mLogSize) {
96 | this.mNext++;
97 | this.mFile = new File(file.getPath() + File.separator + new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".R" + this.mRun + "." + this.mNext + "." + this.mLogConfig.mFileName);
98 | this.mFile.delete();
99 | }
100 | }
101 | return this.mFile;
102 | }
103 |
104 | private long getLogFileSize() {
105 | long j = -1;
106 | if (this.mFile == null) {
107 | return -1;
108 | }
109 | try {
110 | FileInputStream fileInputStream = new FileInputStream(this.mFile);
111 | j = (long) fileInputStream.available();
112 | fileInputStream.close();
113 | return j;
114 | } catch (Exception e) {
115 | return j;
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/android/XLUtil.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.android;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.net.ConnectivityManager;
6 | import android.net.NetworkInfo;
7 | import android.net.wifi.WifiInfo;
8 | import android.net.wifi.WifiManager;
9 | import android.os.Build;
10 | import android.os.Build.VERSION;
11 | import android.telephony.TelephonyManager;
12 | import android.text.TextUtils;
13 | import android.util.Base64;
14 | import java.io.FileNotFoundException;
15 | import java.io.IOException;
16 | import java.io.InputStream;
17 | import java.io.OutputStream;
18 | import java.io.UnsupportedEncodingException;
19 | import java.net.NetworkInterface;
20 | import java.security.MessageDigest;
21 | import java.security.NoSuchAlgorithmException;
22 | import java.util.Collections;
23 | import java.util.HashMap;
24 | import java.util.Iterator;
25 | import java.util.Map;
26 | import java.util.Map.Entry;
27 | import java.util.concurrent.locks.ReadWriteLock;
28 | import java.util.concurrent.locks.ReentrantReadWriteLock;
29 | import org.json.JSONException;
30 | import org.json.JSONObject;
31 |
32 | public class XLUtil {
33 | private static final int IMEI_LEN = 15;
34 | private static final String TAG = "XLUtil";
35 | private static final ConfigFile sConfigFile = new ConfigFile();
36 |
37 | private static class ConfigFile {
38 | private static final String IDENTIFY_FILE_NAME = "Identify.txt";
39 | private Map configMap;
40 | private ReadWriteLock lock;
41 |
42 | private ConfigFile() {
43 | this.configMap = new HashMap();
44 | this.lock = new ReentrantReadWriteLock();
45 | }
46 |
47 | String get(Context context, String str, String str2) {
48 | this.lock.readLock().lock();
49 | String str3 = (String) this.configMap.get(str);
50 | if (str3 == null) {
51 | loadFile(context);
52 | str3 = (String) this.configMap.get(str);
53 | }
54 | this.lock.readLock().unlock();
55 | return str3 != null ? str3 : str2;
56 | }
57 |
58 | void set(Context context, String str, String str2) {
59 | this.lock.writeLock().lock();
60 | this.configMap.put(str, str2);
61 | saveFile(context);
62 | this.lock.writeLock().unlock();
63 | XLLog.i(XLUtil.TAG, "ConfigFile set key=" + str + " value=" + str2);
64 | }
65 |
66 | private void loadFile(Context context) {
67 | XLLog.i(XLUtil.TAG, "loadAndParseFile start");
68 | if (context == null || IDENTIFY_FILE_NAME == null) {
69 | XLLog.e(XLUtil.TAG, "loadAndParseFile end, parameter invalid, fileName:Identify.txt");
70 | return;
71 | }
72 | String readFromFile = readFromFile(context, IDENTIFY_FILE_NAME);
73 | if (readFromFile == null) {
74 | XLLog.i(XLUtil.TAG, "loadAndParseFile end, fileContext is empty");
75 | return;
76 | }
77 | this.configMap.clear();
78 | String[] split = readFromFile.split("\n");
79 | for (String split2 : split) {
80 | String[] split3 = split2.split("=");
81 | if (split3.length == 2) {
82 | this.configMap.put(split3[0], split3[1]);
83 | XLLog.i(XLUtil.TAG, "ConfigFile loadFile key=" + split3[0] + " value=" + split3[1]);
84 | }
85 | }
86 | XLLog.i(XLUtil.TAG, "loadAndParseFile end");
87 | }
88 |
89 | private void saveFile(Context context) {
90 | StringBuilder stringBuilder = new StringBuilder();
91 | for (Entry entry : this.configMap.entrySet()) {
92 | stringBuilder.append(((String) entry.getKey()) + "=" + ((String) entry.getValue()) + "\n");
93 | }
94 | writeToFile(context, stringBuilder.toString(), IDENTIFY_FILE_NAME);
95 | }
96 |
97 | private void writeToFile(Context context, String str, String str2) {
98 | if (context == null || str == null || str2 == null) {
99 | XLLog.e(XLUtil.TAG, "writeToFile, Parameter invalid, fileName:" + str2);
100 | return;
101 | }
102 | try {
103 | OutputStream openFileOutput = context.openFileOutput(str2, 0);
104 | try {
105 | openFileOutput.write(str.getBytes("utf-8"));
106 | openFileOutput.close();
107 | } catch (UnsupportedEncodingException e) {
108 | e.printStackTrace();
109 | } catch (IOException e2) {
110 | e2.printStackTrace();
111 | }
112 | } catch (FileNotFoundException e3) {
113 | e3.printStackTrace();
114 | }
115 | }
116 |
117 | private String readFromFile(Context context, String str) {
118 | String str2 = null;
119 | if (context == null || str == null) {
120 | XLLog.e(XLUtil.TAG, "readFromFile, parameter invalid, fileName:" + str);
121 | } else {
122 | try {
123 | InputStream openFileInput = context.openFileInput(str);
124 | byte[] bArr = new byte[256];
125 | try {
126 | int read = openFileInput.read(bArr);
127 | if (read > 0) {
128 | str2 = new String(bArr, 0, read, "utf-8");
129 | }
130 | openFileInput.close();
131 | } catch (IOException e) {
132 | e.printStackTrace();
133 | }
134 | } catch (FileNotFoundException e2) {
135 | XLLog.i(XLUtil.TAG, str + " File Not Found");
136 | }
137 | }
138 | return str2;
139 | }
140 | }
141 |
142 | public enum GUID_TYPE {
143 | DEFAULT,
144 | JUST_IMEI,
145 | JUST_MAC,
146 | ALL
147 | }
148 |
149 | public static class GuidInfo {
150 | public String mGuid = null;
151 | public GUID_TYPE mType = GUID_TYPE.DEFAULT;
152 | }
153 |
154 | public enum NetWorkCarrier {
155 | UNKNOWN,
156 | CMCC,
157 | CU,
158 | CT
159 | }
160 |
161 | public static long getCurrentUnixTime() {
162 | return System.currentTimeMillis() / 1000;
163 | }
164 |
165 | public static String getPeerid(Context context) {
166 | if (context == null) {
167 | return null;
168 | }
169 | String str = sConfigFile.get(context, "peerid", null);
170 | if (!TextUtils.isEmpty(str)) {
171 | return str;
172 | }
173 | String mac = getMAC(context);
174 | if (TextUtils.isEmpty(mac)) {
175 | mac = getIMEI(context);
176 | if (!TextUtils.isEmpty(mac)) {
177 | str = mac + "V";
178 | }
179 | } else {
180 | str = mac + "004V";
181 | }
182 | if (TextUtils.isEmpty(str)) {
183 | return null;
184 | }
185 | sConfigFile.set(context, "peerid", str);
186 | return str;
187 | }
188 |
189 | public static String getMAC(Context context) {
190 | String str = null;
191 | if (context != null) {
192 | str = sConfigFile.get(context, "MAC", null);
193 | if (TextUtils.isEmpty(str)) {
194 | str = getWifiMacAddress();
195 | if (!TextUtils.isEmpty(str)) {
196 | sConfigFile.set(context, "MAC", str);
197 | }
198 | }
199 | }
200 | return str;
201 | }
202 |
203 | @SuppressLint({"NewApi"})
204 | public static String getWifiMacAddress() {
205 | try {
206 | String str = "wlan0";
207 | for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
208 | if (networkInterface.getName().equalsIgnoreCase(str)) {
209 | byte[] hardwareAddress = networkInterface.getHardwareAddress();
210 | if (hardwareAddress == null) {
211 | return null;
212 | }
213 | StringBuilder stringBuilder = new StringBuilder();
214 | int length = hardwareAddress.length;
215 | for (int i = 0; i < length; i++) {
216 | stringBuilder.append(String.format("%02X", new Object[]{Byte.valueOf(hardwareAddress[i])}));
217 | }
218 | return stringBuilder.toString();
219 | }
220 | }
221 | } catch (Exception e) {
222 | e.printStackTrace();
223 | }
224 | return null;
225 | }
226 |
227 | public static String getIMEI(Context context) {
228 | Exception e;
229 | if (context == null) {
230 | return null;
231 | }
232 | String str = sConfigFile.get(context, "IMEI", null);
233 | if (!TextUtils.isEmpty(str)) {
234 | return str;
235 | }
236 | String deviceId;
237 | TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
238 | if (telephonyManager != null) {
239 | try {
240 | deviceId = telephonyManager.getDeviceId();
241 | if (deviceId != null) {
242 | try {
243 | if (deviceId.length() < 15) {
244 | str = deviceId;
245 | int length = 15 - deviceId.length();
246 | while (true) {
247 | int i = length - 1;
248 | if (length <= 0) {
249 | break;
250 | }
251 | str = str + "M";
252 | length = i;
253 | }
254 | deviceId = str;
255 | }
256 | sConfigFile.set(context, "IMEI", deviceId);
257 | } catch (Exception e2) {
258 | e = e2;
259 | e.printStackTrace();
260 | return deviceId;
261 | }
262 | }
263 | } catch (Exception e3) {
264 | Exception exception = e3;
265 | deviceId = str;
266 | e = exception;
267 | }
268 | } else {
269 | deviceId = str;
270 | }
271 | return deviceId;
272 | }
273 |
274 | public static GuidInfo generateGuid(Context context) {
275 | GuidInfo guidInfo = new GuidInfo();
276 | GUID_TYPE guid_type = GUID_TYPE.DEFAULT;
277 | String imei = getIMEI(context);
278 | if (TextUtils.isEmpty(imei)) {
279 | imei = "000000000000000";
280 | } else {
281 | guid_type = GUID_TYPE.JUST_IMEI;
282 | }
283 | String mac = getMAC(context);
284 | if (TextUtils.isEmpty(mac)) {
285 | mac = "000000000000";
286 | } else if (guid_type == GUID_TYPE.JUST_IMEI) {
287 | guid_type = GUID_TYPE.ALL;
288 | } else {
289 | guid_type = GUID_TYPE.JUST_MAC;
290 | }
291 | guidInfo.mGuid = imei + "_" + mac;
292 | guidInfo.mType = guid_type;
293 | return guidInfo;
294 | }
295 |
296 | public static String getOSVersion(Context context) {
297 | StringBuilder stringBuilder = new StringBuilder();
298 | stringBuilder.append("SDKV = " + VERSION.RELEASE);
299 | stringBuilder.append("_MANUFACTURER = " + Build.MANUFACTURER);
300 | stringBuilder.append("_MODEL = " + Build.MODEL);
301 | stringBuilder.append("_PRODUCT = " + Build.PRODUCT);
302 | stringBuilder.append("_FINGERPRINT = " + Build.FINGERPRINT);
303 | stringBuilder.append("_CPU_ABI = " + Build.CPU_ABI);
304 | stringBuilder.append("_ID = " + Build.ID);
305 | return stringBuilder.toString();
306 | }
307 |
308 | public static String getAPNName(Context context) {
309 | if (context == null) {
310 | return null;
311 | }
312 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
313 | if (connectivityManager == null) {
314 | return null;
315 | }
316 | NetworkInfo networkInfo = connectivityManager.getNetworkInfo(0);
317 | if (networkInfo == null) {
318 | return null;
319 | }
320 | return networkInfo.getExtraInfo();
321 | }
322 |
323 | public static String getSSID(Context context) {
324 | if (context == null) {
325 | XLLog.e(TAG, "getSSID, context invalid");
326 | return null;
327 | }
328 | WifiManager wifiManager = (WifiManager) context.getSystemService("wifi");
329 | if (wifiManager != null) {
330 | WifiInfo connectionInfo = wifiManager.getConnectionInfo();
331 | if (connectionInfo != null) {
332 | return connectionInfo.getSSID();
333 | }
334 | }
335 | return null;
336 | }
337 |
338 | public static String getBSSID(Context context) {
339 | if (context == null) {
340 | XLLog.e(TAG, "getBSSID, context invalid");
341 | return null;
342 | }
343 | WifiManager wifiManager = (WifiManager) context.getSystemService("wifi");
344 | if (wifiManager != null) {
345 | try {
346 | WifiInfo connectionInfo = wifiManager.getConnectionInfo();
347 | if (connectionInfo != null) {
348 | return connectionInfo.getBSSID();
349 | }
350 | } catch (Exception e) {
351 | }
352 | }
353 | return null;
354 | }
355 |
356 | public static int getNetworkTypeComplete(Context context) {
357 | if (context == null) {
358 | XLLog.e(TAG, "getNetworkTypeComplete, context invalid");
359 | return 0;
360 | }
361 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
362 | if (connectivityManager == null) {
363 | return 0;
364 | }
365 | NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
366 | if (activeNetworkInfo == null) {
367 | return 0;
368 | }
369 | int type = activeNetworkInfo.getType();
370 | if (type == 1) {
371 | return 9;
372 | }
373 | if (type != 0) {
374 | return 5;
375 | }
376 | int i;
377 | switch (activeNetworkInfo.getSubtype()) {
378 | case 1:
379 | case 2:
380 | case 4:
381 | case 7:
382 | case 11:
383 | return 2;
384 | case 3:
385 | case 5:
386 | case 6:
387 | case 8:
388 | case 9:
389 | case 10:
390 | case 12:
391 | case 14:
392 | case 15:
393 | return 3;
394 | case 13:
395 | i = 4;
396 | break;
397 | default:
398 | i = 0;
399 | break;
400 | }
401 | return i;
402 | }
403 |
404 | public static int getNetworkTypeSimple(Context context) {
405 | if (context == null) {
406 | XLLog.e(TAG, "getNetworkTypeSimple, context invalid");
407 | return 0;
408 | }
409 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
410 | if (connectivityManager == null) {
411 | return 1;
412 | }
413 | NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
414 | if (activeNetworkInfo == null) {
415 | return 1;
416 | }
417 | int type = activeNetworkInfo.getType();
418 | if (type == 1) {
419 | return 2;
420 | }
421 | if (type != 0) {
422 | return 1;
423 | }
424 | int i;
425 | switch (activeNetworkInfo.getSubtype()) {
426 | case 1:
427 | case 2:
428 | case 3:
429 | case 4:
430 | case 5:
431 | case 6:
432 | case 7:
433 | case 8:
434 | case 9:
435 | case 10:
436 | case 11:
437 | case 12:
438 | case 13:
439 | case 14:
440 | case 15:
441 | i = 3;
442 | break;
443 | default:
444 | i = 1;
445 | break;
446 | }
447 | return i;
448 | }
449 |
450 | public static String getMd5(String str) {
451 | if (str == null) {
452 | XLLog.e(TAG, "getMd5, key invalid");
453 | return null;
454 | }
455 | try {
456 | char[] cArr = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
457 | MessageDigest instance = MessageDigest.getInstance("MD5");
458 | byte[] bytes = str.getBytes();
459 | instance.update(bytes, 0, bytes.length);
460 | byte[] digest = instance.digest();
461 | StringBuilder stringBuilder = new StringBuilder(32);
462 | for (byte b : digest) {
463 | stringBuilder.append(cArr[(b >> 4) & 15]).append(cArr[(b >> 0) & 15]);
464 | }
465 | return stringBuilder.toString();
466 | } catch (NoSuchAlgorithmException e) {
467 | e.printStackTrace();
468 | return str;
469 | }
470 | }
471 |
472 | public static String generateAppKey(String str, short s, byte b) {
473 | if (str == null) {
474 | XLLog.e(TAG, "generateAppKey, appName invalid");
475 | return null;
476 | }
477 | int length = str.length();
478 | byte[] bArr = new byte[(((length + 1) + 2) + 1)];
479 | byte[] bytes = str.getBytes();
480 | for (int i = 0; i < bytes.length; i++) {
481 | bArr[i] = bytes[i];
482 | }
483 | bArr[length] = (byte) 0;
484 | bArr[length + 1] = (byte) (s & 255);
485 | bArr[length + 2] = (byte) ((s >> 8) & 255);
486 | bArr[length + 3] = b;
487 | return new String(Base64.encode(bArr, 0)).trim();
488 | }
489 |
490 | public static Map parseJSONString(String str) {
491 | if (str == null) {
492 | XLLog.e(TAG, "parseJSONString, JSONString invalid");
493 | return null;
494 | }
495 | Map hashMap = new HashMap();
496 | try {
497 | JSONObject jSONObject = new JSONObject(str);
498 | Iterator keys = jSONObject.keys();
499 | while (keys.hasNext()) {
500 | String str2 = (String) keys.next();
501 | hashMap.put(str2, jSONObject.getString(str2));
502 | }
503 | } catch (JSONException e) {
504 | e.printStackTrace();
505 | }
506 | return hashMap;
507 | }
508 |
509 | public static NetWorkCarrier getNetWorkCarrier(Context context) {
510 | if (context != null) {
511 | TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
512 | if (telephonyManager != null) {
513 | try {
514 | String subscriberId = telephonyManager.getSubscriberId();
515 | if (subscriberId.startsWith("46000") || subscriberId.startsWith("46002")) {
516 | return NetWorkCarrier.CMCC;
517 | }
518 | if (subscriberId.startsWith("46001")) {
519 | return NetWorkCarrier.CU;
520 | }
521 | if (subscriberId.startsWith("46003")) {
522 | return NetWorkCarrier.CT;
523 | }
524 | } catch (Exception e) {
525 | e.printStackTrace();
526 | }
527 | }
528 | }
529 | return NetWorkCarrier.UNKNOWN;
530 | }
531 | }
532 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/BtIndexSet.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class BtIndexSet {
4 | public int[] mIndexSet;
5 |
6 | public BtIndexSet(int i) {
7 | this.mIndexSet = new int[i];
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/BtSubTaskDetail.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class BtSubTaskDetail {
4 | public int mFileIndex;
5 | public boolean mIsSelect;
6 | public XLTaskInfo mTaskInfo = new XLTaskInfo();
7 | }
8 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/BtTaskParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class BtTaskParam {
4 | public int mCreateMode;
5 | public String mFilePath;
6 | public int mMaxConcurrent;
7 | public int mSeqId;
8 | public String mTorrentPath;
9 |
10 | public BtTaskParam() {
11 | }
12 |
13 | public BtTaskParam(String str, String str2, int i, int i2, int i3) {
14 | this.mTorrentPath = str;
15 | this.mFilePath = str2;
16 | this.mMaxConcurrent = i;
17 | this.mCreateMode = i2;
18 | this.mSeqId = i3;
19 | }
20 |
21 | public void setTorrentPath(String str) {
22 | this.mTorrentPath = str;
23 | }
24 |
25 | public void setFilePath(String str) {
26 | this.mFilePath = str;
27 | }
28 |
29 | public void setMaxConcurrent(int i) {
30 | this.mMaxConcurrent = i;
31 | }
32 |
33 | public void setCreateMode(int i) {
34 | this.mCreateMode = i;
35 | }
36 |
37 | public void setSeqId(int i) {
38 | this.mSeqId = i;
39 | }
40 |
41 | public boolean checkMemberVar() {
42 | if (this.mTorrentPath == null || this.mFilePath == null) {
43 | return false;
44 | }
45 | return true;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/BtTaskStatus.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class BtTaskStatus {
4 | public int[] mStatus;
5 |
6 | public BtTaskStatus(int i) {
7 | this.mStatus = new int[i];
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/CIDTaskParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class CIDTaskParam {
4 | public String mBcid;
5 | public String mCid;
6 | public int mCreateMode;
7 | public String mFileName;
8 | public String mFilePath;
9 | public long mFileSize;
10 | public String mGcid;
11 | public int mSeqId;
12 |
13 | public CIDTaskParam(String str, String str2, String str3, String str4, String str5, long j, int i, int i2) {
14 | this.mCid = str;
15 | this.mGcid = str2;
16 | this.mBcid = str3;
17 | this.mFilePath = str4;
18 | this.mFileName = str5;
19 | this.mFileSize = j;
20 | this.mCreateMode = i;
21 | this.mSeqId = i2;
22 | }
23 |
24 | public void setCid(String str) {
25 | this.mCid = str;
26 | }
27 |
28 | public void setGcid(String str) {
29 | this.mGcid = str;
30 | }
31 |
32 | public void setBcid(String str) {
33 | this.mBcid = str;
34 | }
35 |
36 | public void setFilePath(String str) {
37 | this.mFilePath = str;
38 | }
39 |
40 | public void setFileName(String str) {
41 | this.mFileName = str;
42 | }
43 |
44 | public void setFileSize(long j) {
45 | this.mFileSize = j;
46 | }
47 |
48 | public void setCreateMode(int i) {
49 | this.mCreateMode = i;
50 | }
51 |
52 | public void setSeqId(int i) {
53 | this.mSeqId = i;
54 | }
55 |
56 | public boolean checkMemberVar() {
57 | if (this.mCid == null || this.mGcid == null || this.mBcid == null || this.mFilePath == null || this.mFileName == null) {
58 | return false;
59 | }
60 | return true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/EmuleTaskParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class EmuleTaskParam {
4 | public int mCreateMode;
5 | public String mFileName;
6 | public String mFilePath;
7 | public int mSeqId;
8 | public String mUrl;
9 |
10 | public EmuleTaskParam() {
11 | }
12 |
13 | public EmuleTaskParam(String str, String str2, String str3, int i, int i2) {
14 | this.mFileName = str;
15 | this.mFilePath = str2;
16 | this.mUrl = str3;
17 | this.mCreateMode = i;
18 | this.mSeqId = i2;
19 | }
20 |
21 | public void setFileName(String str) {
22 | this.mFileName = str;
23 | }
24 |
25 | public void setFilePath(String str) {
26 | this.mFilePath = str;
27 | }
28 |
29 | public void setUrl(String str) {
30 | this.mUrl = str;
31 | }
32 |
33 | public void setCreateMode(int i) {
34 | this.mCreateMode = i;
35 | }
36 |
37 | public void setSeqId(int i) {
38 | this.mSeqId = i;
39 | }
40 |
41 | public boolean checkMemberVar() {
42 | if (this.mFileName == null || this.mFilePath == null || this.mUrl == null) {
43 | return false;
44 | }
45 | return true;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/ErrorCodeToMsg.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class ErrorCodeToMsg {
4 | public static final String ErrCodeToMsg = "{ \"9000\": \"XL_NO_ERRNO \" , \"9101\": \"XL_ALREADY_INIT \" , \"9102\": \"XL_SDK_NOT_INIT \" , \"9103\": \"XL_TASK_ALREADY_EXIST \" , \"9104\": \"XL_TASK_NOT_EXIST \" , \"9105\": \"XL_TASK_ALREADY_STOPPED \" , \"9106\": \"XL_TASK_ALREADY_RUNNING \" , \"9107\": \"XL_TASK_NOT_START \" , \"9108\": \"XL_TASK_STILL_RUNNING \" , \"9109\": \"XL_FILE_EXISTED \" , \"9110\": \"XL_DISK_FULL \" , \"9111\": \"XL_TOO_MUCH_TASK \" , \"9112\": \"XL_PARAM_ERROR \" , \"9113\": \"XL_SCHEMA_NOT_SUPPORT \" , \"9114\": \"XL_DYNAMIC_PARAM_FAIL \" , \"9115\": \"XL_CONTINUE_NO_NAME \" , \"9116\": \"XL_APPNAME_APPKEY_ERROR \" , \"9117\": \"XL_CREATE_THREAD_ERROR \" , \"9118\": \"XL_TASK_FINISH \" , \"9119\": \"XL_TASK_NOT_RUNNING \" , \"9120\": \"XL_TASK_NOT_IDLE \" , \"9121\": \"XL_TASK_TYPE_NOT_SUPPORT \" , \"9122\": \"XL_ADD_RESOURCE_ERROR \" , \"9123\": \"XL_TASK_LOADING_CFG \" , \"9301\": \"XL_NO_ENOUGH_BUFFER \" , \"9302\": \"XL_TORRENT_PARSE_ERROR \" , \"9303\": \"XL_INDEX_NOT_READY \" , \"9304\": \"XL_TORRENT_IMCOMPLETE \" , \"9900\": \"DOWNLOAD_MANAGER_ERROR \" , \"9901\": \"APPKEY_CHECKER_ERROR \" , \"111024\": \"COMMON_ERRCODE_BASE \" , \"111025\": \"TARGET_THREAD_STOPING \" , \"111026\": \"OUT_OF_MEMORY \" , \"111031\": \"TASK_USE_TOO_MUCH_MEM \" , \"111032\": \"OUT_OF_FIXED_MEMORY \" , \"111033\": \"QUEUE_NO_ROOM \" , \"111035\": \"MAP_UNINIT \" , \"111036\": \"MAP_DUPLICATE_KEY \" , \"111037\": \"MAP_KEY_NOT_FOUND \" , \"111038\": \"INVALID_ITERATOR \" , \"111039\": \"BUFFER_OVERFLOW \" , \"111041\": \"INVALID_ARGUMENT \" , \"111048\": \"INVALID_SOCKET_DESCRIPTOR \" , \"111050\": \"ERROR_INVALID_INADDR \" , \"111181\": \"REDIRECT_TOO_MUCH \" , \"111057\": \"NOT_IMPLEMENT \" , \"111074\": \"INVALID_TIMER_INDEX \" , \"111078\": \"DNS_INVALID_ADDR \" , \"111083\": \"BAD_DIR_PATH \" , \"111084\": \"FILE_CANNOT_TRUNCATE \" , \"111085\": \"INSUFFICIENT_DISK_SPACE \" , \"111086\": \"FILE_TOO_BIG \" , \"111118\": \"DISPATCHER_ERRCODE_BASE \" , \"111119\": \"DATA_MGR_ERRCODE_BASE \" , \"111120\": \"ALLOC_INVALID_SIZE \" , \"111121\": \"DATA_BUFFER_IS_FULL \" , \"111122\": \"BLOCK_NO_INVALID \" , \"111123\": \"CHECK_DATA_BUFFER_NOT_ENOUG \" , \"111124\": \"BCID_CHECK_FAIL \" , \"111125\": \"BCID_ONCE_CHECT_TOO_MUCH \" , \"111126\": \"READ_FILE_ERR \" , \"111127\": \"WRITE_FILE_ERR \" , \"111128\": \"OPEN_FILE_ERR \" , \"111129\": \"FILE_PATH_TOO_LONG \" , \"111130\": \"SD_INVALID_FILE_SIZE \" , \"111131\": \"FILE_CFG_MAGIC_ERROR \" , \"111132\": \"FILE_CFG_READ_ERROR \" , \"111133\": \"FILE_CFG_WRITE_ERROR \" , \"111134\": \"FILE_CFG_READ_HEADER_ERROR \" , \"111135\": \"FILE_CFG_RESOLVE_ERROR \" , \"111136\": \"TASK_FAILURE_NO_DATA_PIPE \" , \"111137\": \"NO_FILE_NAME \" , \"111138\": \"CANNOT_GET_FILE_NAME \" , \"111139\": \"CREATE_FILE_FAIL \" , \"111140\": \"OPEN_OLD_FILE_FAIL \" , \"111141\": \"FILE_SIZE_NOT_BELIEVE \" , \"111142\": \"FILE_SIZE_TOO_SMALL \" , \"111143\": \"FILE_NOT_EXIST \" , \"111144\": \"FILE_INVALID_PARA \" , \"111145\": \"FILE_CREATING \" , \"111146\": \"FIL_INFO_INVALID_DATA \" , \"111147\": \"FIL_INFO_RECVED_DATA \" , \"111159\": \"CONF_MGR_ERRCODE_BASE \" , \"111160\": \"SETTINGS_ERR_UNKNOWN \" , \"111161\": \"SETTINGS_ERR_INVALID_FILE_NAME \" , \"111162\": \"SETTINGS_ERR_CFG_FILE_NOT_EXIST \" , \"111163\": \"SETTINGS_ERR_INVALID_LINE \" , \"111164\": \"SETTINGS_ERR_INVALID_ITEM_NAME \" , \"111165\": \"SETTINGS_ERR_INVALID_ITEM_VALUE \" , \"111166\": \"SETTINGS_ERR_LIST_EMPTY \" , \"111167\": \"SETTINGS_ERR_ITEM_NOT_FOUND \" , \"111168\": \"NET_REACTOR_ERRCODE_BASE \" , \"111169\": \"NET_CONNECT_SSL_ERR \" , \"111170\": \"NET_BROKEN_PIPE \" , \"111171\": \"NET_CONNECTION_REFUSED \" , \"111172\": \"NET_SSL_GET_FD_ERROR \" , \"111173\": \"NET_OP_CANCEL \" , \"111174\": \"NET_UNKNOWN_ERROR \" , \"111175\": \"NET_NORMAL_CLOSE \" , \"111176\": \"TASK_FAIL_LONG_TIME_NO_RECV_DATA \" , \"111177\": \"TASK_FILE_SIZE_TOO_LARGE \" , \"111178\": \"TASK_RETRY_ALWAY_FAIL \" , \"111300\": \"ASYN_FILE_E_BASE \" , \"111301\": \"ASYN_FILE_E_OP_NONE \" , \"111302\": \"ASYN_FILE_E_OP_BUSY \" , \"111303\": \"ASYN_FILE_E_FILE_NOT_OPEN \" , \"111304\": \"ASYN_FILE_E_FILE_REOPEN \" , \"111305\": \"ASYN_FILE_E_EMPTY_FILE \" , \"111306\": \"ASYN_FILE_E_FILE_SIZE_LESS \" , \"111307\": \"ASYN_FILE_E_TOO_MUCH_DATA \" , \"111308\": \"ASYN_FILE_E_FILE_CLOSING \" , \"112400\": \"ERR_PTL_PROTOCOL_NOT_SUPPORT \" , \"112500\": \"ERR_PTL_PEER_OFFLINE \" , \"112600\": \"ERR_PTL_GET_PEERSN_FAILED \" , \"11300\": \"P2P_PIPE_ERRCODE_BASE\t\t\t \" , \"11301\": \"ERR_P2P_VERSION_NOT_SUPPORT\t\t \" , \"11302\": \"ERR_P2P_WAITING_CLOSE\t\t\t \" , \"11303\": \"ERR_P2P_HANDSHAKE_RESP_FAIL\t\t \" , \"11304\": \"ERR_P2P_REQUEST_RESP_FAIL\t\t \" , \"11305\": \"ERR_P2P_UPLOAD_OVER_MAX\t\t\t \" , \"11306\": \"ERR_P2P_REMOTE_UNKNOWN_MY_CMD\t \" , \"11307\": \"ERR_P2P_NOT_SUPPORT_UDT\t\t\t \" , \"11308\": \"ERR_P2P_BROKER_CONNECT\t\t\t \" , \"11309\": \"ERR_P2P_INVALID_COMMAND\t\t\t \" , \"11310\": \"ERR_P2P_INVALID_PARAM\t\t\t \" , \"11311\": \"ERR_P2P_CONNECT_FAILED\t\t\t \" , \"11312\": \"ERR_P2P_CONNECT_UPLOAD_SLOW\t \" , \"11313\": \"ERR_P2P_ALLOC_MEM_ERR \" , \"11314\": \"ERR_P2P_SEND_HANDSHAKE \" , \"114001\": \"TASK_FAILURE_QUERY_EMULE_HUB_FAILED\" , \"114101\": \"TASK_FAILURE_EMULE_NO_RECORD \" , \"114002\": \"TASK_FAILURE_SUBTASK_FAILED \" , \"114003\": \"TASK_FAILURE_CANNOT_START_SUBTASK \" , \"114004\": \"TASK_FAILURE_QUERY_BT_HUB_FAILED \" , \"114005\": \"TASK_FAILURE_PARSE_TORRENT_FAILED \" , \"114006\": \"TASK_FAILURE_GET_TORRENT_FAILED \" , \"114007\": \"TASK_FAILURE_SAVE_TORRENT_FAILED \" , \"115000\": \"RES_QUERY_E_BASE \" , \"115100\": \"HTTP_HUB_CLIENT_E_BASE \" , \"116000\": \"IP6_ERRCODE_BASE \" , \"116001\": \"ERR_INVALID_ADDRESS_FAMILY \" , \"116002\": \"IP6_INVALID_IN6ADDR \" , \"116003\": \"IP6_NOT_SUPPORT_SSL \" , \"117000\": \"PAUSE_TASK_WRITE_CFG_ERR \" , \"117001\": \"PAUSE_TASK_WRITE_DATA_TIMEOUT \" }";
5 | }
6 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/GetDownloadHead.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class GetDownloadHead {
4 | public String mHttpResponse = null;
5 | public int mHttpState = -1;
6 | }
7 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/GetDownloadLibVersion.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class GetDownloadLibVersion {
4 | public String mVersion = null;
5 | }
6 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/GetFileName.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class GetFileName {
4 | private String mFileName;
5 |
6 | public String getFileName() {
7 | return this.mFileName;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/GetTaskId.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class GetTaskId {
4 | private long mTaskId;
5 |
6 | public long getTaskId() {
7 | return this.mTaskId;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/InitParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class InitParam {
4 | public String mAppKey;
5 | public String mAppVersion;
6 | public int mPermissionLevel;
7 | public String mStatCfgSavePath;
8 | public String mStatSavePath;
9 |
10 | public InitParam(String str, String str2, String str3, String str4, int i) {
11 | this.mAppKey = str;
12 | this.mAppVersion = str2;
13 | this.mStatSavePath = str3;
14 | this.mStatCfgSavePath = str4;
15 | this.mPermissionLevel = i;
16 | }
17 |
18 | public InitParam() {
19 | }
20 |
21 | public boolean checkMemberVar() {
22 | if (this.mAppKey == null || this.mAppVersion == null || this.mStatSavePath == null || this.mStatCfgSavePath == null) {
23 | return false;
24 | }
25 | return true;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/MagnetTaskParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class MagnetTaskParam {
4 | public String mFileName;
5 | public String mFilePath;
6 | public String mUrl;
7 |
8 | public MagnetTaskParam(String str, String str2, String str3) {
9 | this.mFileName = str;
10 | this.mFilePath = str2;
11 | this.mUrl = str3;
12 | }
13 |
14 | public MagnetTaskParam() {
15 | }
16 |
17 | public void setUrl(String str) {
18 | this.mUrl = str;
19 | }
20 |
21 | public void setFileName(String str) {
22 | this.mFileName = str;
23 | }
24 |
25 | public void setFilePath(String str) {
26 | this.mFilePath = str;
27 | }
28 |
29 |
30 |
31 | public boolean checkMemberVar() {
32 | if (this.mFileName == null || this.mFilePath == null || this.mUrl == null) {
33 | return false;
34 | }
35 | return true;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/MaxDownloadSpeedParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class MaxDownloadSpeedParam {
4 | public long mSpeed;
5 | }
6 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/P2spTaskParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class P2spTaskParam {
4 | public String mCookie;
5 | public int mCreateMode;
6 | public String mFileName;
7 | public String mFilePath;
8 | public String mPass;
9 | public String mRefUrl;
10 | public int mSeqId;
11 | public String mUrl;
12 | public String mUser;
13 |
14 | public P2spTaskParam() {
15 | }
16 |
17 | public P2spTaskParam(String str, String str2, String str3, String str4, String str5, String str6, String str7, int i, int i2) {
18 | this.mFileName = str;
19 | this.mFilePath = str2;
20 | this.mUrl = str3;
21 | this.mCookie = str4;
22 | this.mRefUrl = str5;
23 | this.mUser = str6;
24 | this.mPass = str7;
25 | this.mCreateMode = i;
26 | this.mSeqId = i2;
27 | }
28 |
29 | public void setUrl(String str) {
30 | this.mUrl = str;
31 | }
32 |
33 | public void setFileName(String str) {
34 | this.mFileName = str;
35 | }
36 |
37 | public void setFilePath(String str) {
38 | this.mFilePath = str;
39 | }
40 |
41 | public void setCookie(String str) {
42 | this.mCookie = str;
43 | }
44 |
45 | public void setRefUrl(String str) {
46 | this.mRefUrl = str;
47 | }
48 |
49 | public void setUser(String str) {
50 | this.mUser = str;
51 | }
52 |
53 | public void setPass(String str) {
54 | this.mPass = str;
55 | }
56 |
57 | public void setCreateMode(int i) {
58 | this.mCreateMode = i;
59 | }
60 |
61 | public void setSeqId(int i) {
62 | this.mSeqId = i;
63 | }
64 |
65 | public boolean checkMemberVar() {
66 | if (this.mFileName == null || this.mFilePath == null || this.mUrl == null || this.mCookie == null || this.mRefUrl == null || this.mUser == null || this.mPass == null) {
67 | return false;
68 | }
69 | return true;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/PeerResourceParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class PeerResourceParam {
4 | public int mCapabilityFlag;
5 | public int mInternalIp;
6 | public String mJmpKey;
7 | public String mPeerId;
8 | public int mResLevel;
9 | public int mResPriority;
10 | public int mResType;
11 | public int mTcpPort;
12 | public int mUdpPort;
13 | public long mUserId;
14 | public String mVipCdnAuth;
15 |
16 | public PeerResourceParam(String str, long j, String str2, String str3, int i, int i2, int i3, int i4, int i5, int i6, int i7) {
17 | this.mPeerId = str;
18 | this.mUserId = j;
19 | this.mJmpKey = str2;
20 | this.mVipCdnAuth = str3;
21 | this.mInternalIp = i;
22 | this.mTcpPort = i2;
23 | this.mUdpPort = i3;
24 | this.mResLevel = i4;
25 | this.mResPriority = i5;
26 | this.mCapabilityFlag = i6;
27 | this.mResType = i7;
28 | }
29 |
30 | public void setPeerId(String str) {
31 | this.mPeerId = str;
32 | }
33 |
34 | public void setUserId(long j) {
35 | this.mUserId = j;
36 | }
37 |
38 | public void setJmpKey(String str) {
39 | this.mJmpKey = str;
40 | }
41 |
42 | public void setVipCdnAuth(String str) {
43 | this.mVipCdnAuth = str;
44 | }
45 |
46 | public void setInternalIp(int i) {
47 | this.mInternalIp = i;
48 | }
49 |
50 | public void setTcpPort(int i) {
51 | this.mTcpPort = i;
52 | }
53 |
54 | public void setUdpPort(int i) {
55 | this.mUdpPort = i;
56 | }
57 |
58 | public void setResLevel(int i) {
59 | this.mResLevel = i;
60 | }
61 |
62 | public void setResPriority(int i) {
63 | this.mResPriority = i;
64 | }
65 |
66 | public void setCapabilityFlag(int i) {
67 | this.mCapabilityFlag = i;
68 | }
69 |
70 | public void setResType(int i) {
71 | this.mResType = i;
72 | }
73 |
74 | public boolean checkMemberVar() {
75 | if (this.mPeerId == null || this.mJmpKey == null || this.mVipCdnAuth == null) {
76 | return false;
77 | }
78 | return true;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/ServerResourceParam.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class ServerResourceParam {
4 | public String mCookie;
5 | public String mRefUrl;
6 | public int mResType;
7 | public int mStrategy;
8 | public String mUrl;
9 |
10 | public ServerResourceParam(String str, String str2, String str3, int i, int i2) {
11 | this.mUrl = str;
12 | this.mRefUrl = str2;
13 | this.mCookie = str3;
14 | this.mResType = i;
15 | this.mStrategy = i2;
16 | }
17 |
18 | public void setUrl(String str) {
19 | this.mUrl = str;
20 | }
21 |
22 | public void setRefUrl(String str) {
23 | this.mRefUrl = str;
24 | }
25 |
26 | public void setCookie(String str) {
27 | this.mCookie = str;
28 | }
29 |
30 | public void setRestype(int i) {
31 | this.mResType = i;
32 | }
33 |
34 | public void setStrategy(int i) {
35 | this.mStrategy = i;
36 | }
37 |
38 | public boolean checkMemberVar() {
39 | if (this.mUrl == null || this.mRefUrl == null || this.mCookie == null) {
40 | return false;
41 | }
42 | return true;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/ThunderUrlInfo.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class ThunderUrlInfo {
4 | public String mUrl;
5 |
6 | public ThunderUrlInfo() {
7 | }
8 |
9 | public ThunderUrlInfo(String str) {
10 | this.mUrl = str;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/TorrentFileInfo.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class TorrentFileInfo {
4 | public int mFileIndex;
5 | public String mFileName;
6 | public long mFileSize;
7 | public int mRealIndex;
8 | public String mSubPath;
9 | public String playUrl;
10 | public String hash;
11 | }
12 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/TorrentInfo.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class TorrentInfo {
4 | public int mFileCount;
5 | public String mInfoHash;
6 | public boolean mIsMultiFiles;
7 | public String mMultiFileBaseFolder;
8 | public TorrentFileInfo[] mSubFileInfo;
9 | }
10 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/UrlQuickInfo.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class UrlQuickInfo {
4 | public String mContentType;
5 | public String mFileNameAdvice;
6 | public long mFileSize;
7 | public int mState;
8 | }
9 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLConstant.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class XLConstant {
4 |
5 | public static class QuickInfoState {
6 | public static final int QI_FAILED = 3;
7 | public static final int QI_FINISH = 2;
8 | public static final int QI_STOP = 0;
9 | public static final int QI_TRY = 1;
10 | }
11 |
12 | public enum XLCreateTaskMode {
13 | NEW_TASK,
14 | CONTINUE_TASK
15 | }
16 |
17 | public enum XLDownloadHeaderState {
18 | GDHS_UNKOWN,
19 | GDHS_REQUESTING,
20 | GDHS_SUCCESS,
21 | GDHS_ERROR
22 | }
23 |
24 | public static class XLErrorCode {
25 | public static final int ADD_RESOURCE_ERROR = 9122;
26 | public static final int ALREADY_INIT = 9101;
27 | public static final int APPKEY_CHECKER_ERROR = 9901;
28 | public static final int APPNAME_APPKEY_ERROR = 9116;
29 | public static final int ASYN_FILE_E_BASE = 111300;
30 | public static final int ASYN_FILE_E_EMPTY_FILE = 111305;
31 | public static final int ASYN_FILE_E_FILE_CLOSING = 111308;
32 | public static final int ASYN_FILE_E_FILE_NOT_OPEN = 111303;
33 | public static final int ASYN_FILE_E_FILE_REOPEN = 111304;
34 | public static final int ASYN_FILE_E_FILE_SIZE_LESS = 111306;
35 | public static final int ASYN_FILE_E_OP_BUSY = 111302;
36 | public static final int ASYN_FILE_E_OP_NONE = 111301;
37 | public static final int ASYN_FILE_E_TOO_MUCH_DATA = 111307;
38 | public static final int BAD_DIR_PATH = 111083;
39 | public static final int BT_SUB_TASK_NOT_SELECT = 9306;
40 | public static final int BUFFER_OVERFLOW = 111039;
41 | public static final int COMMON_ERRCODE_BASE = 111024;
42 | public static final int CONF_MGR_ERRCODE_BASE = 111159;
43 | public static final int CONTINUE_NO_NAME = 9115;
44 | public static final int CORRECT_CDN_ERROR = 111180;
45 | public static final int CORRECT_TIMES_TOO_MUCH = 111179;
46 | public static final int CREATE_FILE_FAIL = 111139;
47 | public static final int CREATE_THREAD_ERROR = 9117;
48 | public static final int DATA_MGR_ERRCODE_BASE = 111119;
49 | public static final int DISK_FULL = 9110;
50 | public static final int DISPATCHER_ERRCODE_BASE = 111118;
51 | public static final int DNS_INVALID_ADDR = 111078;
52 | public static final int DNS_NO_SERVER = 111077;
53 | public static final int DOWNLOAD_MANAGER_ERROR = 9900;
54 | public static final int DYNAMIC_PARAM_FAIL = 9114;
55 | public static final int ERROR_INVALID_INADDR = 111050;
56 | public static final int ERR_DPLAY_ALL_SEND_COMPLETE = 118000;
57 | public static final int ERR_DPLAY_BROKEN_SOCKET_RECV = 118307;
58 | public static final int ERR_DPLAY_BROKEN_SOCKET_SEND = 118306;
59 | public static final int ERR_DPLAY_CLIENT_ACTIVE_DISCONNECT = 118001;
60 | public static final int ERR_DPLAY_DO_DOWNLOAD_FAIL = 118305;
61 | public static final int ERR_DPLAY_DO_READFILE_FAIL = 118311;
62 | public static final int ERR_DPLAY_EV_SEND_TIMTOUT = 118310;
63 | public static final int ERR_DPLAY_HANDLE_DOWNLOAD_FAILED = 118302;
64 | public static final int ERR_DPLAY_NOT_FOUND = 118005;
65 | public static final int ERR_DPLAY_PLAY_FILE_NOT_EXIST = 118304;
66 | public static final int ERR_DPLAY_RECV_STATE_INVALID = 118308;
67 | public static final int ERR_DPLAY_SEND_FAILED = 118300;
68 | public static final int ERR_DPLAY_SEND_RANGE_INVALID = 118301;
69 | public static final int ERR_DPLAY_SEND_STATE_INVALID = 118309;
70 | public static final int ERR_DPLAY_TASK_FINISH_CANNT_DOWNLOAD = 118004;
71 | public static final int ERR_DPLAY_TASK_FINISH_CONTINUE = 118003;
72 | public static final int ERR_DPLAY_TASK_FINISH_DESTROY = 118002;
73 | public static final int ERR_DPLAY_UNKNOW_HTTP_METHOD = 118303;
74 | public static final int ERR_INVALID_ADDRESS_FAMILY = 116001;
75 | public static final int ERR_P2P_ALLOC_MEM_ERR = 11313;
76 | public static final int ERR_P2P_BROKER_CONNECT = 11308;
77 | public static final int ERR_P2P_CONNECT_FAILED = 11311;
78 | public static final int ERR_P2P_CONNECT_UPLOAD_SLOW = 11312;
79 | public static final int ERR_P2P_HANDSHAKE_RESP_FAIL = 11303;
80 | public static final int ERR_P2P_INVALID_COMMAND = 11309;
81 | public static final int ERR_P2P_INVALID_PARAM = 11310;
82 | public static final int ERR_P2P_NOT_SUPPORT_UDT = 11307;
83 | public static final int ERR_P2P_REMOTE_UNKNOWN_MY_CMD = 11306;
84 | public static final int ERR_P2P_REQUEST_RESP_FAIL = 11304;
85 | public static final int ERR_P2P_SEND_HANDSHAKE = 11314;
86 | public static final int ERR_P2P_UPLOAD_OVER_MAX = 11305;
87 | public static final int ERR_P2P_VERSION_NOT_SUPPORT = 11301;
88 | public static final int ERR_P2P_WAITING_CLOSE = 11302;
89 | public static final int ERR_PTL_GET_PEERSN_FAILED = 112600;
90 | public static final int ERR_PTL_PEER_OFFLINE = 112500;
91 | public static final int ERR_PTL_PROTOCOL_NOT_SUPPORT = 112400;
92 | public static final int FILE_CANNOT_TRUNCATE = 111084;
93 | public static final int FILE_CFG_ERASE_ERROR = 111130;
94 | public static final int FILE_CFG_MAGIC_ERROR = 111131;
95 | public static final int FILE_CFG_READ_ERROR = 111132;
96 | public static final int FILE_CFG_READ_HEADER_ERROR = 111134;
97 | public static final int FILE_CFG_RESOLVE_ERROR = 111135;
98 | public static final int FILE_CFG_TRY_FIX = 111129;
99 | public static final int FILE_CFG_WRITE_ERROR = 111133;
100 | public static final int FILE_CREATING = 111145;
101 | public static final int FILE_EXISTED = 9109;
102 | public static final int FILE_INVALID_PARA = 111144;
103 | public static final int FILE_NAME_TOO_LONG = 9125;
104 | public static final int FILE_NOT_EXIST = 111143;
105 | public static final int FILE_PATH_TOO_LONG = 111120;
106 | public static final int FILE_SIZE_NOT_BELIEVE = 111141;
107 | public static final int FILE_SIZE_TOO_SMALL = 111142;
108 | public static final int FILE_TOO_BIG = 111086;
109 | public static final int FIL_INFO_INVALID_DATA = 111146;
110 | public static final int FIL_INFO_RECVED_DATA = 111147;
111 | public static final int FULL_PATH_NAME_OCCUPIED = 9128;
112 | public static final int FULL_PATH_NAME_TOO_LONG = 9127;
113 | public static final int FUNCTION_NOT_SUPPORT = 9123;
114 | public static final int HTTP_HUB_CLIENT_E_BASE = 115100;
115 | public static final int HTTP_SERVER_NOT_START = 9400;
116 | public static final int INDEX_NOT_READY = 9303;
117 | public static final int INSUFFICIENT_DISK_SPACE = 111085;
118 | public static final int INVALID_ARGUMENT = 111041;
119 | public static final int INVALID_ITERATOR = 111038;
120 | public static final int INVALID_SOCKET_DESCRIPTOR = 111048;
121 | public static final int INVALID_TIMER_INDEX = 111074;
122 | public static final int IP6_ERRCODE_BASE = 116000;
123 | public static final int IP6_INVALID_IN6ADDR = 116002;
124 | public static final int IP6_NOT_SUPPORT_SSL = 116003;
125 | public static final int MAP_DUPLICATE_KEY = 111036;
126 | public static final int MAP_KEY_NOT_FOUND = 111037;
127 | public static final int MAP_UNINIT = 111035;
128 | public static final int NET_BROKEN_PIPE = 111170;
129 | public static final int NET_CONNECTION_REFUSED = 111171;
130 | public static final int NET_CONNECT_SSL_ERR = 111169;
131 | public static final int NET_NORMAL_CLOSE = 111175;
132 | public static final int NET_OP_CANCEL = 111173;
133 | public static final int NET_REACTOR_ERRCODE_BASE = 111168;
134 | public static final int NET_SSL_GET_FD_ERROR = 111172;
135 | public static final int NET_UNKNOWN_ERROR = 111174;
136 | public static final int NOT_FULL_PATH_NAME = 9404;
137 | public static final int NOT_IMPLEMENT = 111057;
138 | public static final int NO_ENOUGH_BUFFER = 9301;
139 | public static final int NO_ERROR = 9000;
140 | public static final int ONE_PATH_LEVEL_NAME_TOO_LONG = 9126;
141 | public static final int OPEN_FILE_ERR = 111128;
142 | public static final int OPEN_OLD_FILE_FAIL = 111140;
143 | public static final int OUT_OF_FIXED_MEMORY = 111032;
144 | public static final int OUT_OF_MEMORY = 111026;
145 | public static final int P2P_PIPE_ERRCODE_BASE = 11300;
146 | public static final int PARAM_ERROR = 9112;
147 | public static final int PAUSE_TASK_WRITE_CFG_ERR = 117000;
148 | public static final int PAUSE_TASK_WRITE_DATA_TIMEOUT = 117001;
149 | public static final int PRIOR_TASK_FINISH = 9308;
150 | public static final int PRIOR_TASK_NO_INDEX = 9307;
151 | public static final int QUEUE_NO_ROOM = 111033;
152 | public static final int READ_FILE_ERR = 111126;
153 | public static final int REDIRECT_TOO_MUCH = 111181;
154 | public static final int RES_QUERY_E_BASE = 115000;
155 | public static final int SCHEMA_NOT_SUPPORT = 9113;
156 | public static final int SDK_NOT_INIT = 9102;
157 | public static final int SETTINGS_ERR_CFG_FILE_NOT_EXIST = 111162;
158 | public static final int SETTINGS_ERR_INVALID_FILE_NAME = 111161;
159 | public static final int SETTINGS_ERR_INVALID_ITEM_NAME = 111164;
160 | public static final int SETTINGS_ERR_INVALID_ITEM_VALUE = 111165;
161 | public static final int SETTINGS_ERR_INVALID_LINE = 111163;
162 | public static final int SETTINGS_ERR_ITEM_NOT_FOUND = 111167;
163 | public static final int SETTINGS_ERR_LIST_EMPTY = 111166;
164 | public static final int SETTINGS_ERR_UNKNOWN = 111160;
165 | public static final int TARGET_THREAD_STOPING = 111025;
166 | public static final int TASK_ALREADY_EXIST = 9103;
167 | public static final int TASK_ALREADY_RUNNING = 9106;
168 | public static final int TASK_ALREADY_STOPPED = 9105;
169 | public static final int TASK_CONTROL_STRATEGY = 9501;
170 | public static final int TASK_FAILURE_ALL_SUBTASK_FAILED = 114009;
171 | public static final int TASK_FAILURE_BTHUB_NO_RECORD = 114008;
172 | public static final int TASK_FAILURE_CANNOT_START_SUBTASK = 114003;
173 | public static final int TASK_FAILURE_EMULE_NO_RECORD = 114101;
174 | public static final int TASK_FAILURE_GET_TORRENT_FAILED = 114006;
175 | public static final int TASK_FAILURE_NO_DATA_PIPE = 111136;
176 | public static final int TASK_FAILURE_PARSE_TORRENT_FAILED = 114005;
177 | public static final int TASK_FAILURE_PART_SUBTASK_FAILED = 114011;
178 | public static final int TASK_FAILURE_QUERY_BT_HUB_FAILED = 114004;
179 | public static final int TASK_FAILURE_QUERY_EMULE_HUB_FAILED = 114001;
180 | public static final int TASK_FAILURE_SAVE_TORRENT_FAILED = 114007;
181 | public static final int TASK_FAILURE_SUBTASK_FAILED = 114002;
182 | public static final int TASK_FAILURE_THEONLY_SUBTASK_FAILED = 114010;
183 | public static final int TASK_FAIL_LONG_TIME_NO_RECV_DATA = 111176;
184 | public static final int TASK_FILE_NAME_EMPTY = 9401;
185 | public static final int TASK_FILE_NOT_VEDIO = 9402;
186 | public static final int TASK_FILE_SIZE_TOO_LARGE = 111177;
187 | public static final int TASK_FINISH = 9118;
188 | public static final int TASK_NOT_EXIST = 9104;
189 | public static final int TASK_NOT_IDLE = 9120;
190 | public static final int TASK_NOT_RUNNING = 9119;
191 | public static final int TASK_NOT_START = 9107;
192 | public static final int TASK_NO_FILE_NAME = 9129;
193 | public static final int TASK_NO_INDEX_NO_ORIGIN = 111148;
194 | public static final int TASK_ORIGIN_NONEXISTENCE = 111149;
195 | public static final int TASK_RETRY_ALWAY_FAIL = 111178;
196 | public static final int TASK_STILL_RUNNING = 9108;
197 | public static final int TASK_TYPE_NOT_SUPPORT = 9121;
198 | public static final int TASK_UNKNOWN_ERROR = 9403;
199 | public static final int TASK_USE_TOO_MUCH_MEM = 111031;
200 | public static final int THUNDER_URL_PARSE_ERROR = 9305;
201 | public static final int TOO_MUCH_TASK = 9111;
202 | public static final int TORRENT_IMCOMPLETE = 9304;
203 | public static final int TORRENT_PARSE_ERROR = 9302;
204 | public static final int URL_IS_TOO_LONG = 111047;
205 | public static final int URL_PARSER_ERROR = 111046;
206 | public static final int VIDEO_CACHE_FINISH = 9410;
207 | public static final int WRITE_FILE_ERR = 111127;
208 | }
209 |
210 | public enum XLManagerStatus {
211 | MANAGER_UNINIT,
212 | MANAGER_INIT_FAIL,
213 | MANAGER_RUNNING
214 | }
215 |
216 | public enum XLNetWorkCarrier {
217 | NWC_Unknow,
218 | NWC_CMCC,
219 | NWC_CU,
220 | NWC_CT
221 | }
222 |
223 | public static class XLOriginResState {
224 | public static final int ORIGIN_RES_CHECKING = 1;
225 | public static final int ORIGIN_RES_DEATH_LINK = 3;
226 | public static final int ORIGIN_RES_UNUSED = 0;
227 | public static final int ORIGIN_RES_VALID_LINK = 2;
228 | }
229 |
230 | public enum XLQueryIndexStatus {
231 | QIS_UNQUERY,
232 | QIS_QUERYING,
233 | QIS_QUERY_HAVE_INFO,
234 | QIS_QUERY_HAVENT_INFO
235 | }
236 |
237 | public enum XLResStrategy {
238 | RUS_PRIOR_USE
239 | }
240 |
241 | public static class XLTaskStatus {
242 | public static final int TASK_FAILED = 3;
243 | public static final int TASK_IDLE = 0;
244 | public static final int TASK_RUNNING = 1;
245 | public static final int TASK_STOPPED = 4;
246 | public static final int TASK_SUCCESS = 2;
247 | }
248 |
249 | public static class XLTaskType {
250 | public static final int P2SP_TASK_TYP = 1;
251 | }
252 | }
253 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLProductInfo.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class XLProductInfo {
4 | public String mProductKey;
5 | public String mProductName;
6 |
7 | public XLProductInfo(String str, String str2) {
8 | this.mProductKey = str;
9 | this.mProductName = str2;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLSessionInfo.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class XLSessionInfo {
4 | public long mSendByte;
5 | public long mStartTime;
6 | }
7 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskInfo.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.os.Parcelable.Creator;
6 |
7 | public class XLTaskInfo implements Parcelable {
8 | public static final Creator CREATOR = new Creator() {
9 | public final XLTaskInfo createFromParcel(Parcel parcel) {
10 | return new XLTaskInfo(parcel);
11 | }
12 |
13 | public final XLTaskInfo[] newArray(int i) {
14 | return new XLTaskInfo[i];
15 | }
16 | };
17 | public int mAddedHighSourceState;
18 | public int mAdditionalResCount;
19 | public long mAdditionalResDCDNBytes;
20 | public long mAdditionalResDCDNSpeed;
21 | public long mAdditionalResPeerBytes;
22 | public long mAdditionalResPeerSpeed;
23 | public int mAdditionalResType;
24 | public long mAdditionalResVipRecvBytes;
25 | public long mAdditionalResVipSpeed;
26 | public String mCid;
27 | public long mDownloadSize;
28 | public long mDownloadSpeed;
29 | public int mErrorCode;
30 | public String mFileName;
31 | public long mFileSize;
32 | public String mGcid;
33 | public int mInfoLen;
34 | public long mOriginRecvBytes;
35 | public long mOriginSpeed;
36 | public long mP2PRecvBytes;
37 | public long mP2PSpeed;
38 | public long mP2SRecvBytes;
39 | public long mP2SSpeed;
40 | public int mQueryIndexStatus;
41 | public long mTaskId;
42 | public int mTaskStatus;
43 |
44 | public int describeContents() {
45 | return 0;
46 | }
47 |
48 | public void writeToParcel(Parcel parcel, int i) {
49 | parcel.writeLong(this.mTaskId);
50 | parcel.writeString(this.mFileName);
51 | parcel.writeInt(this.mInfoLen);
52 | parcel.writeInt(this.mTaskStatus);
53 | parcel.writeInt(this.mErrorCode);
54 | parcel.writeLong(this.mFileSize);
55 | parcel.writeLong(this.mDownloadSize);
56 | parcel.writeLong(this.mDownloadSpeed);
57 | parcel.writeInt(this.mQueryIndexStatus);
58 | parcel.writeString(this.mCid);
59 | parcel.writeString(this.mGcid);
60 | parcel.writeLong(this.mOriginSpeed);
61 | parcel.writeLong(this.mOriginRecvBytes);
62 | parcel.writeLong(this.mP2SSpeed);
63 | parcel.writeLong(this.mP2SRecvBytes);
64 | parcel.writeLong(this.mP2PSpeed);
65 | parcel.writeLong(this.mP2PRecvBytes);
66 | parcel.writeInt(this.mAdditionalResCount);
67 | parcel.writeInt(this.mAdditionalResType);
68 | parcel.writeLong(this.mAdditionalResVipSpeed);
69 | parcel.writeLong(this.mAdditionalResVipRecvBytes);
70 | parcel.writeLong(this.mAdditionalResPeerSpeed);
71 | parcel.writeLong(this.mAdditionalResPeerBytes);
72 | }
73 |
74 | public XLTaskInfo() {
75 | }
76 |
77 | public XLTaskInfo(Parcel parcel) {
78 | this.mTaskId = parcel.readLong();
79 | this.mFileName = parcel.readString();
80 | this.mInfoLen = parcel.readInt();
81 | this.mTaskStatus = parcel.readInt();
82 | this.mErrorCode = parcel.readInt();
83 | this.mFileSize = parcel.readLong();
84 | this.mDownloadSize = parcel.readLong();
85 | this.mDownloadSpeed = parcel.readLong();
86 | this.mQueryIndexStatus = parcel.readInt();
87 | this.mCid = parcel.readString();
88 | this.mGcid = parcel.readString();
89 | this.mOriginSpeed = parcel.readLong();
90 | this.mOriginRecvBytes = parcel.readLong();
91 | this.mP2SSpeed = parcel.readLong();
92 | this.mP2SRecvBytes = parcel.readLong();
93 | this.mP2PSpeed = parcel.readLong();
94 | this.mP2PRecvBytes = parcel.readLong();
95 | this.mAdditionalResCount = parcel.readInt();
96 | this.mAdditionalResType = parcel.readInt();
97 | this.mAdditionalResVipSpeed = parcel.readLong();
98 | this.mAdditionalResVipRecvBytes = parcel.readLong();
99 | this.mAdditionalResPeerSpeed = parcel.readLong();
100 | this.mAdditionalResPeerBytes = parcel.readLong();
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskInfoEx.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class XLTaskInfoEx {
4 | public int mErrorCode;
5 | public int mInfoLen;
6 | public int mOriginResState;
7 | public int mP2pAbandonTotal;
8 | public int mP2pUsedTotal;
9 | public int mP2sAbandonTotal;
10 | public int mP2sUsedTotal;
11 | public long mTaskId;
12 | }
13 |
--------------------------------------------------------------------------------
/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskLocalUrl.java:
--------------------------------------------------------------------------------
1 | package com.xunlei.downloadlib.parameter;
2 |
3 | public class XLTaskLocalUrl {
4 | public String mStrUrl;
5 | }
6 |
--------------------------------------------------------------------------------
/thunder/src/main/jniLibs/armeabi/libxl_stat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/thunder/src/main/jniLibs/armeabi/libxl_stat.so
--------------------------------------------------------------------------------
/thunder/src/main/jniLibs/armeabi/libxl_thunder_iface.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/thunder/src/main/jniLibs/armeabi/libxl_thunder_iface.so
--------------------------------------------------------------------------------
/thunder/src/main/jniLibs/armeabi/libxl_thunder_sdk.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/thunder/src/main/jniLibs/armeabi/libxl_thunder_sdk.so
--------------------------------------------------------------------------------
/thunder/src/main/jniLibs/armeabi/libxluagc.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MaxMax2016/MiniThunder/31fce530f901834f593b3d19c0ae07e4eb383284/thunder/src/main/jniLibs/armeabi/libxluagc.so
--------------------------------------------------------------------------------
/thunder/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | thunder
3 |
4 |
--------------------------------------------------------------------------------
/thunder/src/test/java/com/ghost/thunder/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.ghost.thunder;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------