Usb changes and strings for connected devices 2.0

New metrics constant and usb strings for the new
notification / details page.

Bug: 69333961
Test: Check notification
Change-Id: If9bde7f787e40e42bb991a99b032e1ff968a0a41
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3cde765..224503b 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3222,19 +3222,23 @@
     <string name="dlg_ok">OK</string>
 
     <!-- USB_PREFERENCES: Notification for when the user connected to the charger only.  This is the title -->
-    <string name="usb_charging_notification_title">USB charging this device</string>
+    <string name="usb_charging_notification_title">Charging this device via USB</string>
     <!-- USB_PREFERENCES: Notification for when the user connects the phone to supply power to attached device.  This is the title -->
-    <string name="usb_supplying_notification_title">USB supplying power to attached device</string>
+    <string name="usb_supplying_notification_title">Charging connected device via USB</string>
     <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in MTP mode.  This is the title -->
-    <string name="usb_mtp_notification_title">USB for file transfer</string>
+    <string name="usb_mtp_notification_title">USB file transfer turned on</string>
     <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in PTP mode.  This is the title -->
-    <string name="usb_ptp_notification_title">USB for photo transfer</string>
+    <string name="usb_ptp_notification_title">PTP via USB turned on</string>
+    <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in Tethering mode.  This is the title -->
+    <string name="usb_tether_notification_title">USB tethering turned on</string>
     <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in MIDI mode.  This is the title -->
-    <string name="usb_midi_notification_title">USB for MIDI</string>
+    <string name="usb_midi_notification_title">MIDI via USB turned on</string>
     <!-- USB_PREFERENCES: Notification for when a USB accessory is attached.  This is the title -->
-    <string name="usb_accessory_notification_title">Connected to a USB accessory</string>
+    <string name="usb_accessory_notification_title">USB accessory mode turned on</string>
     <!-- See USB_PREFERENCES. This is the message. -->
     <string name="usb_notification_message">Tap for more options.</string>
+    <!-- See USB_PREFERENCES. This is the message when a data mode is turned on (mtp, ptp, midi) and the device is supplying power.. -->
+    <string name="usb_power_notification_message">Charging connected device. Tap for more options.</string>
     <!-- USB_PREFERENCES: Notification for when a type-c USB audio accessory is attached but not supported.  This is the title -->
     <string name="usb_unsupported_audio_accessory_title">Analog audio accessory detected</string>
     <!-- Message of notification shown when a type-c USB audio accessory is attached but not supported. -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index a62d49e..a338f89 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2026,8 +2026,10 @@
   <java-symbol type="string" name="usb_mtp_notification_title" />
   <java-symbol type="string" name="usb_charging_notification_title" />
   <java-symbol type="string" name="usb_notification_message" />
+  <java-symbol type="string" name="usb_power_notification_message" />
   <java-symbol type="string" name="usb_ptp_notification_title" />
   <java-symbol type="string" name="usb_midi_notification_title" />
+  <java-symbol type="string" name="usb_tether_notification_title" />
   <java-symbol type="string" name="usb_supplying_notification_title" />
   <java-symbol type="string" name="usb_unsupported_audio_accessory_title" />
   <java-symbol type="string" name="usb_unsupported_audio_accessory_message" />
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index 7539d88..83657bb 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -5172,6 +5172,11 @@
     // Package: Package of the autofill service
     // OS: P
     AUTOFILL_INVALID_PERMISSION = 1289;
+    
+    // OPEN: Settings->Connected Devices->USB->(click on details link)
+    // CATEGORY: SETTINGS
+    // OS: P
+    USB_DEVICE_DETAILS = 1290;
 
     // ---- End P Constants, all P constants go above this line ----
     // Add new aosp constants above this line.
diff --git a/proto/src/system_messages.proto b/proto/src/system_messages.proto
index db70184..08fdb97 100644
--- a/proto/src/system_messages.proto
+++ b/proto/src/system_messages.proto
@@ -200,6 +200,10 @@
     // Package: android
     NOTE_CARRIER_NETWORK_AVAILABLE = 46;
 
+    // Inform that USB is configured for Tethering
+    // Package: android
+    NOTE_USB_TETHER = 47;
+
     // ADD_NEW_IDS_ABOVE_THIS_LINE
     // Legacy IDs with arbitrary values appear below
     // Legacy IDs existed as stable non-conflicting constants prior to the O release
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index 1ea2f97..d3022b4 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -1072,6 +1072,8 @@
             int id = 0;
             int titleRes = 0;
             Resources r = mContext.getResources();
+            CharSequence message = r.getText(
+                    com.android.internal.R.string.usb_notification_message);
             if (mAudioAccessoryConnected && !mAudioAccessorySupported) {
                 titleRes = com.android.internal.R.string.usb_unsupported_audio_accessory_title;
                 id = SystemMessage.NOTE_USB_AUDIO_ACCESSORY_NOT_SUPPORTED;
@@ -1085,13 +1087,22 @@
                 } else if (mCurrentFunctions == UsbManager.FUNCTION_MIDI) {
                     titleRes = com.android.internal.R.string.usb_midi_notification_title;
                     id = SystemMessage.NOTE_USB_MIDI;
+                } else if (mCurrentFunctions == UsbManager.FUNCTION_RNDIS) {
+                    titleRes = com.android.internal.R.string.usb_tether_notification_title;
+                    id = SystemMessage.NOTE_USB_TETHER;
                 } else if (mCurrentFunctions == UsbManager.FUNCTION_ACCESSORY) {
                     titleRes = com.android.internal.R.string.usb_accessory_notification_title;
                     id = SystemMessage.NOTE_USB_ACCESSORY;
-                } else if (mSourcePower) {
-                    titleRes = com.android.internal.R.string.usb_supplying_notification_title;
-                    id = SystemMessage.NOTE_USB_SUPPLYING;
-                } else {
+                }
+                if (mSourcePower) {
+                    if (titleRes != 0) {
+                        message = r.getText(
+                                com.android.internal.R.string.usb_power_notification_message);
+                    } else {
+                        titleRes = com.android.internal.R.string.usb_supplying_notification_title;
+                        id = SystemMessage.NOTE_USB_SUPPLYING;
+                    }
+                } else if (titleRes == 0) {
                     titleRes = com.android.internal.R.string.usb_charging_notification_title;
                     id = SystemMessage.NOTE_USB_CHARGING;
                 }
@@ -1111,7 +1122,6 @@
                     mUsbNotificationId = 0;
                 }
                 if (id != 0) {
-                    CharSequence message;
                     CharSequence title = r.getText(titleRes);
                     PendingIntent pi;
                     String channel;
@@ -1121,12 +1131,10 @@
                             .usb_unsupported_audio_accessory_title) {
                         Intent intent = Intent.makeRestartActivityTask(
                                 new ComponentName("com.android.settings",
-                                        "com.android.settings.deviceinfo.UsbModeChooserActivity"));
+                                        "com.android.settings.Settings$UsbDetailsActivity"));
                         pi = PendingIntent.getActivityAsUser(mContext, 0,
                                 intent, 0, null, UserHandle.CURRENT);
                         channel = SystemNotificationChannels.USB;
-                        message = r.getText(
-                                com.android.internal.R.string.usb_notification_message);
                     } else {
                         final Intent intent = new Intent();
                         intent.setClassName("com.android.settings",