Skip to content

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

Notifications You must be signed in to change notification settings

siren-ocean/SystemUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 中文文档

SystemUI from android-11.0.0_r10

Building SystemUI outside AOSP source in Android Studio

Please switch to the corresponding branch for different Android version support

Support Notes

  • Instead of changing the project's directory structure, we add additional configurations and dependencies to build Gradle environment support
  • Scripts are used to remove some attributes and fields that AS does not support, and then use git local ignore
  • The running effect will still be slightly different from the native one, which is due to the style differences caused by the failure to reference private attributes after being separated from the source code (as shown below)

pixel2 running effect: Gradle build VS Android.bp build



Building with Command Line

Environment Requirements

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

# Execute pre-filter task
./gradlew :Filter:run

# Build and package
./gradlew assemble

Building in Android Studio

Recommended

  • Android Studio 4.2.2 & JDK version >= 8

Step 1: Run the main function on Filter to execute the filter task

Step 2: Execute Build APK in Android Studio, then push the apk to the SystemUI directory on the device

adb push SystemUI.apk /system/system_ext/priv-app/SystemUI/

adb shell killall com.android.systemui
If SystemUI 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

@core-all.jar:
// AOSP/android-11/out/soong/.intermediates/libcore/core-all/android_common/javac/core-all.jar
compileOnly files('libs/core-all.jar')

avatar

@preference-1.2.0-alpha01.aar:
// AOSP/android-11/prebuilts/sdk/current/androidx/m2repository/androidx/preference/preference/1.2.0-alpha01/preference-1.2.0-alpha01.aar
implementation(name: 'preference-1.2.0-alpha01', ext: 'aar')

avatar

ps: androidx.preference is not easy to reference in the following way, so it is replaced with static
## implementation 'androidx.preference:preference:1.2.0-alpha01'
@libprotobuf-java-nano.jar:
// AOSP/android-11/out/soong/.intermediates/external/protobuf/libprotobuf-java-nano/android_common/javac/libprotobuf-java-nano.jar
implementation files('libs/libprotobuf-java-nano.jar')

avatar

@SystemUIPluginLib.jar:
// AOSP/android-11/out/soong/.intermediates/frameworks/base/packages/SystemUI/plugin/SystemUIPluginLib/android_common/javac/SystemUIPluginLib.jar
implementation files('libs/SystemUIPluginLib.jar')

avatar

@SystemUISharedLib.jar:
// AOSP/android-11/out/soong/.intermediates/frameworks/base/packages/SystemUI/shared/SystemUISharedLib/android_common/javac/SystemUISharedLib.jar
implementation files('libs/SystemUISharedLib.jar')

avatar

@WindowManager-Shell.jar:
// AOSP/android-11/out/soong/.intermediates/frameworks/base/libs/WindowManager/Shell/WindowManager-Shell/android_common/javac/WindowManager-Shell.jar
implementation files('libs/WindowManager-Shell.jar')

avatar

@SystemUI-tags.jar:
// AOSP/android-11/out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-tags/android_common/javac/SystemUI-tags.jar
implementation files('libs/SystemUI-tags.jar')

avatar

@SystemUI-proto.jar:
// AOSP/android-11/out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-proto/android_common/javac/SystemUI-proto.jar
implementation files('libs/SystemUI-proto.jar')

avatar

@SystemUI-statsd.jar:
// AOSP/android-11/out/soong/.intermediates/frameworks/base/packages/SystemUI/shared/SystemUI-statsd/android_common/javac/SystemUI-statsd.jar
implementation files('libs/SystemUI-statsd.jar')

avatar

Step 2: Add Module

Import the code from the specific path directly into the project as a Module dependency. During build, you can directly reference it through implementation project, or you can use gradle build to generate aar and place it in the libs folder.
@iconloaderlib:
// AOSP/android-11/frameworks/libs/systemui/iconloaderlib
implementation project(':iconloaderlib')

avatar

@WifiTrackerLib:
// AOSP/android-11/frameworks/opt/net/wifi/libs/WifiTrackerLib
implementation project(':WifiTrackerLib')

avatar

@SettingsLib:
// AOSP/android-11/frameworks/base/packages/SettingsLib
implementation project(':SettingsLib:RestrictedLockUtils')
implementation project(':SettingsLib:AdaptiveIcon')
implementation project(':SettingsLib:HelpUtils')
implementation project(':SettingsLib:ActionBarShadow')
implementation project(':SettingsLib:AppPreference')
implementation project(':SettingsLib:SearchWidget')
implementation project(':SettingsLib:SettingsSpinner')
implementation project(':SettingsLib:LayoutPreference')
implementation project(':SettingsLib:ActionButtonsPreference')
implementation project(':SettingsLib:EntityHeaderWidgets')
implementation project(':SettingsLib:BarChartPreference')
implementation project(':SettingsLib:ProgressBar')
implementation project(':SettingsLib:RadioButtonPreference')
implementation project(':SettingsLib:DisplayDensityUtils')
implementation project(':SettingsLib:Utils')

avatar

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

PS:

View ignored file list
git ls-files -v | grep '^h\ '
Ignore and restore a single file
git update-index --assume-unchanged $path
git update-index --no-assume-unchanged $path
Restore all ignored files
git ls-files -v | grep '^h' | awk '{print $2}' |xargs git update-index --no-assume-unchanged 

Related Projects

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published