summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/values/strings.xml6
-rw-r--r--packages/SystemUI/src/com/android/systemui/usb/UsbContaminantActivity.java19
2 files changed, 22 insertions, 3 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 16222f7ebd8d..9779e53a9161 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -165,6 +165,12 @@
<!-- Message of USB contaminant presence dialog [CHAR LIMIT=NONE] -->
<string name="usb_contaminant_message">To protect your device from liquid or debris, the USB port is disabled and won\u2019t detect any accessories.\n\nYou\u2019ll be notified when it\u2019s safe to use the USB port again.</string>
+ <!-- Toast for enabling ports from USB contaminant dialog [CHAR LIMIT=NONE] -->
+ <string name="usb_port_enabled">USB port enabled to detect chargers and accessories</string>
+
+ <!-- Button text to disable contaminant detection [CHAR LIMIT=NONE] -->
+ <string name="usb_disable_contaminant_detection">Enable USB</string>
+
<!-- Checkbox label for application compatibility mode ON (zooming app to look like it's running
on a phone). [CHAR LIMIT=25] -->
<string name="compat_mode_on">Zoom to fill screen</string>
diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbContaminantActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbContaminantActivity.java
index fa4b3fe4be18..ecf608beb91c 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/UsbContaminantActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/UsbContaminantActivity.java
@@ -16,14 +16,17 @@
package com.android.systemui.usb;
+import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.usb.ParcelableUsbPort;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbPort;
import android.os.Bundle;
+import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
+import android.widget.Toast;
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
@@ -36,7 +39,6 @@ public class UsbContaminantActivity extends AlertActivity
implements DialogInterface.OnClickListener {
private static final String TAG = "UsbContaminantActivity";
- private UsbDisconnectedReceiver mDisconnectedReceiver;
private UsbPort mUsbPort;
@Override
@@ -55,8 +57,10 @@ public class UsbContaminantActivity extends AlertActivity
final AlertController.AlertParams ap = mAlertParams;
ap.mTitle = getString(R.string.usb_contaminant_title);
ap.mMessage = getString(R.string.usb_contaminant_message);
- ap.mPositiveButtonText = getString(android.R.string.ok);
- ap.mPositiveButtonListener = this;
+ ap.mNegativeButtonText = getString(android.R.string.ok);
+ ap.mNeutralButtonText = getString(R.string.usb_disable_contaminant_detection);
+ ap.mNegativeButtonListener = this;
+ ap.mNeutralButtonListener = this;
setupAlert();
}
@@ -68,6 +72,15 @@ public class UsbContaminantActivity extends AlertActivity
@Override
public void onClick(DialogInterface dialog, int which) {
+ if (which == AlertDialog.BUTTON_NEUTRAL) {
+ try {
+ mUsbPort.enableContaminantDetection(false);
+ Toast.makeText(this, R.string.usb_port_enabled,
+ Toast.LENGTH_SHORT).show();
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to notify Usb service", e);
+ }
+ }
finish();
}
}