@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]); } }); }
@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]); } }); }
@Override public void onSetRequest(ProviderRequestUnbundled requests, WorkSource source) { Log.v(TAG, "onSetRequest: " + requests + " by " + source); long autoTime = Math.max(requests.getInterval(), FASTEST_REFRESH_INTERVAL); boolean autoUpdate = requests.getReportLocation(); Log.v(TAG, "using autoUpdate=" + autoUpdate + " autoTime=" + autoTime); if (autoUpdate) { helper.setTime(autoTime); helper.enable(); } else { helper.disable(); } }
@Override public LocationRequest createFromParcel(Parcel in) { LocationRequest request = new LocationRequest(); request.setQuality(in.readInt()); request.setFastestInterval(in.readLong()); request.setInterval(in.readLong()); request.setExpireAt(in.readLong()); request.setNumUpdates(in.readInt()); request.setSmallestDisplacement(in.readFloat()); request.setHideFromAppOps(in.readInt() != 0); String provider = in.readString(); if (provider != null) request.setProvider(provider); WorkSource workSource = in.readParcelable(null); if (workSource != null) request.setWorkSource(workSource); return request; }
@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; }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { int index = ArrayUtils.indexOfFirst(args, WorkSource.class); if (index >= 0) { args[index] = null; } return super.call(who, method, args); }
/** * Request a scan for access points. Returns immediately. The availability * of the results is made known later by means of an asynchronous event sent * on completion of the scan. * @return {@code true} if the operation succeeded, i.e., the scan was initiated */ public boolean startScan() { try { final WorkSource workSource = null; mService.startScan(workSource); return true; } catch (RemoteException e) { return false; } }
/** @hide */ public boolean startScan(WorkSource workSource) { try { mService.startScan(workSource); return true; } catch (RemoteException e) { return false; } }
@Override public void onSetMinTime(long minTime, WorkSource ws) { Log.v(TAG, "onSetMinTime: " + minTime + " by " + ws); autoTime = Math.max(minTime, FASTEST_REFRESH_INTERVAL); helper.setTime(autoTime); if (autoUpdate) helper.enable(); }
@Override public void onSetRequest(final ProviderRequestUnbundled requests, final WorkSource ws) { try { if (DEBUG) Log.d(TAG, "onSetRequest: requests=" + requests + ", ws=" + ws); wirelessEnvListener.disable(); long autoTime = Long.MAX_VALUE; boolean autoUpdate = false; for (final LocationRequestUnbundled request : requests.getLocationRequests()) { if (DEBUG) Log.d(TAG, "onSetRequest: request=" + request); if (autoTime > request.getInterval()) { autoTime = request.getInterval(); } autoUpdate = true; } if (autoUpdate) { if (autoTime < 1500) { autoTime = 1500; } wirelessEnvListener.setTime(autoTime); wirelessEnvListener.enable(); } else { wirelessEnvListener.disable(); } } catch (Exception e) { Log.e(TAG, "onSetRequest: e=" + e, e); } }
/** * @hide */ public WorkSource getWorkSource() { return null; }
@Override public void onAddListener(final int uid, final WorkSource ws) { if (DEBUG) Log.d(TAG, uid + " is listening as " + ws != null ? (ws + " (contents:" + ws.describeContents() + ")") : "[unknown WorkSource]"); }
@Override public void onRemoveListener(final int uid, final WorkSource ws) { }
@Override public void onSetMinTime(final long minTime, final WorkSource ws) { autoTime = minTime; }
public void setMinTime(long minTime, WorkSource ws) { LocationProvider.this.onSetMinTime(minTime, ws); }
public void addListener(int uid) { LocationProvider.this.onAddListener(uid, new WorkSource(uid)); }
public void removeListener(int uid) { LocationProvider.this.onRemoveListener(uid, new WorkSource(uid)); }
/** * @hide */ public WorkSource getWorkSource() { return mWorkSource; }
/** * Notifies the location provider of the smallest minimum time between updates amongst * all clients that are listening for locations. This allows the provider to reduce * the frequency of updates to match the requested frequency. * * @param minTime the smallest minTime value over all listeners for this provider. * @param ws the source this work is coming from. */ public abstract void onSetMinTime(long minTime, WorkSource ws);
/** * Notifies the location provider when a new client is listening for locations. * * @param uid user ID of the new client. * @param ws a WorkSource representation of the client. */ public abstract void onAddListener(int uid, WorkSource ws);
/** * Notifies the location provider when a client is no longer listening for locations. * * @param uid user ID of the client no longer listening. * @param ws a WorkSource representation of the client. */ public abstract void onRemoveListener(int uid, WorkSource ws);
/** * Set the {@link ProviderRequest} requirements for this provider. * <p>Each call to this method overrides all previous requests. * <p>This method might trigger the provider to start returning * locations, or to stop returning locations, depending on the * parameters in the request. */ public abstract void onSetRequest(ProviderRequestUnbundled request, WorkSource source);
/** * Sets the WorkSource to use for power blaming of this location request. * <p/> * <p>No permissions are required to make this call, however the LocationManager * will throw a SecurityException when requesting location updates if the caller * doesn't have the {@link android.Manifest.permission#UPDATE_DEVICE_STATS} permission. * * @param workSource WorkSource defining power blame for this location request. * @hide */ public void setWorkSource(WorkSource workSource) { }
@Override public void onAddListener(int uid, WorkSource ws) { }
@Override public void onRemoveListener(int uid, WorkSource ws) { }
/** * Sets the WorkSource to use for power blaming of this location request. * <p/> * <p>No permissions are required to make this call, however the LocationManager * will throw a SecurityException when requesting location updates if the caller * doesn't have the {@link android.Manifest.permission#UPDATE_DEVICE_STATS} permission. * * @param workSource WorkSource defining power blame for this location request. * @hide */ public void setWorkSource(WorkSource workSource) { mWorkSource = workSource; }