首页 > 其他分享 >Android 13 GMS 内置壁纸

Android 13 GMS 内置壁纸

时间:2024-08-13 20:25:29浏览次数:15  
标签:13 mAppContext res wallpaper jpg GMS 壁纸 Android android

在这里插入图片描述
如图,原生系统上,设备上的壁纸 显示系统内置壁纸。如果没有添加内置壁纸,就显示默认的壁纸。点击进去就是预览页面

扩展下,默认壁纸在

frameworks/base/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.png
frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.png
frameworks/base/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.png

添加默认壁纸,追溯下代码。

1.ThemePicker

当前页面是 com.android.wallpaper/.picker.CustomizationPickerActivity ,对应源码 packages/apps/ThemePicker

但是在此目录下找不到 CustomizationPickerActivity 。

查看 packages/apps/ThemePicker/Android.bp

java_defaults {
    name: "ThemePicker_defaults",

    static_libs: [
        "guava",
        "monet",
	    "renderscript_toolkit",
        "wallpaper-common-deps",
        "SettingsLibSettingsTheme",
        "SystemUI-statsd",
        "styleprotoslite",
        "androidx.lifecycle_lifecycle-livedata-ktx",
        "androidx.lifecycle_lifecycle-runtime-ktx",
        "androidx.lifecycle_lifecycle-viewmodel-ktx",
        "androidx.recyclerview_recyclerview",
        "SystemUICustomizationLib",
    ],

    jni_libs: [
        "librenderscript-toolkit",
    ],

    srcs: [
        ":WallpaperPicker2_srcs",
        ":ThemePicker_srcs",
        ":ThemePicker_src_overrides",
    ],

    use_embedded_native_libs: true,

    resource_zips: [":WallpaperPicker2_res", ":ThemePicker_res", ":ThemePicker_res_overrides"],

    optimize: {
        enabled: false,
    },
    kotlincflags: ["-Xjvm-default=enable"],
    certificate: "",

    privileged: true,
    system_ext_specific: true,
}

//
// Build app code.
//
android_app {
    name: "ThemePicker",
    defaults: ["ThemePicker_defaults"],

    platform_apis: true,
    manifest: "AndroidManifest.xml",
    additional_manifests: [":WallpaperPicker2_Manifest"],
    overrides: ["WallpaperPicker2"],
}

ThemePicker 引用了 WallpaperPicker2,在 WallpaperPicker2 里找到了 CustomizationPickerActivity 。

2.WallpaperPicker2

找到 DefaultCategoryProvider.java ,

	/**
     * AsyncTask subclass used for fetching all the categories and pushing them one at a time to
     * the receiver.
     */
    protected static class FetchCategoriesTask extends AsyncTask<Void, Category, Void> {
        private CategoryReceiver mReceiver;
        private PartnerProvider mPartnerProvider;
        protected final Context mAppContext;

        public FetchCategoriesTask(CategoryReceiver receiver, Context context) {
            mReceiver = receiver;
            mAppContext = context.getApplicationContext();
        }

        @Override
        protected Void doInBackground(Void... voids) {
            mPartnerProvider = InjectorProvider.getInjector().getPartnerProvider(
                    mAppContext);

            // "My photos" wallpapers
            android.util.Log.d("luoah", "[DefaultCategoryProvider] doInBackground ,My photos wallpapers");
            publishProgress(getMyPhotosCategory());

			android.util.Log.d("luoah", "[DefaultCategoryProvider] doInBackground ,publishDeviceCategories");
            publishDeviceCategories();

            // Legacy On-device wallpapers. Only show if on mobile.
            android.util.Log.d("luoah", "[DefaultCategoryProvider] doInBackground ,getOnDeviceCategory");
            publishProgress(getOnDeviceCategory());

            // Live wallpapers -- if the device supports them.
            if (mAppContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LIVE_WALLPAPER)) {				
                List<WallpaperInfo> liveWallpapers = LiveWallpaperInfo.getAll(
                        mAppContext, getExcludedLiveWallpaperPackageNames());
				android.util.Log.d("luoah", "[DefaultCategoryProvider] doInBackground ,liveWallpapers.size():"+liveWallpapers.size());
                if (liveWallpapers.size() > 0) {
                    publishProgress(
                            new ThirdPartyLiveWallpaperCategory(
                                    mAppContext.getString(R.string.live_wallpapers_category_title),
                                    mAppContext.getString(R.string.live_wallpaper_collection_id),
                                    liveWallpapers,
                                    PRIORITY_LIVE,
                                    getExcludedLiveWallpaperPackageNames()));
                }
            }

            // Third party apps.
            android.util.Log.d("luoah", "[DefaultCategoryProvider] doInBackground ,Third party apps");
            List<ThirdPartyAppCategory> thirdPartyApps = ThirdPartyAppCategory.getAll(
                    mAppContext, PRIORITY_THIRD_PARTY, getExcludedThirdPartyPackageNames());
            for (ThirdPartyAppCategory thirdPartyApp : thirdPartyApps) {
                publishProgress(thirdPartyApp);
            }

            return null;
        }

2.1 图库上的壁纸

2.2 设备上的壁纸

packages/apps/WallpaperPicker2/src/com/android/wallpaper/module/DefaultCategoryProvider.java
getOnDeviceCategory 方法,

        /**
         * Returns a category which incorporates both GEL and bundled wallpapers.
         */
        protected Category getOnDeviceCategory() {
            android.util.Log.d("luoah", "[DefaultCategoryProvider] getOnDeviceCategory");
			try {
                throw new Exception("luoah_getOnDeviceCategory");
            } catch (Exception e) {
                e.printStackTrace();
            }
            List<WallpaperInfo> onDeviceWallpapers = new ArrayList<>();

            if (!mPartnerProvider.shouldHideDefaultWallpaper()) {
                DefaultWallpaperInfo defaultWallpaperInfo = new DefaultWallpaperInfo();
                onDeviceWallpapers.add(defaultWallpaperInfo);
            }

            List<WallpaperInfo> partnerWallpaperInfos = PartnerWallpaperInfo.getAll(mAppContext);
            onDeviceWallpapers.addAll(partnerWallpaperInfos);

            List<WallpaperInfo> legacyPartnerWallpaperInfos = LegacyPartnerWallpaperInfo.getAll(
                    mAppContext);
            onDeviceWallpapers.addAll(legacyPartnerWallpaperInfos);

            List<WallpaperInfo> privateWallpapers = getPrivateDeviceWallpapers();
            if (privateWallpapers != null) {
                onDeviceWallpapers.addAll(privateWallpapers);
            }

            return onDeviceWallpapers.isEmpty() ? null : new WallpaperCategory(
                    mAppContext.getString(R.string.on_device_wallpapers_category_title),
                    mAppContext.getString(R.string.on_device_wallpaper_collection_id),
                    onDeviceWallpapers,
                    PRIORITY_ON_DEVICE);
        }

packages/apps/WallpaperPicker2/src/com/android/wallpaper/model/PartnerWallpaperInfo.java ,

/**
     * @param ctx
     * @return All partner wallpapers found on the device.
     */
    public static List<WallpaperInfo> getAll(Context ctx) {
        PartnerProvider partnerProvider = InjectorProvider.getInjector().getPartnerProvider(ctx);

        List<WallpaperInfo> wallpaperInfos = new ArrayList<>();

        final Resources partnerRes = partnerProvider.getResources();
        final String packageName = partnerProvider.getPackageName();
        if (partnerRes == null) {
            return wallpaperInfos;
        }

        final int resId = partnerRes.getIdentifier(PartnerProvider.LEGACY_WALLPAPER_RES_ID, "array",
                packageName);
		android.util.Log.d("luoah", "[PartnerWallpaperInfo] getAll , packageName:"+packageName+" , resId:"+resId);
        // Certain partner configurations don't have wallpapers provided, so need to check; return
        // early if they are missing.
        if (resId == 0) {
            return wallpaperInfos;
        }

        final String[] extras = partnerRes.getStringArray(resId);
        for (String extra : extras) {
            int wpResId = partnerRes.getIdentifier(extra, "drawable", packageName);
			android.util.Log.d("luoah", "[PartnerWallpaperInfo] getAll , wpResId:"+wpResId);
            if (wpResId != 0) {
                final int thumbRes = partnerRes.getIdentifier(extra + "_small", "drawable", packageName);

                if (thumbRes != 0) {
                    final int fullRes = partnerRes.getIdentifier(extra, "drawable", packageName);
					android.util.Log.d("luoah", "[PartnerWallpaperInfo] extras in , thumbRes:"+thumbRes);
                    WallpaperInfo wallpaperInfo = new PartnerWallpaperInfo(thumbRes, fullRes);
                    wallpaperInfos.add(wallpaperInfo);
                }
            } else {
                Log.e("PartnerWallpaperInfo", "Couldn't find wallpaper " + extra);
            }
        }

        return wallpaperInfos;
    }

加打印,机器上 packageName 是 com.google.android.gmsintegration , 即 vendor/partner_gms/apps/GmsSampleIntegration

结合源码分析,在 GmsSampleIntegration 应用里加一组数组,数组元素是壁纸图片名称,

  • 添加 res/values/arrays.xml
<resources>
        <string-array name="partner_wallpapers" translatable="false">
            <item>wallpaper_01</item>
            <item>wallpaper_02</item>
            <item>wallpaper_03</item>
            <item>wallpaper_04</item>
            <item>wallpaper_05</item>
            <item>wallpaper_06</item>
</string-array>
  • res_dhs_full/drawable/ 目录放入壁纸,同时存放 *_small.jpg ,
wallpaper_01.jpg
wallpaper_01_small.jpg
wallpaper_02.jpg
wallpaper_02_small.jpg
wallpaper_03.jpg
wallpaper_03_small.jpg
wallpaper_04.jpg
wallpaper_04_small.jpg
wallpaper_05.jpg
wallpaper_05_small.jpg
wallpaper_06.jpg
wallpaper_06_small.jpg

替换后的效果,点击进去显示选择图片,选择图片后是预览页面,
在这里插入图片描述

2.3 动态壁纸

2.4 三方应用的壁纸

标签:13,mAppContext,res,wallpaper,jpg,GMS,壁纸,Android,android
From: https://blog.csdn.net/weixin_44021334/article/details/140636977

相关文章

  • 8,13号考试错题总结
    考试情况ABCDEF100030100160考题A.P1571眼红的MedusaB.P2249【深基13.例1】查找C.P1678烦恼的高考志愿D.P1918保龄球E.P1102A-B数对F.B3799[NICA#1]序列考点/易错点A.P1571眼红的Medusa:考二分模板掌握度B.P2249【深基13.例1】查找:同上......
  • 数据库系统 第13节 索引
    索引(Indexing)是一种数据结构技术,广泛应用于数据库和文件系统中,用于提高数据检索的速度。在没有索引的情况下,数据库必须从头到尾扫描整个表来找到所需的数据行,这被称为全表扫描(FullTableScan),对于大型数据库来说效率极低。索引的基本原理索引类似于书籍的目录。当你需要查......
  • RK3399 Android8.1静默安装APK
    在RK3399Android8.1上面,实现APK静默安装功能,下面是我们的测试验试过程:1.在RK3399Android8.1源码目录下生成系统签名KEY:  进入build/target/product/security目录:cdbuild/target/product/security  创建build_system_jks2.sh文件,内容如下:#!/bin/bashecho"生......
  • 如何使用Android WakeLock?
    在Android应用或者Framworks里面,要如何使用AndroidWakeLock来避免系统待机,或者系统息屏后加个锁进行网络等后台操作处理呢?我们可以在代码里面导入并创建相应对象,有如下内容:importandroid.os.PowerManager;importandroid.os.PowerManager.WakeLock;WakeLockmWakeLock;P......
  • Android Studio Gradle->Android Studio创建项目后,生成文件详解
    Gradle版本:gradle-8.0AndroidStudio版本:AndroidStudioGiraffe|2022.3.1Patch3.gradle文件夹作用:存储Gradle缓存和构建信息内容:包括Gradle构建缓存、已下载的依赖项等。这个文件夹可以安全地删除,Gradle会在下次构建时重新生成它.idea文件夹作用:存......
  • 8.13今日份作业
     链栈,自己实现一遍,但是节点存储不是整数,存储学生信息(年龄,分数,姓名)三级引用。1、建立学生信息结构体,将data改为学生信息结构体类型。2、循环入栈和入队。链式栈:#include<myhead.h>typedefintmy_int;typedefcharSTR[20];typedefstruct{ STRname;//姓名 my_int......
  • 嵌入式软件--数据结构与算法 DAY 13
    在嵌入式中,对算法的要求不高,但顺序查找和冒泡排序是经典算法,必须掌握。1.算法定义算法是一个用于解决特定问题的有限指令序列(计算机可以执行的操作)。通俗的理解就是可以解决特定问题的方法。2.时间复杂度时间复杂度不是执行完一段程序的总时间,而是描述为一个算法中基本操作......
  • 20240813:组合计数选做
    P3214[HNOI2011]卡农题意:\(m\)个集合,\(n\)种元素,求集合间互不相同且每种元素出现偶数次的方案数。题目等价于从\(1\sim2^n-1\)里选出\(m\)个不同的数,使他们异或和为\(0\)。不妨对每个数标号,由于互不相同,最后除以\(m!\)即可。设\(f_i\)表示前\(i\)个数异或......
  • VisionPro二次开发学习笔记13-使用CogToolBlock进行图像交互
    该程序演示了如何使用CogToolBlock进行图像交互.从vpp文件中加载一个ToolBlock。用户可以通过应用程序窗体上的数字增减控件修改ToolBlock输入端子的值。用户还可以从coins.idb或采集FIFO中选择图像。“运行一次”按钮执行以下操作:获取下一个图像或读取下一个图像......
  • ARC134E
    手玩题思路由于数据范围小,所以可以手动模拟找规律。假设\(A\)为先手,据题意,当轮到\(A\)操作时,如果此时序列里最大数为\(0\)(也就是序列里全是\(0\)),那么\(A\)就赢了。由于\(A\)操作时序列的状态是由\(B\)操作时的序列取模之后得到的,所以\(B\)操作时的序列中的元素肯定有相同的约......