Search in sources :

Example 41 with WorkSource

use of android.os.WorkSource in project android_frameworks_base by DirtyUnicorns.

the class LocationManagerService method removeUpdates.

@Override
public void removeUpdates(ILocationListener listener, PendingIntent intent, String packageName) {
    checkPackageName(packageName);
    final int pid = Binder.getCallingPid();
    final int uid = Binder.getCallingUid();
    synchronized (mLock) {
        WorkSource workSource = null;
        boolean hideFromAppOps = false;
        Receiver receiver = checkListenerOrIntentLocked(listener, intent, pid, uid, packageName, workSource, hideFromAppOps);
        // providers may use public location API's, need to clear identity
        long identity = Binder.clearCallingIdentity();
        try {
            removeUpdatesLocked(receiver);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }
}
Also used : BroadcastReceiver(android.content.BroadcastReceiver) WorkSource(android.os.WorkSource)

Example 42 with WorkSource

use of android.os.WorkSource in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method startRunningVoiceLocked.

void startRunningVoiceLocked(IVoiceInteractionSession session, int targetUid) {
    Slog.d(TAG, "<<<  startRunningVoiceLocked()");
    mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
    if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
        boolean wasRunningVoice = mRunningVoice != null;
        mRunningVoice = session;
        if (!wasRunningVoice) {
            mVoiceWakeLock.acquire();
            updateSleepIfNeededLocked();
        }
    }
}
Also used : WorkSource(android.os.WorkSource)

Example 43 with WorkSource

use of android.os.WorkSource in project android_frameworks_base by DirtyUnicorns.

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();
        }
    }
}
Also used : WorkSource(android.os.WorkSource)

Example 44 with WorkSource

use of android.os.WorkSource in project android_frameworks_base by DirtyUnicorns.

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);
    }
}
Also used : WorkSource(android.os.WorkSource)

Example 45 with WorkSource

use of android.os.WorkSource in project android_frameworks_base by AOSPA.

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 (record != null && record.mReceiver != null && 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 (record != null && record.mReceiver != null && 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);
}
Also used : LocationRequest(android.location.LocationRequest) WorkSource(android.os.WorkSource) LocationProviderInterface(com.android.server.location.LocationProviderInterface) ProviderRequest(com.android.internal.location.ProviderRequest)

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