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);
}
}
}
}
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);
}
}
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);
}
}
}
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();
}
}
}
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);
}
}
}
}
Aggregations