如果第一次按下音量按钮和三点图标,声音和振动菜单上的音量选项将丢失

问题描述:
Actual Results: Volume options are missing on Sound & vibration menu if press volume button and three dots icon for the first time.

Expected Results: Volume options should show correctly on Sound & vibration menu after press volume button and three dots icon every time.

Reproduction Steps:

  1. Flash the latest image.
  2. Press any hardware volume button -> three dots (for the first time).
  3. Sound & vibration menu launched.
  4. Find volume options are missing. ==> Problem
  5. Press any hardware volume button -> three dots again.
  6. Find volume options can show correctly.

Reproducibility: The first time



解决方案是:在第一次点击时增加了一些延迟(1000ms).
packages/apps/Settings/src/com/android/settings/panel/PanelFragment.java

import static android.content.Context.MODE_PRIVATE;
import android.content.SharedPreferences;
//BSPA-222615 Determine whether it is the first click or not.
private boolean isHasOpened;
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {
        mLayoutView = inflater.inflate(R.layout.panel_layout, container, false);
        mLayoutView.getViewTreeObserver()
                .addOnGlobalLayoutListener(mPanelLayoutListener);
        mMaxHeight = getResources().getDimensionPixelSize(R.dimen.output_switcher_slice_max_height);
        mPanelCreating = true;
        //BSAP-222615 Determine whether it is the first click or not
        SharedPreferences pref = getActivity().getSharedPreferences("paneldata",MODE_PRIVATE);
        isHasOpened = pref.getBoolean("volumedata",false);
        createPanelContent();
        return mLayoutView;
    }
private void loadAllSlices() {
        mSliceLiveData.clear();
...
final SliceMetadata metadata = SliceMetadata.from(getActivity(), slice);
                if (slice == null || metadata.isErrorSlice()) {
                    removeSliceLiveData(uri);
                    mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
                } else if (metadata.getLoadingState() == SliceMetadata.LOADED_ALL) {
                    mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
                } else {
                    Handler handler = new Handler();
                    handler.postDelayed(() -> {
                        mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
                        loadPanelWhenReady();
                    }, isHasOpened ? DURATION_SLICE_BINDING_TIMEOUT_MS:1000);
                }

                loadPanelWhenReady();
...
}
private void removeSliceLiveData(Uri uri) {
        final List<String> allowList = Arrays.asList(
                getResources().getStringArray(
                        R.array.config_panel_keep_observe_uri));
        if (!allowList.contains(uri.toString())) {
            mSliceLiveData.remove(uri);
        }
    }

    /**
     * When all of the Slices have loaded for the first time, then we can setup the
     * {@link RecyclerView}.
     * <p>
     * When the Recyclerview has been laid out, we can begin the animation with the
     * {@link mOnGlobalLayoutListener}, which calls {@link #animateIn()}.
     */
    private void loadPanelWhenReady() {
        if (mPanelSlicesLoaderCountdownLatch.isPanelReadyToLoad()) {
            mAdapter = new PanelSlicesAdapter(
                    this, mSliceLiveData, mPanel.getMetricsCategory());
            mPanelSlices.setAdapter(mAdapter);
            mPanelSlices.getViewTreeObserver()
                    .addOnGlobalLayoutListener(mOnGlobalLayoutListener);
            mPanelSlices.setVisibility(View.VISIBLE);

            final FragmentActivity activity = getActivity();
            if (activity == null) {
                return;
            }
            final DividerItemDecoration itemDecoration = new DividerItemDecoration(activity);
            itemDecoration
                    .setDividerCondition(DividerItemDecoration.DIVIDER_CONDITION_BOTH);
            if (mPanelSlices.getItemDecorationCount() == 0) {
                mPanelSlices.addItemDecoration(itemDecoration);
            }
        }
        //BSPA-222615 Modify the attribute value after the first click.
        SharedPreferences.Editor editor = getActivity().getSharedPreferences("paneldata",MODE_PRIVATE).edit();
        editor.putBoolean("volumedata",true);
        editor.apply();
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值