Merge "RESTRICT AUTOMERGE Revert "Support CMF default wallpaper"" into udc-dev
This commit is contained in:
@@ -2933,62 +2933,21 @@ public class WallpaperManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isComponentExist(context, cn)) {
|
// Check if the package exists
|
||||||
cn = null;
|
if (cn != null) {
|
||||||
}
|
try {
|
||||||
|
final PackageManager packageManager = context.getPackageManager();
|
||||||
return cn;
|
packageManager.getPackageInfo(cn.getPackageName(),
|
||||||
}
|
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
||||||
|
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
|
||||||
/**
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
* Return {@link ComponentName} of the CMF default wallpaper, or
|
cn = null;
|
||||||
* {@link #getDefaultWallpaperComponent(Context)} if none is defined.
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static ComponentName getCmfDefaultWallpaperComponent(Context context) {
|
|
||||||
ComponentName cn = null;
|
|
||||||
String[] cmfWallpaperMap = context.getResources().getStringArray(
|
|
||||||
com.android.internal.R.array.cmf_default_wallpaper_component);
|
|
||||||
if (cmfWallpaperMap == null || cmfWallpaperMap.length == 0) {
|
|
||||||
Log.d(TAG, "No CMF wallpaper config");
|
|
||||||
return getDefaultWallpaperComponent(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String entry : cmfWallpaperMap) {
|
|
||||||
String[] cmfWallpaper;
|
|
||||||
if (!TextUtils.isEmpty(entry)) {
|
|
||||||
cmfWallpaper = entry.split(",");
|
|
||||||
if (cmfWallpaper != null && cmfWallpaper.length == 2 && VALUE_CMF_COLOR.equals(
|
|
||||||
cmfWallpaper[0]) && !TextUtils.isEmpty(cmfWallpaper[1])) {
|
|
||||||
cn = ComponentName.unflattenFromString(cmfWallpaper[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isComponentExist(context, cn)) {
|
|
||||||
cn = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cn;
|
return cn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isComponentExist(Context context, ComponentName cn) {
|
|
||||||
if (cn == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final PackageManager packageManager = context.getPackageManager();
|
|
||||||
packageManager.getPackageInfo(cn.getPackageName(),
|
|
||||||
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
|
||||||
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a callback for lock wallpaper observation. Only the OS may use this.
|
* Register a callback for lock wallpaper observation. Only the OS may use this.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1817,16 +1817,6 @@
|
|||||||
specified -->
|
specified -->
|
||||||
<string name="default_wallpaper_component" translatable="false">@null</string>
|
<string name="default_wallpaper_component" translatable="false">@null</string>
|
||||||
|
|
||||||
<!-- CMF colors to default wallpaper component map, the component with color matching the device
|
|
||||||
color will be the cmf default wallpapers. The default wallpaper will be default wallpaper
|
|
||||||
component if not specified.
|
|
||||||
|
|
||||||
E.g. for SLV color, and com.android.example/com.android.example.SlVDefaultWallpaper
|
|
||||||
<item>SLV,com.android.example/com.android.example.SlVDefaultWallpaper</item> -->
|
|
||||||
<string-array name="cmf_default_wallpaper_component" translatable="false">
|
|
||||||
<!-- Add packages here -->
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<!-- By default a product has no distinct default lock wallpaper -->
|
<!-- By default a product has no distinct default lock wallpaper -->
|
||||||
<item name="default_lock_wallpaper" type="drawable">@null</item>
|
<item name="default_lock_wallpaper" type="drawable">@null</item>
|
||||||
|
|
||||||
|
|||||||
@@ -2116,7 +2116,6 @@
|
|||||||
<java-symbol type="string" name="data_usage_rapid_body" />
|
<java-symbol type="string" name="data_usage_rapid_body" />
|
||||||
<java-symbol type="string" name="data_usage_rapid_app_body" />
|
<java-symbol type="string" name="data_usage_rapid_app_body" />
|
||||||
<java-symbol type="string" name="default_wallpaper_component" />
|
<java-symbol type="string" name="default_wallpaper_component" />
|
||||||
<java-symbol type="array" name="cmf_default_wallpaper_component" />
|
|
||||||
<java-symbol type="string" name="device_storage_monitor_notification_channel" />
|
<java-symbol type="string" name="device_storage_monitor_notification_channel" />
|
||||||
<java-symbol type="string" name="dlg_ok" />
|
<java-symbol type="string" name="dlg_ok" />
|
||||||
<java-symbol type="string" name="dump_heap_notification" />
|
<java-symbol type="string" name="dump_heap_notification" />
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class WallpaperUpdateReceiver extends BroadcastReceiver {
|
|||||||
} else {
|
} else {
|
||||||
//live wallpaper
|
//live wallpaper
|
||||||
ComponentName currCN = info.getComponent();
|
ComponentName currCN = info.getComponent();
|
||||||
ComponentName defaultCN = WallpaperManager.getCmfDefaultWallpaperComponent(context);
|
ComponentName defaultCN = WallpaperManager.getDefaultWallpaperComponent(context);
|
||||||
if (!currCN.equals(defaultCN)) {
|
if (!currCN.equals(defaultCN)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1588,7 +1588,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
|||||||
mShuttingDown = false;
|
mShuttingDown = false;
|
||||||
mImageWallpaper = ComponentName.unflattenFromString(
|
mImageWallpaper = ComponentName.unflattenFromString(
|
||||||
context.getResources().getString(R.string.image_wallpaper_component));
|
context.getResources().getString(R.string.image_wallpaper_component));
|
||||||
mDefaultWallpaperComponent = WallpaperManager.getCmfDefaultWallpaperComponent(context);
|
mDefaultWallpaperComponent = WallpaperManager.getDefaultWallpaperComponent(context);
|
||||||
mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
|
mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
|
||||||
mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
|
mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
|
||||||
mIPackageManager = AppGlobals.getPackageManager();
|
mIPackageManager = AppGlobals.getPackageManager();
|
||||||
|
|||||||
@@ -172,12 +172,12 @@ public class WallpaperManagerServiceTests {
|
|||||||
sImageWallpaperComponentName = ComponentName.unflattenFromString(
|
sImageWallpaperComponentName = ComponentName.unflattenFromString(
|
||||||
sContext.getResources().getString(R.string.image_wallpaper_component));
|
sContext.getResources().getString(R.string.image_wallpaper_component));
|
||||||
// Mock default wallpaper as image wallpaper if there is no pre-defined default wallpaper.
|
// Mock default wallpaper as image wallpaper if there is no pre-defined default wallpaper.
|
||||||
sDefaultWallpaperComponent = WallpaperManager.getCmfDefaultWallpaperComponent(sContext);
|
sDefaultWallpaperComponent = WallpaperManager.getDefaultWallpaperComponent(sContext);
|
||||||
|
|
||||||
if (sDefaultWallpaperComponent == null) {
|
if (sDefaultWallpaperComponent == null) {
|
||||||
sDefaultWallpaperComponent = sImageWallpaperComponentName;
|
sDefaultWallpaperComponent = sImageWallpaperComponentName;
|
||||||
doReturn(sImageWallpaperComponentName).when(() ->
|
doReturn(sImageWallpaperComponentName).when(() ->
|
||||||
WallpaperManager.getCmfDefaultWallpaperComponent(any()));
|
WallpaperManager.getDefaultWallpaperComponent(any()));
|
||||||
} else {
|
} else {
|
||||||
sContext.addMockService(sDefaultWallpaperComponent, sWallpaperService);
|
sContext.addMockService(sDefaultWallpaperComponent, sWallpaperService);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user