* commit 'e4a5951925f16f18dae91ed65567e96528f17fee': Fix issue #3154576: battery stats checkin should include UID -> packages+ map
This commit is contained in:
@ -152,6 +152,7 @@ public final class Pm {
|
|||||||
* pm list permission-groups
|
* pm list permission-groups
|
||||||
* pm list permissions
|
* pm list permissions
|
||||||
* pm list features
|
* pm list features
|
||||||
|
* pm list libraries
|
||||||
* pm list instrumentation
|
* pm list instrumentation
|
||||||
*/
|
*/
|
||||||
private void runList() {
|
private void runList() {
|
||||||
@ -169,6 +170,8 @@ public final class Pm {
|
|||||||
runListPermissions();
|
runListPermissions();
|
||||||
} else if ("features".equals(type)) {
|
} else if ("features".equals(type)) {
|
||||||
runListFeatures();
|
runListFeatures();
|
||||||
|
} else if ("libraries".equals(type)) {
|
||||||
|
runListLibraries();
|
||||||
} else if ("instrumentation".equals(type)) {
|
} else if ("instrumentation".equals(type)) {
|
||||||
runListInstrumentation();
|
runListInstrumentation();
|
||||||
} else {
|
} else {
|
||||||
@ -181,6 +184,8 @@ public final class Pm {
|
|||||||
* Lists all the installed packages.
|
* Lists all the installed packages.
|
||||||
*/
|
*/
|
||||||
private void runListPackages(boolean showApplicationPackage) {
|
private void runListPackages(boolean showApplicationPackage) {
|
||||||
|
int getFlags = 0;
|
||||||
|
boolean listDisabled = false, listEnabled = false;
|
||||||
try {
|
try {
|
||||||
String opt;
|
String opt;
|
||||||
while ((opt=nextOption()) != null) {
|
while ((opt=nextOption()) != null) {
|
||||||
@ -190,6 +195,12 @@ public final class Pm {
|
|||||||
showApplicationPackage = true;
|
showApplicationPackage = true;
|
||||||
} else if (opt.equals("-f")) {
|
} else if (opt.equals("-f")) {
|
||||||
showApplicationPackage = true;
|
showApplicationPackage = true;
|
||||||
|
} else if (opt.equals("-d")) {
|
||||||
|
listDisabled = true;
|
||||||
|
} else if (opt.equals("-e")) {
|
||||||
|
listEnabled = true;
|
||||||
|
} else if (opt.equals("-u")) {
|
||||||
|
getFlags |= PackageManager.GET_UNINSTALLED_PACKAGES;
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Error: Unknown option: " + opt);
|
System.err.println("Error: Unknown option: " + opt);
|
||||||
showUsage();
|
showUsage();
|
||||||
@ -202,18 +213,26 @@ public final class Pm {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String filter = nextArg();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<PackageInfo> packages = mPm.getInstalledPackages(0 /* all */);
|
List<PackageInfo> packages = mPm.getInstalledPackages(getFlags);
|
||||||
|
|
||||||
int count = packages.size();
|
int count = packages.size();
|
||||||
for (int p = 0 ; p < count ; p++) {
|
for (int p = 0 ; p < count ; p++) {
|
||||||
PackageInfo info = packages.get(p);
|
PackageInfo info = packages.get(p);
|
||||||
System.out.print("package:");
|
if (filter != null && !info.packageName.contains(filter)) {
|
||||||
if (showApplicationPackage) {
|
continue;
|
||||||
System.out.print(info.applicationInfo.sourceDir);
|
}
|
||||||
System.out.print("=");
|
if ((!listDisabled || !info.applicationInfo.enabled) &&
|
||||||
|
(!listEnabled || info.applicationInfo.enabled)) {
|
||||||
|
System.out.print("package:");
|
||||||
|
if (showApplicationPackage) {
|
||||||
|
System.out.print(info.applicationInfo.sourceDir);
|
||||||
|
System.out.print("=");
|
||||||
|
}
|
||||||
|
System.out.println(info.packageName);
|
||||||
}
|
}
|
||||||
System.out.println(info.packageName);
|
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
System.err.println(e.toString());
|
System.err.println(e.toString());
|
||||||
@ -259,6 +278,42 @@ public final class Pm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all of the libraries supported by the current device.
|
||||||
|
*
|
||||||
|
* pm list libraries
|
||||||
|
*/
|
||||||
|
private void runListLibraries() {
|
||||||
|
try {
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
String[] rawList = mPm.getSystemSharedLibraryNames();
|
||||||
|
for (int i=0; i<rawList.length; i++) {
|
||||||
|
list.add(rawList[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Sort by name
|
||||||
|
Collections.sort(list, new Comparator<String>() {
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
if (o1 == o2) return 0;
|
||||||
|
if (o1 == null) return -1;
|
||||||
|
if (o2 == null) return 1;
|
||||||
|
return o1.compareTo(o2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
int count = (list != null) ? list.size() : 0;
|
||||||
|
for (int p = 0; p < count; p++) {
|
||||||
|
String lib = list.get(p);
|
||||||
|
System.out.print("library:");
|
||||||
|
System.out.println(lib);
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
System.err.println(e.toString());
|
||||||
|
System.err.println(PM_NOT_RUNNING_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all of the installed instrumentation, or all for a given package
|
* Lists all of the installed instrumentation, or all for a given package
|
||||||
*
|
*
|
||||||
@ -882,11 +937,12 @@ public final class Pm {
|
|||||||
|
|
||||||
private static void showUsage() {
|
private static void showUsage() {
|
||||||
System.err.println("usage: pm [list|path|install|uninstall]");
|
System.err.println("usage: pm [list|path|install|uninstall]");
|
||||||
System.err.println(" pm list packages [-f]");
|
System.err.println(" pm list packages [-f] [-d] [-e] [-u] [FILTER]");
|
||||||
System.err.println(" pm list permission-groups");
|
System.err.println(" pm list permission-groups");
|
||||||
System.err.println(" pm list permissions [-g] [-f] [-d] [-u] [GROUP]");
|
System.err.println(" pm list permissions [-g] [-f] [-d] [-u] [GROUP]");
|
||||||
System.err.println(" pm list instrumentation [-f] [TARGET-PACKAGE]");
|
System.err.println(" pm list instrumentation [-f] [TARGET-PACKAGE]");
|
||||||
System.err.println(" pm list features");
|
System.err.println(" pm list features");
|
||||||
|
System.err.println(" pm list libraries");
|
||||||
System.err.println(" pm path PACKAGE");
|
System.err.println(" pm path PACKAGE");
|
||||||
System.err.println(" pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH");
|
System.err.println(" pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH");
|
||||||
System.err.println(" pm uninstall [-k] PACKAGE");
|
System.err.println(" pm uninstall [-k] PACKAGE");
|
||||||
@ -894,8 +950,12 @@ public final class Pm {
|
|||||||
System.err.println(" pm disable PACKAGE_OR_COMPONENT");
|
System.err.println(" pm disable PACKAGE_OR_COMPONENT");
|
||||||
System.err.println(" pm setInstallLocation [0/auto] [1/internal] [2/external]");
|
System.err.println(" pm setInstallLocation [0/auto] [1/internal] [2/external]");
|
||||||
System.err.println("");
|
System.err.println("");
|
||||||
System.err.println("The list packages command prints all packages. Options:");
|
System.err.println("The list packages command prints all packages, optionally only");
|
||||||
|
System.err.println("those whose package name contains the text in FILTER. Options:");
|
||||||
System.err.println(" -f: see their associated file.");
|
System.err.println(" -f: see their associated file.");
|
||||||
|
System.err.println(" -d: filter to include disbled packages.");
|
||||||
|
System.err.println(" -e: filter to include enabled packages.");
|
||||||
|
System.err.println(" -u: also include uninstalled packages.");
|
||||||
System.err.println("");
|
System.err.println("");
|
||||||
System.err.println("The list permission-groups command prints all known");
|
System.err.println("The list permission-groups command prints all known");
|
||||||
System.err.println("permission groups.");
|
System.err.println("permission groups.");
|
||||||
|
@ -195,7 +195,7 @@ public class PackageParser {
|
|||||||
pi.versionName = p.mVersionName;
|
pi.versionName = p.mVersionName;
|
||||||
pi.sharedUserId = p.mSharedUserId;
|
pi.sharedUserId = p.mSharedUserId;
|
||||||
pi.sharedUserLabel = p.mSharedUserLabel;
|
pi.sharedUserLabel = p.mSharedUserLabel;
|
||||||
pi.applicationInfo = p.applicationInfo;
|
pi.applicationInfo = generateApplicationInfo(p, flags);
|
||||||
pi.installLocation = p.installLocation;
|
pi.installLocation = p.installLocation;
|
||||||
pi.firstInstallTime = firstInstallTime;
|
pi.firstInstallTime = firstInstallTime;
|
||||||
pi.lastUpdateTime = lastUpdateTime;
|
pi.lastUpdateTime = lastUpdateTime;
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
package android.os;
|
package android.os;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Formatter;
|
import java.util.Formatter;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Printer;
|
import android.util.Printer;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
@ -120,6 +123,7 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
private static final long BYTES_PER_GB = 1073741824; //1024^3
|
private static final long BYTES_PER_GB = 1073741824; //1024^3
|
||||||
|
|
||||||
|
|
||||||
|
private static final String UID_DATA = "uid";
|
||||||
private static final String APK_DATA = "apk";
|
private static final String APK_DATA = "apk";
|
||||||
private static final String PROCESS_DATA = "pr";
|
private static final String PROCESS_DATA = "pr";
|
||||||
private static final String SENSOR_DATA = "sr";
|
private static final String SENSOR_DATA = "sr";
|
||||||
@ -1460,7 +1464,7 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
|
|
||||||
for (int iu=0; iu<NU; iu++) {
|
for (int iu=0; iu<NU; iu++) {
|
||||||
final int uid = uidStats.keyAt(iu);
|
final int uid = uidStats.keyAt(iu);
|
||||||
if (reqUid >= 0 && uid != reqUid) {
|
if (reqUid >= 0 && uid != reqUid && uid != Process.SYSTEM_UID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1877,7 +1881,7 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void dumpCheckinLocked(PrintWriter pw, String[] args) {
|
public void dumpCheckinLocked(PrintWriter pw, String[] args, List<ApplicationInfo> apps) {
|
||||||
boolean isUnpluggedOnly = false;
|
boolean isUnpluggedOnly = false;
|
||||||
|
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
@ -1887,6 +1891,33 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (apps != null) {
|
||||||
|
SparseArray<ArrayList<String>> uids = new SparseArray<ArrayList<String>>();
|
||||||
|
for (int i=0; i<apps.size(); i++) {
|
||||||
|
ApplicationInfo ai = apps.get(i);
|
||||||
|
ArrayList<String> pkgs = uids.get(ai.uid);
|
||||||
|
if (pkgs == null) {
|
||||||
|
pkgs = new ArrayList<String>();
|
||||||
|
uids.put(ai.uid, pkgs);
|
||||||
|
}
|
||||||
|
pkgs.add(ai.packageName);
|
||||||
|
}
|
||||||
|
SparseArray<? extends Uid> uidStats = getUidStats();
|
||||||
|
final int NU = uidStats.size();
|
||||||
|
String[] lineArgs = new String[2];
|
||||||
|
for (int i=0; i<NU; i++) {
|
||||||
|
int uid = uidStats.keyAt(i);
|
||||||
|
ArrayList<String> pkgs = uids.get(uid);
|
||||||
|
if (pkgs != null) {
|
||||||
|
for (int j=0; j<pkgs.size(); j++) {
|
||||||
|
lineArgs[0] = Integer.toString(uid);
|
||||||
|
lineArgs[1] = pkgs.get(j);
|
||||||
|
dumpLine(pw, 0 /* uid */, "i" /* category */, UID_DATA,
|
||||||
|
(Object[])lineArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isUnpluggedOnly) {
|
if (isUnpluggedOnly) {
|
||||||
dumpCheckinLocked(pw, STATS_SINCE_UNPLUGGED, -1);
|
dumpCheckinLocked(pw, STATS_SINCE_UNPLUGGED, -1);
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
StopwatchTimer mVideoOnTimer;
|
StopwatchTimer mVideoOnTimer;
|
||||||
|
|
||||||
int mPhoneSignalStrengthBin = -1;
|
int mPhoneSignalStrengthBin = -1;
|
||||||
|
int mPhoneSignalStrengthBinRaw = -1;
|
||||||
final StopwatchTimer[] mPhoneSignalStrengthsTimer =
|
final StopwatchTimer[] mPhoneSignalStrengthsTimer =
|
||||||
new StopwatchTimer[NUM_SIGNAL_STRENGTH_BINS];
|
new StopwatchTimer[NUM_SIGNAL_STRENGTH_BINS];
|
||||||
|
|
||||||
@ -250,6 +251,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
private int mBluetoothPingStart = -1;
|
private int mBluetoothPingStart = -1;
|
||||||
|
|
||||||
private int mPhoneServiceState = -1;
|
private int mPhoneServiceState = -1;
|
||||||
|
private int mPhoneServiceStateRaw = -1;
|
||||||
|
private int mPhoneSimStateRaw = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Holds a SamplingTimer associated with each kernel wakelock name being tracked.
|
* Holds a SamplingTimer associated with each kernel wakelock name being tracked.
|
||||||
@ -1645,40 +1648,54 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private int fixPhoneServiceState(int state, int signalBin) {
|
||||||
* Telephony stack updates the phone state.
|
if (mPhoneSimStateRaw == TelephonyManager.SIM_STATE_ABSENT) {
|
||||||
* @param state phone state from ServiceState.getState()
|
// In this case we will always be STATE_OUT_OF_SERVICE, so need
|
||||||
*/
|
// to infer that we are scanning from other data.
|
||||||
public void notePhoneStateLocked(int state) {
|
if (state == ServiceState.STATE_OUT_OF_SERVICE
|
||||||
boolean scanning = false;
|
&& signalBin > SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
|
||||||
|
state = ServiceState.STATE_IN_SERVICE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int bin = mPhoneSignalStrengthBin;
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAllPhoneStateLocked(int state, int simState, int bin) {
|
||||||
|
boolean scanning = false;
|
||||||
|
boolean newHistory = false;
|
||||||
|
|
||||||
|
mPhoneServiceStateRaw = state;
|
||||||
|
mPhoneSimStateRaw = simState;
|
||||||
|
mPhoneSignalStrengthBinRaw = bin;
|
||||||
|
|
||||||
|
if (simState == TelephonyManager.SIM_STATE_ABSENT) {
|
||||||
|
// In this case we will always be STATE_OUT_OF_SERVICE, so need
|
||||||
|
// to infer that we are scanning from other data.
|
||||||
|
if (state == ServiceState.STATE_OUT_OF_SERVICE
|
||||||
|
&& bin > SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
|
||||||
|
state = ServiceState.STATE_IN_SERVICE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the phone is powered off, stop all timers.
|
// If the phone is powered off, stop all timers.
|
||||||
if (state == ServiceState.STATE_POWER_OFF) {
|
if (state == ServiceState.STATE_POWER_OFF) {
|
||||||
stopAllSignalStrengthTimersLocked(-1);
|
bin = -1;
|
||||||
|
|
||||||
// If we're back in service or continuing in service, restart the old timer.
|
// If we are in service, make sure the correct signal string timer is running.
|
||||||
} if (state == ServiceState.STATE_IN_SERVICE) {
|
} else if (state == ServiceState.STATE_IN_SERVICE) {
|
||||||
if (bin == -1) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
// Bin will be changed below.
|
||||||
if (!mPhoneSignalStrengthsTimer[bin].isRunningLocked()) {
|
|
||||||
mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're out of service, we are in the lowest signal strength
|
// If we're out of service, we are in the lowest signal strength
|
||||||
// bin and have the scanning bit set.
|
// bin and have the scanning bit set.
|
||||||
} else if (state == ServiceState.STATE_OUT_OF_SERVICE) {
|
} else if (state == ServiceState.STATE_OUT_OF_SERVICE) {
|
||||||
scanning = true;
|
scanning = true;
|
||||||
mPhoneSignalStrengthBin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
||||||
stopAllSignalStrengthTimersLocked(mPhoneSignalStrengthBin);
|
|
||||||
if (!mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].isRunningLocked()) {
|
|
||||||
mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].startRunningLocked(this);
|
|
||||||
}
|
|
||||||
if (!mPhoneSignalScanningTimer.isRunningLocked()) {
|
if (!mPhoneSignalScanningTimer.isRunningLocked()) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_PHONE_SCANNING_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_PHONE_SCANNING_FLAG;
|
||||||
|
newHistory = true;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Phone started scanning to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Phone started scanning to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
|
||||||
mPhoneSignalScanningTimer.startRunningLocked(this);
|
mPhoneSignalScanningTimer.startRunningLocked(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1689,7 +1706,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mHistoryCur.states &= ~HistoryItem.STATE_PHONE_SCANNING_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_PHONE_SCANNING_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Phone stopped scanning to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Phone stopped scanning to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
newHistory = true;
|
||||||
mPhoneSignalScanningTimer.stopRunningLocked(this);
|
mPhoneSignalScanningTimer.stopRunningLocked(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1697,21 +1714,48 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
if (mPhoneServiceState != state) {
|
if (mPhoneServiceState != state) {
|
||||||
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_PHONE_STATE_MASK)
|
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_PHONE_STATE_MASK)
|
||||||
| (state << HistoryItem.STATE_PHONE_STATE_SHIFT);
|
| (state << HistoryItem.STATE_PHONE_STATE_SHIFT);
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Phone state " + bin + " to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Phone state " + state + " to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
newHistory = true;
|
||||||
mPhoneServiceState = state;
|
mPhoneServiceState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mPhoneSignalStrengthBin != bin) {
|
||||||
|
if (mPhoneSignalStrengthBin >= 0) {
|
||||||
|
mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].stopRunningLocked(this);
|
||||||
|
}
|
||||||
|
if (bin >= 0) {
|
||||||
|
if (!mPhoneSignalStrengthsTimer[bin].isRunningLocked()) {
|
||||||
|
mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
|
||||||
|
}
|
||||||
|
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_SIGNAL_STRENGTH_MASK)
|
||||||
|
| (bin << HistoryItem.STATE_SIGNAL_STRENGTH_SHIFT);
|
||||||
|
if (DEBUG_HISTORY) Slog.v(TAG, "Signal strength " + bin + " to: "
|
||||||
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
|
newHistory = true;
|
||||||
|
} else {
|
||||||
|
stopAllSignalStrengthTimersLocked(-1);
|
||||||
|
}
|
||||||
|
mPhoneSignalStrengthBin = bin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newHistory) {
|
||||||
|
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Telephony stack updates the phone state.
|
||||||
|
* @param state phone state from ServiceState.getState()
|
||||||
|
*/
|
||||||
|
public void notePhoneStateLocked(int state, int simState) {
|
||||||
|
updateAllPhoneStateLocked(state, simState, mPhoneSignalStrengthBinRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notePhoneSignalStrengthLocked(SignalStrength signalStrength) {
|
public void notePhoneSignalStrengthLocked(SignalStrength signalStrength) {
|
||||||
// Bin the strength.
|
// Bin the strength.
|
||||||
int bin;
|
int bin;
|
||||||
if (mPhoneServiceState == ServiceState.STATE_POWER_OFF
|
|
||||||
|| mPhoneServiceState == ServiceState.STATE_OUT_OF_SERVICE) {
|
|
||||||
// Ignore any signal strength changes when radio was turned off or out of service.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!signalStrength.isGsm()) {
|
if (!signalStrength.isGsm()) {
|
||||||
int dBm = signalStrength.getCdmaDbm();
|
int dBm = signalStrength.getCdmaDbm();
|
||||||
if (dBm >= -75) bin = SIGNAL_STRENGTH_GREAT;
|
if (dBm >= -75) bin = SIGNAL_STRENGTH_GREAT;
|
||||||
@ -1727,18 +1771,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
else if (asu >= 4) bin = SIGNAL_STRENGTH_MODERATE;
|
else if (asu >= 4) bin = SIGNAL_STRENGTH_MODERATE;
|
||||||
else bin = SIGNAL_STRENGTH_POOR;
|
else bin = SIGNAL_STRENGTH_POOR;
|
||||||
}
|
}
|
||||||
if (mPhoneSignalStrengthBin != bin) {
|
|
||||||
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_SIGNAL_STRENGTH_MASK)
|
updateAllPhoneStateLocked(mPhoneServiceStateRaw, mPhoneSimStateRaw, bin);
|
||||||
| (bin << HistoryItem.STATE_SIGNAL_STRENGTH_SHIFT);
|
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Signal strength " + bin + " to: "
|
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
|
||||||
if (mPhoneSignalStrengthBin >= 0) {
|
|
||||||
mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].stopRunningLocked(this);
|
|
||||||
}
|
|
||||||
mPhoneSignalStrengthBin = bin;
|
|
||||||
mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notePhoneDataConnectionStateLocked(int dataType, boolean hasData) {
|
public void notePhoneDataConnectionStateLocked(int dataType, boolean hasData) {
|
||||||
@ -3973,6 +4007,9 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mKernelWakelockStats.clear();
|
mKernelWakelockStats.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mLowDischargeAmountSinceCharge = 0;
|
||||||
|
mHighDischargeAmountSinceCharge = 0;
|
||||||
|
|
||||||
clearHistoryLocked();
|
clearHistoryLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3994,12 +4031,10 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
// level to a now very high level).
|
// level to a now very high level).
|
||||||
if (oldStatus == BatteryManager.BATTERY_STATUS_FULL
|
if (oldStatus == BatteryManager.BATTERY_STATUS_FULL
|
||||||
|| level >= 95
|
|| level >= 95
|
||||||
|| (mDischargeCurrentLevel < 30 && level >= 90)) {
|
|| (mDischargeCurrentLevel < 20 && level >= 80)) {
|
||||||
doWrite = true;
|
doWrite = true;
|
||||||
resetAllStatsLocked();
|
resetAllStatsLocked();
|
||||||
mDischargeStartLevel = level;
|
mDischargeStartLevel = level;
|
||||||
mLowDischargeAmountSinceCharge = 0;
|
|
||||||
mHighDischargeAmountSinceCharge = 0;
|
|
||||||
}
|
}
|
||||||
updateKernelWakelocksLocked();
|
updateKernelWakelocksLocked();
|
||||||
mHistoryCur.batteryLevel = (byte)level;
|
mHistoryCur.batteryLevel = (byte)level;
|
||||||
@ -4089,11 +4124,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mHistoryCur.batteryPlugType = (byte)plugType;
|
mHistoryCur.batteryPlugType = (byte)plugType;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (mHistoryCur.batteryTemperature != temp) {
|
if (temp >= (mHistoryCur.batteryTemperature+10)
|
||||||
|
|| temp <= (mHistoryCur.batteryTemperature-10)) {
|
||||||
mHistoryCur.batteryTemperature = (char)temp;
|
mHistoryCur.batteryTemperature = (char)temp;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (mHistoryCur.batteryVoltage != volt) {
|
if (volt > (mHistoryCur.batteryVoltage+20)
|
||||||
|
|| volt < (mHistoryCur.batteryVoltage-20)) {
|
||||||
mHistoryCur.batteryVoltage = (char)volt;
|
mHistoryCur.batteryVoltage = (char)volt;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@ -4289,20 +4326,28 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getDischargeCurrentLevelLocked() {
|
public int getDischargeCurrentLevelLocked() {
|
||||||
return mDischargeCurrentLevel;
|
return mDischargeCurrentLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLowDischargeAmountSinceCharge() {
|
public int getLowDischargeAmountSinceCharge() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
return mLowDischargeAmountSinceCharge;
|
int val = mLowDischargeAmountSinceCharge;
|
||||||
|
if (mOnBattery && mDischargeCurrentLevel < mDischargeUnplugLevel) {
|
||||||
|
val += mDischargeUnplugLevel-mDischargeCurrentLevel-1;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHighDischargeAmountSinceCharge() {
|
public int getHighDischargeAmountSinceCharge() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
return mHighDischargeAmountSinceCharge;
|
int val = mHighDischargeAmountSinceCharge;
|
||||||
|
if (mOnBattery && mDischargeCurrentLevel < mDischargeUnplugLevel) {
|
||||||
|
val += mDischargeUnplugLevel-mDischargeCurrentLevel;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4804,8 +4849,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
out.writeLong(computeRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED));
|
out.writeLong(computeRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED));
|
||||||
out.writeInt(mDischargeUnplugLevel);
|
out.writeInt(mDischargeUnplugLevel);
|
||||||
out.writeInt(mDischargeCurrentLevel);
|
out.writeInt(mDischargeCurrentLevel);
|
||||||
out.writeInt(mLowDischargeAmountSinceCharge);
|
out.writeInt(getLowDischargeAmountSinceCharge());
|
||||||
out.writeInt(mHighDischargeAmountSinceCharge);
|
out.writeInt(getHighDischargeAmountSinceCharge());
|
||||||
|
|
||||||
mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
|
mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
|
||||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||||
|
@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@ -53,6 +54,17 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
|
|||||||
View mNoAppsText;
|
View mNoAppsText;
|
||||||
IntentFilter mBroadcastIntentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
IntentFilter mBroadcastIntentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||||
|
|
||||||
|
Handler mHandler = new Handler();
|
||||||
|
Runnable mCleanup = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
// dump extra memory we're hanging on to
|
||||||
|
for (TextView icon: mIcons) {
|
||||||
|
icon.setCompoundDrawables(null, null, null, null);
|
||||||
|
icon.setTag(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private int mIconSize;
|
private int mIconSize;
|
||||||
|
|
||||||
public RecentApplicationsDialog(Context context) {
|
public RecentApplicationsDialog(Context context) {
|
||||||
@ -144,6 +156,8 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
|
|||||||
|
|
||||||
// receive broadcasts
|
// receive broadcasts
|
||||||
getContext().registerReceiver(mBroadcastReceiver, mBroadcastIntentFilter);
|
getContext().registerReceiver(mBroadcastReceiver, mBroadcastIntentFilter);
|
||||||
|
|
||||||
|
mHandler.removeCallbacks(mCleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,18 +167,14 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
|
|||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
||||||
// dump extra memory we're hanging on to
|
|
||||||
for (TextView icon: mIcons) {
|
|
||||||
icon.setCompoundDrawables(null, null, null, null);
|
|
||||||
icon.setTag(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sStatusBar != null) {
|
if (sStatusBar != null) {
|
||||||
sStatusBar.disable(StatusBarManager.DISABLE_NONE);
|
sStatusBar.disable(StatusBarManager.DISABLE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop receiving broadcasts
|
// stop receiving broadcasts
|
||||||
getContext().unregisterReceiver(mBroadcastReceiver);
|
getContext().unregisterReceiver(mBroadcastReceiver);
|
||||||
|
|
||||||
|
mHandler.postDelayed(mCleanup, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5699,9 +5699,6 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
res.removedInfo.removedPackage = packageName;
|
res.removedInfo.removedPackage = packageName;
|
||||||
// Remove existing system package
|
// Remove existing system package
|
||||||
removePackageLI(oldPkg, true);
|
removePackageLI(oldPkg, true);
|
||||||
synchronized (mPackages) {
|
|
||||||
res.removedInfo.removedUid = mSettings.disableSystemPackageLP(packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Successfully disabled the old package. Now proceed with re-installation
|
// Successfully disabled the old package. Now proceed with re-installation
|
||||||
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
||||||
|
@ -18,6 +18,7 @@ package com.android.server.am;
|
|||||||
|
|
||||||
import android.bluetooth.BluetoothHeadset;
|
import android.bluetooth.BluetoothHeadset;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@ -25,6 +26,7 @@ import android.os.Process;
|
|||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.WorkSource;
|
import android.os.WorkSource;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.app.IBatteryStats;
|
import com.android.internal.app.IBatteryStats;
|
||||||
@ -33,6 +35,7 @@ import com.android.internal.os.PowerProfile;
|
|||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All information we are collecting about things that can happen that impact
|
* All information we are collecting about things that can happen that impact
|
||||||
@ -213,8 +216,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
|
|||||||
|
|
||||||
public void notePhoneState(int state) {
|
public void notePhoneState(int state) {
|
||||||
enforceCallingPermission();
|
enforceCallingPermission();
|
||||||
|
int simState = TelephonyManager.getDefault().getSimState();
|
||||||
synchronized (mStats) {
|
synchronized (mStats) {
|
||||||
mStats.notePhoneStateLocked(state);
|
mStats.notePhoneStateLocked(state, simState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,19 +417,28 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
synchronized (mStats) {
|
boolean isCheckin = false;
|
||||||
boolean isCheckin = false;
|
if (args != null) {
|
||||||
if (args != null) {
|
for (String arg : args) {
|
||||||
for (String arg : args) {
|
if ("--checkin".equals(arg)) {
|
||||||
if ("--checkin".equals(arg)) {
|
isCheckin = true;
|
||||||
isCheckin = true;
|
} else if ("--reset".equals(arg)) {
|
||||||
} else if ("--reset".equals(arg)) {
|
synchronized (mStats) {
|
||||||
mStats.resetAllStatsLocked();
|
mStats.resetAllStatsLocked();
|
||||||
|
pw.println("Battery stats reset.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isCheckin) mStats.dumpCheckinLocked(pw, args);
|
}
|
||||||
else mStats.dumpLocked(pw);
|
if (isCheckin) {
|
||||||
|
List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0);
|
||||||
|
synchronized (mStats) {
|
||||||
|
mStats.dumpCheckinLocked(pw, args, apps);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
synchronized (mStats) {
|
||||||
|
mStats.dumpLocked(pw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user