Android 让Search不到相应的Activity

Issue:

Actual Results: Flashlight option is listing under settings search and is not opening.

Expected Results: options not present in settings app should not be listed for search results.

Reproduction Steps:

  1. Launch settings application.
  2. Search for Flashlight.
  3. Tap on the result displayed(No action performed).

Reproducibility:100%

Commit:
"
Description: Flashlight option is listing under settings search and is not opening.
Solution: Hide the flashlight in setting's search.
"
就是有些功能未能实现,但是Settings 搜索的时候还是能检索到,点击的时候又没作用。


Android 让Search不到相应的Activity_第1张图片
解决方案如下:
找到这个Activity对应的code:

Android 让Search不到相应的Activity_第2张图片
code:
pacakages/apps/src/com/android/settings/flashlight/FlashlightHandleActivity.java
 

 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {

                @Override
                public List getRawDataToIndex(Context context,
                        boolean enabled) {

                    final List result = new ArrayList<>();

                    SearchIndexableRaw data = new SearchIndexableRaw(context);
                    //BSPA-232771 Hide the flashlight in setting's search.
                    if (!ZebraUtils.isZebra().orElse(false)){
                        data.title = context.getString(R.string.power_flashlight);
                        data.screenTitle = context.getString(R.string.power_flashlight);
                        data.keywords = context.getString(R.string.keywords_flashlight);
                    }
                    data.intentTargetPackage = context.getPackageName();
                    data.intentTargetClass = FlashlightHandleActivity.class.getName();
                    data.intentAction = Intent.ACTION_MAIN;
                    data.key = DATA_KEY;
                    result.add(data);

                    return result;
                }

                @Override
                public List getNonIndexableKeys(Context context) {
                    List keys = super.getNonIndexableKeys(context);
                    if (!FlashlightSlice.isFlashlightAvailable(context)) {
                        Log.i(TAG, "Flashlight is unavailable");
                        keys.add(DATA_KEY);
                    }
                    return keys;
                }
            };

你可能感兴趣的:(android)