Search in sources :

Example 31 with WorkSource

use of android.os.WorkSource in project platform_frameworks_base by android.

the class PackageDexOptimizer method dexOptSecondaryDexPath.

/**
     * Performs dexopt on the secondary dex {@code path} belonging to the app {@code info}.
     *
     * @return
     *      DEX_OPT_FAILED if there was any exception during dexopt
     *      DEX_OPT_PERFORMED if dexopt was performed successfully on the given path.
     * NOTE that DEX_OPT_PERFORMED for secondary dex files includes the case when the dex file
     * didn't need an update. That's because at the moment we don't get more than success/failure
     * from installd.
     *
     * TODO(calin): Consider adding return codes to installd dexopt invocation (rather than
     * throwing exceptions). Or maybe make a separate call to installd to get DexOptNeeded, though
     * that seems wasteful.
     */
public int dexOptSecondaryDexPath(ApplicationInfo info, String path, Set<String> isas, String compilerFilter, boolean isUsedByOtherApps) {
    synchronized (mInstallLock) {
        // During boot the system doesn't need to instantiate and obtain a wake lock.
        // PowerManager might not be ready, but that doesn't mean that we can't proceed with
        // dexopt.
        final boolean useLock = mSystemReady;
        if (useLock) {
            mDexoptWakeLock.setWorkSource(new WorkSource(info.uid));
            mDexoptWakeLock.acquire();
        }
        try {
            return dexOptSecondaryDexPathLI(info, path, isas, compilerFilter, isUsedByOtherApps);
        } finally {
            if (useLock) {
                mDexoptWakeLock.release();
            }
        }
    }
}
Also used : WorkSource(android.os.WorkSource)

Example 32 with WorkSource

use of android.os.WorkSource in project platform_frameworks_base by android.

the class PackageDexOptimizer method performDexOpt.

/**
     * Performs dexopt on all code paths and libraries of the specified package for specified
     * instruction sets.
     *
     * <p>Calls to {@link com.android.server.pm.Installer#dexopt} on {@link #mInstaller} are
     * synchronized on {@link #mInstallLock}.
     */
int performDexOpt(PackageParser.Package pkg, String[] sharedLibraries, String[] instructionSets, boolean checkProfiles, String targetCompilationFilter, CompilerStats.PackageStats packageStats, boolean isUsedByOtherApps) {
    if (!canOptimizePackage(pkg)) {
        return DEX_OPT_SKIPPED;
    }
    synchronized (mInstallLock) {
        // During boot the system doesn't need to instantiate and obtain a wake lock.
        // PowerManager might not be ready, but that doesn't mean that we can't proceed with
        // dexopt.
        final boolean useLock = mSystemReady;
        if (useLock) {
            mDexoptWakeLock.setWorkSource(new WorkSource(pkg.applicationInfo.uid));
            mDexoptWakeLock.acquire();
        }
        try {
            return performDexOptLI(pkg, sharedLibraries, instructionSets, checkProfiles, targetCompilationFilter, packageStats, isUsedByOtherApps);
        } finally {
            if (useLock) {
                mDexoptWakeLock.release();
            }
        }
    }
}
Also used : WorkSource(android.os.WorkSource)

Example 33 with WorkSource

use of android.os.WorkSource in project platform_frameworks_base by android.

the class AlarmManagerService method setWakelockWorkSource.

/**
     * Attribute blame for a WakeLock.
     * @param pi PendingIntent to attribute blame to if ws is null.
     * @param ws WorkSource to attribute blame.
     * @param knownUid attribution uid; < 0 if we need to derive it from the PendingIntent sender
     */
void setWakelockWorkSource(PendingIntent pi, WorkSource ws, int type, String tag, int knownUid, boolean first) {
    try {
        final boolean unimportant = pi == mTimeTickSender;
        mWakeLock.setUnimportantForLogging(unimportant);
        if (first || mLastWakeLockUnimportantForLogging) {
            mWakeLock.setHistoryTag(tag);
        } else {
            mWakeLock.setHistoryTag(null);
        }
        mLastWakeLockUnimportantForLogging = unimportant;
        if (ws != null) {
            mWakeLock.setWorkSource(ws);
            return;
        }
        final int uid = (knownUid >= 0) ? knownUid : ActivityManagerNative.getDefault().getUidForIntentSender(pi.getTarget());
        if (uid >= 0) {
            mWakeLock.setWorkSource(new WorkSource(uid));
            return;
        }
    } catch (Exception e) {
    }
    // Something went wrong; fall back to attributing the lock to the OS
    mWakeLock.setWorkSource(null);
}
Also used : WorkSource(android.os.WorkSource) RemoteException(android.os.RemoteException)

Example 34 with WorkSource

use of android.os.WorkSource in project platform_frameworks_base by android.

the class GnssLocationProvider method updateRequirements.

// Called when the requirements for GPS may have changed
private void updateRequirements() {
    if (mProviderRequest == null || mWorkSource == null) {
        return;
    }
    boolean singleShot = false;
    // see if the request is for a single update
    if (mProviderRequest.locationRequests != null && mProviderRequest.locationRequests.size() > 0) {
        // if any request has zero or more than one updates
        // requested, then this is not single-shot mode
        singleShot = true;
        for (LocationRequest lr : mProviderRequest.locationRequests) {
            if (lr.getNumUpdates() != 1) {
                singleShot = false;
            }
        }
    }
    if (DEBUG)
        Log.d(TAG, "setRequest " + mProviderRequest);
    if (mProviderRequest.reportLocation && !mDisableGps && isEnabled()) {
        // update client uids
        updateClientUids(mWorkSource);
        mFixInterval = (int) mProviderRequest.interval;
        // check for overflow
        if (mFixInterval != mProviderRequest.interval) {
            Log.w(TAG, "interval overflow: " + mProviderRequest.interval);
            mFixInterval = Integer.MAX_VALUE;
        }
        // apply request to GPS engine
        if (mStarted && hasCapability(GPS_CAPABILITY_SCHEDULING)) {
            // change period
            if (!native_set_position_mode(mPositionMode, GPS_POSITION_RECURRENCE_PERIODIC, mFixInterval, 0, 0)) {
                Log.e(TAG, "set_position_mode failed in setMinTime()");
            }
        } else if (!mStarted) {
            // start GPS
            startNavigating(singleShot);
        }
    } else {
        updateClientUids(new WorkSource());
        stopNavigating();
        mAlarmManager.cancel(mWakeupIntent);
        mAlarmManager.cancel(mTimeoutIntent);
    }
}
Also used : LocationRequest(android.location.LocationRequest) WorkSource(android.os.WorkSource)

Example 35 with WorkSource

use of android.os.WorkSource in project platform_frameworks_base by android.

the class GnssLocationProvider method handleDisable.

private void handleDisable() {
    if (DEBUG)
        Log.d(TAG, "handleDisable");
    updateClientUids(new WorkSource());
    stopNavigating();
    mAlarmManager.cancel(mWakeupIntent);
    mAlarmManager.cancel(mTimeoutIntent);
    // do this before releasing wakelock
    native_cleanup();
    mGnssMeasurementsProvider.onGpsEnabledChanged();
    mGnssNavigationMessageProvider.onGpsEnabledChanged();
}
Also used : WorkSource(android.os.WorkSource)

Aggregations

WorkSource (android.os.WorkSource)60 LocationRequest (android.location.LocationRequest)17 RemoteException (android.os.RemoteException)11 BroadcastReceiver (android.content.BroadcastReceiver)10 ProviderRequest (com.android.internal.location.ProviderRequest)6 LocationProviderInterface (com.android.server.location.LocationProviderInterface)6 PowerManager (android.os.PowerManager)5 JobStatus (com.android.server.job.controllers.JobStatus)5