use of android.app.usage.UsageStatsManagerInternal in project android_frameworks_base by crdroidandroid.
the class UsageStatsBackupHelper method getBackupPayload.
@Override
protected byte[] getBackupPayload(String key) {
if (KEY_USAGE_STATS.equals(key)) {
UsageStatsManagerInternal localUsageStatsManager = LocalServices.getService(UsageStatsManagerInternal.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
try {
out.writeInt(UserHandle.USER_SYSTEM);
out.write(localUsageStatsManager.getBackupPayload(UserHandle.USER_SYSTEM, key));
} catch (IOException ioe) {
if (DEBUG)
Log.e(TAG, "Failed to backup Usage Stats", ioe);
baos.reset();
}
return baos.toByteArray();
}
return null;
}
use of android.app.usage.UsageStatsManagerInternal in project android_frameworks_base by crdroidandroid.
the class UsageStatsBackupHelper method applyRestoredPayload.
@Override
protected void applyRestoredPayload(String key, byte[] payload) {
if (KEY_USAGE_STATS.equals(key)) {
UsageStatsManagerInternal localUsageStatsManager = LocalServices.getService(UsageStatsManagerInternal.class);
DataInputStream in = new DataInputStream(new ByteArrayInputStream(payload));
try {
int user = in.readInt();
byte[] restoreData = new byte[payload.length - 4];
in.read(restoreData, 0, restoreData.length);
localUsageStatsManager.applyRestoredPayload(user, key, restoreData);
} catch (IOException ioe) {
if (DEBUG)
Log.e(TAG, "Failed to restore Usage Stats", ioe);
}
}
}
use of android.app.usage.UsageStatsManagerInternal in project platform_frameworks_base by android.
the class UsageStatsBackupHelper method getBackupPayload.
@Override
protected byte[] getBackupPayload(String key) {
if (KEY_USAGE_STATS.equals(key)) {
UsageStatsManagerInternal localUsageStatsManager = LocalServices.getService(UsageStatsManagerInternal.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
try {
out.writeInt(UserHandle.USER_SYSTEM);
out.write(localUsageStatsManager.getBackupPayload(UserHandle.USER_SYSTEM, key));
} catch (IOException ioe) {
if (DEBUG)
Log.e(TAG, "Failed to backup Usage Stats", ioe);
baos.reset();
}
return baos.toByteArray();
}
return null;
}
use of android.app.usage.UsageStatsManagerInternal in project android_frameworks_base by AOSPA.
the class UsageStatsBackupHelper method getBackupPayload.
@Override
protected byte[] getBackupPayload(String key) {
if (KEY_USAGE_STATS.equals(key)) {
UsageStatsManagerInternal localUsageStatsManager = LocalServices.getService(UsageStatsManagerInternal.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
try {
out.writeInt(UserHandle.USER_SYSTEM);
out.write(localUsageStatsManager.getBackupPayload(UserHandle.USER_SYSTEM, key));
} catch (IOException ioe) {
if (DEBUG)
Log.e(TAG, "Failed to backup Usage Stats", ioe);
baos.reset();
}
return baos.toByteArray();
}
return null;
}
use of android.app.usage.UsageStatsManagerInternal in project android_frameworks_base by AOSPA.
the class UsageStatsBackupHelper method applyRestoredPayload.
@Override
protected void applyRestoredPayload(String key, byte[] payload) {
if (KEY_USAGE_STATS.equals(key)) {
UsageStatsManagerInternal localUsageStatsManager = LocalServices.getService(UsageStatsManagerInternal.class);
DataInputStream in = new DataInputStream(new ByteArrayInputStream(payload));
try {
int user = in.readInt();
byte[] restoreData = new byte[payload.length - 4];
in.read(restoreData, 0, restoreData.length);
localUsageStatsManager.applyRestoredPayload(user, key, restoreData);
} catch (IOException ioe) {
if (DEBUG)
Log.e(TAG, "Failed to restore Usage Stats", ioe);
}
}
}
Aggregations