use of android.os.WorkSource in project android_frameworks_base by ResurrectionRemix.
the class WindowState method pokeDrawLockLw.
public void pokeDrawLockLw(long timeout) {
if (isVisibleOrAdding()) {
if (mDrawLock == null) {
// We want the tag name to be somewhat stable so that it is easier to correlate
// in wake lock statistics. So in particular, we don't want to include the
// window's hash code as in toString().
final CharSequence tag = getWindowTag();
mDrawLock = mService.mPowerManager.newWakeLock(PowerManager.DRAW_WAKE_LOCK, "Window:" + tag);
mDrawLock.setReferenceCounted(false);
mDrawLock.setWorkSource(new WorkSource(mOwnerUid, mAttrs.packageName));
}
// Each call to acquire resets the timeout.
if (DEBUG_POWER) {
Slog.d(TAG, "pokeDrawLock: poking draw lock on behalf of visible window owned by " + mAttrs.packageName);
}
mDrawLock.acquire(timeout);
} else if (DEBUG_POWER) {
Slog.d(TAG, "pokeDrawLock: suppressed draw lock request for invisible window " + "owned by " + mAttrs.packageName);
}
}
use of android.os.WorkSource in project android_frameworks_base by ResurrectionRemix.
the class LocationManagerService method requestLocationUpdates.
@Override
public void requestLocationUpdates(LocationRequest request, ILocationListener listener, PendingIntent intent, String packageName) {
if (request == null)
request = DEFAULT_LOCATION_REQUEST;
checkPackageName(packageName);
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
checkResolutionLevelIsSufficientForProviderUse(allowedResolutionLevel, request.getProvider());
WorkSource workSource = request.getWorkSource();
if (workSource != null && workSource.size() > 0) {
checkDeviceStatsAllowed();
}
boolean hideFromAppOps = request.getHideFromAppOps();
if (hideFromAppOps) {
checkUpdateAppOpsAllowed();
}
LocationRequest sanitizedRequest = createSanitizedRequest(request, allowedResolutionLevel);
final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid();
// providers may use public location API's, need to clear identity
long identity = Binder.clearCallingIdentity();
try {
// We don't check for MODE_IGNORED here; we will do that when we go to deliver
// a location.
checkLocationAccess(pid, uid, packageName, allowedResolutionLevel);
synchronized (mLock) {
Receiver recevier = checkListenerOrIntentLocked(listener, intent, pid, uid, packageName, workSource, hideFromAppOps);
requestLocationUpdatesLocked(sanitizedRequest, recevier, pid, uid, packageName);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.os.WorkSource in project android_frameworks_base by ResurrectionRemix.
the class LocationManagerService method applyRequirementsLocked.
private void applyRequirementsLocked(String provider) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null)
return;
ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider);
WorkSource worksource = new WorkSource();
ProviderRequest providerRequest = new ProviderRequest();
if (records != null) {
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
if (checkLocationAccess(record.mReceiver.mPid, record.mReceiver.mUid, record.mReceiver.mPackageName, record.mReceiver.mAllowedResolutionLevel)) {
LocationRequest locationRequest = record.mRequest;
providerRequest.locationRequests.add(locationRequest);
if (locationRequest.getInterval() < providerRequest.interval) {
providerRequest.reportLocation = true;
providerRequest.interval = locationRequest.getInterval();
}
}
}
}
if (providerRequest.reportLocation) {
// calculate who to blame for power
// This is somewhat arbitrary. We pick a threshold interval
// that is slightly higher that the minimum interval, and
// spread the blame across all applications with a request
// under that threshold.
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
LocationRequest locationRequest = record.mRequest;
// client has no permission to receive location data.
if (!providerRequest.locationRequests.contains(locationRequest)) {
continue;
}
if (locationRequest.getInterval() <= thresholdInterval) {
if (record.mReceiver.mWorkSource != null && record.mReceiver.mWorkSource.size() > 0 && record.mReceiver.mWorkSource.getName(0) != null) {
// Assign blame to another work source.
// Can only assign blame if the WorkSource contains names.
worksource.add(record.mReceiver.mWorkSource);
} else {
// Assign blame to caller.
worksource.add(record.mReceiver.mUid, record.mReceiver.mPackageName);
}
}
}
}
}
}
if (D)
Log.d(TAG, "provider request: " + provider + " " + providerRequest);
p.setRequest(providerRequest, worksource);
}
use of android.os.WorkSource in project android_frameworks_base by ResurrectionRemix.
the class WindowManagerService method setHoldScreenLocked.
void setHoldScreenLocked(final Session newHoldScreen) {
final boolean hold = newHoldScreen != null;
if (hold && mHoldingScreenOn != newHoldScreen) {
mHoldingScreenWakeLock.setWorkSource(new WorkSource(newHoldScreen.mUid));
}
mHoldingScreenOn = newHoldScreen;
final boolean state = mHoldingScreenWakeLock.isHeld();
if (hold != state) {
if (hold) {
if (DEBUG_KEEP_SCREEN_ON) {
Slog.d(TAG_KEEP_SCREEN_ON, "Acquiring screen wakelock due to " + mWindowPlacerLocked.mHoldScreenWindow);
}
mLastWakeLockHoldingWindow = mWindowPlacerLocked.mHoldScreenWindow;
mLastWakeLockObscuringWindow = null;
mHoldingScreenWakeLock.acquire();
mPolicy.keepScreenOnStartedLw();
} else {
if (DEBUG_KEEP_SCREEN_ON) {
Slog.d(TAG_KEEP_SCREEN_ON, "Releasing screen wakelock, obscured by " + mWindowPlacerLocked.mObsuringWindow);
}
mLastWakeLockHoldingWindow = null;
mLastWakeLockObscuringWindow = mWindowPlacerLocked.mObsuringWindow;
mPolicy.keepScreenOnStoppedLw();
mHoldingScreenWakeLock.release();
}
}
}
use of android.os.WorkSource in project android_frameworks_base by crdroidandroid.
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) {
synchronized (mInstallLock) {
final boolean useLock = mSystemReady;
if (useLock) {
mDexoptWakeLock.setWorkSource(new WorkSource(pkg.applicationInfo.uid));
mDexoptWakeLock.acquire();
}
try {
return performDexOptLI(pkg, sharedLibraries, instructionSets, checkProfiles, targetCompilationFilter, packageStats);
} finally {
if (useLock) {
mDexoptWakeLock.release();
}
}
}
}
Aggregations