Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 12819ed

Browse files
committed
Const-ness, nits, codestyle
1 parent 562d3ff commit 12819ed

File tree

14 files changed

+61
-58
lines changed

14 files changed

+61
-58
lines changed

shell/common/engine.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ const std::string& Engine::GetLastEntrypointLibrary() const {
517517

518518
void Engine::CompleteDartLoadLibrary(intptr_t loading_unit_id,
519519
std::string lib_name,
520-
std::vector<std::string>& apkPaths,
520+
const std::vector<std::string>& apkPaths,
521521
std::string abi) {
522522
if (runtime_controller_->IsRootIsolateRunning()) {
523523
// runtime_controller_->CompleteDartLoadLibrary(loading_unit_id, lib_name,

shell/common/engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ class Engine final : public RuntimeDelegate,
800800
///
801801
void CompleteDartLoadLibrary(intptr_t loading_unit_id,
802802
std::string lib_name,
803-
std::vector<std::string>& apkPaths,
803+
const std::vector<std::string>& apkPaths,
804804
std::string abi);
805805

806806
private:

shell/common/platform_view.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,11 @@ Dart_Handle PlatformView::OnDartLoadLibrary(intptr_t loading_unit_id) {
156156
return Dart_Null();
157157
}
158158

159-
void PlatformView::CompleteDartLoadLibrary(intptr_t loading_unit_id,
160-
std::string lib_name,
161-
std::vector<std::string>& apkPaths,
162-
std::string abi) {}
159+
void PlatformView::CompleteDartLoadLibrary(
160+
intptr_t loading_unit_id,
161+
std::string lib_name,
162+
const std::vector<std::string>& apkPaths,
163+
std::string abi) {}
163164

164165
void PlatformView::UpdateAssetManager(
165166
std::shared_ptr<AssetManager> asset_manager) {}

shell/common/platform_view.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,11 @@ class PlatformView {
260260
///
261261
/// @param[in] abi The abi of the library, eg, arm64-v8a
262262
///
263-
virtual void CompleteDartLoadLibrary(intptr_t loading_unit_id,
264-
std::string lib_name,
265-
std::vector<std::string>& apkPaths,
266-
std::string abi) = 0;
263+
virtual void CompleteDartLoadLibrary(
264+
intptr_t loading_unit_id,
265+
std::string lib_name,
266+
const std::vector<std::string>& apkPaths,
267+
std::string abi) = 0;
267268

268269
//--------------------------------------------------------------------------
269270
/// @brief Sets the asset manager of the engine to asset_manager
@@ -657,7 +658,7 @@ class PlatformView {
657658
///
658659
virtual void CompleteDartLoadLibrary(intptr_t loading_unit_id,
659660
std::string lib_name,
660-
std::vector<std::string>& apkPaths,
661+
const std::vector<std::string>& apkPaths,
661662
std::string abi);
662663

663664
//--------------------------------------------------------------------------

shell/common/shell.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ Shell::ComputePlatformViewResolvedLocale(
11901190

11911191
void Shell::CompleteDartLoadLibrary(intptr_t loading_unit_id,
11921192
std::string lib_name,
1193-
std::vector<std::string>& apkPaths,
1193+
const std::vector<std::string>& apkPaths,
11941194
std::string abi) {
11951195
engine_->CompleteDartLoadLibrary(loading_unit_id, lib_name, apkPaths, abi);
11961196
}

shell/common/shell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class Shell final : public PlatformView::Delegate,
518518
// |PlatformView::Delegate|
519519
void CompleteDartLoadLibrary(intptr_t loading_unit_id,
520520
std::string lib_name,
521-
std::vector<std::string>& apkPaths,
521+
const std::vector<std::string>& apkPaths,
522522
std::string abi) override;
523523

524524
// |PlatformView::Delegate|

shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -962,17 +962,18 @@ public void setDynamicFeatureContext(@NonNull Context context) {
962962
@SuppressWarnings("unused")
963963
@UiThread
964964
public void downloadDynamicFeature(int loadingUnitId) {
965-
String loadingUnitIdResName =
965+
String moduleNameIdentifier =
966966
dynamicFeatureContext
967967
.getResources()
968-
.getString(
969-
dynamicFeatureContext
970-
.getResources()
971-
.getIdentifier(
972-
"loadingUnit" + loadingUnitId,
973-
"string",
974-
dynamicFeatureContext.getPackageName()));
975-
downloadDynamicFeature(loadingUnitIdResName, loadingUnitId);
968+
.getIdentifier(
969+
"loadingUnit" + loadingUnitId,
970+
"string",
971+
dynamicFeatureContext.getPackageName());
972+
String moduleName =
973+
dynamicFeatureContext
974+
.getResources()
975+
.getString(moduleNameIdentifier);
976+
downloadDynamicFeature(moduleName, loadingUnitId);
976977
}
977978

978979
// Called by the engine upon invocation of dart loadLibrary() request

shell/platform/android/io/flutter/embedding/engine/dynamicfeatures/PlayStoreDynamicFeatureManager.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public void onStateUpdate(SplitInstallSessionState state) {
5151
{
5252
Log.e(
5353
TAG,
54-
String.format("Module \"%s\" (sessionId %d) install failed with: %s",
54+
String.format(
55+
"Module \"%s\" (sessionId %d) install failed with: %s",
5556
sessionIdToName.get(state.sessionId()),
5657
state.sessionId(),
57-
state.errorCode())
58-
);
58+
state.errorCode()));
5959
flutterJNI.dynamicFeatureInstallFailure(
6060
sessionIdToName.get(state.sessionId()),
6161
sessionIdToLoadingUnitId.get(state.sessionId()),
@@ -69,10 +69,10 @@ public void onStateUpdate(SplitInstallSessionState state) {
6969
{
7070
Log.e(
7171
TAG,
72-
String.format("Module \"%s\" (sessionId %d) install successfully.",
72+
String.format(
73+
"Module \"%s\" (sessionId %d) install successfully.",
7374
sessionIdToName.get(state.sessionId()),
74-
state.sessionId())
75-
);
75+
state.sessionId()));
7676
loadAssets(
7777
sessionIdToName.get(state.sessionId()),
7878
sessionIdToLoadingUnitId.get(state.sessionId()));
@@ -90,71 +90,71 @@ public void onStateUpdate(SplitInstallSessionState state) {
9090
{
9191
Log.e(
9292
TAG,
93-
String.format("Module \"%s\" (sessionId %d) install canceled.",
93+
String.format(
94+
"Module \"%s\" (sessionId %d) install canceled.",
9495
sessionIdToName.get(state.sessionId()),
95-
state.sessionId())
96-
);
96+
state.sessionId()));
9797
sessionIdToName.remove(state.sessionId());
9898
break;
9999
}
100100
case SplitInstallSessionStatus.CANCELING:
101101
{
102102
Log.e(
103103
TAG,
104-
String.format("Module \"%s\" (sessionId %d) install canceling.",
104+
String.format(
105+
"Module \"%s\" (sessionId %d) install canceling.",
105106
sessionIdToName.get(state.sessionId()),
106-
state.sessionId())
107-
);
107+
state.sessionId()));
108108
break;
109109
}
110110
case SplitInstallSessionStatus.PENDING:
111111
{
112112
Log.e(
113113
TAG,
114-
String.format("Module \"%s\" (sessionId %d) install pending.",
114+
String.format(
115+
"Module \"%s\" (sessionId %d) install pending.",
115116
sessionIdToName.get(state.sessionId()),
116-
state.sessionId())
117-
);
117+
state.sessionId()));
118118
break;
119119
}
120120
case SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION:
121121
{
122122
Log.e(
123123
TAG,
124-
String.format("Module \"%s\" (sessionId %d) install requires user confirmation.",
124+
String.format(
125+
"Module \"%s\" (sessionId %d) install requires user confirmation.",
125126
sessionIdToName.get(state.sessionId()),
126-
state.sessionId())
127-
);
127+
state.sessionId()));
128128
break;
129129
}
130130
case SplitInstallSessionStatus.DOWNLOADING:
131131
{
132132
Log.e(
133133
TAG,
134-
String.format("Module \"%s\" (sessionId %d) downloading.",
134+
String.format(
135+
"Module \"%s\" (sessionId %d) downloading.",
135136
sessionIdToName.get(state.sessionId()),
136-
state.sessionId())
137-
);
137+
state.sessionId()));
138138
break;
139139
}
140140
case SplitInstallSessionStatus.DOWNLOADED:
141141
{
142142
Log.e(
143143
TAG,
144-
String.format("Module \"%s\" (sessionId %d) downloaded.",
144+
String.format(
145+
"Module \"%s\" (sessionId %d) downloaded.",
145146
sessionIdToName.get(state.sessionId()),
146-
state.sessionId())
147-
);
147+
state.sessionId()));
148148
break;
149149
}
150150
case SplitInstallSessionStatus.INSTALLING:
151151
{
152152
Log.e(
153153
TAG,
154-
String.format("Module \"%s\" (sessionId %d) installing.",
154+
String.format(
155+
"Module \"%s\" (sessionId %d) installing.",
155156
sessionIdToName.get(state.sessionId()),
156-
state.sessionId())
157-
);
157+
state.sessionId()));
158158
break;
159159
}
160160
default:
@@ -259,7 +259,7 @@ public void loadDartLibrary(String moduleName, int loadingUnitId) {
259259
String pathAbi = abi.replace("-", "_"); // abis are represented with underscores in paths.
260260

261261
// TODO(garyq): Optimize this apk/file discovery process to use less i/o and be more
262-
// performant.
262+
// performant and robust.
263263

264264
// Search directly in APKs first
265265
List<String> apkPaths = new ArrayList();
@@ -276,8 +276,8 @@ public void loadDartLibrary(String moduleName, int loadingUnitId) {
276276
continue;
277277
}
278278
String name = file.getName();
279-
if (name.substring(name.length() - 4).equals(".apk")
280-
&& name.substring(0, moduleName.length()).equals(moduleName)
279+
if (name.endsWith(".apk")
280+
&& name.startsWith(moduleName)
281281
&& name.contains(pathAbi)) {
282282
apkPaths.add(file.getAbsolutePath());
283283
continue;

shell/platform/android/platform_view_android.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ Dart_Handle PlatformViewAndroid::OnDartLoadLibrary(intptr_t loading_unit_id) {
354354
void PlatformViewAndroid::CompleteDartLoadLibrary(
355355
intptr_t loading_unit_id,
356356
std::string lib_name,
357-
std::vector<std::string>& apkPaths,
357+
const std::vector<std::string>& apkPaths,
358358
std::string abi) {
359359
delegate_.CompleteDartLoadLibrary(loading_unit_id, lib_name, apkPaths, abi);
360360
}

shell/platform/android/platform_view_android.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class PlatformViewAndroid final : public PlatformView {
9999
// |PlatformView|
100100
void CompleteDartLoadLibrary(intptr_t loading_unit_id,
101101
std::string lib_name,
102-
std::vector<std::string>& apkPaths,
102+
const std::vector<std::string>& apkPaths,
103103
std::string abi) override;
104104

105105
// |PlatformView|

0 commit comments

Comments
 (0)