Merge "Add "Reset ShortcutManager throttling" to dev options" into nyc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ac27897..c2ff86e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7357,4 +7357,13 @@
     <!-- Developer option to convert to file encryption - final button -->
     <string name="button_confirm_convert_fbe">Wipe and convert</string>
 
+    <!-- Reset rate-limiting in the system service ShortcutManager. [CHAR_LIMIT=none] -->
+    <string name="reset_shortcut_manager_throttling">Reset ShortcutManager rate-limiting counters</string>
+
+    <!-- Title of the dialog box to confirm resetting rate-limiting in the system service ShortcutManager. [CHAR_LIMIT=none] -->
+    <string name="confirm_reset_shortcut_manager_throttling_title">Reset ShortcutManager rate-limiting?</string>
+
+    <!-- Message of the dialog box to confirm resetting rate-limiting in the system service ShortcutManager. [CHAR_LIMIT=none] -->
+    <string name="confirm_reset_shortcut_manager_throttling_message">Reset ShortcutManager rate-limiting counters?</string>
+
 </resources>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 1b056b8..e58ff95 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -365,6 +365,10 @@
             android:key="force_resizable_activities"
             android:title="@string/force_resizable_activities"
             android:summary="@string/force_resizable_activities_summary"/>
+
+        <Preference
+            android:key="reset_shortcut_manager_throttling"
+            android:title="@string/reset_shortcut_manager_throttling" />
      </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index d604473..e33c081 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -23,8 +23,6 @@
 import android.app.AppOpsManager;
 import android.app.AppOpsManager.PackageOps;
 import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.UiModeManager;
 import android.app.admin.DevicePolicyManager;
 import android.app.backup.IBackupManager;
 import android.bluetooth.BluetoothAdapter;
@@ -36,6 +34,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.IShortcutService;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ResolveInfo;
@@ -60,7 +59,6 @@
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
 import android.support.v14.preference.SwitchPreference;
-import android.support.v7.preference.DropDownPreference;
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
@@ -212,6 +210,8 @@
     private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst";
     private static final String FLASH_LOCKED_PROP = "ro.boot.flash.locked";
 
+    private static final String SHORTCUT_MANAGER_RESET_KEY = "reset_shortcut_manager_throttling";
+
     private static final int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0;
 
     private static final int[] MOCK_LOCATION_APP_OPS = new int[] {AppOpsManager.OP_MOCK_LOCATION};
@@ -1919,6 +1919,8 @@
             writeBluetoothDisableAbsVolumeOptions();
         } else if (preference == mWebViewMultiprocess) {
             writeWebViewMultiprocessOptions();
+        } else if (SHORTCUT_MANAGER_RESET_KEY.equals(preference.getKey())) {
+            confirmResetShortcutManagerThrottling();
         } else {
             return super.onPreferenceTreeClick(preference);
         }
@@ -2171,4 +2173,30 @@
                     return keys;
                 }
             };
+
+    private void confirmResetShortcutManagerThrottling() {
+        final IShortcutService service = IShortcutService.Stub.asInterface(
+                ServiceManager.getService(Context.SHORTCUT_SERVICE));
+
+        DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                if (which == DialogInterface.BUTTON_POSITIVE) {
+                    try {
+                        service.resetThrottling();
+                    } catch (RemoteException e) {
+                    }
+                }
+            }
+        };
+
+        new AlertDialog.Builder(getActivity())
+                .setTitle(R.string.confirm_reset_shortcut_manager_throttling_title)
+                .setMessage(R.string.confirm_reset_shortcut_manager_throttling_message)
+                .setPositiveButton(R.string.okay, onClickListener)
+                .setNegativeButton(android.R.string.cancel, null)
+                .create()
+                .show();
+
+    }
 }