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

Commit c5b7a682 authored by kaiyiz's avatar kaiyiz Committed by Gerrit - the friendly Code Review server
Browse files

Regional: Customize auto-popup USB menu

If the feature is enabled, phone will automatically pop up USB
menu when connect with USB cable into PC.

The feature can be enable/disable by overlay key:
always_popup_usb_computer_connection_option

Default is disable(false).

Change-Id: Iacd8fa169942d3b77885e8f8d8b53dce94a690ac
parent ea1eecb4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
-->

<resources>
    <!-- Whether to popup usb computer connection option-->
    <bool name="always_popup_usb_computer_connection_option">false</bool>
    <bool name="kg_enable_camera_default_widget">true</bool>
    <bool name="kg_center_small_widgets_vertically">false</bool>
    <bool name="kg_top_align_page_shrink_on_bouncer_visible">true</bool>
+1 −0
Original line number Diff line number Diff line
@@ -252,6 +252,7 @@
  <java-symbol type="bool" name="action_bar_embed_tabs_pre_jb" />
  <java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" />
  <java-symbol type="bool" name="config_avoidGfxAccel" />
  <java-symbol type="bool" name="always_popup_usb_computer_connection_option" />
  <java-symbol type="bool" name="config_allowActionMenuItemTextWithIcon" />
  <java-symbol type="bool" name="config_bluetooth_address_validation" />
  <java-symbol type="bool" name="config_bluetooth_sco_off_call" />
+20 −1
Original line number Diff line number Diff line
@@ -660,6 +660,10 @@ public class UsbDeviceManager {
                    if (mDebuggingManager != null) {
                        mDebuggingManager.setAdbEnabled(mAdbEnabled);
                    }
                    if (mContext.getResources().getBoolean(com.android.internal.
                            R.bool.always_popup_usb_computer_connection_option)) {
                        updateState(bootState(mConnected, mConfigured));
                    }
                    break;
                case MSG_USER_SWITCHED: {
                    UserManager userManager =
@@ -686,6 +690,18 @@ public class UsbDeviceManager {
            }
        }

        private String bootState(boolean isConnected, boolean isConfigured) {
            String bootState = "CONNECTED";
            if (!isConnected && !isConfigured) {
                bootState = "DISCONNECTED";
            } else if (isConnected && !isConfigured) {
                bootState = "CONNECTED";
            } else if (isConnected && isConfigured) {
                bootState = "CONFIGURED";
            }
            return bootState;
        }

        public UsbAccessory getCurrentAccessory() {
            return mCurrentAccessory;
        }
@@ -713,7 +729,7 @@ public class UsbDeviceManager {
                    //}
                }
            }
            if (id != mUsbNotificationId) {
            if (id != mUsbNotificationId && mBootCompleted) {
                // clear notification if title needs changing
                if (mUsbNotificationId != 0) {
                    mNotificationManager.cancelAsUser(null, mUsbNotificationId,
@@ -747,6 +763,9 @@ public class UsbDeviceManager {
                    mNotificationManager.notifyAsUser(null, id, notification,
                            UserHandle.ALL);
                    mUsbNotificationId = id;
                    if (r.getBoolean(com.android.internal.R.bool.
                            always_popup_usb_computer_connection_option))
                        mContext.startActivity(intent);
                }
            }
        }