Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Utopia&&for free
huawei-dynamic-ability
提交
c373a210
H
huawei-dynamic-ability
项目概览
Utopia&&for free
/
huawei-dynamic-ability
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
huawei-dynamic-ability
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c373a210
编写于
9月 18, 2020
作者:
Utopia&&for free
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update demo.java
上级
fbe5cb51
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
312 addition
and
78 deletion
+312
-78
demo.java
demo.java
+312
-78
未找到文件。
demo.java
浏览文件 @
c373a210
Last
login:
Fri
Sep
18
17
:
48
:
35
on
console
Identity
added:
/
Users
/
zsw
/.
ssh
/
id_rsa
(/
Users
/
zsw
/.
ssh
/
id_rsa
)
Made
safe
aliases
for
mv
/
cp
/
rm
,
trash
at
/
Users
/
zsw
/.
__trash
.
candyqjluo
@
17
:
48
:
45
~
$
ls
:
wq
htc_server_struct
.
sql
Adlm
image
Applications
java_error_in_idea
.
hprof
Desktop
java_error_in_idea_30922
.
log
Documents
logs
Downloads
nohup
.
out
Library
personal
Movies
swtools
Music
test
Parallels
v2rayx_backup_26
-
09
-
2019
11
:
29
.
json
Pictures
work
Postman
硬件方案
attack_request
.
log
项目需求
htc_local
.
sql
好停车技术手册
htc_local_dmg0718
.
sql
candyqjluo
@
17
:
49
:
04
~
$
candyqjluo
@
17
:
49
:
04
~
$
cd
work
/
git
/
htc
-
local
-
center
candyqjluo
@
17
:
49
:
11
~/
work
/
git
/
htc
-
local
-
center
$
ls
README
.
md
lib
sync_test
.
sh
bin
logs
target
build
.
sh
nohup
.
out
upgrade
.
sh
dist
.
xml
pom
.
xml
upgrade_from_local
.
sh
etc
release_note
vendor
extensions
scripts
version
.
log
install_vendor
.
sh
src
webapp
led_sound
sync
.
sh
candyqjluo
@
17
:
49
:
11
~/
work
/
git
/
htc
-
local
-
center
$
candyqjluo
@
17
:
49
:
12
~/
work
/
git
/
htc
-
local
-
center
$
ls
README
.
md
lib
sync_test
.
sh
bin
logs
target
build
.
sh
nohup
.
out
upgrade
.
sh
dist
.
xml
pom
.
xml
upgrade_from_local
.
sh
etc
release_note
vendor
extensions
scripts
version
.
log
install_vendor
.
sh
src
webapp
led_sound
sync
.
sh
candyqjluo
@
18
:
48
:
31
~/
work
/
git
/
htc
-
local
-
center
$
cd
...
..
candyqjluo
@
18
:
48
:
41
~/
work
/
git
$
ls
KOA2
KQZ392
.
log
code
-
csdn
config
.
properties_htc_local_center_debug
config
.
properties_htc_mobile
generate_company_statistic
.
py
generate_park_statistic_company
.
py
generate_park_statistic_company
.
py_bak0628
htc
-
alipay
-
mobile
-
fe
htc
-
cloud
-
server
htc
-
cloud
-
server
-
bak0617
public
void
onFailure
(
Exception
exception
)
{
htc
-
common
htc
-
common
-
bk
htc
-
local
-
center
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All righ
*/
package
com.huawei.android.dynamicfeaturesplit
;
6
<
200
b
>
package
com.huawei.android.dynamicfeaturesplit
;
6
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
...
...
@@ -98,4 +22,314 @@ import com.huawei.hms.feature.model.FeatureInstallException;
import
com.huawei.hms.feature.model.FeatureInstallRequest
;
import
com.huawei.hms.feature.model.FeatureInstallSessionStatus
;
import
com.huawei.hms.feature.model.InstallState
;
--
INSERT
--
import
com.huawei.hms.feature.tasks.FeatureTask
;
import
com.huawei.hms.feature.tasks.listener.OnFeatureCompleteLis
import
com.huawei.hms.feature.tasks.listener.OnFeatureFailureList
import
com.huawei.hms.feature.tasks.listener.OnFeatureSuccessList
/**
* Sample entry.
*/
public
class
SampleEntry
extends
Activity
{
private
ProgressBar
progressBar
;
private
static
final
String
TAG
=
SampleEntry
.
class
.
getSimple
private
FeatureInstallManager
mFeatureInstallManager
;
private
int
sessionId
=
10086
;
// 安装状态监听
private
InstallStateListener
mStateUpdateListener
=
new
Insta
@Override
public
void
onStateUpdate
(
InstallState
state
)
{
Log
.
d
(
TAG
,
"install session state "
+
state
);
if
(
state
.
status
()
==
FeatureInstallSessionStatus
.
REQ
try
{
mFeatureInstallManager
.
triggerUserConfirm
(
sta
}
catch
(
IntentSender
.
SendIntentException
e
)
{
e
.
printStackTrace
();
}
return
;
}
if
(
state
.
status
()
==
FeatureInstallSessionStatus
.
REQ
try
{
mFeatureInstallManager
.
triggerUserConfirm
(
sta
}
catch
(
IntentSender
.
SendIntentException
e
)
{
e
.
printStackTrace
();
}
return
;
}
if
(
state
.
status
()
==
FeatureInstallSessionStatus
.
INS
Log
.
i
(
TAG
,
"installed success ,can use new featur
makeToast("
installed
success
,
can
test
new
featu
return
;
}
if
(
state
.
status
()
==
FeatureInstallSessionStatus
.
UNK
Log
.
e
(
TAG
,
"installed in unknown status"
);
makeToast
(
"installed in unknown status "
);
return
;
}
if
(
state
.
status
()
==
FeatureInstallSessionStatus
.
DOW
long
process
=
state
.
bytesDownloaded
()
*
100
/
st
Log
.
d
(
TAG
,
"downloading percentage: "
+
process
)
makeToast
(
"downloading percentage: "
+
process
);
return
;
}
if
(
state
.
status
()
==
FeatureInstallSessionStatus
.
FAI
Log
.
e
(
TAG
,
"installed failed, errorcode : "
+
sta
makeToast
(
"installed failed, errorcode : "
+
stat
return
;
}
}
};
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
progressBar
=
findViewById
(
R
.
id
.
progress_bar
);
mFeatureInstallManager
=
FeatureInstallManagerFactory
.
cr
}
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
if
(
mFeatureInstallManager
!=
null
)
{
mFeatureInstallManager
.
registerInstallListener
(
mStat
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
if
(
mFeatureInstallManager
!=
null
)
{
mFeatureInstallManager
.
unregisterInstallListener
(
mSt
}
}
/**
* 安装动态特性
*/
public
void
installFeature
(
View
view
)
{
if
(
mFeatureInstallManager
==
null
)
{
return
;
}
// start install
FeatureInstallRequest
request
=
FeatureInstallRequest
.
ne
.
addModule
(
"SplitSampleFeature01"
)
.
build
();
// 添加安装监听
final
FeatureTask
<
Integer
>
task
=
mFeatureInstallManager
task
.
addOnListener
(
new
OnFeatureSuccessListener
<
Integer
>
@Override
public
void
onSuccess
(
Integer
integer
)
{
Log
.
d
(
TAG
,
"load feature onSuccess.session id:"
}
});
task
.
addOnListener
(
new
OnFeatureFailureListener
<
Integer
>
@Override
public
void
onFailure
(
Exception
exception
)
{
if
(
exception
instanceof
FeatureInstallException
int
errorCode
=
((
FeatureInstallException
)
e
Log
.
d
(
TAG
,
"load feature onFailure.errorCode
} else {
exception.printStackTrace();
} }
});
task.addOnListener(new OnFeatureCompleteListener<Integer
@Override
public void onComplete(FeatureTask<Integer> featureT
if (featureTask.isComplete()) {
Log.d(TAG, "
complete
to
start
install
.
");
if (featureTask.isSuccessful()) {
Integer result = featureTask.getResult()
sessionId = result;
Log.d(TAG, "
succeed
to
start
install
.
se
}
else
{
Log
.
d
(
TAG
,
"fail to start install."
);
Exception
exception
=
featureTask
.
getExc
exception
.
printStackTrace
();
}
}
}
});
Log
.
d
(
TAG
,
"start install func end"
);
}
/**
* 打开动态特性⻚页⾯面
*/
public
void
startFeature01
(
View
view
)
{
// test getInstallModules
Set
<
String
>
moduleNames
=
mFeatureInstallManager
.
getAllI
Log
.
d
(
TAG
,
"getInstallModules : "
+
moduleNames
);
if
(
moduleNames
!=
null
&&
moduleNames
.
contains
(
"SplitSa
try {
startActivity(new Intent(this, Class.forName(
"
com
.
huawei
.
android
.
dynamicfeaturesplit
.
}
catch
(
Exception
e
)
{
Log
.
w
(
TAG
,
""
,
e
);
}
}
}
/**
* 中断安装特性
*/
public
void
abortInstallFeature
(
View
view
)
{
Log
.
d
(
TAG
,
"begin abort_install : "
+
sessionId
);
FeatureTask
<
Void
>
task
=
mFeatureInstallManager
.
abortIns
task
.
addOnListener
(
new
OnFeatureCompleteListener
<
Void
>()
@Override
public
void
onComplete
(
FeatureTask
<
Void
>
featureTask
if
(
featureTask
.
isComplete
())
{
Log
.
d
(
TAG
,
"complete to abort_install."
);
if
(
featureTask
.
isSuccessful
())
{
Log
.
d
(
TAG
,
"succeed to abort_install."
);
}
else
{
Log
.
d
(
TAG
,
"fail to abort_install."
);
Exception
exception
=
featureTask
.
getExc
exception
.
printStackTrace
();
}
}
}
});
}
/**
* get install task state
*
* @param view the view
*/
public
void
getInstallState
(
View
view
)
{
Log
.
d
(
TAG
,
"begin to get session state for: "
+
sessionI
FeatureTask
<
InstallState
>
task
=
mFeatureInstallManager
.
task
.
addOnListener
(
new
OnFeatureCompleteListener
<
Install
@Override
public
void
onComplete
(
FeatureTask
<
InstallState
>
fea
if
(
featureTask
.
isComplete
())
{
Log
.
d
(
TAG
,
"complete to get session state."
)
if
(
featureTask
.
isSuccessful
())
{
InstallState
state
=
featureTask
.
getResu
Log
.
d
(
TAG
,
"succeed to get session state
Log.d(TAG, state.toString());
} else {
Log.e(TAG, "
failed
to
get
session
state
.
Exception
exception
=
featureTask
.
getExc
exception
.
printStackTrace
();
}
}
}
});
}
/**
* get states of all install tasks
*
* @param view the view
*/
public
void
getAllInstallStates
(
View
view
)
{
Log
.
d
(
TAG
,
"begin to get all session states."
);
FeatureTask
<
List
<
InstallState
>>
task
=
mFeatureInstallMa
task
.
addOnListener
(
new
OnFeatureCompleteListener
<
List
<
In
@Override
public
void
onComplete
(
FeatureTask
<
List
<
InstallState
Log
.
d
(
TAG
,
"complete to get session states."
);
if
(
featureTask
.
isSuccessful
())
{
Log
.
d
(
TAG
,
"succeed to get session states."
)
List
<
InstallState
>
stateList
=
featureTask
.
g
for
(
InstallState
state
:
stateList
)
{
Log
.
d
(
TAG
,
state
.
toString
());
}
}
else
{
Log
.
e
(
TAG
,
"fail to get session states."
);
Exception
exception
=
featureTask
.
getExcepti
exception
.
printStackTrace
();
}
}
});
}
/**
* 延迟安装动态特性
*/
public
void
delayedInstallFeature
(
View
view
)
{
List
<
String
>
features
=
new
ArrayList
<>();
features
.
add
(
"SplitSampleFeature01"
);
FeatureTask
<
Void
>
task
=
mFeatureInstallManager
.
delayedI
task
.
addOnListener
(
new
OnFeatureCompleteListener
<
Void
>()
@Override
public
void
onComplete
(
FeatureTask
<
Void
>
featureTask
if
(
featureTask
.
isComplete
())
{
Log
.
d
(
TAG
,
"complete to delayed_Install"
);
if
(
featureTask
.
isSuccessful
())
{
Log
.
d
(
TAG
,
"succeed to delayed_install"
)
}
else
{
Log
.
d
(
TAG
,
"fail to delayed_install."
);
Exception
exception
=
featureTask
.
getExc
exception
.
printStackTrace
();
}
}
}
});
}
/**
* 延迟卸载特性
*/
public
void
delayedUninstallFeature
(
View
view
)
{
List
<
String
>
features
=
new
ArrayList
<>();
features
.
add
(
"SplitSampleFeature01"
);
FeatureTask
<
Void
>
task
=
mFeatureInstallManager
.
delayedU
task
.
addOnListener
(
new
OnFeatureCompleteListener
<
Void
>()
@Override
public
void
onComplete
(
FeatureTask
<
Void
>
featureTask
if
(
featureTask
.
isComplete
())
{
Log
.
d
(
TAG
,
"complete to delayed_uninstall"
);
if
(
featureTask
.
isSuccessful
())
{
Log
.
d
(
TAG
,
"succeed to delayed_uninstall
} else {
Log.d(TAG, "
fail
to
delayed_uninstall
.
")
Exception exception = featureTask.getExc
exception.printStackTrace();
} }
} });
}
/**
* install languages
*
* @param view the view
*/
public void loadLanguage(View view) {
if (mFeatureInstallManager == null) {
return; }
// start install
Set<String> languages = new HashSet<>();
languages.add("
fr
-
FR
");
FeatureInstallRequest.Builder builder = FeatureInstallRe
for (String lang : languages) {
builder.addLanguage(Locale.forLanguageTag(lang));
}
FeatureInstallRequest request = builder.build();
FeatureTask<Integer> task = mFeatureInstallManager.insta
task.addOnListener(new OnFeatureSuccessListener<Integer>
@Override
public void onSuccess(Integer result) {
Log.d(TAG, "
onSuccess
callback
result
" + result
} });
task.addOnListener(new OnFeatureFailureListener<Integer>
@Override
public void onFailure(Exception exception) {
if (exception instanceof FeatureInstallException
Log.d(TAG, "
onFailure
callback
"
+ ((FeatureInstallException) exception
} else {
Log.d(TAG, "
onFailure
callback
", exception)
} }
});
task.addOnListener(new OnFeatureCompleteListener<Integer
@Override
public void onComplete(FeatureTask<Integer> task) {
Log.d(TAG, "
onComplete
callback
"
);
}
});
{
private
void
makeToast
(
String
msg
)
{
Toast
.
makeText
(
this
,
msg
,
Toast
.
LENGTH_LONG
).
show
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录