Skip to content

siren-ocean/DocumentsUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 中文文档

DocumentsUI from android-11.0.0_r10

Building DocumentsUI outside AOSP source in Android Studio

Support Notes

  • 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);
}

Building with Command Line

Environment Requirements

  • Gradle 6.5
  • JDK version >= 8
# Setup build environment
gradle wrapper

# Build and package
./gradlew assemble

Building in Android Studio

Recommended

  • Android Studio >= 4.2.2 & JDK version >= 8

Execute Build APK in Android Studio, then push the apk to the DocumentsUI directory on the device

adb push DocumentsUI.apk /system/priv-app/DocumentsUI/

adb shell killall com.android.documentsui

PS: If DocumentsUI cannot start properly, you need to reboot the device.

adb reboot

Build Steps

Step 1: Add Static Dependencies

@framework.jar:
// AOSP/android-11/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-header.jar
compileOnly files('libs/framework.jar')

avatar

@guava.jar:
// AOSP/android-11/out/soong/.intermediates/external/guava/guava/android_common/turbine-combined/guava.jar
implementation files('libs/guava.jar')

avatar

@legacy-support-v13-1.1.0-alpha01.aar:
// 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')

avatar

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'

Step 2: Add Code

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'
    }
}

Generate platform.keystore Default Signature

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
        }
    }

Related Projects

About

Enabled DocumentsUI to build and run in Android Studio. Supported Android 11~14(使DocumentsUI能在Android Studio上单编运行,现已支持安卓11~14的版本)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages