English | 中文文档
- Instead of changing the project's directory structure, we add additional configurations and dependencies to build Gradle environment support
- The following two code modifications are required for proper operation (as shown below)
1. com.android.documentsui.DirectoryLoader
*********************************************************
// Deprecated method
//@Override
protected Executor getExecutor() {
return ProviderExecutor.forAuthority(mRoot.authority);
}
2. com.android.documentsui.roots.ProvidersCache
********************************************************
public void updateAsync(boolean forceRefreshAll, @Nullable Runnable callback) {
// NOTE: This method is called when the UI language changes.
// For that reason we update our RecentsRoot to reflect
// the current language.
final String title = mContext.getString(R.string.root_recent);
for (UserId userId : mUserIdManager.getUserIds()) {
RootInfo recentRoot = createOrGetRecentsRoot(userId);
recentRoot.title = title;
// Nothing else about the root should ever change.
assert (recentRoot.authority == null);
assert (recentRoot.rootId == null);
assert (recentRoot.derivedIcon == R.drawable.ic_root_recent);
assert (recentRoot.derivedType == RootInfo.TYPE_RECENTS);
// Ignore this assertion, the values are not equal, but the AOSP compiled version won't crash !=_=
//assert (recentRoot.flags == (Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_IS_CHILD));
assert (recentRoot.availableBytes == -1);
}
new UpdateTask(forceRefreshAll, null, callback).executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR);
}
- Gradle 6.5
- JDK version >= 8
# Setup build environment
gradle wrapper
# Build and package
./gradlew assemble
- Android Studio >= 4.2.2 & JDK version >= 8
adb push DocumentsUI.apk /system/priv-app/DocumentsUI/
adb shell killall com.android.documentsui
adb reboot
// AOSP/android-11/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-header.jar
compileOnly files('libs/framework.jar')
// AOSP/android-11/out/soong/.intermediates/external/guava/guava/android_common/turbine-combined/guava.jar
implementation files('libs/guava.jar')
// AOSP/android-11/prebuilts/sdk/current/androidx-legacy/m2repository/androidx/legacy/legacy-support-v13/1.1.0-alpha01/legacy-support-v13-1.1.0-alpha01.aar
implementation(name: 'legacy-support-v13-1.1.0-alpha01', ext: 'aar')
PS: legacy-support-v13-1.1.0 cannot be referenced online in the current version, so we use a static dependency instead
## implementation 'androidx.legacy:legacy-support-v13-1.1.0-alpha01'
Import a special class DocumentsStatsLog, which is auto-generated and can be found in the out directory
// AOSP/android-11/out/soong/.intermediates/packages/apps/DocumentsUI/statslog-docsui-java-gen
sourceSets {
main {
java.srcDirs = ['src', 'statslog-docsui-java-gen/gen']
res.srcDirs = ['res']
manifest.srcFile 'AndroidManifest.xml'
}
}
Find the signing certificates in the AOSP/android-11/build/target/product/security path and use keytool-importkeypair to generate the keystore. Execute the following command:
./keytool-importkeypair -k platform.keystore -p 123456 -pk8 platform.pk8 -cert platform.x509.pem -alias platform
And add the following code to the gradle configuration:
signingConfigs {
platform {
storeFile file("platform.keystore")
storePassword '123456'
keyAlias 'platform'
keyPassword '123456'
}
}
buildTypes {
release {
debuggable false
minifyEnabled false
signingConfig signingConfigs.platform
}
debug {
debuggable true
minifyEnabled false
signingConfig signingConfigs.platform
}
}


