Merge change Iab5c49c7 into eclair-mr2
* changes: move event log tags used by system server into this package
This commit is contained in:
@ -5,7 +5,8 @@ LOCAL_PATH:= $(call my-dir)
|
|||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
$(call all-subdir-java-files)
|
$(call all-subdir-java-files) \
|
||||||
|
com/android/server/EventLogTags.logtags
|
||||||
|
|
||||||
LOCAL_MODULE:= services
|
LOCAL_MODULE:= services
|
||||||
|
|
||||||
|
@ -102,22 +102,6 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
private static final int MSG_RUN_CLEAR = 4;
|
private static final int MSG_RUN_CLEAR = 4;
|
||||||
private static final int MSG_RUN_INITIALIZE = 5;
|
private static final int MSG_RUN_INITIALIZE = 5;
|
||||||
|
|
||||||
// Event tags -- see system/core/logcat/event-log-tags
|
|
||||||
private static final int BACKUP_DATA_CHANGED_EVENT = 2820;
|
|
||||||
private static final int BACKUP_START_EVENT = 2821;
|
|
||||||
private static final int BACKUP_TRANSPORT_FAILURE_EVENT = 2822;
|
|
||||||
private static final int BACKUP_AGENT_FAILURE_EVENT = 2823;
|
|
||||||
private static final int BACKUP_PACKAGE_EVENT = 2824;
|
|
||||||
private static final int BACKUP_SUCCESS_EVENT = 2825;
|
|
||||||
private static final int BACKUP_RESET_EVENT = 2826;
|
|
||||||
private static final int BACKUP_INITIALIZE_EVENT = 2827;
|
|
||||||
|
|
||||||
private static final int RESTORE_START_EVENT = 2830;
|
|
||||||
private static final int RESTORE_TRANSPORT_FAILURE_EVENT = 2831;
|
|
||||||
private static final int RESTORE_AGENT_FAILURE_EVENT = 2832;
|
|
||||||
private static final int RESTORE_PACKAGE_EVENT = 2833;
|
|
||||||
private static final int RESTORE_SUCCESS_EVENT = 2834;
|
|
||||||
|
|
||||||
// Timeout interval for deciding that a bind or clear-data has taken too long
|
// Timeout interval for deciding that a bind or clear-data has taken too long
|
||||||
static final long TIMEOUT_INTERVAL = 10 * 1000;
|
static final long TIMEOUT_INTERVAL = 10 * 1000;
|
||||||
|
|
||||||
@ -1016,7 +1000,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
EventLog.writeEvent(BACKUP_START_EVENT, mTransport.transportDirName());
|
EventLog.writeEvent(EventLogTags.BACKUP_START, mTransport.transportDirName());
|
||||||
|
|
||||||
// If we haven't stored package manager metadata yet, we must init the transport.
|
// If we haven't stored package manager metadata yet, we must init the transport.
|
||||||
File pmState = new File(mStateDir, PACKAGE_MANAGER_SENTINEL);
|
File pmState = new File(mStateDir, PACKAGE_MANAGER_SENTINEL);
|
||||||
@ -1025,9 +1009,9 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
resetBackupState(mStateDir); // Just to make sure.
|
resetBackupState(mStateDir); // Just to make sure.
|
||||||
status = mTransport.initializeDevice();
|
status = mTransport.initializeDevice();
|
||||||
if (status == BackupConstants.TRANSPORT_OK) {
|
if (status == BackupConstants.TRANSPORT_OK) {
|
||||||
EventLog.writeEvent(BACKUP_INITIALIZE_EVENT);
|
EventLog.writeEvent(EventLogTags.BACKUP_INITIALIZE);
|
||||||
} else {
|
} else {
|
||||||
EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, "(initialize)");
|
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, "(initialize)");
|
||||||
Log.e(TAG, "Transport error in initializeDevice()");
|
Log.e(TAG, "Transport error in initializeDevice()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1056,9 +1040,9 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
status = mTransport.finishBackup();
|
status = mTransport.finishBackup();
|
||||||
if (status == BackupConstants.TRANSPORT_OK) {
|
if (status == BackupConstants.TRANSPORT_OK) {
|
||||||
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
||||||
EventLog.writeEvent(BACKUP_SUCCESS_EVENT, mQueue.size(), millis);
|
EventLog.writeEvent(EventLogTags.BACKUP_SUCCESS, mQueue.size(), millis);
|
||||||
} else {
|
} else {
|
||||||
EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, "(finish)");
|
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, "(finish)");
|
||||||
Log.e(TAG, "Transport error in finishBackup()");
|
Log.e(TAG, "Transport error in finishBackup()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1067,7 +1051,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// The backend reports that our dataset has been wiped. We need to
|
// The backend reports that our dataset has been wiped. We need to
|
||||||
// reset all of our bookkeeping and instead run a new backup pass for
|
// reset all of our bookkeeping and instead run a new backup pass for
|
||||||
// everything. This must come after mBackupOrRestoreInProgress is cleared.
|
// everything. This must come after mBackupOrRestoreInProgress is cleared.
|
||||||
EventLog.writeEvent(BACKUP_RESET_EVENT, mTransport.transportDirName());
|
EventLog.writeEvent(EventLogTags.BACKUP_RESET, mTransport.transportDirName());
|
||||||
resetBackupState(mStateDir);
|
resetBackupState(mStateDir);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1201,7 +1185,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
if (DEBUG) Log.v(TAG, "doBackup() success");
|
if (DEBUG) Log.v(TAG, "doBackup() success");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error backing up " + packageName, e);
|
Log.e(TAG, "Error backing up " + packageName, e);
|
||||||
EventLog.writeEvent(BACKUP_AGENT_FAILURE_EVENT, packageName, e.toString());
|
EventLog.writeEvent(EventLogTags.BACKUP_AGENT_FAILURE, packageName, e.toString());
|
||||||
backupDataName.delete();
|
backupDataName.delete();
|
||||||
newStateName.delete();
|
newStateName.delete();
|
||||||
return BackupConstants.TRANSPORT_ERROR;
|
return BackupConstants.TRANSPORT_ERROR;
|
||||||
@ -1241,13 +1225,13 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
if (result == BackupConstants.TRANSPORT_OK) {
|
if (result == BackupConstants.TRANSPORT_OK) {
|
||||||
backupDataName.delete();
|
backupDataName.delete();
|
||||||
newStateName.renameTo(savedStateName);
|
newStateName.renameTo(savedStateName);
|
||||||
EventLog.writeEvent(BACKUP_PACKAGE_EVENT, packageName, size);
|
EventLog.writeEvent(EventLogTags.BACKUP_PACKAGE, packageName, size);
|
||||||
} else {
|
} else {
|
||||||
EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, packageName);
|
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, packageName);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Transport error backing up " + packageName, e);
|
Log.e(TAG, "Transport error backing up " + packageName, e);
|
||||||
EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, packageName);
|
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, packageName);
|
||||||
result = BackupConstants.TRANSPORT_ERROR;
|
result = BackupConstants.TRANSPORT_ERROR;
|
||||||
} finally {
|
} finally {
|
||||||
try { if (backupData != null) backupData.close(); } catch (IOException e) {}
|
try { if (backupData != null) backupData.close(); } catch (IOException e) {}
|
||||||
@ -1364,7 +1348,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// build the set of apps to restore
|
// build the set of apps to restore
|
||||||
try {
|
try {
|
||||||
// TODO: Log this before getAvailableRestoreSets, somehow
|
// TODO: Log this before getAvailableRestoreSets, somehow
|
||||||
EventLog.writeEvent(RESTORE_START_EVENT, mTransport.transportDirName(), mToken);
|
EventLog.writeEvent(EventLogTags.RESTORE_START, mTransport.transportDirName(), mToken);
|
||||||
|
|
||||||
// Get the list of all packages which have backup enabled.
|
// Get the list of all packages which have backup enabled.
|
||||||
// (Include the Package Manager metadata pseudo-package first.)
|
// (Include the Package Manager metadata pseudo-package first.)
|
||||||
@ -1391,24 +1375,24 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
if (mTransport.startRestore(mToken, restorePackages.toArray(new PackageInfo[0])) !=
|
if (mTransport.startRestore(mToken, restorePackages.toArray(new PackageInfo[0])) !=
|
||||||
BackupConstants.TRANSPORT_OK) {
|
BackupConstants.TRANSPORT_OK) {
|
||||||
Log.e(TAG, "Error starting restore operation");
|
Log.e(TAG, "Error starting restore operation");
|
||||||
EventLog.writeEvent(RESTORE_TRANSPORT_FAILURE_EVENT);
|
EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String packageName = mTransport.nextRestorePackage();
|
String packageName = mTransport.nextRestorePackage();
|
||||||
if (packageName == null) {
|
if (packageName == null) {
|
||||||
Log.e(TAG, "Error getting first restore package");
|
Log.e(TAG, "Error getting first restore package");
|
||||||
EventLog.writeEvent(RESTORE_TRANSPORT_FAILURE_EVENT);
|
EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE);
|
||||||
return;
|
return;
|
||||||
} else if (packageName.equals("")) {
|
} else if (packageName.equals("")) {
|
||||||
Log.i(TAG, "No restore data available");
|
Log.i(TAG, "No restore data available");
|
||||||
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
||||||
EventLog.writeEvent(RESTORE_SUCCESS_EVENT, 0, millis);
|
EventLog.writeEvent(EventLogTags.RESTORE_SUCCESS, 0, millis);
|
||||||
return;
|
return;
|
||||||
} else if (!packageName.equals(PACKAGE_MANAGER_SENTINEL)) {
|
} else if (!packageName.equals(PACKAGE_MANAGER_SENTINEL)) {
|
||||||
Log.e(TAG, "Expected restore data for \"" + PACKAGE_MANAGER_SENTINEL
|
Log.e(TAG, "Expected restore data for \"" + PACKAGE_MANAGER_SENTINEL
|
||||||
+ "\", found only \"" + packageName + "\"");
|
+ "\", found only \"" + packageName + "\"");
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, PACKAGE_MANAGER_SENTINEL,
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, PACKAGE_MANAGER_SENTINEL,
|
||||||
"Package manager data missing");
|
"Package manager data missing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1423,7 +1407,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// the restore operation.
|
// the restore operation.
|
||||||
if (!pmAgent.hasMetadata()) {
|
if (!pmAgent.hasMetadata()) {
|
||||||
Log.e(TAG, "No restore metadata available, so not restoring settings");
|
Log.e(TAG, "No restore metadata available, so not restoring settings");
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, PACKAGE_MANAGER_SENTINEL,
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, PACKAGE_MANAGER_SENTINEL,
|
||||||
"Package manager restore metadata missing");
|
"Package manager restore metadata missing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1434,7 +1418,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
|
|
||||||
if (packageName == null) {
|
if (packageName == null) {
|
||||||
Log.e(TAG, "Error getting next restore package");
|
Log.e(TAG, "Error getting next restore package");
|
||||||
EventLog.writeEvent(RESTORE_TRANSPORT_FAILURE_EVENT);
|
EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE);
|
||||||
return;
|
return;
|
||||||
} else if (packageName.equals("")) {
|
} else if (packageName.equals("")) {
|
||||||
break;
|
break;
|
||||||
@ -1452,7 +1436,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
Metadata metaInfo = pmAgent.getRestoredMetadata(packageName);
|
Metadata metaInfo = pmAgent.getRestoredMetadata(packageName);
|
||||||
if (metaInfo == null) {
|
if (metaInfo == null) {
|
||||||
Log.e(TAG, "Missing metadata for " + packageName);
|
Log.e(TAG, "Missing metadata for " + packageName);
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, packageName,
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName,
|
||||||
"Package metadata missing");
|
"Package metadata missing");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1463,7 +1447,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
packageInfo = mPackageManager.getPackageInfo(packageName, flags);
|
packageInfo = mPackageManager.getPackageInfo(packageName, flags);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Log.e(TAG, "Invalid package restoring data", e);
|
Log.e(TAG, "Invalid package restoring data", e);
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, packageName,
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName,
|
||||||
"Package missing on device");
|
"Package missing on device");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1472,13 +1456,13 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
String message = "Version " + metaInfo.versionCode
|
String message = "Version " + metaInfo.versionCode
|
||||||
+ " > installed version " + packageInfo.versionCode;
|
+ " > installed version " + packageInfo.versionCode;
|
||||||
Log.w(TAG, "Package " + packageName + ": " + message);
|
Log.w(TAG, "Package " + packageName + ": " + message);
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, packageName, message);
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName, message);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!signaturesMatch(metaInfo.signatures, packageInfo)) {
|
if (!signaturesMatch(metaInfo.signatures, packageInfo)) {
|
||||||
Log.w(TAG, "Signature mismatch restoring " + packageName);
|
Log.w(TAG, "Signature mismatch restoring " + packageName);
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, packageName,
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName,
|
||||||
"Signature mismatch");
|
"Signature mismatch");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1505,7 +1489,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
: IApplicationThread.BACKUP_MODE_RESTORE));
|
: IApplicationThread.BACKUP_MODE_RESTORE));
|
||||||
if (agent == null) {
|
if (agent == null) {
|
||||||
Log.w(TAG, "Can't find backup agent for " + packageName);
|
Log.w(TAG, "Can't find backup agent for " + packageName);
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, packageName,
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName,
|
||||||
"Restore agent missing");
|
"Restore agent missing");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1536,7 +1520,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// if we get this far, report success to the observer
|
// if we get this far, report success to the observer
|
||||||
error = 0;
|
error = 0;
|
||||||
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
||||||
EventLog.writeEvent(RESTORE_SUCCESS_EVENT, count, millis);
|
EventLog.writeEvent(EventLogTags.RESTORE_SUCCESS, count, millis);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error in restore thread", e);
|
Log.e(TAG, "Error in restore thread", e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -1594,7 +1578,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
|
|
||||||
if (mTransport.getRestoreData(backupData) != BackupConstants.TRANSPORT_OK) {
|
if (mTransport.getRestoreData(backupData) != BackupConstants.TRANSPORT_OK) {
|
||||||
Log.e(TAG, "Error getting restore data for " + packageName);
|
Log.e(TAG, "Error getting restore data for " + packageName);
|
||||||
EventLog.writeEvent(RESTORE_TRANSPORT_FAILURE_EVENT);
|
EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1627,10 +1611,10 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
//newStateName.renameTo(savedStateName); // TODO: replace with this
|
//newStateName.renameTo(savedStateName); // TODO: replace with this
|
||||||
|
|
||||||
int size = (int) backupDataName.length();
|
int size = (int) backupDataName.length();
|
||||||
EventLog.writeEvent(RESTORE_PACKAGE_EVENT, packageName, size);
|
EventLog.writeEvent(EventLogTags.RESTORE_PACKAGE, packageName, size);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error restoring data for " + packageName, e);
|
Log.e(TAG, "Error restoring data for " + packageName, e);
|
||||||
EventLog.writeEvent(RESTORE_AGENT_FAILURE_EVENT, packageName, e.toString());
|
EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName, e.toString());
|
||||||
|
|
||||||
// If the agent fails restore, it might have put the app's data
|
// If the agent fails restore, it might have put the app's data
|
||||||
// into an incoherent state. For consistency we wipe its data
|
// into an incoherent state. For consistency we wipe its data
|
||||||
@ -1702,7 +1686,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "Initializing (wiping) backup transport storage: " + transportName);
|
Log.i(TAG, "Initializing (wiping) backup transport storage: " + transportName);
|
||||||
EventLog.writeEvent(BACKUP_START_EVENT, transport.transportDirName());
|
EventLog.writeEvent(EventLogTags.BACKUP_START, transport.transportDirName());
|
||||||
long startRealtime = SystemClock.elapsedRealtime();
|
long startRealtime = SystemClock.elapsedRealtime();
|
||||||
int status = transport.initializeDevice();
|
int status = transport.initializeDevice();
|
||||||
|
|
||||||
@ -1714,9 +1698,9 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
if (status == BackupConstants.TRANSPORT_OK) {
|
if (status == BackupConstants.TRANSPORT_OK) {
|
||||||
Log.i(TAG, "Device init successful");
|
Log.i(TAG, "Device init successful");
|
||||||
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
|
||||||
EventLog.writeEvent(BACKUP_INITIALIZE_EVENT);
|
EventLog.writeEvent(EventLogTags.BACKUP_INITIALIZE);
|
||||||
resetBackupState(new File(mBaseStateDir, transport.transportDirName()));
|
resetBackupState(new File(mBaseStateDir, transport.transportDirName()));
|
||||||
EventLog.writeEvent(BACKUP_SUCCESS_EVENT, 0, millis);
|
EventLog.writeEvent(EventLogTags.BACKUP_SUCCESS, 0, millis);
|
||||||
synchronized (mQueueLock) {
|
synchronized (mQueueLock) {
|
||||||
recordInitPendingLocked(false, transportName);
|
recordInitPendingLocked(false, transportName);
|
||||||
}
|
}
|
||||||
@ -1724,7 +1708,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// If this didn't work, requeue this one and try again
|
// If this didn't work, requeue this one and try again
|
||||||
// after a suitable interval
|
// after a suitable interval
|
||||||
Log.e(TAG, "Transport error in initializeDevice()");
|
Log.e(TAG, "Transport error in initializeDevice()");
|
||||||
EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, "(initialize)");
|
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, "(initialize)");
|
||||||
synchronized (mQueueLock) {
|
synchronized (mQueueLock) {
|
||||||
recordInitPendingLocked(true, transportName);
|
recordInitPendingLocked(true, transportName);
|
||||||
}
|
}
|
||||||
@ -1757,7 +1741,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// Record that we need a backup pass for the caller. Since multiple callers
|
// Record that we need a backup pass for the caller. Since multiple callers
|
||||||
// may share a uid, we need to note all candidates within that uid and schedule
|
// may share a uid, we need to note all candidates within that uid and schedule
|
||||||
// a backup pass for each of them.
|
// a backup pass for each of them.
|
||||||
EventLog.writeEvent(BACKUP_DATA_CHANGED_EVENT, packageName);
|
EventLog.writeEvent(EventLogTags.BACKUP_DATA_CHANGED, packageName);
|
||||||
|
|
||||||
// If the caller does not hold the BACKUP permission, it can only request a
|
// If the caller does not hold the BACKUP permission, it can only request a
|
||||||
// backup of its own data.
|
// backup of its own data.
|
||||||
@ -2103,7 +2087,7 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
}
|
}
|
||||||
if (mRestoreSets == null) { // valid transport; do the one-time fetch
|
if (mRestoreSets == null) { // valid transport; do the one-time fetch
|
||||||
mRestoreSets = mRestoreTransport.getAvailableRestoreSets();
|
mRestoreSets = mRestoreTransport.getAvailableRestoreSets();
|
||||||
if (mRestoreSets == null) EventLog.writeEvent(RESTORE_TRANSPORT_FAILURE_EVENT);
|
if (mRestoreSets == null) EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE);
|
||||||
}
|
}
|
||||||
return mRestoreSets;
|
return mRestoreSets;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -68,23 +68,19 @@ import java.io.PrintWriter;
|
|||||||
*/
|
*/
|
||||||
class BatteryService extends Binder {
|
class BatteryService extends Binder {
|
||||||
private static final String TAG = BatteryService.class.getSimpleName();
|
private static final String TAG = BatteryService.class.getSimpleName();
|
||||||
|
|
||||||
private static final boolean LOCAL_LOGV = false;
|
private static final boolean LOCAL_LOGV = false;
|
||||||
|
|
||||||
static final int LOG_BATTERY_LEVEL = 2722;
|
|
||||||
static final int LOG_BATTERY_STATUS = 2723;
|
|
||||||
static final int LOG_BATTERY_DISCHARGE_STATUS = 2730;
|
|
||||||
|
|
||||||
static final int BATTERY_SCALE = 100; // battery capacity is a percentage
|
static final int BATTERY_SCALE = 100; // battery capacity is a percentage
|
||||||
|
|
||||||
// Used locally for determining when to make a last ditch effort to log
|
// Used locally for determining when to make a last ditch effort to log
|
||||||
// discharge stats before the device dies.
|
// discharge stats before the device dies.
|
||||||
private static final int CRITICAL_BATTERY_LEVEL = 4;
|
private static final int CRITICAL_BATTERY_LEVEL = 4;
|
||||||
|
|
||||||
private static final int DUMP_MAX_LENGTH = 24 * 1024;
|
private static final int DUMP_MAX_LENGTH = 24 * 1024;
|
||||||
private static final String[] DUMPSYS_ARGS = new String[] { "--checkin", "-u" };
|
private static final String[] DUMPSYS_ARGS = new String[] { "--checkin", "-u" };
|
||||||
private static final String BATTERY_STATS_SERVICE_NAME = "batteryinfo";
|
private static final String BATTERY_STATS_SERVICE_NAME = "batteryinfo";
|
||||||
|
|
||||||
private static final String DUMPSYS_DATA_PATH = "/data/system/";
|
private static final String DUMPSYS_DATA_PATH = "/data/system/";
|
||||||
|
|
||||||
// This should probably be exposed in the API, though it's not critical
|
// This should probably be exposed in the API, though it's not critical
|
||||||
@ -92,7 +88,7 @@ class BatteryService extends Binder {
|
|||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final IBatteryStats mBatteryStats;
|
private final IBatteryStats mBatteryStats;
|
||||||
|
|
||||||
private boolean mAcOnline;
|
private boolean mAcOnline;
|
||||||
private boolean mUsbOnline;
|
private boolean mUsbOnline;
|
||||||
private int mBatteryStatus;
|
private int mBatteryStatus;
|
||||||
@ -117,12 +113,12 @@ class BatteryService extends Binder {
|
|||||||
|
|
||||||
private int mPlugType;
|
private int mPlugType;
|
||||||
private int mLastPlugType = -1; // Extra state so we can detect first run
|
private int mLastPlugType = -1; // Extra state so we can detect first run
|
||||||
|
|
||||||
private long mDischargeStartTime;
|
private long mDischargeStartTime;
|
||||||
private int mDischargeStartLevel;
|
private int mDischargeStartLevel;
|
||||||
|
|
||||||
private boolean mSentLowBatteryBroadcast = false;
|
private boolean mSentLowBatteryBroadcast = false;
|
||||||
|
|
||||||
public BatteryService(Context context) {
|
public BatteryService(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBatteryStats = BatteryStatsService.getService();
|
mBatteryStats = BatteryStatsService.getService();
|
||||||
@ -219,20 +215,20 @@ class BatteryService extends Binder {
|
|||||||
mPlugType != mLastPlugType ||
|
mPlugType != mLastPlugType ||
|
||||||
mBatteryVoltage != mLastBatteryVoltage ||
|
mBatteryVoltage != mLastBatteryVoltage ||
|
||||||
mBatteryTemperature != mLastBatteryTemperature) {
|
mBatteryTemperature != mLastBatteryTemperature) {
|
||||||
|
|
||||||
if (mPlugType != mLastPlugType) {
|
if (mPlugType != mLastPlugType) {
|
||||||
if (mLastPlugType == BATTERY_PLUGGED_NONE) {
|
if (mLastPlugType == BATTERY_PLUGGED_NONE) {
|
||||||
// discharging -> charging
|
// discharging -> charging
|
||||||
|
|
||||||
// There's no value in this data unless we've discharged at least once and the
|
// There's no value in this data unless we've discharged at least once and the
|
||||||
// battery level has changed; so don't log until it does.
|
// battery level has changed; so don't log until it does.
|
||||||
if (mDischargeStartTime != 0 && mDischargeStartLevel != mBatteryLevel) {
|
if (mDischargeStartTime != 0 && mDischargeStartLevel != mBatteryLevel) {
|
||||||
dischargeDuration = SystemClock.elapsedRealtime() - mDischargeStartTime;
|
dischargeDuration = SystemClock.elapsedRealtime() - mDischargeStartTime;
|
||||||
logOutlier = true;
|
logOutlier = true;
|
||||||
EventLog.writeEvent(LOG_BATTERY_DISCHARGE_STATUS, dischargeDuration,
|
EventLog.writeEvent(EventLogTags.BATTERY_DISCHARGE, dischargeDuration,
|
||||||
mDischargeStartLevel, mBatteryLevel);
|
mDischargeStartLevel, mBatteryLevel);
|
||||||
// make sure we see a discharge event before logging again
|
// make sure we see a discharge event before logging again
|
||||||
mDischargeStartTime = 0;
|
mDischargeStartTime = 0;
|
||||||
}
|
}
|
||||||
} else if (mPlugType == BATTERY_PLUGGED_NONE) {
|
} else if (mPlugType == BATTERY_PLUGGED_NONE) {
|
||||||
// charging -> discharging or we just powered up
|
// charging -> discharging or we just powered up
|
||||||
@ -244,19 +240,19 @@ class BatteryService extends Binder {
|
|||||||
mBatteryHealth != mLastBatteryHealth ||
|
mBatteryHealth != mLastBatteryHealth ||
|
||||||
mBatteryPresent != mLastBatteryPresent ||
|
mBatteryPresent != mLastBatteryPresent ||
|
||||||
mPlugType != mLastPlugType) {
|
mPlugType != mLastPlugType) {
|
||||||
EventLog.writeEvent(LOG_BATTERY_STATUS,
|
EventLog.writeEvent(EventLogTags.BATTERY_STATUS,
|
||||||
mBatteryStatus, mBatteryHealth, mBatteryPresent ? 1 : 0,
|
mBatteryStatus, mBatteryHealth, mBatteryPresent ? 1 : 0,
|
||||||
mPlugType, mBatteryTechnology);
|
mPlugType, mBatteryTechnology);
|
||||||
}
|
}
|
||||||
if (mBatteryLevel != mLastBatteryLevel ||
|
if (mBatteryLevel != mLastBatteryLevel ||
|
||||||
mBatteryVoltage != mLastBatteryVoltage ||
|
mBatteryVoltage != mLastBatteryVoltage ||
|
||||||
mBatteryTemperature != mLastBatteryTemperature) {
|
mBatteryTemperature != mLastBatteryTemperature) {
|
||||||
EventLog.writeEvent(LOG_BATTERY_LEVEL,
|
EventLog.writeEvent(EventLogTags.BATTERY_LEVEL,
|
||||||
mBatteryLevel, mBatteryVoltage, mBatteryTemperature);
|
mBatteryLevel, mBatteryVoltage, mBatteryTemperature);
|
||||||
}
|
}
|
||||||
if (mBatteryLevel != mLastBatteryLevel && mPlugType == BATTERY_PLUGGED_NONE) {
|
if (mBatteryLevel != mLastBatteryLevel && mPlugType == BATTERY_PLUGGED_NONE) {
|
||||||
// If the battery level has changed and we are on battery, update the current level.
|
// If the battery level has changed and we are on battery, update the current level.
|
||||||
// This is used for discharge cycle tracking so this shouldn't be updated while the
|
// This is used for discharge cycle tracking so this shouldn't be updated while the
|
||||||
// battery is charging.
|
// battery is charging.
|
||||||
try {
|
try {
|
||||||
mBatteryStats.recordCurrentLevel(mBatteryLevel);
|
mBatteryStats.recordCurrentLevel(mBatteryLevel);
|
||||||
@ -271,7 +267,7 @@ class BatteryService extends Binder {
|
|||||||
dischargeDuration = SystemClock.elapsedRealtime() - mDischargeStartTime;
|
dischargeDuration = SystemClock.elapsedRealtime() - mDischargeStartTime;
|
||||||
logOutlier = true;
|
logOutlier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean plugged = mPlugType != BATTERY_PLUGGED_NONE;
|
final boolean plugged = mPlugType != BATTERY_PLUGGED_NONE;
|
||||||
final boolean oldPlugged = mLastPlugType != BATTERY_PLUGGED_NONE;
|
final boolean oldPlugged = mLastPlugType != BATTERY_PLUGGED_NONE;
|
||||||
|
|
||||||
@ -285,9 +281,9 @@ class BatteryService extends Binder {
|
|||||||
&& mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
|
&& mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
|
||||||
&& mBatteryLevel <= mLowBatteryWarningLevel
|
&& mBatteryLevel <= mLowBatteryWarningLevel
|
||||||
&& (oldPlugged || mLastBatteryLevel > mLowBatteryWarningLevel);
|
&& (oldPlugged || mLastBatteryLevel > mLowBatteryWarningLevel);
|
||||||
|
|
||||||
sendIntent();
|
sendIntent();
|
||||||
|
|
||||||
// Separate broadcast is sent for power connected / not connected
|
// Separate broadcast is sent for power connected / not connected
|
||||||
// since the standard intent will not wake any applications and some
|
// since the standard intent will not wake any applications and some
|
||||||
// applications may want to have smart behavior based on this.
|
// applications may want to have smart behavior based on this.
|
||||||
@ -311,12 +307,12 @@ class BatteryService extends Binder {
|
|||||||
statusIntent.setAction(Intent.ACTION_BATTERY_OKAY);
|
statusIntent.setAction(Intent.ACTION_BATTERY_OKAY);
|
||||||
mContext.sendBroadcast(statusIntent);
|
mContext.sendBroadcast(statusIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This needs to be done after sendIntent() so that we get the lastest battery stats.
|
// This needs to be done after sendIntent() so that we get the lastest battery stats.
|
||||||
if (logOutlier && dischargeDuration != 0) {
|
if (logOutlier && dischargeDuration != 0) {
|
||||||
logOutlier(dischargeDuration);
|
logOutlier(dischargeDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastBatteryStatus = mBatteryStatus;
|
mLastBatteryStatus = mBatteryStatus;
|
||||||
mLastBatteryHealth = mBatteryHealth;
|
mLastBatteryHealth = mBatteryHealth;
|
||||||
mLastBatteryPresent = mBatteryPresent;
|
mLastBatteryPresent = mBatteryPresent;
|
||||||
@ -337,7 +333,7 @@ class BatteryService extends Binder {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// Should never happen.
|
// Should never happen.
|
||||||
}
|
}
|
||||||
|
|
||||||
int icon = getIcon(mBatteryLevel);
|
int icon = getIcon(mBatteryLevel);
|
||||||
|
|
||||||
intent.putExtra(BatteryManager.EXTRA_STATUS, mBatteryStatus);
|
intent.putExtra(BatteryManager.EXTRA_STATUS, mBatteryStatus);
|
||||||
@ -353,8 +349,8 @@ class BatteryService extends Binder {
|
|||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
Log.d(TAG, "updateBattery level:" + mBatteryLevel +
|
Log.d(TAG, "updateBattery level:" + mBatteryLevel +
|
||||||
" scale:" + BATTERY_SCALE + " status:" + mBatteryStatus +
|
" scale:" + BATTERY_SCALE + " status:" + mBatteryStatus +
|
||||||
" health:" + mBatteryHealth + " present:" + mBatteryPresent +
|
" health:" + mBatteryHealth + " present:" + mBatteryPresent +
|
||||||
" voltage: " + mBatteryVoltage +
|
" voltage: " + mBatteryVoltage +
|
||||||
" temperature: " + mBatteryTemperature +
|
" temperature: " + mBatteryTemperature +
|
||||||
" technology: " + mBatteryTechnology +
|
" technology: " + mBatteryTechnology +
|
||||||
@ -366,7 +362,7 @@ class BatteryService extends Binder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final void logBatteryStats() {
|
private final void logBatteryStats() {
|
||||||
|
|
||||||
IBinder batteryInfoService = ServiceManager.getService(BATTERY_STATS_SERVICE_NAME);
|
IBinder batteryInfoService = ServiceManager.getService(BATTERY_STATS_SERVICE_NAME);
|
||||||
if (batteryInfoService != null) {
|
if (batteryInfoService != null) {
|
||||||
byte[] buffer = new byte[DUMP_MAX_LENGTH];
|
byte[] buffer = new byte[DUMP_MAX_LENGTH];
|
||||||
@ -385,15 +381,15 @@ class BatteryService extends Binder {
|
|||||||
FileInputStream fileInputStream = new FileInputStream(dumpFile);
|
FileInputStream fileInputStream = new FileInputStream(dumpFile);
|
||||||
int nread = fileInputStream.read(buffer, 0, length);
|
int nread = fileInputStream.read(buffer, 0, length);
|
||||||
if (nread > 0) {
|
if (nread > 0) {
|
||||||
Checkin.logEvent(mContext.getContentResolver(),
|
Checkin.logEvent(mContext.getContentResolver(),
|
||||||
Checkin.Events.Tag.BATTERY_DISCHARGE_INFO,
|
Checkin.Events.Tag.BATTERY_DISCHARGE_INFO,
|
||||||
new String(buffer, 0, nread));
|
new String(buffer, 0, nread));
|
||||||
if (LOCAL_LOGV) Log.v(TAG, "dumped " + nread + "b from " +
|
if (LOCAL_LOGV) Log.v(TAG, "dumped " + nread + "b from " +
|
||||||
batteryInfoService + "to log");
|
batteryInfoService + "to log");
|
||||||
if (LOCAL_LOGV) Log.v(TAG, "actual dump:" + new String(buffer, 0, nread));
|
if (LOCAL_LOGV) Log.v(TAG, "actual dump:" + new String(buffer, 0, nread));
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "failed to dump service '" + BATTERY_STATS_SERVICE_NAME +
|
Log.e(TAG, "failed to dump service '" + BATTERY_STATS_SERVICE_NAME +
|
||||||
"':" + e);
|
"':" + e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "failed to write dumpsys file: " + e);
|
Log.e(TAG, "failed to write dumpsys file: " + e);
|
||||||
@ -413,29 +409,29 @@ class BatteryService extends Binder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void logOutlier(long duration) {
|
private final void logOutlier(long duration) {
|
||||||
ContentResolver cr = mContext.getContentResolver();
|
ContentResolver cr = mContext.getContentResolver();
|
||||||
String dischargeThresholdString = Settings.Gservices.getString(cr,
|
String dischargeThresholdString = Settings.Gservices.getString(cr,
|
||||||
Settings.Gservices.BATTERY_DISCHARGE_THRESHOLD);
|
Settings.Gservices.BATTERY_DISCHARGE_THRESHOLD);
|
||||||
String durationThresholdString = Settings.Gservices.getString(cr,
|
String durationThresholdString = Settings.Gservices.getString(cr,
|
||||||
Settings.Gservices.BATTERY_DISCHARGE_DURATION_THRESHOLD);
|
Settings.Gservices.BATTERY_DISCHARGE_DURATION_THRESHOLD);
|
||||||
|
|
||||||
if (dischargeThresholdString != null && durationThresholdString != null) {
|
if (dischargeThresholdString != null && durationThresholdString != null) {
|
||||||
try {
|
try {
|
||||||
long durationThreshold = Long.parseLong(durationThresholdString);
|
long durationThreshold = Long.parseLong(durationThresholdString);
|
||||||
int dischargeThreshold = Integer.parseInt(dischargeThresholdString);
|
int dischargeThreshold = Integer.parseInt(dischargeThresholdString);
|
||||||
if (duration <= durationThreshold &&
|
if (duration <= durationThreshold &&
|
||||||
mDischargeStartLevel - mBatteryLevel >= dischargeThreshold) {
|
mDischargeStartLevel - mBatteryLevel >= dischargeThreshold) {
|
||||||
// If the discharge cycle is bad enough we want to know about it.
|
// If the discharge cycle is bad enough we want to know about it.
|
||||||
logBatteryStats();
|
logBatteryStats();
|
||||||
}
|
}
|
||||||
if (LOCAL_LOGV) Log.v(TAG, "duration threshold: " + durationThreshold +
|
if (LOCAL_LOGV) Log.v(TAG, "duration threshold: " + durationThreshold +
|
||||||
" discharge threshold: " + dischargeThreshold);
|
" discharge threshold: " + dischargeThreshold);
|
||||||
if (LOCAL_LOGV) Log.v(TAG, "duration: " + duration + " discharge: " +
|
if (LOCAL_LOGV) Log.v(TAG, "duration: " + duration + " discharge: " +
|
||||||
(mDischargeStartLevel - mBatteryLevel));
|
(mDischargeStartLevel - mBatteryLevel));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, "Invalid DischargeThresholds GService string: " +
|
Log.e(TAG, "Invalid DischargeThresholds GService string: " +
|
||||||
durationThresholdString + " or " + dischargeThresholdString);
|
durationThresholdString + " or " + dischargeThresholdString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -458,7 +454,7 @@ class BatteryService extends Binder {
|
|||||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
||||||
pw.println("Permission Denial: can't dump Battery service from from pid="
|
pw.println("Permission Denial: can't dump Battery service from from pid="
|
||||||
+ Binder.getCallingPid()
|
+ Binder.getCallingPid()
|
||||||
+ ", uid=" + Binder.getCallingUid());
|
+ ", uid=" + Binder.getCallingUid());
|
||||||
|
@ -56,9 +56,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
private static final boolean DBG = true;
|
private static final boolean DBG = true;
|
||||||
private static final String TAG = "ConnectivityService";
|
private static final String TAG = "ConnectivityService";
|
||||||
|
|
||||||
// Event log tags (must be in sync with event-log-tags)
|
|
||||||
private static final int EVENTLOG_CONNECTIVITY_STATE_CHANGED = 50020;
|
|
||||||
|
|
||||||
// how long to wait before switching back to a radio's default network
|
// how long to wait before switching back to a radio's default network
|
||||||
private static final int RESTORE_DEFAULT_NETWORK_DELAY = 1 * 60 * 1000;
|
private static final int RESTORE_DEFAULT_NETWORK_DELAY = 1 * 60 * 1000;
|
||||||
// system property that can override the above value
|
// system property that can override the above value
|
||||||
@ -1230,7 +1227,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
int eventLogParam = (info.getType() & 0x7) |
|
int eventLogParam = (info.getType() & 0x7) |
|
||||||
((info.getDetailedState().ordinal() & 0x3f) << 3) |
|
((info.getDetailedState().ordinal() & 0x3f) << 3) |
|
||||||
(info.getSubtype() << 9);
|
(info.getSubtype() << 9);
|
||||||
EventLog.writeEvent(EVENTLOG_CONNECTIVITY_STATE_CHANGED,
|
EventLog.writeEvent(EventLogTags.CONNECTIVITY_STATE_CHANGED,
|
||||||
eventLogParam);
|
eventLogParam);
|
||||||
|
|
||||||
if (info.getDetailedState() ==
|
if (info.getDetailedState() ==
|
||||||
|
@ -63,9 +63,6 @@ class DeviceStorageMonitorService extends Binder {
|
|||||||
private static final int LOW_MEMORY_NOTIFICATION_ID = 1;
|
private static final int LOW_MEMORY_NOTIFICATION_ID = 1;
|
||||||
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
|
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
|
||||||
private static final int DEFAULT_FREE_STORAGE_LOG_INTERVAL_IN_MINUTES = 12*60; //in minutes
|
private static final int DEFAULT_FREE_STORAGE_LOG_INTERVAL_IN_MINUTES = 12*60; //in minutes
|
||||||
private static final int EVENT_LOG_STORAGE_BELOW_THRESHOLD = 2744;
|
|
||||||
private static final int EVENT_LOG_LOW_STORAGE_NOTIFICATION = 2745;
|
|
||||||
private static final int EVENT_LOG_FREE_STORAGE_LEFT = 2746;
|
|
||||||
private static final long DEFAULT_DISK_FREE_CHANGE_REPORTING_THRESHOLD = 2 * 1024 * 1024; // 2MB
|
private static final long DEFAULT_DISK_FREE_CHANGE_REPORTING_THRESHOLD = 2 * 1024 * 1024; // 2MB
|
||||||
private static final long DEFAULT_CHECK_INTERVAL = MONITOR_INTERVAL*60*1000;
|
private static final long DEFAULT_CHECK_INTERVAL = MONITOR_INTERVAL*60*1000;
|
||||||
private long mFreeMem; // on /data
|
private long mFreeMem; // on /data
|
||||||
@ -159,7 +156,7 @@ class DeviceStorageMonitorService extends Binder {
|
|||||||
// ignore; report -1
|
// ignore; report -1
|
||||||
}
|
}
|
||||||
mCacheFileStats.restat(CACHE_PATH);
|
mCacheFileStats.restat(CACHE_PATH);
|
||||||
EventLog.writeEvent(EVENT_LOG_FREE_STORAGE_LEFT,
|
EventLog.writeEvent(EventLogTags.FREE_STORAGE_LEFT,
|
||||||
mFreeMem, mFreeSystem, mFreeCache);
|
mFreeMem, mFreeSystem, mFreeCache);
|
||||||
}
|
}
|
||||||
// Read the reporting threshold from Gservices
|
// Read the reporting threshold from Gservices
|
||||||
@ -170,7 +167,7 @@ class DeviceStorageMonitorService extends Binder {
|
|||||||
long delta = mFreeMem - mLastReportedFreeMem;
|
long delta = mFreeMem - mLastReportedFreeMem;
|
||||||
if (delta > threshold || delta < -threshold) {
|
if (delta > threshold || delta < -threshold) {
|
||||||
mLastReportedFreeMem = mFreeMem;
|
mLastReportedFreeMem = mFreeMem;
|
||||||
EventLog.writeEvent(EVENT_LOG_STORAGE_BELOW_THRESHOLD, mFreeMem);
|
EventLog.writeEvent(EventLogTags.FREE_STORAGE_CHANGED, mFreeMem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +289,7 @@ class DeviceStorageMonitorService extends Binder {
|
|||||||
private final void sendNotification() {
|
private final void sendNotification() {
|
||||||
if(localLOGV) Log.i(TAG, "Sending low memory notification");
|
if(localLOGV) Log.i(TAG, "Sending low memory notification");
|
||||||
//log the event to event log with the amount of free storage(in bytes) left on the device
|
//log the event to event log with the amount of free storage(in bytes) left on the device
|
||||||
EventLog.writeEvent(EVENT_LOG_LOW_STORAGE_NOTIFICATION, mFreeMem);
|
EventLog.writeEvent(EventLogTags.LOW_STORAGE, mFreeMem);
|
||||||
// Pack up the values and broadcast them to everyone
|
// Pack up the values and broadcast them to everyone
|
||||||
Intent lowMemIntent = new Intent(Intent.ACTION_MANAGE_PACKAGE_STORAGE);
|
Intent lowMemIntent = new Intent(Intent.ACTION_MANAGE_PACKAGE_STORAGE);
|
||||||
lowMemIntent.putExtra("memory", mFreeMem);
|
lowMemIntent.putExtra("memory", mFreeMem);
|
||||||
|
139
services/java/com/android/server/EventLogTags.logtags
Normal file
139
services/java/com/android/server/EventLogTags.logtags
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
# See system/core/logcat/event.logtags for a description of the format of this file.
|
||||||
|
|
||||||
|
option java_package com.android.server
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# BatteryService.java
|
||||||
|
# ---------------------------
|
||||||
|
2722 battery_level (level|1|6),(voltage|1|1),(temperature|1|1)
|
||||||
|
2723 battery_status (status|1|5),(health|1|5),(present|1|5),(plugged|1|5),(technology|3)
|
||||||
|
# This is logged when battery goes from discharging to charging.
|
||||||
|
# It lets us count the total amount of time between charges and the discharge level
|
||||||
|
2730 battery_discharge (duration|2|3),(minLevel|1|6),(maxLevel|1|6)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# PowerManagerService.java
|
||||||
|
# ---------------------------
|
||||||
|
# This is logged when the device is being forced to sleep (typically by
|
||||||
|
# the user pressing the power button).
|
||||||
|
2724 power_sleep_requested (wakeLocksCleared|1|1)
|
||||||
|
# This is logged when the screen on broadcast has completed
|
||||||
|
2725 power_screen_broadcast_send (wakelockCount|1|1)
|
||||||
|
# This is logged when the screen broadcast has completed
|
||||||
|
2726 power_screen_broadcast_done (on|1|5),(broadcastDuration|2|3),(wakelockCount|1|1)
|
||||||
|
# This is logged when the screen on broadcast has completed
|
||||||
|
2727 power_screen_broadcast_stop (which|1|5),(wakelockCount|1|1)
|
||||||
|
# This is logged when the screen is turned on or off.
|
||||||
|
2728 power_screen_state (offOrOn|1|5),(becauseOfUser|1|5),(totalTouchDownTime|2|3),(touchCycles|1|1)
|
||||||
|
# This is logged when the partial wake lock (keeping the device awake
|
||||||
|
# regardless of whether the screen is off) is acquired or released.
|
||||||
|
2729 power_partial_wake_state (releasedorAcquired|1|5),(tag|3)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Leave IDs through 2739 for more power logs (2730 used by battery_discharge above)
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# DeviceStorageMonitoryService.java
|
||||||
|
# ---------------------------
|
||||||
|
# The disk space free on the /data partition, in bytes
|
||||||
|
2744 free_storage_changed (data|2|2)
|
||||||
|
# Device low memory notification and disk space free on the /data partition, in bytes at that time
|
||||||
|
2745 low_storage (data|2|2)
|
||||||
|
# disk space free on the /data, /system, and /cache partitions in bytes
|
||||||
|
2746 free_storage_left (data|2|2),(system|2|2),(cache|2|2)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# NotificationManagerService.java
|
||||||
|
# ---------------------------
|
||||||
|
# when a NotificationManager.notify is called
|
||||||
|
2750 notification_enqueue (pkg|3),(id|1|5),(notification|3)
|
||||||
|
# when someone tries to cancel a notification, the notification manager sometimes
|
||||||
|
# calls this with flags too
|
||||||
|
2751 notification_cancel (pkg|3),(id|1|5),(required_flags|1)
|
||||||
|
# when someone tries to cancel all of the notifications for a particular package
|
||||||
|
2752 notification_cancel_all (pkg|3),(required_flags|1)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# Watchdog.java
|
||||||
|
# ---------------------------
|
||||||
|
2802 watchdog (Service|3)
|
||||||
|
2803 watchdog_proc_pss (Process|3),(Pid|1|5),(Pss|1|2)
|
||||||
|
2804 watchdog_soft_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2),(Skip|3)
|
||||||
|
2805 watchdog_hard_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2)
|
||||||
|
2806 watchdog_pss_stats (EmptyPss|1|2),(EmptyCount|1|1),(BackgroundPss|1|2),(BackgroundCount|1|1),(ServicePss|1|2),(ServiceCount|1|1),(VisiblePss|1|2),(VisibleCount|1|1),(ForegroundPss|1|2),(ForegroundCount|1|1),(NoPssCount|1|1)
|
||||||
|
2807 watchdog_proc_stats (DeathsInOne|1|1),(DeathsInTwo|1|1),(DeathsInThree|1|1),(DeathsInFour|1|1),(DeathsInFive|1|1)
|
||||||
|
2808 watchdog_scheduled_reboot (Now|2|1),(Interval|1|3),(StartTime|1|3),(Window|1|3),(Skip|3)
|
||||||
|
2809 watchdog_meminfo (MemFree|1|2),(Buffers|1|2),(Cached|1|2),(Active|1|2),(Inactive|1|2),(AnonPages|1|2),(Mapped|1|2),(Slab|1|2),(SReclaimable|1|2),(SUnreclaim|1|2),(PageTables|1|2)
|
||||||
|
2810 watchdog_vmstat (runtime|2|3),(pgfree|1|1),(pgactivate|1|1),(pgdeactivate|1|1),(pgfault|1|1),(pgmajfault|1|1)
|
||||||
|
2811 watchdog_requested_reboot (NoWait|1|1),(ScheduleInterval|1|3),(RecheckInterval|1|3),(StartTime|1|3),(Window|1|3),(MinScreenOff|1|3),(MinNextAlarm|1|3)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# BackupManagerService.java
|
||||||
|
# ---------------------------
|
||||||
|
2820 backup_data_changed (Package|3)
|
||||||
|
2821 backup_start (Transport|3)
|
||||||
|
2822 backup_transport_failure (Package|3)
|
||||||
|
2823 backup_agent_failure (Package|3),(Message|3)
|
||||||
|
2824 backup_package (Package|3),(Size|1|2)
|
||||||
|
2825 backup_success (Packages|1|1),(Time|1|3)
|
||||||
|
2826 backup_reset (Transport|3)
|
||||||
|
2827 backup_initialize
|
||||||
|
2830 restore_start (Transport|3),(Source|2|5)
|
||||||
|
2831 restore_transport_failure
|
||||||
|
2832 restore_agent_failure (Package|3),(Message|3)
|
||||||
|
2833 restore_package (Package|3),(Size|1|2)
|
||||||
|
2834 restore_success (Packages|1|1),(Time|1|3)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# SystemServer.java
|
||||||
|
# ---------------------------
|
||||||
|
# SystemServer.run() starts:
|
||||||
|
3010 boot_progress_system_run (time|2|3)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# PackageManagerService.java
|
||||||
|
# ---------------------------
|
||||||
|
# Package Manager starts:
|
||||||
|
3060 boot_progress_pms_start (time|2|3)
|
||||||
|
# Package Manager .apk scan starts:
|
||||||
|
3070 boot_progress_pms_system_scan_start (time|2|3)
|
||||||
|
# Package Manager .apk scan starts:
|
||||||
|
3080 boot_progress_pms_data_scan_start (time|2|3)
|
||||||
|
# Package Manager .apk scan ends:
|
||||||
|
3090 boot_progress_pms_scan_end (time|2|3)
|
||||||
|
# Package Manager ready:
|
||||||
|
3100 boot_progress_pms_ready (time|2|3)
|
||||||
|
# + check activity_launch_time for Home app
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# WindowManagerService.java
|
||||||
|
# ---------------------------
|
||||||
|
# Out of memory for surfaces.
|
||||||
|
31000 wm_no_surface_memory (Window|3),(PID|1|5),(Operation|3)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# InputMethodManagerService.java
|
||||||
|
# ---------------------------
|
||||||
|
# Re-connecting to input method service because we haven't received its interface
|
||||||
|
32000 imf_force_reconnect_ime (IME|4),(Time Since Connect|2|3),(Showing|1|1)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# ConnectivityService.java
|
||||||
|
# ---------------------------
|
||||||
|
# Connectivity state changed:
|
||||||
|
# [31-13] Reserved for future use
|
||||||
|
# [12- 9] Network subtype (for mobile network, as defined by TelephonyManager)
|
||||||
|
# [ 8- 3] Detailed state ordinal (as defined by NetworkInfo.DetailedState)
|
||||||
|
# [ 2- 0] Network type (as defined by ConnectivityManager)
|
||||||
|
50020 connectivity_state_changed (custom|1|5)
|
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2008 The Android Open Source Project
|
* Copyright (C) 2006-2008 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* 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
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
* the License at
|
* the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
@ -89,24 +89,22 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
static final String TAG = "InputManagerService";
|
static final String TAG = "InputManagerService";
|
||||||
|
|
||||||
static final int MSG_SHOW_IM_PICKER = 1;
|
static final int MSG_SHOW_IM_PICKER = 1;
|
||||||
|
|
||||||
static final int MSG_UNBIND_INPUT = 1000;
|
static final int MSG_UNBIND_INPUT = 1000;
|
||||||
static final int MSG_BIND_INPUT = 1010;
|
static final int MSG_BIND_INPUT = 1010;
|
||||||
static final int MSG_SHOW_SOFT_INPUT = 1020;
|
static final int MSG_SHOW_SOFT_INPUT = 1020;
|
||||||
static final int MSG_HIDE_SOFT_INPUT = 1030;
|
static final int MSG_HIDE_SOFT_INPUT = 1030;
|
||||||
static final int MSG_ATTACH_TOKEN = 1040;
|
static final int MSG_ATTACH_TOKEN = 1040;
|
||||||
static final int MSG_CREATE_SESSION = 1050;
|
static final int MSG_CREATE_SESSION = 1050;
|
||||||
|
|
||||||
static final int MSG_START_INPUT = 2000;
|
static final int MSG_START_INPUT = 2000;
|
||||||
static final int MSG_RESTART_INPUT = 2010;
|
static final int MSG_RESTART_INPUT = 2010;
|
||||||
|
|
||||||
static final int MSG_UNBIND_METHOD = 3000;
|
static final int MSG_UNBIND_METHOD = 3000;
|
||||||
static final int MSG_BIND_METHOD = 3010;
|
static final int MSG_BIND_METHOD = 3010;
|
||||||
|
|
||||||
static final long TIME_TO_RECONNECT = 10*1000;
|
static final long TIME_TO_RECONNECT = 10*1000;
|
||||||
|
|
||||||
static final int LOG_IMF_FORCE_RECONNECT_IME = 32000;
|
|
||||||
|
|
||||||
final Context mContext;
|
final Context mContext;
|
||||||
final Handler mHandler;
|
final Handler mHandler;
|
||||||
final SettingsObserver mSettingsObserver;
|
final SettingsObserver mSettingsObserver;
|
||||||
@ -115,9 +113,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
final IconData mInputMethodData;
|
final IconData mInputMethodData;
|
||||||
final IWindowManager mIWindowManager;
|
final IWindowManager mIWindowManager;
|
||||||
final HandlerCaller mCaller;
|
final HandlerCaller mCaller;
|
||||||
|
|
||||||
final InputBindResult mNoBinding = new InputBindResult(null, null, -1);
|
final InputBindResult mNoBinding = new InputBindResult(null, null, -1);
|
||||||
|
|
||||||
// All known input methods. mMethodMap also serves as the global
|
// All known input methods. mMethodMap also serves as the global
|
||||||
// lock for this class.
|
// lock for this class.
|
||||||
final ArrayList<InputMethodInfo> mMethodList
|
final ArrayList<InputMethodInfo> mMethodList
|
||||||
@ -127,12 +125,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
|
|
||||||
final TextUtils.SimpleStringSplitter mStringColonSplitter
|
final TextUtils.SimpleStringSplitter mStringColonSplitter
|
||||||
= new TextUtils.SimpleStringSplitter(':');
|
= new TextUtils.SimpleStringSplitter(':');
|
||||||
|
|
||||||
class SessionState {
|
class SessionState {
|
||||||
final ClientState client;
|
final ClientState client;
|
||||||
final IInputMethod method;
|
final IInputMethod method;
|
||||||
final IInputMethodSession session;
|
final IInputMethodSession session;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SessionState{uid " + client.uid + " pid " + client.pid
|
return "SessionState{uid " + client.uid + " pid " + client.pid
|
||||||
@ -150,17 +148,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
session = _session;
|
session = _session;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClientState {
|
class ClientState {
|
||||||
final IInputMethodClient client;
|
final IInputMethodClient client;
|
||||||
final IInputContext inputContext;
|
final IInputContext inputContext;
|
||||||
final int uid;
|
final int uid;
|
||||||
final int pid;
|
final int pid;
|
||||||
final InputBinding binding;
|
final InputBinding binding;
|
||||||
|
|
||||||
boolean sessionRequested;
|
boolean sessionRequested;
|
||||||
SessionState curSession;
|
SessionState curSession;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ClientState{" + Integer.toHexString(
|
return "ClientState{" + Integer.toHexString(
|
||||||
@ -177,122 +175,122 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
binding = new InputBinding(null, inputContext.asBinder(), uid, pid);
|
binding = new InputBinding(null, inputContext.asBinder(), uid, pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashMap<IBinder, ClientState> mClients
|
final HashMap<IBinder, ClientState> mClients
|
||||||
= new HashMap<IBinder, ClientState>();
|
= new HashMap<IBinder, ClientState>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set once the system is ready to run third party code.
|
* Set once the system is ready to run third party code.
|
||||||
*/
|
*/
|
||||||
boolean mSystemReady;
|
boolean mSystemReady;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id of the currently selected input method.
|
* Id of the currently selected input method.
|
||||||
*/
|
*/
|
||||||
String mCurMethodId;
|
String mCurMethodId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current binding sequence number, incremented every time there is
|
* The current binding sequence number, incremented every time there is
|
||||||
* a new bind performed.
|
* a new bind performed.
|
||||||
*/
|
*/
|
||||||
int mCurSeq;
|
int mCurSeq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client that is currently bound to an input method.
|
* The client that is currently bound to an input method.
|
||||||
*/
|
*/
|
||||||
ClientState mCurClient;
|
ClientState mCurClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last window token that gained focus.
|
* The last window token that gained focus.
|
||||||
*/
|
*/
|
||||||
IBinder mCurFocusedWindow;
|
IBinder mCurFocusedWindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The input context last provided by the current client.
|
* The input context last provided by the current client.
|
||||||
*/
|
*/
|
||||||
IInputContext mCurInputContext;
|
IInputContext mCurInputContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes last provided by the current client.
|
* The attributes last provided by the current client.
|
||||||
*/
|
*/
|
||||||
EditorInfo mCurAttribute;
|
EditorInfo mCurAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The input method ID of the input method service that we are currently
|
* The input method ID of the input method service that we are currently
|
||||||
* connected to or in the process of connecting to.
|
* connected to or in the process of connecting to.
|
||||||
*/
|
*/
|
||||||
String mCurId;
|
String mCurId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true if our ServiceConnection is currently actively bound to
|
* Set to true if our ServiceConnection is currently actively bound to
|
||||||
* a service (whether or not we have gotten its IBinder back yet).
|
* a service (whether or not we have gotten its IBinder back yet).
|
||||||
*/
|
*/
|
||||||
boolean mHaveConnection;
|
boolean mHaveConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the client has asked for the input method to be shown.
|
* Set if the client has asked for the input method to be shown.
|
||||||
*/
|
*/
|
||||||
boolean mShowRequested;
|
boolean mShowRequested;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if we were explicitly told to show the input method.
|
* Set if we were explicitly told to show the input method.
|
||||||
*/
|
*/
|
||||||
boolean mShowExplicitlyRequested;
|
boolean mShowExplicitlyRequested;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if we were forced to be shown.
|
* Set if we were forced to be shown.
|
||||||
*/
|
*/
|
||||||
boolean mShowForced;
|
boolean mShowForced;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if we last told the input method to show itself.
|
* Set if we last told the input method to show itself.
|
||||||
*/
|
*/
|
||||||
boolean mInputShown;
|
boolean mInputShown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Intent used to connect to the current input method.
|
* The Intent used to connect to the current input method.
|
||||||
*/
|
*/
|
||||||
Intent mCurIntent;
|
Intent mCurIntent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The token we have made for the currently active input method, to
|
* The token we have made for the currently active input method, to
|
||||||
* identify it in the future.
|
* identify it in the future.
|
||||||
*/
|
*/
|
||||||
IBinder mCurToken;
|
IBinder mCurToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If non-null, this is the input method service we are currently connected
|
* If non-null, this is the input method service we are currently connected
|
||||||
* to.
|
* to.
|
||||||
*/
|
*/
|
||||||
IInputMethod mCurMethod;
|
IInputMethod mCurMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time that we last initiated a bind to the input method, to determine
|
* Time that we last initiated a bind to the input method, to determine
|
||||||
* if we should try to disconnect and reconnect to it.
|
* if we should try to disconnect and reconnect to it.
|
||||||
*/
|
*/
|
||||||
long mLastBindTime;
|
long mLastBindTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Have we called mCurMethod.bindInput()?
|
* Have we called mCurMethod.bindInput()?
|
||||||
*/
|
*/
|
||||||
boolean mBoundToMethod;
|
boolean mBoundToMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently enabled session. Only touched by service thread, not
|
* Currently enabled session. Only touched by service thread, not
|
||||||
* protected by a lock.
|
* protected by a lock.
|
||||||
*/
|
*/
|
||||||
SessionState mEnabledSession;
|
SessionState mEnabledSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the screen is on. The value is true initially.
|
* True if the screen is on. The value is true initially.
|
||||||
*/
|
*/
|
||||||
boolean mScreenOn = true;
|
boolean mScreenOn = true;
|
||||||
|
|
||||||
AlertDialog.Builder mDialogBuilder;
|
AlertDialog.Builder mDialogBuilder;
|
||||||
AlertDialog mSwitchingDialog;
|
AlertDialog mSwitchingDialog;
|
||||||
InputMethodInfo[] mIms;
|
InputMethodInfo[] mIms;
|
||||||
CharSequence[] mItems;
|
CharSequence[] mItems;
|
||||||
|
|
||||||
class SettingsObserver extends ContentObserver {
|
class SettingsObserver extends ContentObserver {
|
||||||
SettingsObserver(Handler handler) {
|
SettingsObserver(Handler handler) {
|
||||||
super(handler);
|
super(handler);
|
||||||
@ -300,14 +298,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||||
Settings.Secure.DEFAULT_INPUT_METHOD), false, this);
|
Settings.Secure.DEFAULT_INPUT_METHOD), false, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onChange(boolean selfChange) {
|
@Override public void onChange(boolean selfChange) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
updateFromSettingsLocked();
|
updateFromSettingsLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScreenOnOffReceiver extends android.content.BroadcastReceiver {
|
class ScreenOnOffReceiver extends android.content.BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@ -333,13 +331,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PackageReceiver extends android.content.BroadcastReceiver {
|
class PackageReceiver extends android.content.BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
buildInputMethodListLocked(mMethodList, mMethodMap);
|
buildInputMethodListLocked(mMethodList, mMethodMap);
|
||||||
|
|
||||||
InputMethodInfo curIm = null;
|
InputMethodInfo curIm = null;
|
||||||
String curInputMethodId = Settings.Secure.getString(context
|
String curInputMethodId = Settings.Secure.getString(context
|
||||||
.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
@ -351,9 +349,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
String pkg = uri != null ? uri.getSchemeSpecificPart() : null;
|
String pkg = uri != null ? uri.getSchemeSpecificPart() : null;
|
||||||
if (curIm != null && curIm.getPackageName().equals(pkg)) {
|
if (curIm != null && curIm.getPackageName().equals(pkg)) {
|
||||||
@ -377,27 +375,27 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
curInputMethodId);
|
curInputMethodId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (curIm == null) {
|
} else if (curIm == null) {
|
||||||
// We currently don't have a default input method... is
|
// We currently don't have a default input method... is
|
||||||
// one now available?
|
// one now available?
|
||||||
changed = chooseNewDefaultIME();
|
changed = chooseNewDefaultIME();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
updateFromSettingsLocked();
|
updateFromSettingsLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MethodCallback extends IInputMethodCallback.Stub {
|
class MethodCallback extends IInputMethodCallback.Stub {
|
||||||
final IInputMethod mMethod;
|
final IInputMethod mMethod;
|
||||||
|
|
||||||
MethodCallback(IInputMethod method) {
|
MethodCallback(IInputMethod method) {
|
||||||
mMethod = method;
|
mMethod = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishedEvent(int seq, boolean handled) throws RemoteException {
|
public void finishedEvent(int seq, boolean handled) throws RemoteException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,7 +403,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
onSessionCreated(mMethod, session);
|
onSessionCreated(mMethod, session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputMethodManagerService(Context context, StatusBarService statusBar) {
|
public InputMethodManagerService(Context context, StatusBarService statusBar) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mHandler = new Handler(this);
|
mHandler = new Handler(this);
|
||||||
@ -416,7 +414,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
handleMessage(msg);
|
handleMessage(msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
IntentFilter packageFilt = new IntentFilter();
|
IntentFilter packageFilt = new IntentFilter();
|
||||||
packageFilt.addAction(Intent.ACTION_PACKAGE_ADDED);
|
packageFilt.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||||
packageFilt.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
packageFilt.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
||||||
@ -424,13 +422,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
packageFilt.addAction(Intent.ACTION_PACKAGE_RESTARTED);
|
packageFilt.addAction(Intent.ACTION_PACKAGE_RESTARTED);
|
||||||
packageFilt.addDataScheme("package");
|
packageFilt.addDataScheme("package");
|
||||||
mContext.registerReceiver(new PackageReceiver(), packageFilt);
|
mContext.registerReceiver(new PackageReceiver(), packageFilt);
|
||||||
|
|
||||||
IntentFilter screenOnOffFilt = new IntentFilter();
|
IntentFilter screenOnOffFilt = new IntentFilter();
|
||||||
screenOnOffFilt.addAction(Intent.ACTION_SCREEN_ON);
|
screenOnOffFilt.addAction(Intent.ACTION_SCREEN_ON);
|
||||||
screenOnOffFilt.addAction(Intent.ACTION_SCREEN_OFF);
|
screenOnOffFilt.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
screenOnOffFilt.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
screenOnOffFilt.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||||
mContext.registerReceiver(new ScreenOnOffReceiver(), screenOnOffFilt);
|
mContext.registerReceiver(new ScreenOnOffReceiver(), screenOnOffFilt);
|
||||||
|
|
||||||
buildInputMethodListLocked(mMethodList, mMethodMap);
|
buildInputMethodListLocked(mMethodList, mMethodMap);
|
||||||
|
|
||||||
final String enabledStr = Settings.Secure.getString(
|
final String enabledStr = Settings.Secure.getString(
|
||||||
@ -471,12 +469,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
Settings.Secure.DEFAULT_INPUT_METHOD, defIm.getId());
|
Settings.Secure.DEFAULT_INPUT_METHOD, defIm.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mStatusBar = statusBar;
|
mStatusBar = statusBar;
|
||||||
mInputMethodData = IconData.makeIcon("ime", null, 0, 0, 0);
|
mInputMethodData = IconData.makeIcon("ime", null, 0, 0, 0);
|
||||||
mInputMethodIcon = statusBar.addIcon(mInputMethodData, null);
|
mInputMethodIcon = statusBar.addIcon(mInputMethodData, null);
|
||||||
statusBar.setIconVisibility(mInputMethodIcon, false);
|
statusBar.setIconVisibility(mInputMethodIcon, false);
|
||||||
|
|
||||||
mSettingsObserver = new SettingsObserver(mHandler);
|
mSettingsObserver = new SettingsObserver(mHandler);
|
||||||
updateFromSettingsLocked();
|
updateFromSettingsLocked();
|
||||||
}
|
}
|
||||||
@ -508,7 +506,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InputMethodInfo> getInputMethodList() {
|
public List<InputMethodInfo> getInputMethodList() {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
return new ArrayList<InputMethodInfo>(mMethodList);
|
return new ArrayList<InputMethodInfo>(mMethodList);
|
||||||
@ -523,14 +521,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
|
|
||||||
List<InputMethodInfo> getEnabledInputMethodListLocked() {
|
List<InputMethodInfo> getEnabledInputMethodListLocked() {
|
||||||
final ArrayList<InputMethodInfo> res = new ArrayList<InputMethodInfo>();
|
final ArrayList<InputMethodInfo> res = new ArrayList<InputMethodInfo>();
|
||||||
|
|
||||||
final String enabledStr = Settings.Secure.getString(
|
final String enabledStr = Settings.Secure.getString(
|
||||||
mContext.getContentResolver(),
|
mContext.getContentResolver(),
|
||||||
Settings.Secure.ENABLED_INPUT_METHODS);
|
Settings.Secure.ENABLED_INPUT_METHODS);
|
||||||
if (enabledStr != null) {
|
if (enabledStr != null) {
|
||||||
final TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
|
final TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
|
||||||
splitter.setString(enabledStr);
|
splitter.setString(enabledStr);
|
||||||
|
|
||||||
while (splitter.hasNext()) {
|
while (splitter.hasNext()) {
|
||||||
InputMethodInfo info = mMethodMap.get(splitter.next());
|
InputMethodInfo info = mMethodMap.get(splitter.next());
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
@ -538,7 +536,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,13 +547,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
inputContext, uid, pid));
|
inputContext, uid, pid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeClient(IInputMethodClient client) {
|
public void removeClient(IInputMethodClient client) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
mClients.remove(client.asBinder());
|
mClients.remove(client.asBinder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void executeOrSendMessage(IInterface target, Message msg) {
|
void executeOrSendMessage(IInterface target, Message msg) {
|
||||||
if (target.asBinder() instanceof Binder) {
|
if (target.asBinder() instanceof Binder) {
|
||||||
mCaller.sendMessage(msg);
|
mCaller.sendMessage(msg);
|
||||||
@ -564,7 +562,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
msg.recycle();
|
msg.recycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unbindCurrentClientLocked() {
|
void unbindCurrentClientLocked() {
|
||||||
if (mCurClient != null) {
|
if (mCurClient != null) {
|
||||||
if (DEBUG) Log.v(TAG, "unbindCurrentInputLocked: client = "
|
if (DEBUG) Log.v(TAG, "unbindCurrentInputLocked: client = "
|
||||||
@ -579,7 +577,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
|
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
|
||||||
MSG_UNBIND_METHOD, mCurSeq, mCurClient.client));
|
MSG_UNBIND_METHOD, mCurSeq, mCurClient.client));
|
||||||
mCurClient.sessionRequested = false;
|
mCurClient.sessionRequested = false;
|
||||||
|
|
||||||
// Call setActive(false) on the old client
|
// Call setActive(false) on the old client
|
||||||
try {
|
try {
|
||||||
mCurClient.client.setActive(false);
|
mCurClient.client.setActive(false);
|
||||||
@ -588,11 +586,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
+ mCurClient.pid + " uid " + mCurClient.uid);
|
+ mCurClient.pid + " uid " + mCurClient.uid);
|
||||||
}
|
}
|
||||||
mCurClient = null;
|
mCurClient = null;
|
||||||
|
|
||||||
hideInputMethodMenuLocked();
|
hideInputMethodMenuLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getImeShowFlags() {
|
private int getImeShowFlags() {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (mShowForced) {
|
if (mShowForced) {
|
||||||
@ -603,7 +601,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getAppShowFlags() {
|
private int getAppShowFlags() {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (mShowForced) {
|
if (mShowForced) {
|
||||||
@ -613,7 +611,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputBindResult attachNewInputLocked(boolean initial, boolean needResult) {
|
InputBindResult attachNewInputLocked(boolean initial, boolean needResult) {
|
||||||
if (!mBoundToMethod) {
|
if (!mBoundToMethod) {
|
||||||
executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO(
|
executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO(
|
||||||
@ -636,7 +634,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
? new InputBindResult(session.session, mCurId, mCurSeq)
|
? new InputBindResult(session.session, mCurId, mCurSeq)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputBindResult startInputLocked(IInputMethodClient client,
|
InputBindResult startInputLocked(IInputMethodClient client,
|
||||||
IInputContext inputContext, EditorInfo attribute,
|
IInputContext inputContext, EditorInfo attribute,
|
||||||
boolean initial, boolean needResult) {
|
boolean initial, boolean needResult) {
|
||||||
@ -644,13 +642,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
if (mCurMethodId == null) {
|
if (mCurMethodId == null) {
|
||||||
return mNoBinding;
|
return mNoBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientState cs = mClients.get(client.asBinder());
|
ClientState cs = mClients.get(client.asBinder());
|
||||||
if (cs == null) {
|
if (cs == null) {
|
||||||
throw new IllegalArgumentException("unknown client "
|
throw new IllegalArgumentException("unknown client "
|
||||||
+ client.asBinder());
|
+ client.asBinder());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!mIWindowManager.inputMethodClientHasFocus(cs.client)) {
|
if (!mIWindowManager.inputMethodClientHasFocus(cs.client)) {
|
||||||
// Check with the window manager to make sure this client actually
|
// Check with the window manager to make sure this client actually
|
||||||
@ -664,7 +662,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurClient != cs) {
|
if (mCurClient != cs) {
|
||||||
// If the client is changing, we need to switch over to the new
|
// If the client is changing, we need to switch over to the new
|
||||||
// one.
|
// one.
|
||||||
@ -682,14 +680,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bump up the sequence for this client and attach it.
|
// Bump up the sequence for this client and attach it.
|
||||||
mCurSeq++;
|
mCurSeq++;
|
||||||
if (mCurSeq <= 0) mCurSeq = 1;
|
if (mCurSeq <= 0) mCurSeq = 1;
|
||||||
mCurClient = cs;
|
mCurClient = cs;
|
||||||
mCurInputContext = inputContext;
|
mCurInputContext = inputContext;
|
||||||
mCurAttribute = attribute;
|
mCurAttribute = attribute;
|
||||||
|
|
||||||
// Check if the input method is changing.
|
// Check if the input method is changing.
|
||||||
if (mCurId != null && mCurId.equals(mCurMethodId)) {
|
if (mCurId != null && mCurId.equals(mCurMethodId)) {
|
||||||
if (cs.curSession != null) {
|
if (cs.curSession != null) {
|
||||||
@ -720,33 +718,33 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
// to see if we can get back in touch with the service.
|
// to see if we can get back in touch with the service.
|
||||||
return new InputBindResult(null, mCurId, mCurSeq);
|
return new InputBindResult(null, mCurId, mCurSeq);
|
||||||
} else {
|
} else {
|
||||||
EventLog.writeEvent(LOG_IMF_FORCE_RECONNECT_IME, mCurMethodId,
|
EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME,
|
||||||
SystemClock.uptimeMillis()-mLastBindTime, 0);
|
mCurMethodId, SystemClock.uptimeMillis()-mLastBindTime, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return startInputInnerLocked();
|
return startInputInnerLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputBindResult startInputInnerLocked() {
|
InputBindResult startInputInnerLocked() {
|
||||||
if (mCurMethodId == null) {
|
if (mCurMethodId == null) {
|
||||||
return mNoBinding;
|
return mNoBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSystemReady) {
|
if (!mSystemReady) {
|
||||||
// If the system is not yet ready, we shouldn't be running third
|
// If the system is not yet ready, we shouldn't be running third
|
||||||
// party code.
|
// party code.
|
||||||
return new InputBindResult(null, mCurMethodId, mCurSeq);
|
return new InputBindResult(null, mCurMethodId, mCurSeq);
|
||||||
}
|
}
|
||||||
|
|
||||||
InputMethodInfo info = mMethodMap.get(mCurMethodId);
|
InputMethodInfo info = mMethodMap.get(mCurMethodId);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
|
throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
|
||||||
}
|
}
|
||||||
|
|
||||||
unbindCurrentMethodLocked(false);
|
unbindCurrentMethodLocked(false);
|
||||||
|
|
||||||
mCurIntent = new Intent(InputMethod.SERVICE_INTERFACE);
|
mCurIntent = new Intent(InputMethod.SERVICE_INTERFACE);
|
||||||
mCurIntent.setComponent(info.getComponent());
|
mCurIntent.setComponent(info.getComponent());
|
||||||
mCurIntent.putExtra(Intent.EXTRA_CLIENT_LABEL,
|
mCurIntent.putExtra(Intent.EXTRA_CLIENT_LABEL,
|
||||||
@ -772,7 +770,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputBindResult startInput(IInputMethodClient client,
|
public InputBindResult startInput(IInputMethodClient client,
|
||||||
IInputContext inputContext, EditorInfo attribute,
|
IInputContext inputContext, EditorInfo attribute,
|
||||||
boolean initial, boolean needResult) {
|
boolean initial, boolean needResult) {
|
||||||
@ -786,10 +784,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishInput(IInputMethodClient client) {
|
public void finishInput(IInputMethodClient client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
if (mCurIntent != null && name.equals(mCurIntent.getComponent())) {
|
if (mCurIntent != null && name.equals(mCurIntent.getComponent())) {
|
||||||
@ -830,13 +828,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unbindCurrentMethodLocked(boolean reportToClient) {
|
void unbindCurrentMethodLocked(boolean reportToClient) {
|
||||||
if (mHaveConnection) {
|
if (mHaveConnection) {
|
||||||
mContext.unbindService(this);
|
mContext.unbindService(this);
|
||||||
mHaveConnection = false;
|
mHaveConnection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurToken != null) {
|
if (mCurToken != null) {
|
||||||
try {
|
try {
|
||||||
if (DEBUG) Log.v(TAG, "Removing window token: " + mCurToken);
|
if (DEBUG) Log.v(TAG, "Removing window token: " + mCurToken);
|
||||||
@ -845,16 +843,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
mCurToken = null;
|
mCurToken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurId = null;
|
mCurId = null;
|
||||||
clearCurMethodLocked();
|
clearCurMethodLocked();
|
||||||
|
|
||||||
if (reportToClient && mCurClient != null) {
|
if (reportToClient && mCurClient != null) {
|
||||||
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
|
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
|
||||||
MSG_UNBIND_METHOD, mCurSeq, mCurClient.client));
|
MSG_UNBIND_METHOD, mCurSeq, mCurClient.client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearCurMethodLocked() {
|
void clearCurMethodLocked() {
|
||||||
if (mCurMethod != null) {
|
if (mCurMethod != null) {
|
||||||
for (ClientState cs : mClients.values()) {
|
for (ClientState cs : mClients.values()) {
|
||||||
@ -865,7 +863,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
mStatusBar.setIconVisibility(mInputMethodIcon, false);
|
mStatusBar.setIconVisibility(mInputMethodIcon, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
if (DEBUG) Log.v(TAG, "Service disconnected: " + name
|
if (DEBUG) Log.v(TAG, "Service disconnected: " + name
|
||||||
@ -893,7 +891,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
Log.w(TAG, "Ignoring setInputMethod of token: " + token);
|
Log.w(TAG, "Ignoring setInputMethod of token: " + token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
if (iconId == 0) {
|
if (iconId == 0) {
|
||||||
if (DEBUG) Log.d(TAG, "hide the small icon for the input method");
|
if (DEBUG) Log.d(TAG, "hide the small icon for the input method");
|
||||||
@ -932,17 +930,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
unbindCurrentMethodLocked(true);
|
unbindCurrentMethodLocked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInputMethodLocked(String id) {
|
void setInputMethodLocked(String id) {
|
||||||
InputMethodInfo info = mMethodMap.get(id);
|
InputMethodInfo info = mMethodMap.get(id);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
|
throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id.equals(mCurMethodId)) {
|
if (id.equals(mCurMethodId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
mCurMethodId = id;
|
mCurMethodId = id;
|
||||||
@ -959,7 +957,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showSoftInput(IInputMethodClient client, int flags,
|
public boolean showSoftInput(IInputMethodClient client, int flags,
|
||||||
ResultReceiver resultReceiver) {
|
ResultReceiver resultReceiver) {
|
||||||
long ident = Binder.clearCallingIdentity();
|
long ident = Binder.clearCallingIdentity();
|
||||||
@ -979,7 +977,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) Log.v(TAG, "Client requesting input be shown");
|
if (DEBUG) Log.v(TAG, "Client requesting input be shown");
|
||||||
return showCurrentInputLocked(flags, resultReceiver);
|
return showCurrentInputLocked(flags, resultReceiver);
|
||||||
}
|
}
|
||||||
@ -987,7 +985,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean showCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
|
boolean showCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
|
||||||
mShowRequested = true;
|
mShowRequested = true;
|
||||||
if ((flags&InputMethodManager.SHOW_IMPLICIT) == 0) {
|
if ((flags&InputMethodManager.SHOW_IMPLICIT) == 0) {
|
||||||
@ -997,11 +995,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mShowExplicitlyRequested = true;
|
mShowExplicitlyRequested = true;
|
||||||
mShowForced = true;
|
mShowForced = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSystemReady) {
|
if (!mSystemReady) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
if (mCurMethod != null) {
|
if (mCurMethod != null) {
|
||||||
executeOrSendMessage(mCurMethod, mCaller.obtainMessageIOO(
|
executeOrSendMessage(mCurMethod, mCaller.obtainMessageIOO(
|
||||||
@ -1015,15 +1013,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
// we have been sitting here too long with a connection to the
|
// we have been sitting here too long with a connection to the
|
||||||
// service and no interface received, so let's disconnect/connect
|
// service and no interface received, so let's disconnect/connect
|
||||||
// to try to prod things along.
|
// to try to prod things along.
|
||||||
EventLog.writeEvent(LOG_IMF_FORCE_RECONNECT_IME, mCurMethodId,
|
EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME, mCurMethodId,
|
||||||
SystemClock.uptimeMillis()-mLastBindTime,1);
|
SystemClock.uptimeMillis()-mLastBindTime,1);
|
||||||
mContext.unbindService(this);
|
mContext.unbindService(this);
|
||||||
mContext.bindService(mCurIntent, this, Context.BIND_AUTO_CREATE);
|
mContext.bindService(mCurIntent, this, Context.BIND_AUTO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hideSoftInput(IInputMethodClient client, int flags,
|
public boolean hideSoftInput(IInputMethodClient client, int flags,
|
||||||
ResultReceiver resultReceiver) {
|
ResultReceiver resultReceiver) {
|
||||||
long ident = Binder.clearCallingIdentity();
|
long ident = Binder.clearCallingIdentity();
|
||||||
@ -1043,7 +1041,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) Log.v(TAG, "Client requesting input be hidden");
|
if (DEBUG) Log.v(TAG, "Client requesting input be hidden");
|
||||||
return hideCurrentInputLocked(flags, resultReceiver);
|
return hideCurrentInputLocked(flags, resultReceiver);
|
||||||
}
|
}
|
||||||
@ -1051,7 +1049,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hideCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
|
boolean hideCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
|
||||||
if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0
|
if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0
|
||||||
&& (mShowExplicitlyRequested || mShowForced)) {
|
&& (mShowExplicitlyRequested || mShowForced)) {
|
||||||
@ -1078,7 +1076,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mShowForced = false;
|
mShowForced = false;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void windowGainedFocus(IInputMethodClient client, IBinder windowToken,
|
public void windowGainedFocus(IInputMethodClient client, IBinder windowToken,
|
||||||
boolean viewHasFocus, boolean isTextEditor, int softInputMode,
|
boolean viewHasFocus, boolean isTextEditor, int softInputMode,
|
||||||
boolean first, int windowFlags) {
|
boolean first, int windowFlags) {
|
||||||
@ -1091,7 +1089,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
+ " softInputMode=#" + Integer.toHexString(softInputMode)
|
+ " softInputMode=#" + Integer.toHexString(softInputMode)
|
||||||
+ " first=" + first + " flags=#"
|
+ " first=" + first + " flags=#"
|
||||||
+ Integer.toHexString(windowFlags));
|
+ Integer.toHexString(windowFlags));
|
||||||
|
|
||||||
if (mCurClient == null || client == null
|
if (mCurClient == null || client == null
|
||||||
|| mCurClient.client.asBinder() != client.asBinder()) {
|
|| mCurClient.client.asBinder() != client.asBinder()) {
|
||||||
try {
|
try {
|
||||||
@ -1105,13 +1103,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurFocusedWindow == windowToken) {
|
if (mCurFocusedWindow == windowToken) {
|
||||||
Log.w(TAG, "Window already focused, ignoring focus gain of: " + client);
|
Log.w(TAG, "Window already focused, ignoring focus gain of: " + client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCurFocusedWindow = windowToken;
|
mCurFocusedWindow = windowToken;
|
||||||
|
|
||||||
switch (softInputMode&WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE) {
|
switch (softInputMode&WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE) {
|
||||||
case WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED:
|
case WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED:
|
||||||
if (!isTextEditor || (softInputMode &
|
if (!isTextEditor || (softInputMode &
|
||||||
@ -1166,7 +1164,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showInputMethodPickerFromClient(IInputMethodClient client) {
|
public void showInputMethodPickerFromClient(IInputMethodClient client) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
if (mCurClient == null || client == null
|
if (mCurClient == null || client == null
|
||||||
@ -1216,7 +1214,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showMySoftInput(IBinder token, int flags) {
|
public void showMySoftInput(IBinder token, int flags) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
if (token == null || mCurToken != token) {
|
if (token == null || mCurToken != token) {
|
||||||
@ -1251,16 +1249,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
HandlerCaller.SomeArgs args;
|
HandlerCaller.SomeArgs args;
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_SHOW_IM_PICKER:
|
case MSG_SHOW_IM_PICKER:
|
||||||
showInputMethodMenu();
|
showInputMethodMenu();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
case MSG_UNBIND_INPUT:
|
case MSG_UNBIND_INPUT:
|
||||||
try {
|
try {
|
||||||
((IInputMethod)msg.obj).unbindInput();
|
((IInputMethod)msg.obj).unbindInput();
|
||||||
@ -1308,7 +1306,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
case MSG_START_INPUT:
|
case MSG_START_INPUT:
|
||||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||||
try {
|
try {
|
||||||
@ -1329,9 +1327,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
case MSG_UNBIND_METHOD:
|
case MSG_UNBIND_METHOD:
|
||||||
try {
|
try {
|
||||||
((IInputMethodClient)msg.obj).onUnbindMethod(msg.arg1);
|
((IInputMethodClient)msg.obj).onUnbindMethod(msg.arg1);
|
||||||
@ -1373,13 +1371,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
HashMap<String, InputMethodInfo> map) {
|
HashMap<String, InputMethodInfo> map) {
|
||||||
list.clear();
|
list.clear();
|
||||||
map.clear();
|
map.clear();
|
||||||
|
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
|
||||||
List<ResolveInfo> services = pm.queryIntentServices(
|
List<ResolveInfo> services = pm.queryIntentServices(
|
||||||
new Intent(InputMethod.SERVICE_INTERFACE),
|
new Intent(InputMethod.SERVICE_INTERFACE),
|
||||||
PackageManager.GET_META_DATA);
|
PackageManager.GET_META_DATA);
|
||||||
|
|
||||||
for (int i = 0; i < services.size(); ++i) {
|
for (int i = 0; i < services.size(); ++i) {
|
||||||
ResolveInfo ri = services.get(i);
|
ResolveInfo ri = services.get(i);
|
||||||
ServiceInfo si = ri.serviceInfo;
|
ServiceInfo si = ri.serviceInfo;
|
||||||
@ -1407,7 +1405,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Found a third-party input method " + p);
|
Log.d(TAG, "Found a third-party input method " + p);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
Log.w(TAG, "Unable to load input method " + compName, e);
|
Log.w(TAG, "Unable to load input method " + compName, e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -1423,24 +1421,24 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
void showInputMethodMenu() {
|
void showInputMethodMenu() {
|
||||||
if (DEBUG) Log.v(TAG, "Show switching menu");
|
if (DEBUG) Log.v(TAG, "Show switching menu");
|
||||||
|
|
||||||
hideInputMethodMenu();
|
hideInputMethodMenu();
|
||||||
|
|
||||||
final Context context = mContext;
|
final Context context = mContext;
|
||||||
|
|
||||||
final PackageManager pm = context.getPackageManager();
|
final PackageManager pm = context.getPackageManager();
|
||||||
|
|
||||||
String lastInputMethodId = Settings.Secure.getString(context
|
String lastInputMethodId = Settings.Secure.getString(context
|
||||||
.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
if (DEBUG) Log.v(TAG, "Current IME: " + lastInputMethodId);
|
if (DEBUG) Log.v(TAG, "Current IME: " + lastInputMethodId);
|
||||||
|
|
||||||
final List<InputMethodInfo> immis = getEnabledInputMethodList();
|
final List<InputMethodInfo> immis = getEnabledInputMethodList();
|
||||||
|
|
||||||
int N = (immis == null ? 0 : immis.size());
|
int N = (immis == null ? 0 : immis.size());
|
||||||
|
|
||||||
mItems = new CharSequence[N];
|
mItems = new CharSequence[N];
|
||||||
@ -1465,7 +1463,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
hideInputMethodMenu();
|
hideInputMethodMenu();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TypedArray a = context.obtainStyledAttributes(null,
|
TypedArray a = context.obtainStyledAttributes(null,
|
||||||
com.android.internal.R.styleable.DialogPreference,
|
com.android.internal.R.styleable.DialogPreference,
|
||||||
com.android.internal.R.attr.alertDialogStyle, 0);
|
com.android.internal.R.attr.alertDialogStyle, 0);
|
||||||
@ -1479,7 +1477,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
.setIcon(a.getDrawable(
|
.setIcon(a.getDrawable(
|
||||||
com.android.internal.R.styleable.DialogPreference_dialogTitle));
|
com.android.internal.R.styleable.DialogPreference_dialogTitle));
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
mDialogBuilder.setSingleChoiceItems(mItems, checkedItem,
|
mDialogBuilder.setSingleChoiceItems(mItems, checkedItem,
|
||||||
new AlertDialog.OnClickListener() {
|
new AlertDialog.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
@ -1498,13 +1496,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mSwitchingDialog.show();
|
mSwitchingDialog.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideInputMethodMenu() {
|
void hideInputMethodMenu() {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
hideInputMethodMenuLocked();
|
hideInputMethodMenuLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideInputMethodMenuLocked() {
|
void hideInputMethodMenuLocked() {
|
||||||
if (DEBUG) Log.v(TAG, "Hide switching menu");
|
if (DEBUG) Log.v(TAG, "Hide switching menu");
|
||||||
|
|
||||||
@ -1512,14 +1510,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mSwitchingDialog.dismiss();
|
mSwitchingDialog.dismiss();
|
||||||
mSwitchingDialog = null;
|
mSwitchingDialog = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDialogBuilder = null;
|
mDialogBuilder = null;
|
||||||
mItems = null;
|
mItems = null;
|
||||||
mIms = null;
|
mIms = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public boolean setInputMethodEnabled(String id, boolean enabled) {
|
public boolean setInputMethodEnabled(String id, boolean enabled) {
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
if (mContext.checkCallingOrSelfPermission(
|
if (mContext.checkCallingOrSelfPermission(
|
||||||
@ -1529,7 +1527,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
"Requires permission "
|
"Requires permission "
|
||||||
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
|
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
long ident = Binder.clearCallingIdentity();
|
long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
// Make sure this is a valid input method.
|
// Make sure this is a valid input method.
|
||||||
@ -1539,12 +1537,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
|
throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder(256);
|
StringBuilder builder = new StringBuilder(256);
|
||||||
|
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
String firstId = null;
|
String firstId = null;
|
||||||
|
|
||||||
// Look through the currently enabled input methods.
|
// Look through the currently enabled input methods.
|
||||||
String enabledStr = Settings.Secure.getString(mContext.getContentResolver(),
|
String enabledStr = Settings.Secure.getString(mContext.getContentResolver(),
|
||||||
Settings.Secure.ENABLED_INPUT_METHODS);
|
Settings.Secure.ENABLED_INPUT_METHODS);
|
||||||
@ -1573,7 +1571,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
// We are disabling the input method but it is already
|
// We are disabling the input method but it is already
|
||||||
@ -1596,17 +1594,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
// Previous state was enabled.
|
// Previous state was enabled.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add in the newly enabled input method.
|
// Add in the newly enabled input method.
|
||||||
if (enabledStr == null || enabledStr.length() == 0) {
|
if (enabledStr == null || enabledStr.length() == 0) {
|
||||||
enabledStr = id;
|
enabledStr = id;
|
||||||
} else {
|
} else {
|
||||||
enabledStr = enabledStr + ':' + id;
|
enabledStr = enabledStr + ':' + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Secure.putString(mContext.getContentResolver(),
|
Settings.Secure.putString(mContext.getContentResolver(),
|
||||||
Settings.Secure.ENABLED_INPUT_METHODS, enabledStr);
|
Settings.Secure.ENABLED_INPUT_METHODS, enabledStr);
|
||||||
|
|
||||||
// Previous state was disabled.
|
// Previous state was disabled.
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
@ -1616,12 +1614,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
||||||
pw.println("Permission Denial: can't dump InputMethodManager from from pid="
|
pw.println("Permission Denial: can't dump InputMethodManager from from pid="
|
||||||
+ Binder.getCallingPid()
|
+ Binder.getCallingPid()
|
||||||
+ ", uid=" + Binder.getCallingUid());
|
+ ", uid=" + Binder.getCallingUid());
|
||||||
@ -1630,9 +1628,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
|
|
||||||
IInputMethod method;
|
IInputMethod method;
|
||||||
ClientState client;
|
ClientState client;
|
||||||
|
|
||||||
final Printer p = new PrintWriterPrinter(pw);
|
final Printer p = new PrintWriterPrinter(pw);
|
||||||
|
|
||||||
synchronized (mMethodMap) {
|
synchronized (mMethodMap) {
|
||||||
p.println("Current Input Method Manager state:");
|
p.println("Current Input Method Manager state:");
|
||||||
int N = mMethodList.size();
|
int N = mMethodList.size();
|
||||||
@ -1669,7 +1667,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
+ " mInputShown=" + mInputShown);
|
+ " mInputShown=" + mInputShown);
|
||||||
p.println(" mSystemReady=" + mSystemReady + " mScreenOn=" + mScreenOn);
|
p.println(" mSystemReady=" + mSystemReady + " mScreenOn=" + mScreenOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
p.println(" ");
|
p.println(" ");
|
||||||
pw.flush();
|
pw.flush();
|
||||||
@ -1679,7 +1677,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
p.println("Input method client dead: " + e);
|
p.println("Input method client dead: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
p.println(" ");
|
p.println(" ");
|
||||||
pw.flush();
|
pw.flush();
|
||||||
|
@ -75,8 +75,8 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
|
|
||||||
private static final int LONG_DELAY = 3500; // 3.5 seconds
|
private static final int LONG_DELAY = 3500; // 3.5 seconds
|
||||||
private static final int SHORT_DELAY = 2000; // 2 seconds
|
private static final int SHORT_DELAY = 2000; // 2 seconds
|
||||||
|
|
||||||
private static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250};
|
private static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250};
|
||||||
|
|
||||||
private static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_NOTIFICATION;
|
private static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_NOTIFICATION;
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
private boolean mAdbEnabled = false;
|
private boolean mAdbEnabled = false;
|
||||||
private boolean mAdbNotificationShown = false;
|
private boolean mAdbNotificationShown = false;
|
||||||
private Notification mAdbNotification;
|
private Notification mAdbNotification;
|
||||||
|
|
||||||
private final ArrayList<NotificationRecord> mNotificationList =
|
private final ArrayList<NotificationRecord> mNotificationList =
|
||||||
new ArrayList<NotificationRecord>();
|
new ArrayList<NotificationRecord>();
|
||||||
|
|
||||||
@ -127,11 +127,6 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
private static final int BATTERY_BLINK_ON = 125;
|
private static final int BATTERY_BLINK_ON = 125;
|
||||||
private static final int BATTERY_BLINK_OFF = 2875;
|
private static final int BATTERY_BLINK_OFF = 2875;
|
||||||
|
|
||||||
// Tag IDs for EventLog.
|
|
||||||
private static final int EVENT_LOG_ENQUEUE = 2750;
|
|
||||||
private static final int EVENT_LOG_CANCEL = 2751;
|
|
||||||
private static final int EVENT_LOG_CANCEL_ALL = 2752;
|
|
||||||
|
|
||||||
private static String idDebugString(Context baseContext, String packageName, int id) {
|
private static String idDebugString(Context baseContext, String packageName, int id) {
|
||||||
Context c = null;
|
Context c = null;
|
||||||
|
|
||||||
@ -191,7 +186,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
+ " ledOnMS=" + notification.ledOnMS
|
+ " ledOnMS=" + notification.ledOnMS
|
||||||
+ " ledOffMS=" + notification.ledOffMS);
|
+ " ledOffMS=" + notification.ledOffMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString()
|
public final String toString()
|
||||||
{
|
{
|
||||||
@ -221,11 +216,11 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
void update(int duration) {
|
void update(int duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump(PrintWriter pw, String prefix) {
|
void dump(PrintWriter pw, String prefix) {
|
||||||
pw.println(prefix + this);
|
pw.println(prefix + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString()
|
public final String toString()
|
||||||
{
|
{
|
||||||
@ -354,7 +349,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
SettingsObserver(Handler handler) {
|
SettingsObserver(Handler handler) {
|
||||||
super(handler);
|
super(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void observe() {
|
void observe() {
|
||||||
ContentResolver resolver = mContext.getContentResolver();
|
ContentResolver resolver = mContext.getContentResolver();
|
||||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||||
@ -422,7 +417,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
mContext.registerReceiver(mIntentReceiver, filter);
|
mContext.registerReceiver(mIntentReceiver, filter);
|
||||||
|
|
||||||
SettingsObserver observer = new SettingsObserver(mHandler);
|
SettingsObserver observer = new SettingsObserver(mHandler);
|
||||||
observer.observe();
|
observer.observe();
|
||||||
}
|
}
|
||||||
@ -621,12 +616,12 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
Notification notification, int[] idOut)
|
Notification notification, int[] idOut)
|
||||||
{
|
{
|
||||||
checkIncomingCall(pkg);
|
checkIncomingCall(pkg);
|
||||||
|
|
||||||
// This conditional is a dirty hack to limit the logging done on
|
// This conditional is a dirty hack to limit the logging done on
|
||||||
// behalf of the download manager without affecting other apps.
|
// behalf of the download manager without affecting other apps.
|
||||||
if (!pkg.equals("com.android.providers.downloads")
|
if (!pkg.equals("com.android.providers.downloads")
|
||||||
|| Log.isLoggable("DownloadManager", Log.VERBOSE)) {
|
|| Log.isLoggable("DownloadManager", Log.VERBOSE)) {
|
||||||
EventLog.writeEvent(EVENT_LOG_ENQUEUE, pkg, id, notification.toString());
|
EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, notification.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pkg == null || notification == null) {
|
if (pkg == null || notification == null) {
|
||||||
@ -660,20 +655,20 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
old.notification.flags&Notification.FLAG_FOREGROUND_SERVICE;
|
old.notification.flags&Notification.FLAG_FOREGROUND_SERVICE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure if this is a foreground service that the proper additional
|
// Ensure if this is a foreground service that the proper additional
|
||||||
// flags are set.
|
// flags are set.
|
||||||
if ((notification.flags&Notification.FLAG_FOREGROUND_SERVICE) != 0) {
|
if ((notification.flags&Notification.FLAG_FOREGROUND_SERVICE) != 0) {
|
||||||
notification.flags |= Notification.FLAG_ONGOING_EVENT
|
notification.flags |= Notification.FLAG_ONGOING_EVENT
|
||||||
| Notification.FLAG_NO_CLEAR;
|
| Notification.FLAG_NO_CLEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification.icon != 0) {
|
if (notification.icon != 0) {
|
||||||
IconData icon = IconData.makeIcon(null, pkg, notification.icon,
|
IconData icon = IconData.makeIcon(null, pkg, notification.icon,
|
||||||
notification.iconLevel,
|
notification.iconLevel,
|
||||||
notification.number);
|
notification.number);
|
||||||
CharSequence truncatedTicker = notification.tickerText;
|
CharSequence truncatedTicker = notification.tickerText;
|
||||||
|
|
||||||
// TODO: make this restriction do something smarter like never fill
|
// TODO: make this restriction do something smarter like never fill
|
||||||
// more than two screens. "Why would anyone need more than 80 characters." :-/
|
// more than two screens. "Why would anyone need more than 80 characters." :-/
|
||||||
final int maxTickerLen = 80;
|
final int maxTickerLen = 80;
|
||||||
@ -738,7 +733,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
.getSystemService(Context.AUDIO_SERVICE);
|
.getSystemService(Context.AUDIO_SERVICE);
|
||||||
// sound
|
// sound
|
||||||
final boolean useDefaultSound =
|
final boolean useDefaultSound =
|
||||||
(notification.defaults & Notification.DEFAULT_SOUND) != 0;
|
(notification.defaults & Notification.DEFAULT_SOUND) != 0;
|
||||||
if (useDefaultSound || notification.sound != null) {
|
if (useDefaultSound || notification.sound != null) {
|
||||||
Uri uri;
|
Uri uri;
|
||||||
if (useDefaultSound) {
|
if (useDefaultSound) {
|
||||||
@ -769,12 +764,12 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
|
|
||||||
// vibrate
|
// vibrate
|
||||||
final boolean useDefaultVibrate =
|
final boolean useDefaultVibrate =
|
||||||
(notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
|
(notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
|
||||||
if ((useDefaultVibrate || notification.vibrate != null)
|
if ((useDefaultVibrate || notification.vibrate != null)
|
||||||
&& audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) {
|
&& audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) {
|
||||||
mVibrateNotification = r;
|
mVibrateNotification = r;
|
||||||
|
|
||||||
mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN
|
mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN
|
||||||
: notification.vibrate,
|
: notification.vibrate,
|
||||||
((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);
|
((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);
|
||||||
}
|
}
|
||||||
@ -869,24 +864,24 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels a notification ONLY if it has all of the {@code mustHaveFlags}
|
* Cancels a notification ONLY if it has all of the {@code mustHaveFlags}
|
||||||
* and none of the {@code mustNotHaveFlags}.
|
* and none of the {@code mustNotHaveFlags}.
|
||||||
*/
|
*/
|
||||||
private void cancelNotification(String pkg, String tag, int id, int mustHaveFlags,
|
private void cancelNotification(String pkg, String tag, int id, int mustHaveFlags,
|
||||||
int mustNotHaveFlags) {
|
int mustNotHaveFlags) {
|
||||||
EventLog.writeEvent(EVENT_LOG_CANCEL, pkg, id, mustHaveFlags);
|
EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL, pkg, id, mustHaveFlags);
|
||||||
|
|
||||||
synchronized (mNotificationList) {
|
synchronized (mNotificationList) {
|
||||||
int index = indexOfNotificationLocked(pkg, tag, id);
|
int index = indexOfNotificationLocked(pkg, tag, id);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
NotificationRecord r = mNotificationList.get(index);
|
NotificationRecord r = mNotificationList.get(index);
|
||||||
|
|
||||||
if ((r.notification.flags & mustHaveFlags) != mustHaveFlags) {
|
if ((r.notification.flags & mustHaveFlags) != mustHaveFlags) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((r.notification.flags & mustNotHaveFlags) != 0) {
|
if ((r.notification.flags & mustNotHaveFlags) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mNotificationList.remove(index);
|
mNotificationList.remove(index);
|
||||||
|
|
||||||
cancelNotificationLocked(r);
|
cancelNotificationLocked(r);
|
||||||
@ -901,7 +896,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
*/
|
*/
|
||||||
void cancelAllNotificationsInt(String pkg, int mustHaveFlags,
|
void cancelAllNotificationsInt(String pkg, int mustHaveFlags,
|
||||||
int mustNotHaveFlags) {
|
int mustNotHaveFlags) {
|
||||||
EventLog.writeEvent(EVENT_LOG_CANCEL_ALL, pkg, mustHaveFlags);
|
EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL_ALL, pkg, mustHaveFlags);
|
||||||
|
|
||||||
synchronized (mNotificationList) {
|
synchronized (mNotificationList) {
|
||||||
final int N = mNotificationList.size();
|
final int N = mNotificationList.size();
|
||||||
@ -927,7 +922,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void cancelNotification(String pkg, int id) {
|
public void cancelNotification(String pkg, int id) {
|
||||||
cancelNotificationWithTag(pkg, null /* tag */, id);
|
cancelNotificationWithTag(pkg, null /* tag */, id);
|
||||||
}
|
}
|
||||||
@ -942,7 +937,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
|
|
||||||
public void cancelAllNotifications(String pkg) {
|
public void cancelAllNotifications(String pkg) {
|
||||||
checkIncomingCall(pkg);
|
checkIncomingCall(pkg);
|
||||||
|
|
||||||
// Calling from user space, don't allow the canceling of actively
|
// Calling from user space, don't allow the canceling of actively
|
||||||
// running foreground services.
|
// running foreground services.
|
||||||
cancelAllNotificationsInt(pkg, 0, Notification.FLAG_FOREGROUND_SERVICE);
|
cancelAllNotificationsInt(pkg, 0, Notification.FLAG_FOREGROUND_SERVICE);
|
||||||
@ -964,7 +959,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
throw new SecurityException("Unknown package " + pkg);
|
throw new SecurityException("Unknown package " + pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelAll() {
|
void cancelAll() {
|
||||||
synchronized (mNotificationList) {
|
synchronized (mNotificationList) {
|
||||||
final int N = mNotificationList.size();
|
final int N = mNotificationList.size();
|
||||||
@ -1103,14 +1098,14 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
intent, 0);
|
intent, 0);
|
||||||
|
|
||||||
mAdbNotification.setLatestEventInfo(mContext, title, message, pi);
|
mAdbNotification.setLatestEventInfo(mContext, title, message, pi);
|
||||||
|
|
||||||
mAdbNotificationShown = true;
|
mAdbNotificationShown = true;
|
||||||
notificationManager.notify(
|
notificationManager.notify(
|
||||||
com.android.internal.R.string.adb_active_notification_title,
|
com.android.internal.R.string.adb_active_notification_title,
|
||||||
mAdbNotification);
|
mAdbNotification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (mAdbNotificationShown) {
|
} else if (mAdbNotificationShown) {
|
||||||
NotificationManager notificationManager = (NotificationManager) mContext
|
NotificationManager notificationManager = (NotificationManager) mContext
|
||||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
@ -1138,7 +1133,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
+ ", uid=" + Binder.getCallingUid());
|
+ ", uid=" + Binder.getCallingUid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw.println("Current Notification Manager state:");
|
pw.println("Current Notification Manager state:");
|
||||||
|
|
||||||
int N;
|
int N;
|
||||||
@ -1152,7 +1147,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
}
|
}
|
||||||
pw.println(" ");
|
pw.println(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mNotificationList) {
|
synchronized (mNotificationList) {
|
||||||
@ -1164,7 +1159,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
}
|
}
|
||||||
pw.println(" ");
|
pw.println(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
N = mLights.size();
|
N = mLights.size();
|
||||||
if (N > 0) {
|
if (N > 0) {
|
||||||
pw.println(" Lights List:");
|
pw.println(" Lights List:");
|
||||||
@ -1173,7 +1168,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
}
|
}
|
||||||
pw.println(" ");
|
pw.println(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
pw.println(" mSoundNotification=" + mSoundNotification);
|
pw.println(" mSoundNotification=" + mSoundNotification);
|
||||||
pw.println(" mSound=" + mSound);
|
pw.println(" mSound=" + mSound);
|
||||||
pw.println(" mVibrateNotification=" + mVibrateNotification);
|
pw.println(" mVibrateNotification=" + mVibrateNotification);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -133,7 +133,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
static final boolean ANIMATE_SCREEN_LIGHTS = true;
|
static final boolean ANIMATE_SCREEN_LIGHTS = true;
|
||||||
static final boolean ANIMATE_BUTTON_LIGHTS = false;
|
static final boolean ANIMATE_BUTTON_LIGHTS = false;
|
||||||
static final boolean ANIMATE_KEYBOARD_LIGHTS = false;
|
static final boolean ANIMATE_KEYBOARD_LIGHTS = false;
|
||||||
|
|
||||||
static final int ANIM_STEPS = 60/4;
|
static final int ANIM_STEPS = 60/4;
|
||||||
// Slower animation for autobrightness changes
|
// Slower animation for autobrightness changes
|
||||||
static final int AUTOBRIGHTNESS_ANIM_STEPS = 60;
|
static final int AUTOBRIGHTNESS_ANIM_STEPS = 60;
|
||||||
@ -144,14 +144,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
static final int INITIAL_SCREEN_BRIGHTNESS = 255;
|
static final int INITIAL_SCREEN_BRIGHTNESS = 255;
|
||||||
static final int INITIAL_BUTTON_BRIGHTNESS = Power.BRIGHTNESS_OFF;
|
static final int INITIAL_BUTTON_BRIGHTNESS = Power.BRIGHTNESS_OFF;
|
||||||
static final int INITIAL_KEYBOARD_BRIGHTNESS = Power.BRIGHTNESS_OFF;
|
static final int INITIAL_KEYBOARD_BRIGHTNESS = Power.BRIGHTNESS_OFF;
|
||||||
|
|
||||||
static final int LOG_POWER_SLEEP_REQUESTED = 2724;
|
|
||||||
static final int LOG_POWER_SCREEN_BROADCAST_SEND = 2725;
|
|
||||||
static final int LOG_POWER_SCREEN_BROADCAST_DONE = 2726;
|
|
||||||
static final int LOG_POWER_SCREEN_BROADCAST_STOP = 2727;
|
|
||||||
static final int LOG_POWER_SCREEN_STATE = 2728;
|
|
||||||
static final int LOG_POWER_PARTIAL_WAKE_STATE = 2729;
|
|
||||||
|
|
||||||
private final int MY_UID;
|
private final int MY_UID;
|
||||||
|
|
||||||
private boolean mDoneBooting = false;
|
private boolean mDoneBooting = false;
|
||||||
@ -419,7 +412,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
|
|
||||||
// assume nothing is on yet
|
// assume nothing is on yet
|
||||||
mUserState = mPowerState = 0;
|
mUserState = mPowerState = 0;
|
||||||
|
|
||||||
// Add ourself to the Watchdog monitors.
|
// Add ourself to the Watchdog monitors.
|
||||||
Watchdog.getInstance().addMonitor(this);
|
Watchdog.getInstance().addMonitor(this);
|
||||||
}
|
}
|
||||||
@ -447,7 +440,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
mHandlerThread.start();
|
mHandlerThread.start();
|
||||||
|
|
||||||
synchronized (mHandlerThread) {
|
synchronized (mHandlerThread) {
|
||||||
while (!mInitComplete) {
|
while (!mInitComplete) {
|
||||||
try {
|
try {
|
||||||
@ -458,7 +451,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initInThread() {
|
void initInThread() {
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
|
|
||||||
@ -686,7 +679,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if (newlock) {
|
if (newlock) {
|
||||||
mPartialCount++;
|
mPartialCount++;
|
||||||
if (mPartialCount == 1) {
|
if (mPartialCount == 1) {
|
||||||
if (LOG_PARTIAL_WL) EventLog.writeEvent(LOG_POWER_PARTIAL_WAKE_STATE, 1, tag);
|
if (LOG_PARTIAL_WL) EventLog.writeEvent(EventLogTags.POWER_PARTIAL_WAKE_STATE, 1, tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Power.acquireWakeLock(Power.PARTIAL_WAKE_LOCK,PARTIAL_NAME);
|
Power.acquireWakeLock(Power.PARTIAL_WAKE_LOCK,PARTIAL_NAME);
|
||||||
@ -731,7 +724,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if (wl == null) {
|
if (wl == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSpew) {
|
if (mSpew) {
|
||||||
Log.d(TAG, "releaseWakeLock flags=0x"
|
Log.d(TAG, "releaseWakeLock flags=0x"
|
||||||
+ Integer.toHexString(wl.flags) + " tag=" + wl.tag);
|
+ Integer.toHexString(wl.flags) + " tag=" + wl.tag);
|
||||||
@ -748,7 +741,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
else if ((wl.flags & LOCK_MASK) == PowerManager.PARTIAL_WAKE_LOCK) {
|
else if ((wl.flags & LOCK_MASK) == PowerManager.PARTIAL_WAKE_LOCK) {
|
||||||
mPartialCount--;
|
mPartialCount--;
|
||||||
if (mPartialCount == 0) {
|
if (mPartialCount == 0) {
|
||||||
if (LOG_PARTIAL_WL) EventLog.writeEvent(LOG_POWER_PARTIAL_WAKE_STATE, 0, wl.tag);
|
if (LOG_PARTIAL_WL) EventLog.writeEvent(EventLogTags.POWER_PARTIAL_WAKE_STATE, 0, wl.tag);
|
||||||
Power.releaseWakeLock(PARTIAL_NAME);
|
Power.releaseWakeLock(PARTIAL_NAME);
|
||||||
}
|
}
|
||||||
} else if ((wl.flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) {
|
} else if ((wl.flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) {
|
||||||
@ -855,7 +848,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
|
|
||||||
int oldCumulativeTimeout = oldPokey & POKE_LOCK_TIMEOUT_MASK;
|
int oldCumulativeTimeout = oldPokey & POKE_LOCK_TIMEOUT_MASK;
|
||||||
int newCumulativeTimeout = pokey & POKE_LOCK_TIMEOUT_MASK;
|
int newCumulativeTimeout = pokey & POKE_LOCK_TIMEOUT_MASK;
|
||||||
|
|
||||||
if (oldCumulativeTimeout != newCumulativeTimeout) {
|
if (oldCumulativeTimeout != newCumulativeTimeout) {
|
||||||
setScreenOffTimeoutsLocked();
|
setScreenOffTimeoutsLocked();
|
||||||
// reset the countdown timer, but use the existing nextState so it doesn't
|
// reset the countdown timer, but use the existing nextState so it doesn't
|
||||||
@ -958,7 +951,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mScreenBrightness.dump(pw, " mScreenBrightness: ");
|
mScreenBrightness.dump(pw, " mScreenBrightness: ");
|
||||||
mKeyboardBrightness.dump(pw, " mKeyboardBrightness: ");
|
mKeyboardBrightness.dump(pw, " mKeyboardBrightness: ");
|
||||||
mButtonBrightness.dump(pw, " mButtonBrightness: ");
|
mButtonBrightness.dump(pw, " mButtonBrightness: ");
|
||||||
|
|
||||||
int N = mLocks.size();
|
int N = mLocks.size();
|
||||||
pw.println();
|
pw.println();
|
||||||
pw.println("mLocks.size=" + N + ":");
|
pw.println("mLocks.size=" + N + ":");
|
||||||
@ -976,7 +969,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
pw.println(" " + type + " '" + wl.tag + "'" + acquireCausesWakeup
|
pw.println(" " + type + " '" + wl.tag + "'" + acquireCausesWakeup
|
||||||
+ activated + " (minState=" + wl.minState + ")");
|
+ activated + " (minState=" + wl.minState + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
pw.println();
|
pw.println();
|
||||||
pw.println("mPokeLocks.size=" + mPokeLocks.size() + ":");
|
pw.println("mPokeLocks.size=" + mPokeLocks.size() + ":");
|
||||||
for (PokeLock p: mPokeLocks.values()) {
|
for (PokeLock p: mPokeLocks.values()) {
|
||||||
@ -1106,7 +1099,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
index = -1;
|
index = -1;
|
||||||
// The wake lock was being held, but we're not actually going to do any
|
// The wake lock was being held, but we're not actually going to do any
|
||||||
// broadcasts, so release the wake lock.
|
// broadcasts, so release the wake lock.
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_STOP, 1, mBroadcastWakeLock.mCount);
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 1, mBroadcastWakeLock.mCount);
|
||||||
mBroadcastWakeLock.release();
|
mBroadcastWakeLock.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1117,7 +1110,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
// We always increment the ref count for each notification in the queue
|
// We always increment the ref count for each notification in the queue
|
||||||
// and always decrement when that notification is handled.
|
// and always decrement when that notification is handled.
|
||||||
mBroadcastWakeLock.acquire();
|
mBroadcastWakeLock.acquire();
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_SEND, mBroadcastWakeLock.mCount);
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_SEND, mBroadcastWakeLock.mCount);
|
||||||
mHandler.post(mNotificationTask);
|
mHandler.post(mNotificationTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1141,7 +1134,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
if (value == 1) {
|
if (value == 1) {
|
||||||
mScreenOnStart = SystemClock.uptimeMillis();
|
mScreenOnStart = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
policy.screenTurnedOn();
|
policy.screenTurnedOn();
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().wakingUp();
|
ActivityManagerNative.getDefault().wakingUp();
|
||||||
@ -1157,7 +1150,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mScreenOnBroadcastDone, mHandler, 0, null, null);
|
mScreenOnBroadcastDone, mHandler, 0, null, null);
|
||||||
} else {
|
} else {
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_STOP, 2,
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 2,
|
||||||
mBroadcastWakeLock.mCount);
|
mBroadcastWakeLock.mCount);
|
||||||
mBroadcastWakeLock.release();
|
mBroadcastWakeLock.release();
|
||||||
}
|
}
|
||||||
@ -1165,7 +1158,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
else if (value == 0) {
|
else if (value == 0) {
|
||||||
mScreenOffStart = SystemClock.uptimeMillis();
|
mScreenOffStart = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
policy.screenTurnedOff(why);
|
policy.screenTurnedOff(why);
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().goingToSleep();
|
ActivityManagerNative.getDefault().goingToSleep();
|
||||||
@ -1178,7 +1171,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mScreenOffBroadcastDone, mHandler, 0, null, null);
|
mScreenOffBroadcastDone, mHandler, 0, null, null);
|
||||||
} else {
|
} else {
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_STOP, 3,
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 3,
|
||||||
mBroadcastWakeLock.mCount);
|
mBroadcastWakeLock.mCount);
|
||||||
mBroadcastWakeLock.release();
|
mBroadcastWakeLock.release();
|
||||||
}
|
}
|
||||||
@ -1197,7 +1190,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
private BroadcastReceiver mScreenOnBroadcastDone = new BroadcastReceiver() {
|
private BroadcastReceiver mScreenOnBroadcastDone = new BroadcastReceiver() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_DONE, 1,
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_DONE, 1,
|
||||||
SystemClock.uptimeMillis() - mScreenOnStart, mBroadcastWakeLock.mCount);
|
SystemClock.uptimeMillis() - mScreenOnStart, mBroadcastWakeLock.mCount);
|
||||||
mBroadcastWakeLock.release();
|
mBroadcastWakeLock.release();
|
||||||
}
|
}
|
||||||
@ -1208,7 +1201,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
private BroadcastReceiver mScreenOffBroadcastDone = new BroadcastReceiver() {
|
private BroadcastReceiver mScreenOffBroadcastDone = new BroadcastReceiver() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_DONE, 0,
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_DONE, 0,
|
||||||
SystemClock.uptimeMillis() - mScreenOffStart, mBroadcastWakeLock.mCount);
|
SystemClock.uptimeMillis() - mScreenOffStart, mBroadcastWakeLock.mCount);
|
||||||
mBroadcastWakeLock.release();
|
mBroadcastWakeLock.release();
|
||||||
}
|
}
|
||||||
@ -1492,7 +1485,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mLastTouchDown = 0;
|
mLastTouchDown = 0;
|
||||||
mTotalTouchDownTime = 0;
|
mTotalTouchDownTime = 0;
|
||||||
mTouchCycles = 0;
|
mTouchCycles = 0;
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 1, reason,
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_STATE, 1, reason,
|
||||||
mTotalTouchDownTime, mTouchCycles);
|
mTotalTouchDownTime, mTouchCycles);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
mPowerState |= SCREEN_ON_BIT;
|
mPowerState |= SCREEN_ON_BIT;
|
||||||
@ -1522,12 +1515,12 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int screenOffFinishedAnimatingLocked(int reason) {
|
private int screenOffFinishedAnimatingLocked(int reason) {
|
||||||
// I don't think we need to check the current state here because all of these
|
// I don't think we need to check the current state here because all of these
|
||||||
// Power.setScreenState and sendNotificationLocked can both handle being
|
// Power.setScreenState and sendNotificationLocked can both handle being
|
||||||
// called multiple times in the same state. -joeo
|
// called multiple times in the same state. -joeo
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 0, reason, mTotalTouchDownTime, mTouchCycles);
|
EventLog.writeEvent(EventLogTags.POWER_SCREEN_STATE, 0, reason, mTotalTouchDownTime, mTouchCycles);
|
||||||
mLastTouchDown = 0;
|
mLastTouchDown = 0;
|
||||||
int err = setScreenStateLocked(false);
|
int err = setScreenStateLocked(false);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
@ -1551,14 +1544,14 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if (difference == 0) {
|
if (difference == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int offMask = 0;
|
int offMask = 0;
|
||||||
int dimMask = 0;
|
int dimMask = 0;
|
||||||
int onMask = 0;
|
int onMask = 0;
|
||||||
|
|
||||||
int preferredBrightness = getPreferredBrightness();
|
int preferredBrightness = getPreferredBrightness();
|
||||||
boolean startAnimation = false;
|
boolean startAnimation = false;
|
||||||
|
|
||||||
if ((difference & KEYBOARD_BRIGHT_BIT) != 0) {
|
if ((difference & KEYBOARD_BRIGHT_BIT) != 0) {
|
||||||
if (ANIMATE_KEYBOARD_LIGHTS) {
|
if (ANIMATE_KEYBOARD_LIGHTS) {
|
||||||
if ((newState & KEYBOARD_BRIGHT_BIT) == 0) {
|
if ((newState & KEYBOARD_BRIGHT_BIT) == 0) {
|
||||||
@ -1697,7 +1690,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mHandler.removeCallbacks(mLightAnimator);
|
mHandler.removeCallbacks(mLightAnimator);
|
||||||
mHandler.post(mLightAnimator);
|
mHandler.post(mLightAnimator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offMask != 0) {
|
if (offMask != 0) {
|
||||||
//Log.i(TAG, "Setting brightess off: " + offMask);
|
//Log.i(TAG, "Setting brightess off: " + offMask);
|
||||||
setLightBrightness(offMask, Power.BRIGHTNESS_OFF);
|
setLightBrightness(offMask, Power.BRIGHTNESS_OFF);
|
||||||
@ -1739,24 +1732,24 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
|
|
||||||
class BrightnessState {
|
class BrightnessState {
|
||||||
final int mask;
|
final int mask;
|
||||||
|
|
||||||
boolean initialized;
|
boolean initialized;
|
||||||
int targetValue;
|
int targetValue;
|
||||||
float curValue;
|
float curValue;
|
||||||
float delta;
|
float delta;
|
||||||
boolean animating;
|
boolean animating;
|
||||||
|
|
||||||
BrightnessState(int m) {
|
BrightnessState(int m) {
|
||||||
mask = m;
|
mask = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump(PrintWriter pw, String prefix) {
|
public void dump(PrintWriter pw, String prefix) {
|
||||||
pw.println(prefix + "animating=" + animating
|
pw.println(prefix + "animating=" + animating
|
||||||
+ " targetValue=" + targetValue
|
+ " targetValue=" + targetValue
|
||||||
+ " curValue=" + curValue
|
+ " curValue=" + curValue
|
||||||
+ " delta=" + delta);
|
+ " delta=" + delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean setTargetLocked(int target, int stepsToTarget, int initialValue,
|
boolean setTargetLocked(int target, int stepsToTarget, int initialValue,
|
||||||
int nominalCurrentValue) {
|
int nominalCurrentValue) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@ -1779,7 +1772,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
animating = true;
|
animating = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean stepLocked() {
|
boolean stepLocked() {
|
||||||
if (!animating) return false;
|
if (!animating) return false;
|
||||||
if (false && mSpew) {
|
if (false && mSpew) {
|
||||||
@ -1814,7 +1807,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
return more;
|
return more;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LightAnimator implements Runnable {
|
private class LightAnimator implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
@ -1832,7 +1825,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPreferredBrightness() {
|
private int getPreferredBrightness() {
|
||||||
try {
|
try {
|
||||||
if (mScreenBrightnessOverride >= 0) {
|
if (mScreenBrightnessOverride >= 0) {
|
||||||
@ -1992,7 +1985,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
mWakeLockState = mLocks.reactivateScreenLocksLocked();
|
mWakeLockState = mLocks.reactivateScreenLocksLocked();
|
||||||
setPowerState(mUserState | mWakeLockState, noChangeLights,
|
setPowerState(mUserState | mWakeLockState, noChangeLights,
|
||||||
WindowManagerPolicy.OFF_BECAUSE_OF_USER);
|
WindowManagerPolicy.OFF_BECAUSE_OF_USER);
|
||||||
@ -2129,7 +2122,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
goToSleepLocked(time, WindowManagerPolicy.OFF_BECAUSE_OF_USER);
|
goToSleepLocked(time, WindowManagerPolicy.OFF_BECAUSE_OF_USER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reboot the device immediately, passing 'reason' (may be null)
|
* Reboot the device immediately, passing 'reason' (may be null)
|
||||||
* to the underlying __reboot system call. Should not return.
|
* to the underlying __reboot system call. Should not return.
|
||||||
@ -2159,7 +2152,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
numCleared++;
|
numCleared++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EventLog.writeEvent(LOG_POWER_SLEEP_REQUESTED, numCleared);
|
EventLog.writeEvent(EventLogTags.POWER_SLEEP_REQUESTED, numCleared);
|
||||||
mStillNeedSleepNotification = true;
|
mStillNeedSleepNotification = true;
|
||||||
mUserState = SCREEN_OFF;
|
mUserState = SCREEN_OFF;
|
||||||
setPowerState(SCREEN_OFF, false, reason);
|
setPowerState(SCREEN_OFF, false, reason);
|
||||||
@ -2175,7 +2168,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
return SystemClock.elapsedRealtime() - mScreenOffTime;
|
return SystemClock.elapsedRealtime() - mScreenOffTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboardVisibility(boolean visible) {
|
public void setKeyboardVisibility(boolean visible) {
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
if (mSpew) {
|
if (mSpew) {
|
||||||
@ -2345,7 +2338,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reactivateScreenLocksLocked()
|
int reactivateScreenLocksLocked()
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -2378,7 +2371,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
return mPolicy;
|
return mPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemReady() {
|
void systemReady() {
|
||||||
mSensorManager = new SensorManager(mHandlerThread.getLooper());
|
mSensorManager = new SensorManager(mHandlerThread.getLooper());
|
||||||
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||||
|
@ -70,7 +70,7 @@ class ServerThread extends Thread {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
EventLog.writeEvent(LOG_BOOT_PROGRESS_SYSTEM_RUN,
|
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN,
|
||||||
SystemClock.uptimeMillis());
|
SystemClock.uptimeMillis());
|
||||||
|
|
||||||
ActivityManagerService.prepareTraceFile(false); // create dir
|
ActivityManagerService.prepareTraceFile(false); // create dir
|
||||||
@ -387,7 +387,7 @@ class ServerThread extends Thread {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is now time to start up the app processes...
|
// It is now time to start up the app processes...
|
||||||
|
|
||||||
if (notification != null) {
|
if (notification != null) {
|
||||||
@ -411,7 +411,7 @@ class ServerThread extends Thread {
|
|||||||
final AppWidgetService appWidgetF = appWidget;
|
final AppWidgetService appWidgetF = appWidget;
|
||||||
final WallpaperManagerService wallpaperF = wallpaper;
|
final WallpaperManagerService wallpaperF = wallpaper;
|
||||||
final InputMethodManagerService immF = imm;
|
final InputMethodManagerService immF = imm;
|
||||||
|
|
||||||
// We now tell the activity manager it is okay to run third party
|
// We now tell the activity manager it is okay to run third party
|
||||||
// code. It will call back into us once it has gotten to the state
|
// code. It will call back into us once it has gotten to the state
|
||||||
// where third party code can really run (but before it has actually
|
// where third party code can really run (but before it has actually
|
||||||
@ -421,7 +421,7 @@ class ServerThread extends Thread {
|
|||||||
.systemReady(new Runnable() {
|
.systemReady(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.i(TAG, "Making services ready");
|
Log.i(TAG, "Making services ready");
|
||||||
|
|
||||||
if (batteryF != null) batteryF.systemReady();
|
if (batteryF != null) batteryF.systemReady();
|
||||||
if (connectivityF != null) connectivityF.systemReady();
|
if (connectivityF != null) connectivityF.systemReady();
|
||||||
if (dockF != null) dockF.systemReady();
|
if (dockF != null) dockF.systemReady();
|
||||||
@ -429,13 +429,13 @@ class ServerThread extends Thread {
|
|||||||
|
|
||||||
// It is now okay to let the various system services start their
|
// It is now okay to let the various system services start their
|
||||||
// third party code...
|
// third party code...
|
||||||
|
|
||||||
if (appWidgetF != null) appWidgetF.systemReady(safeMode);
|
if (appWidgetF != null) appWidgetF.systemReady(safeMode);
|
||||||
if (wallpaperF != null) wallpaperF.systemReady();
|
if (wallpaperF != null) wallpaperF.systemReady();
|
||||||
if (immF != null) immF.systemReady();
|
if (immF != null) immF.systemReady();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Looper.loop();
|
Looper.loop();
|
||||||
Log.d(TAG, "System ServerThread is exiting!");
|
Log.d(TAG, "System ServerThread is exiting!");
|
||||||
}
|
}
|
||||||
|
@ -52,16 +52,6 @@ public class Watchdog extends Thread {
|
|||||||
static final int GLOBAL_PSS = 2719;
|
static final int GLOBAL_PSS = 2719;
|
||||||
|
|
||||||
static final int TIME_TO_WAIT = DB ? 15*1000 : 60*1000;
|
static final int TIME_TO_WAIT = DB ? 15*1000 : 60*1000;
|
||||||
static final int EVENT_LOG_TAG = 2802;
|
|
||||||
static final int EVENT_LOG_PROC_PSS_TAG = 2803;
|
|
||||||
static final int EVENT_LOG_SOFT_RESET_TAG = 2804;
|
|
||||||
static final int EVENT_LOG_HARD_RESET_TAG = 2805;
|
|
||||||
static final int EVENT_LOG_PSS_STATS_TAG = 2806;
|
|
||||||
static final int EVENT_LOG_PROC_STATS_TAG = 2807;
|
|
||||||
static final int EVENT_LOG_SCHEDULED_REBOOT_TAG = 2808;
|
|
||||||
static final int EVENT_LOG_MEMINFO_TAG = 2809;
|
|
||||||
static final int EVENT_LOG_VMSTAT_TAG = 2810;
|
|
||||||
static final int EVENT_LOG_REQUESTED_REBOOT_TAG = 2811;
|
|
||||||
|
|
||||||
static final int MEMCHECK_DEFAULT_INTERVAL = DB ? 30 : 30*60; // 30 minutes
|
static final int MEMCHECK_DEFAULT_INTERVAL = DB ? 30 : 30*60; // 30 minutes
|
||||||
static final int MEMCHECK_DEFAULT_LOG_REALTIME_INTERVAL = DB ? 60 : 2*60*60; // 2 hours
|
static final int MEMCHECK_DEFAULT_LOG_REALTIME_INTERVAL = DB ? 60 : 2*60*60; // 2 hours
|
||||||
@ -188,7 +178,7 @@ public class Watchdog extends Thread {
|
|||||||
} else {
|
} else {
|
||||||
mState = STATE_HARD;
|
mState = STATE_HARD;
|
||||||
}
|
}
|
||||||
EventLog.writeEvent(EVENT_LOG_PROC_PSS_TAG, mProcessName, pid, mLastPss);
|
EventLog.writeEvent(EventLogTags.WATCHDOG_PROC_PSS, mProcessName, pid, mLastPss);
|
||||||
|
|
||||||
if (mState == STATE_OK) {
|
if (mState == STATE_OK) {
|
||||||
// Memory is good, don't recover.
|
// Memory is good, don't recover.
|
||||||
@ -197,7 +187,7 @@ public class Watchdog extends Thread {
|
|||||||
|
|
||||||
if (mState == STATE_HARD) {
|
if (mState == STATE_HARD) {
|
||||||
// Memory is really bad, kill right now.
|
// Memory is really bad, kill right now.
|
||||||
EventLog.writeEvent(EVENT_LOG_HARD_RESET_TAG, mProcessName, pid,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_HARD_RESET, mProcessName, pid,
|
||||||
mHardThreshold, mLastPss);
|
mHardThreshold, mLastPss);
|
||||||
return mEnabled;
|
return mEnabled;
|
||||||
}
|
}
|
||||||
@ -212,7 +202,7 @@ public class Watchdog extends Thread {
|
|||||||
} else {
|
} else {
|
||||||
skipReason = shouldWeBeBrutalLocked(curTime);
|
skipReason = shouldWeBeBrutalLocked(curTime);
|
||||||
}
|
}
|
||||||
EventLog.writeEvent(EVENT_LOG_SOFT_RESET_TAG, mProcessName, pid,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_SOFT_RESET, mProcessName, pid,
|
||||||
mSoftThreshold, mLastPss, skipReason != null ? skipReason : "");
|
mSoftThreshold, mLastPss, skipReason != null ? skipReason : "");
|
||||||
if (skipReason != null) {
|
if (skipReason != null) {
|
||||||
mNeedScheduledCheck = true;
|
mNeedScheduledCheck = true;
|
||||||
@ -348,7 +338,7 @@ public class Watchdog extends Thread {
|
|||||||
mReqMinScreenOff = intent.getIntExtra("minScreenOff", -1);
|
mReqMinScreenOff = intent.getIntExtra("minScreenOff", -1);
|
||||||
mReqMinNextAlarm = intent.getIntExtra("minNextAlarm", -1);
|
mReqMinNextAlarm = intent.getIntExtra("minNextAlarm", -1);
|
||||||
mReqRecheckInterval = intent.getIntExtra("recheckInterval", -1);
|
mReqRecheckInterval = intent.getIntExtra("recheckInterval", -1);
|
||||||
EventLog.writeEvent(EVENT_LOG_REQUESTED_REBOOT_TAG,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_REQUESTED_REBOOT,
|
||||||
mReqRebootNoWait ? 1 : 0, mReqRebootInterval,
|
mReqRebootNoWait ? 1 : 0, mReqRebootInterval,
|
||||||
mReqRecheckInterval, mReqRebootStartTime,
|
mReqRecheckInterval, mReqRebootStartTime,
|
||||||
mReqRebootWindow, mReqMinScreenOff, mReqMinNextAlarm);
|
mReqRebootWindow, mReqMinScreenOff, mReqMinNextAlarm);
|
||||||
@ -561,21 +551,21 @@ public class Watchdog extends Thread {
|
|||||||
void logGlobalMemory() {
|
void logGlobalMemory() {
|
||||||
PssStats stats = mPssStats;
|
PssStats stats = mPssStats;
|
||||||
mActivity.collectPss(stats);
|
mActivity.collectPss(stats);
|
||||||
EventLog.writeEvent(EVENT_LOG_PSS_STATS_TAG,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_PSS_STATS,
|
||||||
stats.mEmptyPss, stats.mEmptyCount,
|
stats.mEmptyPss, stats.mEmptyCount,
|
||||||
stats.mBackgroundPss, stats.mBackgroundCount,
|
stats.mBackgroundPss, stats.mBackgroundCount,
|
||||||
stats.mServicePss, stats.mServiceCount,
|
stats.mServicePss, stats.mServiceCount,
|
||||||
stats.mVisiblePss, stats.mVisibleCount,
|
stats.mVisiblePss, stats.mVisibleCount,
|
||||||
stats.mForegroundPss, stats.mForegroundCount,
|
stats.mForegroundPss, stats.mForegroundCount,
|
||||||
stats.mNoPssCount);
|
stats.mNoPssCount);
|
||||||
EventLog.writeEvent(EVENT_LOG_PROC_STATS_TAG,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_PROC_STATS,
|
||||||
stats.mProcDeaths[0], stats.mProcDeaths[1], stats.mProcDeaths[2],
|
stats.mProcDeaths[0], stats.mProcDeaths[1], stats.mProcDeaths[2],
|
||||||
stats.mProcDeaths[3], stats.mProcDeaths[4]);
|
stats.mProcDeaths[3], stats.mProcDeaths[4]);
|
||||||
Process.readProcLines("/proc/meminfo", mMemInfoFields, mMemInfoSizes);
|
Process.readProcLines("/proc/meminfo", mMemInfoFields, mMemInfoSizes);
|
||||||
for (int i=0; i<mMemInfoSizes.length; i++) {
|
for (int i=0; i<mMemInfoSizes.length; i++) {
|
||||||
mMemInfoSizes[i] *= 1024;
|
mMemInfoSizes[i] *= 1024;
|
||||||
}
|
}
|
||||||
EventLog.writeEvent(EVENT_LOG_MEMINFO_TAG,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_MEMINFO,
|
||||||
(int)mMemInfoSizes[0], (int)mMemInfoSizes[1], (int)mMemInfoSizes[2],
|
(int)mMemInfoSizes[0], (int)mMemInfoSizes[1], (int)mMemInfoSizes[2],
|
||||||
(int)mMemInfoSizes[3], (int)mMemInfoSizes[4],
|
(int)mMemInfoSizes[3], (int)mMemInfoSizes[4],
|
||||||
(int)mMemInfoSizes[5], (int)mMemInfoSizes[6], (int)mMemInfoSizes[7],
|
(int)mMemInfoSizes[5], (int)mMemInfoSizes[6], (int)mMemInfoSizes[7],
|
||||||
@ -589,7 +579,7 @@ public class Watchdog extends Thread {
|
|||||||
mVMStatSizes[i] -= mPrevVMStatSizes[i];
|
mVMStatSizes[i] -= mPrevVMStatSizes[i];
|
||||||
mPrevVMStatSizes[i] = v;
|
mPrevVMStatSizes[i] = v;
|
||||||
}
|
}
|
||||||
EventLog.writeEvent(EVENT_LOG_VMSTAT_TAG, dur,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_VMSTAT, dur,
|
||||||
(int)mVMStatSizes[0], (int)mVMStatSizes[1], (int)mVMStatSizes[2],
|
(int)mVMStatSizes[0], (int)mVMStatSizes[1], (int)mVMStatSizes[2],
|
||||||
(int)mVMStatSizes[3], (int)mVMStatSizes[4]);
|
(int)mVMStatSizes[3], (int)mVMStatSizes[4]);
|
||||||
}
|
}
|
||||||
@ -635,7 +625,7 @@ public class Watchdog extends Thread {
|
|||||||
(now-mBootTime) >= (rebootIntervalMillis-rebootWindowMillis)) {
|
(now-mBootTime) >= (rebootIntervalMillis-rebootWindowMillis)) {
|
||||||
if (fromAlarm && rebootWindowMillis <= 0) {
|
if (fromAlarm && rebootWindowMillis <= 0) {
|
||||||
// No reboot window -- just immediately reboot.
|
// No reboot window -- just immediately reboot.
|
||||||
EventLog.writeEvent(EVENT_LOG_SCHEDULED_REBOOT_TAG, now,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_SCHEDULED_REBOOT, now,
|
||||||
(int)rebootIntervalMillis, (int)rebootStartTime*1000,
|
(int)rebootIntervalMillis, (int)rebootStartTime*1000,
|
||||||
(int)rebootWindowMillis, "");
|
(int)rebootWindowMillis, "");
|
||||||
rebootSystem("Checkin scheduled forced");
|
rebootSystem("Checkin scheduled forced");
|
||||||
@ -649,7 +639,7 @@ public class Watchdog extends Thread {
|
|||||||
now, rebootStartTime);
|
now, rebootStartTime);
|
||||||
} else if (now < (realStartTime+rebootWindowMillis)) {
|
} else if (now < (realStartTime+rebootWindowMillis)) {
|
||||||
String doit = shouldWeBeBrutalLocked(now);
|
String doit = shouldWeBeBrutalLocked(now);
|
||||||
EventLog.writeEvent(EVENT_LOG_SCHEDULED_REBOOT_TAG, now,
|
EventLog.writeEvent(EventLogTags.WATCHDOG_SCHEDULED_REBOOT, now,
|
||||||
(int)rebootInterval, (int)rebootStartTime*1000,
|
(int)rebootInterval, (int)rebootStartTime*1000,
|
||||||
(int)rebootWindowMillis, doit != null ? doit : "");
|
(int)rebootWindowMillis, doit != null ? doit : "");
|
||||||
if (doit == null) {
|
if (doit == null) {
|
||||||
@ -838,7 +828,7 @@ public class Watchdog extends Thread {
|
|||||||
// First send a SIGQUIT so that we can see where it was hung. Then
|
// First send a SIGQUIT so that we can see where it was hung. Then
|
||||||
// kill this process so that the system will restart.
|
// kill this process so that the system will restart.
|
||||||
String name = (mCurrentMonitor != null) ? mCurrentMonitor.getClass().getName() : "null";
|
String name = (mCurrentMonitor != null) ? mCurrentMonitor.getClass().getName() : "null";
|
||||||
EventLog.writeEvent(EVENT_LOG_TAG, name);
|
EventLog.writeEvent(EventLogTags.WATCHDOG, name);
|
||||||
Process.sendSignal(Process.myPid(), Process.SIGNAL_QUIT);
|
Process.sendSignal(Process.myPid(), Process.SIGNAL_QUIT);
|
||||||
|
|
||||||
// Wait a bit longer before killing so we can make sure that the stacks are captured.
|
// Wait a bit longer before killing so we can make sure that the stacks are captured.
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user