diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index d127204..b0c38b9 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -560,9 +560,9 @@
      * Listener to setup {@link LayoutTransition} after first layout pass.
      */
     private OnGlobalLayoutListener mFirstLayoutListener = new OnGlobalLayoutListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onGlobalLayout() {
-            mListView.getViewTreeObserver().removeGlobalOnLayoutListener(mFirstLayoutListener);
+            mListView.getViewTreeObserver().removeOnGlobalLayoutListener(mFirstLayoutListener);
 
             mTabsContainer.setLayoutTransition(buildLayoutTransition());
             mHeader.setLayoutTransition(buildLayoutTransition());
@@ -628,7 +628,7 @@
      * Factory that provide empty {@link View} to make {@link TabHost} happy.
      */
     private TabContentFactory mEmptyTabContent = new TabContentFactory() {
-        /** {@inheritDoc} */
+        @Override
         public View createTabContent(String tag) {
             return new View(mTabHost.getContext());
         }
@@ -643,7 +643,7 @@
     }
 
     private OnTabChangeListener mTabListener = new OnTabChangeListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onTabChanged(String tabId) {
             // user changed tab; update body
             updateBody();
@@ -990,7 +990,7 @@
     }
 
     private OnCheckedChangeListener mDataEnabledListener = new OnCheckedChangeListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
             if (mBinding) return;
 
@@ -1011,7 +1011,7 @@
     };
 
     private View.OnClickListener mDisableAtLimitListener = new View.OnClickListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onClick(View v) {
             final boolean disableAtLimit = !mDisableAtLimit.isChecked();
             if (disableAtLimit) {
@@ -1025,7 +1025,7 @@
     };
 
     private View.OnClickListener mAppRestrictListener = new View.OnClickListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onClick(View v) {
             final boolean restrictBackground = !mAppRestrict.isChecked();
 
@@ -1041,7 +1041,7 @@
     };
 
     private OnClickListener mAppSettingsListener = new OnClickListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onClick(View v) {
             // TODO: target torwards entire UID instead of just first package
             startActivity(mAppSettingsIntent);
@@ -1049,7 +1049,7 @@
     };
 
     private OnItemClickListener mListListener = new OnItemClickListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
             final Context context = view.getContext();
             final AppItem app = (AppItem) parent.getItemAtPosition(position);
@@ -1059,7 +1059,7 @@
     };
 
     private OnItemSelectedListener mCycleListener = new OnItemSelectedListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
             final CycleItem cycle = (CycleItem) parent.getItemAtPosition(position);
             if (cycle instanceof CycleChangeItem) {
@@ -1084,7 +1084,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void onNothingSelected(AdapterView<?> parent) {
             // ignored
         }
@@ -1149,12 +1149,12 @@
 
     private final LoaderCallbacks<ChartData> mChartDataCallbacks = new LoaderCallbacks<
             ChartData>() {
-        /** {@inheritDoc} */
+        @Override
         public Loader<ChartData> onCreateLoader(int id, Bundle args) {
             return new ChartDataLoader(getActivity(), mStatsSession, args);
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void onLoadFinished(Loader<ChartData> loader, ChartData data) {
             mChartData = data;
             mChart.bindNetworkStats(mChartData.network);
@@ -1170,7 +1170,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void onLoaderReset(Loader<ChartData> loader) {
             mChartData = null;
             mChart.bindNetworkStats(null);
@@ -1180,18 +1180,18 @@
 
     private final LoaderCallbacks<NetworkStats> mSummaryCallbacks = new LoaderCallbacks<
             NetworkStats>() {
-        /** {@inheritDoc} */
+        @Override
         public Loader<NetworkStats> onCreateLoader(int id, Bundle args) {
             return new SummaryForAllUidLoader(getActivity(), mStatsSession, args);
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void onLoadFinished(Loader<NetworkStats> loader, NetworkStats data) {
             mAdapter.bindStats(data);
             updateEmptyVisible();
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void onLoaderReset(Loader<NetworkStats> loader) {
             mAdapter.bindStats(null);
             updateEmptyVisible();
@@ -1203,6 +1203,7 @@
         }
     };
 
+    @Deprecated
     private boolean isMobilePolicySplit() {
         final Context context = getActivity();
         if (hasReadyMobileRadio(context)) {
@@ -1213,6 +1214,7 @@
         }
     }
 
+    @Deprecated
     private void setMobilePolicySplit(boolean split) {
         final Context context = getActivity();
         if (hasReadyMobileRadio(context)) {
@@ -1228,28 +1230,28 @@
     }
 
     private DataUsageChartListener mChartListener = new DataUsageChartListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onInspectRangeChanged() {
             if (LOGD) Log.d(TAG, "onInspectRangeChanged()");
             updateDetailData();
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void onWarningChanged() {
             setPolicyWarningBytes(mChart.getWarningBytes());
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void onLimitChanged() {
             setPolicyLimitBytes(mChart.getLimitBytes());
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void requestWarningEdit() {
             WarningEditorFragment.show(DataUsageSummary.this);
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void requestLimitEdit() {
             LimitEditorFragment.show(DataUsageSummary.this);
         }
@@ -1287,7 +1289,7 @@
             return false;
         }
 
-        /** {@inheritDoc} */
+        @Override
         public int compareTo(CycleItem another) {
             return Long.compare(start, another.start);
         }
@@ -1615,6 +1617,7 @@
             builder.setMessage(message);
 
             builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                @Override
                 public void onClick(DialogInterface dialog, int which) {
                     final DataUsageSummary target = (DataUsageSummary) getTargetFragment();
                     if (target != null) {
@@ -1670,6 +1673,7 @@
 
             builder.setPositiveButton(R.string.data_usage_cycle_editor_positive,
                     new DialogInterface.OnClickListener() {
+                        @Override
                         public void onClick(DialogInterface dialog, int which) {
                             final int cycleDay = cycleDayPicker.getValue();
                             final String cycleTimezone = new Time().timezone;
@@ -1730,6 +1734,7 @@
 
             builder.setPositiveButton(R.string.data_usage_cycle_editor_positive,
                     new DialogInterface.OnClickListener() {
+                        @Override
                         public void onClick(DialogInterface dialog, int which) {
                             // clear focus to finish pending text edits
                             bytesPicker.clearFocus();
@@ -1792,6 +1797,7 @@
 
             builder.setPositiveButton(R.string.data_usage_cycle_editor_positive,
                     new DialogInterface.OnClickListener() {
+                        @Override
                         public void onClick(DialogInterface dialog, int which) {
                             // clear focus to finish pending text edits
                             bytesPicker.clearFocus();
@@ -1825,6 +1831,7 @@
             builder.setMessage(R.string.data_usage_disable_mobile);
 
             builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                @Override
                 public void onClick(DialogInterface dialog, int which) {
                     final DataUsageSummary target = (DataUsageSummary) getTargetFragment();
                     if (target != null) {
@@ -1841,7 +1848,7 @@
 
     /**
      * Dialog to request user confirmation before setting
-     * {@link Settings.Secure#DATA_ROAMING}.
+     * {@link android.provider.Settings.Secure#DATA_ROAMING}.
      */
     public static class ConfirmDataRoamingFragment extends DialogFragment {
         public static void show(DataUsageSummary parent) {
@@ -1861,6 +1868,7 @@
             builder.setMessage(R.string.roaming_warning);
 
             builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                @Override
                 public void onClick(DialogInterface dialog, int which) {
                     final DataUsageSummary target = (DataUsageSummary) getTargetFragment();
                     if (target != null) {
@@ -1896,6 +1904,7 @@
             builder.setMessage(getString(R.string.data_usage_restrict_background));
 
             builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                @Override
                 public void onClick(DialogInterface dialog, int which) {
                     final DataUsageSummary target = (DataUsageSummary) getTargetFragment();
                     if (target != null) {
@@ -1958,6 +1967,7 @@
             builder.setMessage(R.string.data_usage_app_restrict_dialog);
 
             builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                @Override
                 public void onClick(DialogInterface dialog, int which) {
                     final DataUsageSummary target = (DataUsageSummary) getTargetFragment();
                     if (target != null) {
diff --git a/src/com/android/settings/widget/ChartDataUsageView.java b/src/com/android/settings/widget/ChartDataUsageView.java
index 85ee76a..c07509c 100644
--- a/src/com/android/settings/widget/ChartDataUsageView.java
+++ b/src/com/android/settings/widget/ChartDataUsageView.java
@@ -296,7 +296,7 @@
     }
 
     private OnSweepListener mHorizListener = new OnSweepListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onSweep(ChartSweepView sweep, boolean sweepDone) {
             updatePrimaryRange();
 
@@ -306,7 +306,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void requestEdit(ChartSweepView sweep) {
             // ignored
         }
@@ -324,7 +324,7 @@
     }
 
     private OnSweepListener mVertListener = new OnSweepListener() {
-        /** {@inheritDoc} */
+        @Override
         public void onSweep(ChartSweepView sweep, boolean sweepDone) {
             if (sweepDone) {
                 clearUpdateAxisDelayed(sweep);
@@ -341,7 +341,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public void requestEdit(ChartSweepView sweep) {
             if (sweep == mSweepWarning && mListener != null) {
                 mListener.requestWarningEdit();
@@ -469,7 +469,7 @@
             return Objects.hashCode(mMin, mMax, mSize);
         }
 
-        /** {@inheritDoc} */
+        @Override
         public boolean setBounds(long min, long max) {
             if (mMin != min || mMax != max) {
                 mMin = min;
@@ -480,7 +480,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public boolean setSize(float size) {
             if (mSize != size) {
                 mSize = size;
@@ -490,24 +490,24 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public float convertToPoint(long value) {
             return (mSize * (value - mMin)) / (mMax - mMin);
         }
 
-        /** {@inheritDoc} */
+        @Override
         public long convertToValue(float point) {
             return (long) (mMin + ((point * (mMax - mMin)) / mSize));
         }
 
-        /** {@inheritDoc} */
+        @Override
         public long buildLabel(Resources res, SpannableStringBuilder builder, long value) {
             // TODO: convert to better string
             builder.replace(0, builder.length(), Long.toString(value));
             return value;
         }
 
-        /** {@inheritDoc} */
+        @Override
         public float[] getTickPoints() {
             final float[] ticks = new float[32];
             int i = 0;
@@ -532,7 +532,7 @@
             return Arrays.copyOf(ticks, i);
         }
 
-        /** {@inheritDoc} */
+        @Override
         public int shouldAdjustAxis(long value) {
             // time axis never adjusts
             return 0;
@@ -551,7 +551,7 @@
             return Objects.hashCode(mMin, mMax, mSize);
         }
 
-        /** {@inheritDoc} */
+        @Override
         public boolean setBounds(long min, long max) {
             if (mMin != min || mMax != max) {
                 mMin = min;
@@ -562,7 +562,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public boolean setSize(float size) {
             if (mSize != size) {
                 mSize = size;
@@ -572,7 +572,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public float convertToPoint(long value) {
             if (LOG_SCALE) {
                 // derived polynomial fit to make lower values more visible
@@ -585,7 +585,7 @@
             }
         }
 
-        /** {@inheritDoc} */
+        @Override
         public long convertToValue(float point) {
             if (LOG_SCALE) {
                 final double normalized = point / mSize;
@@ -600,7 +600,7 @@
         private static final Object sSpanSize = new Object();
         private static final Object sSpanUnit = new Object();
 
-        /** {@inheritDoc} */
+        @Override
         public long buildLabel(Resources res, SpannableStringBuilder builder, long value) {
 
             final CharSequence unit;
@@ -633,7 +633,7 @@
             return (long) resultRounded;
         }
 
-        /** {@inheritDoc} */
+        @Override
         public float[] getTickPoints() {
             final long range = mMax - mMin;
 
@@ -650,7 +650,7 @@
             return tickPoints;
         }
 
-        /** {@inheritDoc} */
+        @Override
         public int shouldAdjustAxis(long value) {
             final float point = convertToPoint(value);
             if (point < mSize * 0.1) {
diff --git a/src/com/android/settings/widget/InvertedChartAxis.java b/src/com/android/settings/widget/InvertedChartAxis.java
index 2d820d9..6875749 100644
--- a/src/com/android/settings/widget/InvertedChartAxis.java
+++ b/src/com/android/settings/widget/InvertedChartAxis.java
@@ -30,33 +30,33 @@
         mWrapped = wrapped;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public boolean setBounds(long min, long max) {
         return mWrapped.setBounds(min, max);
     }
 
-    /** {@inheritDoc} */
+    @Override
     public boolean setSize(float size) {
         mSize = size;
         return mWrapped.setSize(size);
     }
 
-    /** {@inheritDoc} */
+    @Override
     public float convertToPoint(long value) {
         return mSize - mWrapped.convertToPoint(value);
     }
 
-    /** {@inheritDoc} */
+    @Override
     public long convertToValue(float point) {
         return mWrapped.convertToValue(mSize - point);
     }
 
-    /** {@inheritDoc} */
+    @Override
     public long buildLabel(Resources res, SpannableStringBuilder builder, long value) {
         return mWrapped.buildLabel(res, builder, value);
     }
 
-    /** {@inheritDoc} */
+    @Override
     public float[] getTickPoints() {
         final float[] points = mWrapped.getTickPoints();
         for (int i = 0; i < points.length; i++) {
@@ -65,7 +65,7 @@
         return points;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public int shouldAdjustAxis(long value) {
         return mWrapped.shouldAdjustAxis(value);
     }
