Search in sources :

Example 86 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method finishBooting.

final void finishBooting() {
    synchronized (this) {
        if (!mBootAnimationComplete) {
            mCallFinishBooting = true;
            return;
        }
        mCallFinishBooting = false;
    }
    ArraySet<String> completedIsas = new ArraySet<String>();
    for (String abi : Build.SUPPORTED_ABIS) {
        Process.establishZygoteConnectionForAbi(abi);
        final String instructionSet = VMRuntime.getInstructionSet(abi);
        if (!completedIsas.contains(instructionSet)) {
            try {
                mInstaller.markBootComplete(VMRuntime.getInstructionSet(abi));
            } catch (InstallerException e) {
                Slog.w(TAG, "Unable to mark boot complete for abi: " + abi + " (" + e.getMessage() + ")");
            }
            completedIsas.add(instructionSet);
        }
    }
    IntentFilter pkgFilter = new IntentFilter();
    pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
    pkgFilter.addDataScheme("package");
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String[] pkgs = intent.getStringArrayExtra(Intent.EXTRA_PACKAGES);
            if (pkgs != null) {
                for (String pkg : pkgs) {
                    synchronized (ActivityManagerService.this) {
                        if (forceStopPackageLocked(pkg, -1, false, false, false, false, false, 0, "query restart")) {
                            setResultCode(Activity.RESULT_OK);
                            return;
                        }
                    }
                }
            }
        }
    }, pkgFilter);
    IntentFilter dumpheapFilter = new IntentFilter();
    dumpheapFilter.addAction(DumpHeapActivity.ACTION_DELETE_DUMPHEAP);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getBooleanExtra(DumpHeapActivity.EXTRA_DELAY_DELETE, false)) {
                mHandler.sendEmptyMessageDelayed(POST_DUMP_HEAP_NOTIFICATION_MSG, 5 * 60 * 1000);
            } else {
                mHandler.sendEmptyMessage(POST_DUMP_HEAP_NOTIFICATION_MSG);
            }
        }
    }, dumpheapFilter);
    // Let system services know.
    mSystemServiceManager.startBootPhase(SystemService.PHASE_BOOT_COMPLETED);
    synchronized (this) {
        // Ensure that any processes we had put on hold are now started
        // up.
        final int NP = mProcessesOnHold.size();
        if (NP > 0) {
            ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mProcessesOnHold);
            for (int ip = 0; ip < NP; ip++) {
                if (DEBUG_PROCESSES)
                    Slog.v(TAG_PROCESSES, "Starting process on hold: " + procs.get(ip));
                startProcessLocked(procs.get(ip), "on-hold", null);
            }
        }
        if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
            // Start looking for apps that are abusing wake locks.
            Message nmsg = mHandler.obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
            mHandler.sendMessageDelayed(nmsg, POWER_CHECK_DELAY);
            // Tell anyone interested that we are done booting!
            SystemProperties.set("sys.boot_completed", "1");
            // And trigger dev.bootcomplete if we are not showing encryption progress
            if (!"trigger_restart_min_framework".equals(SystemProperties.get("vold.decrypt")) || "".equals(SystemProperties.get("vold.encrypt_progress"))) {
                SystemProperties.set("dev.bootcomplete", "1");
            }
            mUserController.sendBootCompletedLocked(new IIntentReceiver.Stub() {

                @Override
                public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
                    synchronized (ActivityManagerService.this) {
                        requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
                    }
                }
            });
            scheduleStartProfilesLocked();
        }
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) ArraySet(android.util.ArraySet) Message(android.os.Message) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) ArrayList(java.util.ArrayList) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) Point(android.graphics.Point) IIntentReceiver(android.content.IIntentReceiver) InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

Example 87 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by AOSPA.

the class SharedStorageAgent method onFullBackup.

/**
     * Full backup of the shared-storage filesystem
     */
@Override
public void onFullBackup(FullBackupDataOutput output) throws IOException {
    // "primary" shared storage volume is first in the list.
    if (mVolumes != null) {
        if (DEBUG)
            Slog.i(TAG, "Backing up " + mVolumes.length + " shared volumes");
        // Ignore all apps' getExternalFilesDir() content; it is backed up as part of
        // each app-specific payload.
        ArraySet<String> externalFilesDirFilter = new ArraySet();
        final File externalAndroidRoot = new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_ANDROID);
        externalFilesDirFilter.add(externalAndroidRoot.getCanonicalPath());
        for (int i = 0; i < mVolumes.length; i++) {
            StorageVolume v = mVolumes[i];
            // Express the contents of volume N this way in the tar stream:
            //     shared/N/path/to/file
            // The restore will then extract to the given volume
            String domain = FullBackup.SHARED_PREFIX + i;
            fullBackupFileTree(null, domain, v.getPath(), null, /* manifestExcludes */
            externalFilesDirFilter, /* systemExcludes */
            output);
        }
    }
}
Also used : StorageVolume(android.os.storage.StorageVolume) ArraySet(android.util.ArraySet) File(java.io.File)

Example 88 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by AOSPA.

the class AppWidgetServiceImpl method updateWidgetPackageSuspensionMaskedState.

/**
     * Incrementally update the masked state due to package suspension state.
     */
private void updateWidgetPackageSuspensionMaskedState(String[] packagesArray, boolean suspended, int profileId) {
    if (packagesArray == null) {
        return;
    }
    Set<String> packages = new ArraySet<String>(Arrays.asList(packagesArray));
    synchronized (mLock) {
        final int N = mProviders.size();
        for (int i = 0; i < N; i++) {
            Provider provider = mProviders.get(i);
            int providerUserId = provider.getUserId();
            if (providerUserId != profileId || !packages.contains(provider.info.provider.getPackageName())) {
                continue;
            }
            if (provider.setMaskedBySuspendedPackageLocked(suspended)) {
                if (provider.isMaskedLocked()) {
                    maskWidgetsViewsLocked(provider, null);
                } else {
                    unmaskWidgetsViewsLocked(provider);
                }
            }
        }
    }
}
Also used : ArraySet(android.util.ArraySet) Point(android.graphics.Point) WidgetBackupProvider(com.android.server.WidgetBackupProvider)

Example 89 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by AOSPA.

the class UserController method unlockUserCleared.

boolean unlockUserCleared(final int userId, byte[] token, byte[] secret, IProgressListener listener) {
    UserState uss;
    synchronized (mService) {
        // TODO Move this block outside of synchronized if it causes lock contention
        if (!StorageManager.isUserKeyUnlocked(userId)) {
            final UserInfo userInfo = getUserInfo(userId);
            final IMountService mountService = getMountService();
            try {
                // We always want to unlock user storage, even user is not started yet
                mountService.unlockUserKey(userId, userInfo.serialNumber, token, secret);
            } catch (RemoteException | RuntimeException e) {
                Slog.w(TAG, "Failed to unlock: " + e.getMessage());
            }
        }
        // Bail if user isn't actually running, otherwise register the given
        // listener to watch for unlock progress
        uss = mStartedUsers.get(userId);
        if (uss == null) {
            notifyFinished(userId, listener);
            return false;
        } else {
            uss.mUnlockProgress.addListener(listener);
            uss.tokenProvided = (token != null);
        }
    }
    finishUserUnlocking(uss);
    final ArraySet<Integer> childProfilesToUnlock = new ArraySet<>();
    synchronized (mService) {
        // managed profiles under that user.
        for (int i = 0; i < mStartedUsers.size(); i++) {
            final int testUserId = mStartedUsers.keyAt(i);
            final UserInfo parent = getUserManager().getProfileParent(testUserId);
            if (parent != null && parent.id == userId && testUserId != userId) {
                Slog.d(TAG, "User " + testUserId + " (parent " + parent.id + "): attempting unlock because parent was just unlocked");
                childProfilesToUnlock.add(testUserId);
            }
        }
    }
    final int size = childProfilesToUnlock.size();
    for (int i = 0; i < size; i++) {
        maybeUnlockUser(childProfilesToUnlock.valueAt(i));
    }
    return true;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArraySet(android.util.ArraySet) IMountService(android.os.storage.IMountService) UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException)

Example 90 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by AOSPA.

the class UserController method dispatchUserSwitch.

void dispatchUserSwitch(final UserState uss, final int oldUserId, final int newUserId) {
    Slog.d(TAG, "Dispatch onUserSwitching oldUser #" + oldUserId + " newUser #" + newUserId);
    final int observerCount = mUserSwitchObservers.beginBroadcast();
    if (observerCount > 0) {
        final ArraySet<String> curWaitingUserSwitchCallbacks = new ArraySet<>();
        synchronized (mService) {
            uss.switching = true;
            mCurWaitingUserSwitchCallbacks = curWaitingUserSwitchCallbacks;
        }
        final AtomicInteger waitingCallbacksCount = new AtomicInteger(observerCount);
        final long dispatchStartedTime = SystemClock.elapsedRealtime();
        for (int i = 0; i < observerCount; i++) {
            try {
                // Prepend with unique prefix to guarantee that keys are unique
                final String name = "#" + i + " " + mUserSwitchObservers.getBroadcastCookie(i);
                synchronized (mService) {
                    curWaitingUserSwitchCallbacks.add(name);
                }
                final IRemoteCallback callback = new IRemoteCallback.Stub() {

                    @Override
                    public void sendResult(Bundle data) throws RemoteException {
                        synchronized (mService) {
                            long delay = SystemClock.elapsedRealtime() - dispatchStartedTime;
                            if (delay > USER_SWITCH_TIMEOUT) {
                                Slog.wtf(TAG, "User switch timeout: observer " + name + " sent result after " + delay + " ms");
                            }
                            // Early return if this session is no longer valid
                            if (curWaitingUserSwitchCallbacks != mCurWaitingUserSwitchCallbacks) {
                                return;
                            }
                            curWaitingUserSwitchCallbacks.remove(name);
                            // Continue switching if all callbacks have been notified
                            if (waitingCallbacksCount.decrementAndGet() == 0) {
                                sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
                            }
                        }
                    }
                };
                mUserSwitchObservers.getBroadcastItem(i).onUserSwitching(newUserId, callback);
            } catch (RemoteException e) {
            }
        }
    } else {
        synchronized (mService) {
            sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
        }
    }
    mUserSwitchObservers.finishBroadcast();
}
Also used : ArraySet(android.util.ArraySet) IRemoteCallback(android.os.IRemoteCallback) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Aggregations

ArraySet (android.util.ArraySet)521 PublicKey (java.security.PublicKey)94 ArrayList (java.util.ArrayList)87 ComponentName (android.content.ComponentName)82 ArrayMap (android.util.ArrayMap)73 Pair (android.util.Pair)47 RemoteException (android.os.RemoteException)43 ResolveInfo (android.content.pm.ResolveInfo)39 Intent (android.content.Intent)38 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)35 File (java.io.File)33 SSLContext (javax.net.ssl.SSLContext)32 IOException (java.io.IOException)31 PackageManager (android.content.pm.PackageManager)29 UserInfo (android.content.pm.UserInfo)28 ApplicationInfo (android.content.pm.ApplicationInfo)24 Point (android.graphics.Point)24 X509Certificate (java.security.cert.X509Certificate)20 PackageInfo (android.content.pm.PackageInfo)19 Test (org.junit.Test)19