1.客户需求隐藏桌面上第三方的桌面小部件;
image.png
1.根据UI定位到对应的视图QsbContainerView,发现里面有直接find小部件对应包名的方法,那就直接根据包名过滤掉对应的视图创建就行;
Index: src/com/android/launcher3/qsb/QsbContainerView.java
===================================================================
@@ -53,6 +53,7 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.FragmentWithPreview;
import com.android.launcher3.widget.util.WidgetSizes;
+import android.util.Log;
/**
* A frame layout which contains a QSB. This internally uses fragment to bind the view, which
@@ -193,7 +194,11 @@
// Only add the view when enabled
if (isQsbEnabled()) {
mQsbWidgetHost.startListening();
- mWrapper.addView(createQsb(mWrapper));
+ String providerPkg = getSearchWidgetPackageName(getContext());
+ Log.e("QsbContainerView", "onCreateView createQsb providerPkg="+providerPkg);
+ if (!providerPkg.contains("com.qiyi.video.pad")) {
+ mWrapper.addView(createQsb(mWrapper));
+ }
}
Utilities.getPrefs(getContext()).registerOnSharedPreferenceChangeListener(this);
return mWrapper;
@@ -311,7 +316,11 @@
if (mWrapper != null && getContext() != null) {
mWrapper.removeAllViews();
- mWrapper.addView(createQsb(mWrapper));
+ String providerPkg = getSearchWidgetPackageName(getContext());
+ Log.e("QsbContainerView", "rebindFragment createQsb providerPkg="+providerPkg);
+ if (!providerPkg.contains("com.qiyi.video.pad")) {
+ mWrapper.addView(createQsb(mWrapper));
+ }
}
}
网友评论