Remove dead code and obsolete patterns

- Remove code and resource for ProcessStatsMemDetail
- Remove TintablePreference (tinting icon is not a supported
  pattern starting in Android O)

Bug: 68426851
Test: robotests
Change-Id: Ib9c2fc8332255fe29c8f3dce378456403d7af8a3
This commit is contained in:
Fan Zhang
2017-10-28 10:32:40 -07:00
parent 34f7b5af59
commit 22d53b14a8
8 changed files with 4 additions and 318 deletions

View File

@@ -16,11 +16,12 @@
package com.android.settings;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.widget.ProgressBar;
public class AppProgressPreference extends TintablePreference {
public class AppProgressPreference extends Preference {
private int mProgress;

View File

@@ -1,55 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.support.annotation.ColorInt;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.widget.ImageView;
public class TintablePreference extends Preference {
@ColorInt
private int mTintColor;
public TintablePreference(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintablePreference);
mTintColor = a.getColor(R.styleable.TintablePreference_android_tint, 0);
a.recycle();
}
public void setTint(int color) {
mTintColor = color;
notifyChanged();
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
if (mTintColor != 0) {
((ImageView) view.findViewById(android.R.id.icon)).setImageTintList(
ColorStateList.valueOf(mTintColor));
} else {
((ImageView) view.findViewById(android.R.id.icon)).setImageTintList(null);
}
}
}

View File

@@ -1,160 +0,0 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.applications;
import android.os.Bundle;
import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.internal.app.procstats.ProcessStats;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
import static com.android.settings.Utils.prepareCustomPreferencesList;
public class ProcessStatsMemDetail extends InstrumentedPreferenceFragment {
public static final String EXTRA_MEM_TIMES = "mem_times";
public static final String EXTRA_MEM_STATE_WEIGHTS = "mem_state_weights";
public static final String EXTRA_MEM_CACHED_WEIGHT = "mem_cached_weight";
public static final String EXTRA_MEM_FREE_WEIGHT = "mem_free_weight";
public static final String EXTRA_MEM_ZRAM_WEIGHT = "mem_zram_weight";
public static final String EXTRA_MEM_KERNEL_WEIGHT = "mem_kernel_weight";
public static final String EXTRA_MEM_NATIVE_WEIGHT = "mem_native_weight";
public static final String EXTRA_MEM_TOTAL_WEIGHT = "mem_total_weight";
public static final String EXTRA_USE_USS = "use_uss";
public static final String EXTRA_TOTAL_TIME = "total_time";
long[] mMemTimes;
double[] mMemStateWeights;
double mMemCachedWeight;
double mMemFreeWeight;
double mMemZRamWeight;
double mMemKernelWeight;
double mMemNativeWeight;
double mMemTotalWeight;
boolean mUseUss;
long mTotalTime;
private View mRootView;
private ViewGroup mMemStateParent;
private ViewGroup mMemUseParent;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Bundle args = getArguments();
mMemTimes = args.getLongArray(EXTRA_MEM_TIMES);
mMemStateWeights = args.getDoubleArray(EXTRA_MEM_STATE_WEIGHTS);
mMemCachedWeight = args.getDouble(EXTRA_MEM_CACHED_WEIGHT);
mMemFreeWeight = args.getDouble(EXTRA_MEM_FREE_WEIGHT);
mMemZRamWeight = args.getDouble(EXTRA_MEM_ZRAM_WEIGHT);
mMemKernelWeight = args.getDouble(EXTRA_MEM_KERNEL_WEIGHT);
mMemNativeWeight = args.getDouble(EXTRA_MEM_NATIVE_WEIGHT);
mMemTotalWeight = args.getDouble(EXTRA_MEM_TOTAL_WEIGHT);
mUseUss = args.getBoolean(EXTRA_USE_USS);
mTotalTime = args.getLong(EXTRA_TOTAL_TIME);
}
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.process_stats_mem_details, container, false);
prepareCustomPreferencesList(container, view, view, false);
mRootView = view;
createDetails();
return view;
}
@Override
public int getMetricsCategory() {
return MetricsEvent.APPLICATIONS_PROCESS_STATS_MEM_DETAIL;
}
@Override
public void onPause() {
super.onPause();
}
private void createDetails() {
mMemStateParent = (ViewGroup)mRootView.findViewById(R.id.mem_state);
mMemUseParent = (ViewGroup)mRootView.findViewById(R.id.mem_use);
fillMemStateSection();
fillMemUseSection();
}
private void addDetailsItem(ViewGroup parent, CharSequence title,
float level, CharSequence value) {
LayoutInflater inflater = getActivity().getLayoutInflater();
ViewGroup item = (ViewGroup) inflater.inflate(R.layout.app_item, null);
inflater.inflate(R.layout.widget_progress_bar,
(ViewGroup) item.findViewById(android.R.id.widget_frame));
parent.addView(item);
item.findViewById(android.R.id.icon).setVisibility(View.GONE);
TextView titleView = (TextView) item.findViewById(android.R.id.title);
TextView valueView = (TextView) item.findViewById(android.R.id.text1);
titleView.setText(title);
valueView.setText(value);
ProgressBar progress = (ProgressBar) item.findViewById(android.R.id.progress);
progress.setProgress(Math.round(level*100));
}
private void fillMemStateSection() {
CharSequence[] labels = getResources().getTextArray(R.array.proc_stats_memory_states);
for (int i=0; i<ProcessStats.ADJ_MEM_FACTOR_COUNT; i++) {
if (mMemTimes[i] > 0) {
float level = ((float)mMemTimes[i])/mTotalTime;
addDetailsItem(mMemStateParent, labels[i], level,
Formatter.formatShortElapsedTime(getActivity(), mMemTimes[i]));
}
}
}
private void addMemUseDetailsItem(ViewGroup parent, CharSequence title, double weight) {
if (weight > 0) {
float level = (float)(weight/mMemTotalWeight);
String value = Formatter.formatShortFileSize(getActivity(),
(long)((weight * 1024) / mTotalTime));
addDetailsItem(parent, title, level, value);
}
}
private void fillMemUseSection() {
CharSequence[] labels = getResources().getTextArray(R.array.proc_stats_process_states);
addMemUseDetailsItem(mMemUseParent,
getResources().getText(R.string.mem_use_kernel_type), mMemKernelWeight);
addMemUseDetailsItem(mMemUseParent,
getResources().getText(R.string.mem_use_zram_type), mMemZRamWeight);
addMemUseDetailsItem(mMemUseParent,
getResources().getText(R.string.mem_use_native_type), mMemNativeWeight);
for (int i=0; i<ProcessStats.STATE_COUNT; i++) {
addMemUseDetailsItem(mMemUseParent, labels[i], mMemStateWeights[i]);
}
addMemUseDetailsItem(mMemUseParent,
getResources().getText(R.string.mem_use_kernel_cache_type), mMemCachedWeight);
addMemUseDetailsItem(mMemUseParent,
getResources().getText(R.string.mem_use_free_type), mMemFreeWeight);
addMemUseDetailsItem(mMemUseParent,
getResources().getText(R.string.mem_use_total), mMemTotalWeight);
}
}

View File

@@ -19,15 +19,14 @@ package com.android.settings.fuelgauge;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.TintablePreference;
import com.android.settings.Utils;
/**
@@ -37,7 +36,7 @@ import com.android.settings.Utils;
* The battery usage info could be usage percentage or usage time. The preference
* won't show any icon if it is null.
*/
public class PowerGaugePreference extends TintablePreference {
public class PowerGaugePreference extends Preference {
private final int mIconSize;
private BatteryEntry mInfo;

View File

@@ -21,7 +21,6 @@ import android.app.LoaderManager;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.Loader;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.BatteryStats;
import android.os.Bundle;
@@ -531,17 +530,10 @@ public class PowerUsageSummary extends PowerUsageBase implements
}
private void refreshAppListGroup() {
final Context context = getContext();
final PowerProfile powerProfile = mStatsHelper.getPowerProfile();
final BatteryStats stats = mStatsHelper.getStats();
final double averagePower = powerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL);
boolean addedSome = false;
TypedArray array = context.obtainStyledAttributes(
new int[]{android.R.attr.colorControlNormal});
final int colorControl = array.getColor(0, 0);
array.recycle();
final int dischargeAmount = USE_FAKE_DATA ? 5000
: stats != null ? stats.getDischargeAmount(mStatsType) : 0;
@@ -583,9 +575,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
contentDescription, entry);
pref.setKey(key);
}
final double percentOfMax = (sipper.totalPowerMah * 100)
/ mStatsHelper.getMaxPower();
sipper.percent = percentOfTotal;
pref.setTitle(entry.getLabel());
pref.setOrder(i + 1);
@@ -596,11 +585,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
BatteryUtils.StatusType.FOREGROUND, sipper.uidObj, mStatsType);
}
setUsageSummary(pref, sipper);
if ((sipper.drainType != DrainType.APP
|| sipper.uidObj.getUid() == Process.ROOT_UID)
&& sipper.drainType != DrainType.USER) {
pref.setTint(colorControl);
}
addedSome = true;
mAppListGroup.addPreference(pref);
if (mAppListGroup.getPreferenceCount() - getCachedCount()