Search in sources :

Example 11 with UsageStatsManagerInternal

use of android.app.usage.UsageStatsManagerInternal in project android_frameworks_base by DirtyUnicorns.

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;
}
Also used : DataOutputStream(java.io.DataOutputStream) UsageStatsManagerInternal(android.app.usage.UsageStatsManagerInternal) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

UsageStatsManagerInternal (android.app.usage.UsageStatsManagerInternal)11 IOException (java.io.IOException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 DataInputStream (java.io.DataInputStream)5 DataOutputStream (java.io.DataOutputStream)5 BeforeClass (org.junit.BeforeClass)1