Search in sources :

Example 6 with UserInfo

use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.

the class SyncManager method doDatabaseCleanup.

private void doDatabaseCleanup() {
    for (UserInfo user : mUserManager.getUsers(true)) {
        // Skip any partially created/removed users
        if (user.partial)
            continue;
        Account[] accountsForUser = AccountManagerService.getSingleton().getAccounts(user.id);
        mSyncStorageEngine.doDatabaseCleanup(accountsForUser, user.id);
    }
}
Also used : Account(android.accounts.Account) UserInfo(android.content.pm.UserInfo)

Example 7 with UserInfo

use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.

the class SyncManager method dumpSyncState.

protected void dumpSyncState(PrintWriter pw) {
    pw.print("data connected: ");
    pw.println(mDataConnectionIsConnected);
    pw.print("auto sync: ");
    List<UserInfo> users = getAllUsers();
    if (users != null) {
        for (UserInfo user : users) {
            pw.print("u" + user.id + "=" + mSyncStorageEngine.getMasterSyncAutomatically(user.id) + " ");
        }
        pw.println();
    }
    pw.print("memory low: ");
    pw.println(mStorageIsLow);
    final AccountAndUser[] accounts = AccountManagerService.getSingleton().getAllAccounts();
    pw.print("accounts: ");
    if (accounts != INITIAL_ACCOUNTS_ARRAY) {
        pw.println(accounts.length);
    } else {
        pw.println("not known yet");
    }
    final long now = SystemClock.elapsedRealtime();
    pw.print("now: ");
    pw.print(now);
    pw.println(" (" + formatTime(System.currentTimeMillis()) + ")");
    pw.print("offset: ");
    pw.print(DateUtils.formatElapsedTime(mSyncRandomOffsetMillis / 1000));
    pw.println(" (HH:MM:SS)");
    pw.print("uptime: ");
    pw.print(DateUtils.formatElapsedTime(now / 1000));
    pw.println(" (HH:MM:SS)");
    pw.print("time spent syncing: ");
    pw.print(DateUtils.formatElapsedTime(mSyncHandler.mSyncTimeTracker.timeSpentSyncing() / 1000));
    pw.print(" (HH:MM:SS), sync ");
    pw.print(mSyncHandler.mSyncTimeTracker.mLastWasSyncing ? "" : "not ");
    pw.println("in progress");
    if (mSyncHandler.mAlarmScheduleTime != null) {
        pw.print("next alarm time: ");
        pw.print(mSyncHandler.mAlarmScheduleTime);
        pw.print(" (");
        pw.print(DateUtils.formatElapsedTime((mSyncHandler.mAlarmScheduleTime - now) / 1000));
        pw.println(" (HH:MM:SS) from now)");
    } else {
        pw.println("no alarm is scheduled (there had better not be any pending syncs)");
    }
    pw.print("notification info: ");
    final StringBuilder sb = new StringBuilder();
    mSyncHandler.mSyncNotificationInfo.toString(sb);
    pw.println(sb.toString());
    pw.println();
    pw.println("Active Syncs: " + mActiveSyncContexts.size());
    final PackageManager pm = mContext.getPackageManager();
    for (SyncManager.ActiveSyncContext activeSyncContext : mActiveSyncContexts) {
        final long durationInSeconds = (now - activeSyncContext.mStartTime) / 1000;
        pw.print("  ");
        pw.print(DateUtils.formatElapsedTime(durationInSeconds));
        pw.print(" - ");
        pw.print(activeSyncContext.mSyncOperation.dump(pm, false));
        pw.println();
    }
    synchronized (mSyncQueue) {
        sb.setLength(0);
        mSyncQueue.dump(sb);
    }
    pw.println();
    pw.print(sb.toString());
    // join the installed sync adapter with the accounts list and emit for everything
    pw.println();
    pw.println("Sync Status");
    for (AccountAndUser account : accounts) {
        pw.printf("Account %s u%d %s\n", account.account.name, account.userId, account.account.type);
        pw.println("=======================================================================");
        final PrintTable table = new PrintTable(13);
        table.set(0, 0, // 0
        "Authority", // 1
        "Syncable", // 2
        "Enabled", // 3
        "Delay", // 4
        "Loc", // 5
        "Poll", // 6
        "Per", // 7
        "Serv", // 8
        "User", // 9
        "Tot", // 10
        "Time", // 11
        "Last Sync", // 12
        "Periodic");
        final List<RegisteredServicesCache.ServiceInfo<SyncAdapterType>> sorted = Lists.newArrayList();
        sorted.addAll(mSyncAdapters.getAllServices(account.userId));
        Collections.sort(sorted, new Comparator<RegisteredServicesCache.ServiceInfo<SyncAdapterType>>() {

            @Override
            public int compare(RegisteredServicesCache.ServiceInfo<SyncAdapterType> lhs, RegisteredServicesCache.ServiceInfo<SyncAdapterType> rhs) {
                return lhs.type.authority.compareTo(rhs.type.authority);
            }
        });
        for (RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterType : sorted) {
            if (!syncAdapterType.type.accountType.equals(account.account.type)) {
                continue;
            }
            int row = table.getNumRows();
            SyncStorageEngine.AuthorityInfo settings = mSyncStorageEngine.getOrCreateAuthority(account.account, account.userId, syncAdapterType.type.authority);
            SyncStatusInfo status = mSyncStorageEngine.getOrCreateSyncStatus(settings);
            String authority = settings.authority;
            if (authority.length() > 50) {
                authority = authority.substring(authority.length() - 50);
            }
            table.set(row, 0, authority, settings.syncable, settings.enabled);
            table.set(row, 4, status.numSourceLocal, status.numSourcePoll, status.numSourcePeriodic, status.numSourceServer, status.numSourceUser, status.numSyncs, DateUtils.formatElapsedTime(status.totalElapsedTime / 1000));
            for (int i = 0; i < settings.periodicSyncs.size(); i++) {
                final Pair<Bundle, Long> pair = settings.periodicSyncs.get(0);
                final String period = String.valueOf(pair.second);
                final String extras = pair.first.size() > 0 ? pair.first.toString() : "";
                final String next = formatTime(status.getPeriodicSyncTime(0) + pair.second * 1000);
                table.set(row + i * 2, 12, period + extras);
                table.set(row + i * 2 + 1, 12, next);
            }
            int row1 = row;
            if (settings.delayUntil > now) {
                table.set(row1++, 12, "D: " + (settings.delayUntil - now) / 1000);
                if (settings.backoffTime > now) {
                    table.set(row1++, 12, "B: " + (settings.backoffTime - now) / 1000);
                    table.set(row1++, 12, settings.backoffDelay / 1000);
                }
            }
            if (status.lastSuccessTime != 0) {
                table.set(row1++, 11, SyncStorageEngine.SOURCES[status.lastSuccessSource] + " " + "SUCCESS");
                table.set(row1++, 11, formatTime(status.lastSuccessTime));
            }
            if (status.lastFailureTime != 0) {
                table.set(row1++, 11, SyncStorageEngine.SOURCES[status.lastFailureSource] + " " + "FAILURE");
                table.set(row1++, 11, formatTime(status.lastFailureTime));
                //noinspection UnusedAssignment
                table.set(row1++, 11, status.lastFailureMesg);
            }
        }
        table.writeTo(pw);
    }
}
Also used : UserInfo(android.content.pm.UserInfo) PackageManager(android.content.pm.PackageManager) AccountAndUser(android.accounts.AccountAndUser) Bundle(android.os.Bundle) SyncStatusInfo(android.content.SyncStatusInfo) SyncAdapterType(android.content.SyncAdapterType) RegisteredServicesCache(android.content.pm.RegisteredServicesCache)

Example 8 with UserInfo

use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.

the class SyncManager method dumpSyncAdapters.

private void dumpSyncAdapters(IndentingPrintWriter pw) {
    pw.println();
    final List<UserInfo> users = getAllUsers();
    if (users != null) {
        for (UserInfo user : users) {
            pw.println("Sync adapters for " + user + ":");
            pw.increaseIndent();
            for (RegisteredServicesCache.ServiceInfo<?> info : mSyncAdapters.getAllServices(user.id)) {
                pw.println(info);
            }
            pw.decreaseIndent();
            pw.println();
        }
    }
}
Also used : UserInfo(android.content.pm.UserInfo) RegisteredServicesCache(android.content.pm.RegisteredServicesCache)

Example 9 with UserInfo

use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.

the class UserManagerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump UserManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " without permission " + android.Manifest.permission.DUMP);
        return;
    }
    long now = System.currentTimeMillis();
    StringBuilder sb = new StringBuilder();
    synchronized (mPackagesLock) {
        pw.println("Users:");
        for (int i = 0; i < mUsers.size(); i++) {
            UserInfo user = mUsers.valueAt(i);
            if (user == null)
                continue;
            pw.print("  ");
            pw.print(user);
            pw.print(" serialNo=");
            pw.print(user.serialNumber);
            if (mRemovingUserIds.get(mUsers.keyAt(i)))
                pw.print(" <removing> ");
            if (user.partial)
                pw.print(" <partial>");
            pw.println();
            pw.print("    Created: ");
            if (user.creationTime == 0) {
                pw.println("<unknown>");
            } else {
                sb.setLength(0);
                TimeUtils.formatDuration(now - user.creationTime, sb);
                sb.append(" ago");
                pw.println(sb);
            }
            pw.print("    Last logged in: ");
            if (user.lastLoggedInTime == 0) {
                pw.println("<unknown>");
            } else {
                sb.setLength(0);
                TimeUtils.formatDuration(now - user.lastLoggedInTime, sb);
                sb.append(" ago");
                pw.println(sb);
            }
        }
    }
}
Also used : UserInfo(android.content.pm.UserInfo)

Example 10 with UserInfo

use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.

the class NetworkPolicyManagerService method updateRulesForRestrictBackgroundLocked.

/**
     * Update rules that might be changed by {@link #mRestrictBackground} value.
     */
private void updateRulesForRestrictBackgroundLocked() {
    final PackageManager pm = mContext.getPackageManager();
    final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    // update rules for all installed applications
    final List<UserInfo> users = um.getUsers();
    final List<ApplicationInfo> apps = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
    for (UserInfo user : users) {
        for (ApplicationInfo app : apps) {
            final int uid = UserHandle.getUid(user.id, app.uid);
            updateRulesForUidLocked(uid);
        }
    }
    // limit data usage for some internal system services
    updateRulesForUidLocked(android.os.Process.MEDIA_UID);
    updateRulesForUidLocked(android.os.Process.DRM_UID);
}
Also used : PackageManager(android.content.pm.PackageManager) UserManager(android.os.UserManager) ApplicationInfo(android.content.pm.ApplicationInfo) UserInfo(android.content.pm.UserInfo)

Aggregations

UserInfo (android.content.pm.UserInfo)814 UserManager (android.os.UserManager)156 RemoteException (android.os.RemoteException)144 ArrayList (java.util.ArrayList)73 UserHandle (android.os.UserHandle)66 Intent (android.content.Intent)58 IOException (java.io.IOException)52 File (java.io.File)47 Bundle (android.os.Bundle)43 ApplicationInfo (android.content.pm.ApplicationInfo)40 PackageManager (android.content.pm.PackageManager)39 ComponentName (android.content.ComponentName)32 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)31 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)30 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)29 AtomicFile (android.util.AtomicFile)28 PackageInfo (android.content.pm.PackageInfo)26 DevicePolicyManager (android.app.admin.DevicePolicyManager)25 LockPatternUtils (com.android.internal.widget.LockPatternUtils)24 PendingIntent (android.app.PendingIntent)23