android.os.WorkSource Java Examples
The following examples show how to use
android.os.WorkSource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlarmManagerHook.java From zjdroid with Apache License 2.0 | 6 votes |
@Override public void startHook() { Method setImplmethod = RefInvoke.findMethodExact( "android.app.AlarmManager", ClassLoader.getSystemClassLoader(), "setImpl",int.class,long.class,long.class,long.class,PendingIntent.class,WorkSource.class); hookhelper.hookMethod(setImplmethod, new AbstractBahaviorHookCallBack() { @Override public void descParam(HookParam param) { Logger.log_behavior("The Alarm Information:"); PendingIntent intent = (PendingIntent) param.args[4]; descPendingIntent(intent); Logger.log_behavior("TriggerAtMillis = "+param.args[1]); Logger.log_behavior("windowMillis = "+param.args[2]); Logger.log_behavior("intervalMillis = "+param.args[3]); } }); }
Example #2
Source File: MockLollipopScanner.java From bitgatt with Mozilla Public License 2.0 | 6 votes |
public BleScanCallbackWrapper(IBluetoothGatt bluetoothGatt, List<ScanFilter> filters, ScanSettings settings, WorkSource workSource, ScanCallback scanCallback, List<List<ResultStorageDescriptor>> resultStorages) { mBluetoothGatt = bluetoothGatt; mFilters = filters; mSettings = settings; mWorkSource = workSource; mScanCallback = scanCallback; mScannerId = 0; mResultStorages = resultStorages; }
Example #3
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override // Binder call public void updateWakeLockWorkSource(IBinder lock, WorkSource ws, String historyTag) { if (lock == null) { throw new IllegalArgumentException("lock must not be null"); } mContext.enforceCallingOrSelfPermission(android.Manifest.permission.WAKE_LOCK, null); if (ws != null && !ws.isEmpty()) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.UPDATE_DEVICE_STATS, null); } else { ws = null; } final int callingUid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { updateWakeLockWorkSourceInternal(lock, ws, historyTag, callingUid); } finally { Binder.restoreCallingIdentity(ident); } }
Example #4
Source File: AlarmManagerHook.java From HeyGirl with Apache License 2.0 | 6 votes |
@Override public void startHook() { Method setImplmethod = RefInvoke.findMethodExact( "android.app.AlarmManager", ClassLoader.getSystemClassLoader(), "setImpl",int.class,long.class,long.class,long.class,PendingIntent.class,WorkSource.class); hookhelper.hookMethod(setImplmethod, new AbstractBahaviorHookCallBack() { @Override public void descParam(HookParam param) { Logger.log_behavior("The Alarm Information:"); PendingIntent intent = (PendingIntent) param.args[4]; if(intent != null) descPendingIntent(intent); Logger.log_behavior("TriggerAtMillis = "+param.args[1]); Logger.log_behavior("windowMillis = "+param.args[2]); Logger.log_behavior("intervalMillis = "+param.args[3]); } }); }
Example #5
Source File: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void setImplLocked(int type, long when, long whenElapsed, long windowLength, long maxWhen, long interval, PendingIntent operation, IAlarmListener directReceiver, String listenerTag, int flags, boolean doValidate, WorkSource workSource, AlarmManager.AlarmClockInfo alarmClock, int callingUid, String callingPackage) { Alarm a = new Alarm(type, when, whenElapsed, windowLength, maxWhen, interval, operation, directReceiver, listenerTag, workSource, flags, alarmClock, callingUid, callingPackage); try { if (ActivityManager.getService().isAppStartModeDisabled(callingUid, callingPackage)) { Slog.w(TAG, "Not setting alarm from " + callingUid + ":" + a + " -- package not allowed to start"); return; } } catch (RemoteException e) { } removeLocked(operation, directReceiver); setImplLocked(a, false, doValidate); }
Example #6
Source File: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public Alarm(int _type, long _when, long _whenElapsed, long _windowLength, long _maxWhen, long _interval, PendingIntent _op, IAlarmListener _rec, String _listenerTag, WorkSource _ws, int _flags, AlarmManager.AlarmClockInfo _info, int _uid, String _pkgName) { type = _type; origWhen = _when; wakeup = _type == AlarmManager.ELAPSED_REALTIME_WAKEUP || _type == AlarmManager.RTC_WAKEUP; when = _when; whenElapsed = _whenElapsed; expectedWhenElapsed = _whenElapsed; windowLength = _windowLength; maxWhenElapsed = expectedMaxWhenElapsed = clampPositive(_maxWhen); repeatInterval = _interval; operation = _op; listener = _rec; listenerTag = _listenerTag; statsTag = makeTag(_op, _listenerTag, _type); workSource = _ws; flags = _flags; alarmClock = _info; uid = _uid; packageName = _pkgName; sourcePackage = (operation != null) ? operation.getCreatorPackage() : packageName; creatorUid = (operation != null) ? operation.getCreatorUid() : uid; }
Example #7
Source File: LocationManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@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); } } }
Example #8
Source File: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void scheduleTimeTickEvent() { final long currentTime = System.currentTimeMillis(); final long nextTime = 60000 * ((currentTime / 60000) + 1); // Schedule this event for the amount of time that it would take to get to // the top of the next minute. final long tickEventDelay = nextTime - currentTime; final WorkSource workSource = null; // Let system take blame for time tick events. setImpl(ELAPSED_REALTIME, SystemClock.elapsedRealtime() + tickEventDelay, 0, 0, mTimeTickSender, null, null, AlarmManager.FLAG_STANDALONE, workSource, null, Process.myUid(), "android"); // Finally, remember when we set the tick alarm synchronized (mLock) { mLastTickSet = currentTime; } }
Example #9
Source File: AlarmManagerHook.java From ZjDroid with Apache License 2.0 | 6 votes |
@Override public void startHook() { Method setImplmethod = RefInvoke.findMethodExact( "android.app.AlarmManager", ClassLoader.getSystemClassLoader(), "setImpl",int.class,long.class,long.class,long.class,PendingIntent.class,WorkSource.class); hookhelper.hookMethod(setImplmethod, new AbstractBahaviorHookCallBack() { @Override public void descParam(HookParam param) { Logger.log_behavior("The Alarm Information:"); PendingIntent intent = (PendingIntent) param.args[4]; descPendingIntent(intent); Logger.log_behavior("TriggerAtMillis = "+param.args[1]); Logger.log_behavior("windowMillis = "+param.args[2]); Logger.log_behavior("intervalMillis = "+param.args[3]); } }); }
Example #10
Source File: AlarmManagerHook.java From AppTroy with Apache License 2.0 | 6 votes |
@Override public void startHook() { Method setImplmethod = RefInvoke.findMethodExact( "android.app.AlarmManager", ClassLoader.getSystemClassLoader(), "setImpl",int.class,long.class,long.class,long.class,PendingIntent.class,WorkSource.class); hookhelper.hookMethod(setImplmethod, new AbstractBahaviorHookCallBack() { @Override public void descParam(HookParam param) { Logger.log_behavior("The Alarm Information:"); PendingIntent intent = (PendingIntent) param.args[4]; descPendingIntent(intent); Logger.log_behavior("TriggerAtMillis = "+param.args[1]); Logger.log_behavior("windowMillis = "+param.args[2]); Logger.log_behavior("intervalMillis = "+param.args[3]); } }); }
Example #11
Source File: LocationManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private Receiver getReceiverLocked(ILocationListener listener, int pid, int uid, String packageName, WorkSource workSource, boolean hideFromAppOps) { IBinder binder = listener.asBinder(); Receiver receiver = mReceivers.get(binder); if (receiver == null) { receiver = new Receiver(listener, null, pid, uid, packageName, workSource, hideFromAppOps); try { receiver.getListener().asBinder().linkToDeath(receiver, 0); } catch (RemoteException e) { Slog.e(TAG, "linkToDeath failed:", e); return null; } mReceivers.put(binder, receiver); } return receiver; }
Example #12
Source File: ActivityManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @hide */ public static void noteAlarmFinish(PendingIntent ps, WorkSource workSource, int sourceUid, String tag) { try { getService().noteAlarmFinish((ps != null) ? ps.getTarget() : null, workSource, sourceUid, tag); } catch (RemoteException ex) { } }
Example #13
Source File: LocationManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private Receiver checkListenerOrIntentLocked(ILocationListener listener, PendingIntent intent, int pid, int uid, String packageName, WorkSource workSource, boolean hideFromAppOps) { if (intent == null && listener == null) { throw new IllegalArgumentException("need either listener or intent"); } else if (intent != null && listener != null) { throw new IllegalArgumentException("cannot register both listener and intent"); } else if (intent != null) { checkPendingIntent(intent); return getReceiverLocked(intent, pid, uid, packageName, workSource, hideFromAppOps); } else { return getReceiverLocked(listener, pid, uid, packageName, workSource, hideFromAppOps); } }
Example #14
Source File: LocationManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private Receiver getReceiverLocked(PendingIntent intent, int pid, int uid, String packageName, WorkSource workSource, boolean hideFromAppOps) { Receiver receiver = mReceivers.get(intent); if (receiver == null) { receiver = new Receiver(null, intent, pid, uid, packageName, workSource, hideFromAppOps); mReceivers.put(intent, receiver); } return receiver; }
Example #15
Source File: LocationManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Whether a given {@code WorkSource} associated with a Location request is valid. */ private static boolean isValidWorkSource(WorkSource workSource) { if (workSource.size() > 0) { // If the WorkSource has one or more non-chained UIDs, make sure they're accompanied // by tags. return workSource.getName(0) != null; } else { // For now, make sure callers have supplied an attribution tag for use with // AppOpsManager. This might be relaxed in the future. final ArrayList<WorkChain> workChains = workSource.getWorkChains(); return workChains != null && !workChains.isEmpty() && workChains.get(0).getAttributionTag() != null; } }
Example #16
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void notifyWakeLockChangingLocked(WakeLock wakeLock, int flags, String tag, String packageName, int uid, int pid, WorkSource ws, String historyTag) { if (mSystemReady && wakeLock.mNotifiedAcquired) { mNotifier.onWakeLockChanging(wakeLock.mFlags, wakeLock.mTag, wakeLock.mPackageName, wakeLock.mOwnerUid, wakeLock.mOwnerPid, wakeLock.mWorkSource, wakeLock.mHistoryTag, flags, tag, packageName, uid, pid, ws, historyTag); notifyWakeLockLongFinishedLocked(wakeLock); // Changing the wake lock will count as releasing the old wake lock(s) and // acquiring the new ones... we do this because otherwise once a wakelock // becomes long, if we just continued to treat it as long we can get in to // situations where we spam battery stats with every following change to it. restartNofifyLongTimerLocked(wakeLock); } }
Example #17
Source File: Notifier.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Called when a wake lock is changing. */ public void onWakeLockChanging(int flags, String tag, String packageName, int ownerUid, int ownerPid, WorkSource workSource, String historyTag, int newFlags, String newTag, String newPackageName, int newOwnerUid, int newOwnerPid, WorkSource newWorkSource, String newHistoryTag) { final int monitorType = getBatteryStatsWakeLockMonitorType(flags); final int newMonitorType = getBatteryStatsWakeLockMonitorType(newFlags); if (workSource != null && newWorkSource != null && monitorType >= 0 && newMonitorType >= 0) { if (DEBUG) { Slog.d(TAG, "onWakeLockChanging: flags=" + newFlags + ", tag=\"" + newTag + "\", packageName=" + newPackageName + ", ownerUid=" + newOwnerUid + ", ownerPid=" + newOwnerPid + ", workSource=" + newWorkSource); } final boolean unimportantForLogging = newOwnerUid == Process.SYSTEM_UID && (newFlags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0; try { mBatteryStats.noteChangeWakelockFromSource(workSource, ownerPid, tag, historyTag, monitorType, newWorkSource, newOwnerPid, newTag, newHistoryTag, newMonitorType, unimportantForLogging); } catch (RemoteException ex) { // Ignore } } else { onWakeLockReleased(flags, tag, packageName, ownerUid, ownerPid, workSource, historyTag); onWakeLockAcquired(newFlags, newTag, newPackageName, newOwnerUid, newOwnerPid, newWorkSource, newHistoryTag); } }
Example #18
Source File: LocationManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@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.isEmpty()) { checkDeviceStatsAllowed(); } boolean hideFromAppOps = request.getHideFromAppOps(); if (hideFromAppOps) { checkUpdateAppOpsAllowed(); } boolean callerHasLocationHardwarePermission = mContext.checkCallingPermission(android.Manifest.permission.LOCATION_HARDWARE) == PERMISSION_GRANTED; LocationRequest sanitizedRequest = createSanitizedRequest(request, allowedResolutionLevel, callerHasLocationHardwarePermission); 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); } }
Example #19
Source File: GnssLocationProvider.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void handleDisable() { if (DEBUG) Log.d(TAG, "handleDisable"); updateClientUids(new WorkSource()); stopNavigating(); mAlarmManager.cancel(mWakeupIntent); mAlarmManager.cancel(mTimeoutIntent); mGnssBatchingProvider.disable(); // do this before releasing wakelock native_cleanup(); mGnssMeasurementsProvider.onGpsEnabledChanged(); mGnssNavigationMessageProvider.onGpsEnabledChanged(); }
Example #20
Source File: BatteryStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void noteChangeWakelockFromSource(WorkSource ws, int pid, String name, String historyName, int type, WorkSource newWs, int newPid, String newName, String newHistoryName, int newType, boolean newUnimportantForLogging) { enforceCallingPermission(); synchronized (mStats) { mStats.noteChangeWakelockFromSourceLocked(ws, pid, name, historyName, type, newWs, newPid, newName, newHistoryName, newType, newUnimportantForLogging); } }
Example #21
Source File: ActivityManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @hide */ public static void noteAlarmStart(PendingIntent ps, WorkSource workSource, int sourceUid, String tag) { try { getService().noteAlarmStart((ps != null) ? ps.getTarget() : null, workSource, sourceUid, tag); } catch (RemoteException ex) { } }
Example #22
Source File: BatteryStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void noteLongPartialWakelockStartFromSource(String name, String historyName, WorkSource workSource) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockStartFromSource(name, historyName, workSource); } }
Example #23
Source File: BatteryStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void noteLongPartialWakelockFinishFromSource(String name, String historyName, WorkSource workSource) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockFinishFromSource(name, historyName, workSource); } }
Example #24
Source File: BatteryStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void noteGpsChanged(WorkSource oldWs, WorkSource newWs) { enforceCallingPermission(); synchronized (mStats) { mStats.noteGpsChangedLocked(oldWs, newWs); } }
Example #25
Source File: AlarmManagerPatch.java From container with GNU General Public License v3.0 | 5 votes |
@Override public boolean beforeCall(Object who, Method method, Object... args) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && args[0] instanceof String) { args[0] = getHostPkg(); } int index = ArrayUtils.indexOfFirst(args, WorkSource.class); if (index >= 0) { args[index] = null; } return true; }
Example #26
Source File: BatteryStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void noteBleScanStopped(WorkSource ws, boolean isUnoptimized) { enforceCallingPermission(); synchronized (mStats) { mStats.noteBluetoothScanStoppedFromSourceLocked(ws, isUnoptimized); } }
Example #27
Source File: BatteryStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void noteBleScanResults(WorkSource ws, int numNewResults) { enforceCallingPermission(); synchronized (mStats) { mStats.noteBluetoothScanResultsFromSourceLocked(ws, numNewResults); } }
Example #28
Source File: BluetoothLeScanner.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public BleScanCallbackWrapper(IBluetoothGatt bluetoothGatt, List<ScanFilter> filters, ScanSettings settings, WorkSource workSource, ScanCallback scanCallback, List<List<ResultStorageDescriptor>> resultStorages) { mBluetoothGatt = bluetoothGatt; mFilters = filters; mSettings = settings; mWorkSource = workSource; mScanCallback = scanCallback; mScannerId = 0; mResultStorages = resultStorages; }
Example #29
Source File: AlarmManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void set(@AlarmType int type, long triggerAtMillis, long windowMillis, long intervalMillis, PendingIntent operation, WorkSource workSource) { setImpl(type, triggerAtMillis, windowMillis, intervalMillis, 0, operation, null, null, null, workSource, null); }
Example #30
Source File: ActivityManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @hide */ public static void noteWakeupAlarm(PendingIntent ps, WorkSource workSource, int sourceUid, String sourcePkg, String tag) { try { getService().noteWakeupAlarm((ps != null) ? ps.getTarget() : null, workSource, sourceUid, sourcePkg, tag); } catch (RemoteException ex) { } }