Loading AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ <uses-permission android:name="android.permission.CHANGE_OVERLAY_PACKAGES"/> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/> <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> <application android:extractNativeLibs="false" Loading src/com/android/customization/model/theme/DefaultThemeProvider.java +62 −43 Original line number Diff line number Diff line Loading @@ -31,15 +31,20 @@ import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY import static com.android.customization.model.ResourceConstants.SETTINGS_PACKAGE; import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.om.OverlayInfo; import android.content.om.OverlayManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.service.wallpaper.WallpaperService; import android.text.TextUtils; import android.util.Log; Loading @@ -54,12 +59,15 @@ import com.android.customization.model.theme.custom.CustomTheme; import com.android.customization.module.CustomizationPreferences; import com.android.wallpaper.R; import com.android.wallpaper.asset.ResourceAsset; import com.android.wallpaper.model.LiveWallpaperInfo; import com.bumptech.glide.request.RequestOptions; import org.json.JSONException; import org.json.JSONObject; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; Loading Loading @@ -169,6 +177,19 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB addNoPreviewIconOverlay(builder, iconSettingsOverlayPackage); addWallpaper(themeName, builder); mThemes.add(builder.build(mContext)); } catch (NameNotFoundException | NotFoundException e) { Log.w(TAG, String.format("Couldn't load part of theme %s, will skip it", themeName), e); } } addCustomTheme(); } private void addWallpaper(String themeName, Builder builder) { try { String wallpaperResName = WALLPAPER_PREFIX + themeName; int wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName, Loading @@ -185,19 +206,39 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB "string", mStubPackageName)) .setWallpaperAsset( getDrawableResourceAsset(WALLPAPER_PREFIX, themeName)); } else { // Try to see if it's a live wallpaper reference wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName, "string", mStubPackageName); if (wallpaperResId > 0) { String wpComponent = mStubApkResources.getString(wallpaperResId); String[] componentParts = wpComponent.split("/"); Intent liveWpIntent = new Intent(WallpaperService.SERVICE_INTERFACE); liveWpIntent.setComponent( new ComponentName(componentParts[0], componentParts[0] + componentParts[1])); Context appContext = mContext.getApplicationContext(); PackageManager pm = appContext.getPackageManager(); ResolveInfo resolveInfo = pm.resolveService(liveWpIntent, PackageManager.GET_META_DATA); if (resolveInfo != null) { android.app.WallpaperInfo wallpaperInfo; try { wallpaperInfo = new android.app.WallpaperInfo(appContext, resolveInfo); LiveWallpaperInfo liveInfo = new LiveWallpaperInfo(wallpaperInfo); builder.setLiveWallpaperInfo(liveInfo) .setWallpaperAsset(liveInfo.getThumbAsset(mContext)); } catch (XmlPullParserException e) { Log.w(TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e); } catch (IOException e) { Log.w(TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e); } } catch (NotFoundException e) { // Nothing to do here, if there's no wallpaper we'll just omit wallpaper } mThemes.add(builder.build(mContext)); } catch (NameNotFoundException | NotFoundException e) { Log.w(TAG, String.format("Couldn't load part of theme %s, will skip it", themeName), e); } } addCustomTheme(); } catch (NotFoundException e) { // Nothing to do here, if there's no wallpaper we'll just omit wallpaper } } private void addColorOverlay(Builder builder, String colorOverlayPackage) Loading Loading @@ -373,29 +414,7 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB addSystemDefaultIcons(builder, SYSUI_PACKAGE, ICONS_FOR_PREVIEW); } try { String wallpaperResName = WALLPAPER_PREFIX + DEFAULT_THEME_NAME; int wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName, "drawable", mStubPackageName); if (wallpaperResId > 0) { builder.setWallpaperInfo(mStubPackageName, wallpaperResName, DEFAULT_THEME_NAME, mStubApkResources.getIdentifier( wallpaperResName, "drawable", mStubPackageName), mStubApkResources.getIdentifier(WALLPAPER_TITLE_PREFIX + DEFAULT_THEME_NAME, "string", mStubPackageName), mStubApkResources.getIdentifier( WALLPAPER_ATTRIBUTION_PREFIX + DEFAULT_THEME_NAME, "string", mStubPackageName), mStubApkResources.getIdentifier( WALLPAPER_ACTION_PREFIX + DEFAULT_THEME_NAME, "string", mStubPackageName)) .setWallpaperAsset( getDrawableResourceAsset(WALLPAPER_PREFIX, DEFAULT_THEME_NAME)); } } catch (NotFoundException e) { // Nothing to do here, if there's no wallpaper we'll just omit wallpaper } addWallpaper(DEFAULT_THEME_NAME, builder); mThemes.add(builder.build(mContext)); } Loading src/com/android/customization/model/theme/ThemeBundle.java +10 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.wallpaper.R; import com.android.wallpaper.asset.Asset; import com.android.wallpaper.asset.BitmapCachingAsset; import com.android.wallpaper.asset.ResourceAsset; import com.android.wallpaper.model.LiveWallpaperInfo; import com.android.wallpaper.model.WallpaperInfo; import org.json.JSONObject; Loading Loading @@ -255,7 +256,7 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { private PreviewInfo(Context context, Typeface bodyFontFamily, Typeface headlineFontFamily, int colorAccentLight, int colorAccentDark, List<Drawable> icons, Drawable shapeDrawable, @Dimension int cornerRadius, @Nullable ResourceAsset wallpaperAsset, List<Drawable> shapeAppIcons) { @Nullable Asset wallpaperAsset, List<Drawable> shapeAppIcons) { this.bodyFontFamily = bodyFontFamily; this.headlineFontFamily = headlineFontFamily; this.colorAccentLight = colorAccentLight; Loading Loading @@ -290,7 +291,7 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { private String mShapePath; private boolean mIsDefault; @Dimension private int mCornerRadius; private ResourceAsset mWallpaperAsset; private Asset mWallpaperAsset; private WallpaperInfo mWallpaperInfo; protected Map<String, String> mPackages = new HashMap<>(); private List<Drawable> mAppIcons = new ArrayList<>(); Loading Loading @@ -372,7 +373,13 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { return this; } public Builder setWallpaperAsset(ResourceAsset wallpaperAsset) { public Builder setLiveWallpaperInfo(LiveWallpaperInfo info) { mWallpaperInfo = info; return this; } public Builder setWallpaperAsset(Asset wallpaperAsset) { mWallpaperAsset = wallpaperAsset; return this; } Loading src/com/android/customization/model/theme/ThemeManager.java +23 −18 Original line number Diff line number Diff line Loading @@ -27,9 +27,7 @@ import static com.android.customization.model.ResourceConstants.SETTINGS_PACKAGE import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE; import android.graphics.Point; import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; Loading @@ -40,8 +38,6 @@ import com.android.customization.model.theme.custom.CustomTheme; import com.android.customization.module.ThemesUserEventLogger; import com.android.wallpaper.R; import com.android.wallpaper.asset.Asset; import com.android.wallpaper.module.Injector; import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.module.WallpaperPersister; import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback; import com.android.wallpaper.module.WallpaperSetter; Loading Loading @@ -95,7 +91,8 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { // Set wallpaper if (theme.shouldUseThemeWallpaper()) { mWallpaperSetter.requestDestination(mActivity, mActivity.getSupportFragmentManager(), R.string.set_theme_wallpaper_dialog_message, new Listener() { R.string.set_theme_wallpaper_dialog_message, theme.getWallpaperInfo(), new Listener() { @Override public void onSetHomeScreen() { applyWallpaper(theme, WallpaperPersister.DEST_HOME_SCREEN, Loading Loading @@ -140,6 +137,7 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { mActivity.getResources(), mActivity.getWindowManager().getDefaultDisplay()); Asset wallpaperAsset = theme.getWallpaperInfo().getAsset(mActivity); if (wallpaperAsset != null) { wallpaperAsset.decodeRawDimensions(mActivity, dimensions -> { float scale = 1f; Loading @@ -153,6 +151,13 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { destination, scale, null, callback); }); } else { mWallpaperSetter.setCurrentWallpaper(mActivity, theme.getWallpaperInfo(), null, destination, 1f, null, callback); } } private void applyOverlays(ThemeBundle theme, Callback callback) { Loading Loading
AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ <uses-permission android:name="android.permission.CHANGE_OVERLAY_PACKAGES"/> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/> <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> <application android:extractNativeLibs="false" Loading
src/com/android/customization/model/theme/DefaultThemeProvider.java +62 −43 Original line number Diff line number Diff line Loading @@ -31,15 +31,20 @@ import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY import static com.android.customization.model.ResourceConstants.SETTINGS_PACKAGE; import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.om.OverlayInfo; import android.content.om.OverlayManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.service.wallpaper.WallpaperService; import android.text.TextUtils; import android.util.Log; Loading @@ -54,12 +59,15 @@ import com.android.customization.model.theme.custom.CustomTheme; import com.android.customization.module.CustomizationPreferences; import com.android.wallpaper.R; import com.android.wallpaper.asset.ResourceAsset; import com.android.wallpaper.model.LiveWallpaperInfo; import com.bumptech.glide.request.RequestOptions; import org.json.JSONException; import org.json.JSONObject; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; Loading Loading @@ -169,6 +177,19 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB addNoPreviewIconOverlay(builder, iconSettingsOverlayPackage); addWallpaper(themeName, builder); mThemes.add(builder.build(mContext)); } catch (NameNotFoundException | NotFoundException e) { Log.w(TAG, String.format("Couldn't load part of theme %s, will skip it", themeName), e); } } addCustomTheme(); } private void addWallpaper(String themeName, Builder builder) { try { String wallpaperResName = WALLPAPER_PREFIX + themeName; int wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName, Loading @@ -185,19 +206,39 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB "string", mStubPackageName)) .setWallpaperAsset( getDrawableResourceAsset(WALLPAPER_PREFIX, themeName)); } else { // Try to see if it's a live wallpaper reference wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName, "string", mStubPackageName); if (wallpaperResId > 0) { String wpComponent = mStubApkResources.getString(wallpaperResId); String[] componentParts = wpComponent.split("/"); Intent liveWpIntent = new Intent(WallpaperService.SERVICE_INTERFACE); liveWpIntent.setComponent( new ComponentName(componentParts[0], componentParts[0] + componentParts[1])); Context appContext = mContext.getApplicationContext(); PackageManager pm = appContext.getPackageManager(); ResolveInfo resolveInfo = pm.resolveService(liveWpIntent, PackageManager.GET_META_DATA); if (resolveInfo != null) { android.app.WallpaperInfo wallpaperInfo; try { wallpaperInfo = new android.app.WallpaperInfo(appContext, resolveInfo); LiveWallpaperInfo liveInfo = new LiveWallpaperInfo(wallpaperInfo); builder.setLiveWallpaperInfo(liveInfo) .setWallpaperAsset(liveInfo.getThumbAsset(mContext)); } catch (XmlPullParserException e) { Log.w(TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e); } catch (IOException e) { Log.w(TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e); } } catch (NotFoundException e) { // Nothing to do here, if there's no wallpaper we'll just omit wallpaper } mThemes.add(builder.build(mContext)); } catch (NameNotFoundException | NotFoundException e) { Log.w(TAG, String.format("Couldn't load part of theme %s, will skip it", themeName), e); } } addCustomTheme(); } catch (NotFoundException e) { // Nothing to do here, if there's no wallpaper we'll just omit wallpaper } } private void addColorOverlay(Builder builder, String colorOverlayPackage) Loading Loading @@ -373,29 +414,7 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB addSystemDefaultIcons(builder, SYSUI_PACKAGE, ICONS_FOR_PREVIEW); } try { String wallpaperResName = WALLPAPER_PREFIX + DEFAULT_THEME_NAME; int wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName, "drawable", mStubPackageName); if (wallpaperResId > 0) { builder.setWallpaperInfo(mStubPackageName, wallpaperResName, DEFAULT_THEME_NAME, mStubApkResources.getIdentifier( wallpaperResName, "drawable", mStubPackageName), mStubApkResources.getIdentifier(WALLPAPER_TITLE_PREFIX + DEFAULT_THEME_NAME, "string", mStubPackageName), mStubApkResources.getIdentifier( WALLPAPER_ATTRIBUTION_PREFIX + DEFAULT_THEME_NAME, "string", mStubPackageName), mStubApkResources.getIdentifier( WALLPAPER_ACTION_PREFIX + DEFAULT_THEME_NAME, "string", mStubPackageName)) .setWallpaperAsset( getDrawableResourceAsset(WALLPAPER_PREFIX, DEFAULT_THEME_NAME)); } } catch (NotFoundException e) { // Nothing to do here, if there's no wallpaper we'll just omit wallpaper } addWallpaper(DEFAULT_THEME_NAME, builder); mThemes.add(builder.build(mContext)); } Loading
src/com/android/customization/model/theme/ThemeBundle.java +10 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.wallpaper.R; import com.android.wallpaper.asset.Asset; import com.android.wallpaper.asset.BitmapCachingAsset; import com.android.wallpaper.asset.ResourceAsset; import com.android.wallpaper.model.LiveWallpaperInfo; import com.android.wallpaper.model.WallpaperInfo; import org.json.JSONObject; Loading Loading @@ -255,7 +256,7 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { private PreviewInfo(Context context, Typeface bodyFontFamily, Typeface headlineFontFamily, int colorAccentLight, int colorAccentDark, List<Drawable> icons, Drawable shapeDrawable, @Dimension int cornerRadius, @Nullable ResourceAsset wallpaperAsset, List<Drawable> shapeAppIcons) { @Nullable Asset wallpaperAsset, List<Drawable> shapeAppIcons) { this.bodyFontFamily = bodyFontFamily; this.headlineFontFamily = headlineFontFamily; this.colorAccentLight = colorAccentLight; Loading Loading @@ -290,7 +291,7 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { private String mShapePath; private boolean mIsDefault; @Dimension private int mCornerRadius; private ResourceAsset mWallpaperAsset; private Asset mWallpaperAsset; private WallpaperInfo mWallpaperInfo; protected Map<String, String> mPackages = new HashMap<>(); private List<Drawable> mAppIcons = new ArrayList<>(); Loading Loading @@ -372,7 +373,13 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { return this; } public Builder setWallpaperAsset(ResourceAsset wallpaperAsset) { public Builder setLiveWallpaperInfo(LiveWallpaperInfo info) { mWallpaperInfo = info; return this; } public Builder setWallpaperAsset(Asset wallpaperAsset) { mWallpaperAsset = wallpaperAsset; return this; } Loading
src/com/android/customization/model/theme/ThemeManager.java +23 −18 Original line number Diff line number Diff line Loading @@ -27,9 +27,7 @@ import static com.android.customization.model.ResourceConstants.SETTINGS_PACKAGE import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE; import android.graphics.Point; import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; Loading @@ -40,8 +38,6 @@ import com.android.customization.model.theme.custom.CustomTheme; import com.android.customization.module.ThemesUserEventLogger; import com.android.wallpaper.R; import com.android.wallpaper.asset.Asset; import com.android.wallpaper.module.Injector; import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.module.WallpaperPersister; import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback; import com.android.wallpaper.module.WallpaperSetter; Loading Loading @@ -95,7 +91,8 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { // Set wallpaper if (theme.shouldUseThemeWallpaper()) { mWallpaperSetter.requestDestination(mActivity, mActivity.getSupportFragmentManager(), R.string.set_theme_wallpaper_dialog_message, new Listener() { R.string.set_theme_wallpaper_dialog_message, theme.getWallpaperInfo(), new Listener() { @Override public void onSetHomeScreen() { applyWallpaper(theme, WallpaperPersister.DEST_HOME_SCREEN, Loading Loading @@ -140,6 +137,7 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { mActivity.getResources(), mActivity.getWindowManager().getDefaultDisplay()); Asset wallpaperAsset = theme.getWallpaperInfo().getAsset(mActivity); if (wallpaperAsset != null) { wallpaperAsset.decodeRawDimensions(mActivity, dimensions -> { float scale = 1f; Loading @@ -153,6 +151,13 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { destination, scale, null, callback); }); } else { mWallpaperSetter.setCurrentWallpaper(mActivity, theme.getWallpaperInfo(), null, destination, 1f, null, callback); } } private void applyOverlays(ThemeBundle theme, Callback callback) { Loading