Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff397103 authored by Jeffrey Huang's avatar Jeffrey Huang Committed by Android (Google) Code Review
Browse files

Merge changes from topic "OemUnlockPreference"

* changes:
  Add comments to avoid merge conflicts
  Introduce OemUnlockPreferenceController
parents 10ba1f1e 52f4ed82
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.development;

import android.content.Context;
import android.content.Intent;

import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -34,6 +35,22 @@ public abstract class DeveloperOptionsPreferenceController extends
        super(context);
    }

    /**
     * Called when an activity returns to the DeveloperSettingsDashboardFragment.
     *
     * @param requestCode The integer request code originally supplied to
     *                    startActivityForResult(), allowing you to identify who this
     *                    result came from.
     * @param resultCode  The integer result code returned by the child activity
     *                    through its setResult().
     * @param data        An Intent, which can return result data to the caller
     *                    (various data can be attached to Intent "extras").
     * @return true if the controller handled the activity result
     */
    public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
        return false;
    }

    /**
     * Called when developer options is enabled
     */
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.development;

/**
 * Interface for storing Activity request codes in development options
 */
public interface DevelopmentOptionsActivityRequestCodes {
    int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0;
}
+115 −5
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.settings.development;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.widget.Switch;

@@ -40,7 +43,7 @@ import java.util.Arrays;
import java.util.List;

public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFragment
        implements SwitchBar.OnSwitchChangeListener {
        implements SwitchBar.OnSwitchChangeListener, OemUnlockDialogHost {

    private static final String TAG = "DevSettingsDashboard";

@@ -103,6 +106,33 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
        }
    }

    @Override
    public void onOemUnlockDialogConfirmed() {
        final OemUnlockPreferenceController controller = getDevelopmentOptionsController(
                OemUnlockPreferenceController.class);
        controller.onOemUnlockConfirmed();
    }

    @Override
    public void onOemUnlockDialogDismissed() {
        final OemUnlockPreferenceController controller = getDevelopmentOptionsController(
                OemUnlockPreferenceController.class);
        controller.onOemUnlockDismissed();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        for (AbstractPreferenceController controller : mPreferenceControllers) {
            if (controller instanceof DeveloperOptionsPreferenceController) {
                if (((DeveloperOptionsPreferenceController) controller).onActivityResult(
                        requestCode, resultCode, data)) {
                    return;
                }
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected String getLogTag() {
        return TAG;
@@ -121,7 +151,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra

    @Override
    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
        mPreferenceControllers = buildPreferenceControllers(context, getLifecycle());
        mPreferenceControllers = buildPreferenceControllers(context, getActivity(), getLifecycle(),
                this /* devOptionsDashboardFragment */);
        return mPreferenceControllers;
    }

@@ -140,14 +171,92 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
    }

    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
            Lifecycle lifecycle) {
            Activity activity, Lifecycle lifecycle, DevelopmentSettingsDashboardFragment fragment) {
        final List<AbstractPreferenceController> controllers = new ArrayList<>();
        // take bug report
        // desktop backup password
        controllers.add(new StayAwakePreferenceController(context, lifecycle));
        // hdcp checking
        controllers.add(new BluetoothSnoopLogPreferenceController(context));

        controllers.add(new OemUnlockPreferenceController(context, activity, fragment));
        // running services
        // convert to file encryption
        // picture color mode
        // webview implementation
        // cool color temperature
        // automatic system updates
        // system ui demo mode
        // quick settings developer tiles
        // usb debugging
        // revoke usb debugging authorizations
        // local terminal
        // bug report shortcut
        // select mock location app
        // enable view attribute inspection
        // select debug app
        // wait for debugger
        // verify apps over usb
        // logger buffer sizes
        // store logger data persistently on device
        // telephony monitor
        // camera laser sensor
        // camera HAL HDR+
        // feature flags
        // wireless display certification
        // enable wi-fi verbose logging
        // aggressive wifi to mobile handover
        // always allow wifi roam scans
        // mobile always active
        // tethering hardware acceleration
        // select usb configuration
        // show bluetooth devices without names
        // disable absolute volume
        // enable in-band ringing
        // bluetooth avrcp version
        // bluetooth audio codec
        // bluetooth audio sample rate
        // bluetooth audio bits per sample
        // bluetooth audio channel mode
        // bluetooth audio ldac codec: playback quality
        // show taps
        // pointer location
        // show surface updates
        // show layout bounds
        // force rtl layout direction
        // window animation scale
        // transition animation scale
        // animator duration scale
        // simulate secondary displays
        // smallest width
        // force gpu rendering
        // show gpu view updates
        // show hardware layers updates
        // debug gpu overdraw
        // debug non-rectangular clip operations
        // force 4x msaa
        // disable hw overlays
        // simulate color space
        // set gpu renderer
        // disable usb audio routing
        // strict mode enabled
        // profile gpu rendering
        // don't keep activities
        // background process limit
        // background check
        // show all anrs
        // show notification channel warnings
        // inactive apps
        // force allow apps on external
        // force activities to be resizable
        // reset shortcutmanager rate-limiting
        return controllers;
    }

    @VisibleForTesting
    <T extends AbstractPreferenceController> T getDevelopmentOptionsController(Class<T> clazz) {
        return getPreferenceController(clazz);
    }

    /**
     * For Search.
     */
@@ -171,7 +280,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
                @Override
                public List<AbstractPreferenceController> getPreferenceControllers(Context
                        context) {
                    return buildPreferenceControllers(context, null /* lifecycle */);
                    return buildPreferenceControllers(context, null /* activity */,
                            null /* lifecycle */, null /* devOptionsDashboardFragment */);
                }
            };
}
+82 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.development;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.os.Bundle;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

public class EnableOemUnlockSettingWarningDialog extends InstrumentedDialogFragment implements
        DialogInterface.OnClickListener, DialogInterface.OnDismissListener {

    public static final String TAG = "EnableOemUnlockDlg";

    public static void show(Fragment host) {
        final FragmentManager manager = host.getActivity().getFragmentManager();
        if (manager.findFragmentByTag(TAG) == null) {
            final EnableOemUnlockSettingWarningDialog dialog =
                    new EnableOemUnlockSettingWarningDialog();
            dialog.setTargetFragment(host, 0 /* requestCode */);
            dialog.show(manager, TAG);
        }
    }

    @Override
    public int getMetricsCategory() {
        return MetricsProto.MetricsEvent.DIALOG_ENABLE_OEM_UNLOCKING;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new AlertDialog.Builder(getActivity())
                .setTitle(R.string.confirm_enable_oem_unlock_title)
                .setMessage(R.string.confirm_enable_oem_unlock_text)
                .setPositiveButton(R.string.enable_text, this /* onClickListener */)
                .setNegativeButton(android.R.string.cancel, this /* onClickListener */)
                .create();
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        final OemUnlockDialogHost host = (OemUnlockDialogHost) getTargetFragment();
        if (host == null) {
            return;
        }
        if (which == DialogInterface.BUTTON_POSITIVE) {
            host.onOemUnlockDialogConfirmed();
        } else {
            host.onOemUnlockDialogDismissed();
        }
    }

    @Override
    public void onDismiss(DialogInterface dialog) {
        super.onDismiss(dialog);
        final OemUnlockDialogHost host = (OemUnlockDialogHost) getTargetFragment();
        if (host == null) {
            return;
        }
        host.onOemUnlockDialogDismissed();
    }
}
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.development;

/**
 * Interface for OemUnlockDialogFragment callbacks.
 */
public interface OemUnlockDialogHost {

    /**
     * Called when the user presses enable on the warning dialog.
     */
    void onOemUnlockDialogConfirmed();

    /**
     * Called when the user dismisses or cancels the warning dialog.
     */
    void onOemUnlockDialogDismissed();
}
Loading