Search in sources :

Example 1 with WorkSource

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

the class GpsLocationProvider method updateClientUids.

private void updateClientUids(WorkSource source) {
    // Update work source.
    WorkSource[] changes = mClientSource.setReturningDiffs(source);
    if (changes == null) {
        return;
    }
    WorkSource newWork = changes[0];
    WorkSource goneWork = changes[1];
    // Update sources that were not previously tracked.
    if (newWork != null) {
        int lastuid = -1;
        for (int i = 0; i < newWork.size(); i++) {
            try {
                int uid = newWork.get(i);
                mAppOpsService.startOperation(AppOpsManager.OP_GPS, uid, newWork.getName(i));
                if (uid != lastuid) {
                    lastuid = uid;
                    mBatteryStats.noteStartGps(uid);
                }
            } catch (RemoteException e) {
                Log.w(TAG, "RemoteException", e);
            }
        }
    }
    // Update sources that are no longer tracked.
    if (goneWork != null) {
        int lastuid = -1;
        for (int i = 0; i < goneWork.size(); i++) {
            try {
                int uid = goneWork.get(i);
                mAppOpsService.finishOperation(AppOpsManager.OP_GPS, uid, goneWork.getName(i));
                if (uid != lastuid) {
                    lastuid = uid;
                    mBatteryStats.noteStopGps(uid);
                }
            } catch (RemoteException e) {
                Log.w(TAG, "RemoteException", e);
            }
        }
    }
}
Also used : WorkSource(android.os.WorkSource) RemoteException(android.os.RemoteException)

Example 2 with WorkSource

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

the class WifiService method acquireWifiLock.

public boolean acquireWifiLock(IBinder binder, int lockMode, String tag, WorkSource ws) {
    mContext.enforceCallingOrSelfPermission(android.Manifest.permission.WAKE_LOCK, null);
    if (lockMode != WifiManager.WIFI_MODE_FULL && lockMode != WifiManager.WIFI_MODE_SCAN_ONLY && lockMode != WifiManager.WIFI_MODE_FULL_HIGH_PERF) {
        Slog.e(TAG, "Illegal argument, lockMode= " + lockMode);
        if (DBG)
            throw new IllegalArgumentException("lockMode=" + lockMode);
        return false;
    }
    if (ws != null && ws.size() == 0) {
        ws = null;
    }
    if (ws != null) {
        enforceWakeSourcePermission(Binder.getCallingUid(), Binder.getCallingPid());
    }
    if (ws == null) {
        ws = new WorkSource(Binder.getCallingUid());
    }
    WifiLock wifiLock = new WifiLock(lockMode, tag, binder, ws);
    synchronized (mLocks) {
        return acquireWifiLockLocked(wifiLock);
    }
}
Also used : WorkSource(android.os.WorkSource)

Example 3 with WorkSource

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

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 4 with WorkSource

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

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 5 with WorkSource

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

the class GnssLocationProvider method updateClientUids.

private void updateClientUids(WorkSource source) {
    // Update work source.
    WorkSource[] changes = mClientSource.setReturningDiffs(source);
    if (changes == null) {
        return;
    }
    WorkSource newWork = changes[0];
    WorkSource goneWork = changes[1];
    // Update sources that were not previously tracked.
    if (newWork != null) {
        int lastuid = -1;
        for (int i = 0; i < newWork.size(); i++) {
            try {
                int uid = newWork.get(i);
                mAppOpsService.startOperation(AppOpsManager.getToken(mAppOpsService), AppOpsManager.OP_GPS, uid, newWork.getName(i));
                if (uid != lastuid) {
                    lastuid = uid;
                    mBatteryStats.noteStartGps(uid);
                }
            } catch (RemoteException e) {
                Log.w(TAG, "RemoteException", e);
            }
        }
    }
    // Update sources that are no longer tracked.
    if (goneWork != null) {
        int lastuid = -1;
        for (int i = 0; i < goneWork.size(); i++) {
            try {
                int uid = goneWork.get(i);
                mAppOpsService.finishOperation(AppOpsManager.getToken(mAppOpsService), AppOpsManager.OP_GPS, uid, goneWork.getName(i));
                if (uid != lastuid) {
                    lastuid = uid;
                    mBatteryStats.noteStopGps(uid);
                }
            } catch (RemoteException e) {
                Log.w(TAG, "RemoteException", e);
            }
        }
    }
}
Also used : WorkSource(android.os.WorkSource) RemoteException(android.os.RemoteException)

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