Add an API to get active icon for screen saver

In order to improve the clarity of current screen saver, we need to get
the active icon from DreamBackend and add it on the left side of current
screen saver preference.

Bug: 129994275
Test: robotests
Change-Id: I844ccdcdccc270f23f1a0f0f0ce5335fce184c5b
This commit is contained in:
Mill Chen
2020-04-25 01:53:54 +08:00
parent 61b20fd6e7
commit 57abc612d3

View File

@@ -159,6 +159,25 @@ public class DreamBackend {
return null;
}
/**
* Gets an icon from active dream.
*/
public Drawable getActiveIcon() {
final ComponentName cn = getActiveDream();
if (cn != null) {
final PackageManager pm = mContext.getPackageManager();
try {
final ServiceInfo ri = pm.getServiceInfo(cn, 0);
if (ri != null) {
return ri.loadIcon(pm);
}
} catch (PackageManager.NameNotFoundException exc) {
return null;
}
}
return null;
}
public @WhenToDream int getWhenToDreamSetting() {
if (!isEnabled()) {
return NEVER;