public synchronized void open3( SipProfile localProfile, PendingIntent incomingCallPendingIntent, ISipSessionListener listener) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); localProfile.setCallingUid(Binder.getCallingUid()); if (incomingCallPendingIntent == null) { Log.w(TAG, "incomingCallPendingIntent cannot be null; " + "the profile is not opened"); return; } if (DEBUG) Log.d( TAG, "open3: " + localProfile.getUriString() + ": " + incomingCallPendingIntent + ": " + listener); try { boolean addingFirstProfile = mSipGroups.isEmpty(); SipSessionGroupExt group = createGroup(localProfile, incomingCallPendingIntent, listener); if (addingFirstProfile && !mSipGroups.isEmpty()) registerReceivers(); if (localProfile.getAutoRegistration()) { group.openToReceiveCalls(); } } catch (SipException e) { Log.e(TAG, "openToReceiveCalls()", e); // TODO: how to send the exception back } }
@Override public synchronized void setTorchEnabled(boolean enabled) { mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_TORCH_SERVICE, null); if (mTorchEnabled != enabled) { mTorchEnabled = enabled; setListenForScreenOff(enabled); postUpdateFlashlight(); } }
@Override public synchronized boolean isAvailable() { mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_TORCH_SERVICE, null); if (mUseCameraInterface) { return mTorchAvailable; } else { File f = new File(mFlashDevice); return f.exists() && f.canWrite(); } }
public synchronized boolean isRegistered(String localProfileUri) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); SipSessionGroupExt group = mSipGroups.get(localProfileUri); if (group == null) return false; if (isCallerCreatorOrRadio(group)) { return group.isRegistered(); } else { Log.w(TAG, "only creator or radio can query on the profile"); return false; } }
public synchronized void setRegistrationListener( String localProfileUri, ISipSessionListener listener) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); SipSessionGroupExt group = mSipGroups.get(localProfileUri); if (group == null) return; if (isCallerCreator(group)) { group.setListener(listener); } else { Log.w(TAG, "only creator can set listener on the profile"); } }
public synchronized SipProfile[] getListOfProfiles() { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); boolean isCallerRadio = isCallerRadio(); ArrayList<SipProfile> profiles = new ArrayList<SipProfile>(); for (SipSessionGroupExt group : mSipGroups.values()) { if (isCallerRadio || isCallerCreator(group)) { profiles.add(group.getLocalProfile()); } } return profiles.toArray(new SipProfile[profiles.size()]); }
public synchronized void open(SipProfile localProfile) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); localProfile.setCallingUid(Binder.getCallingUid()); try { boolean addingFirstProfile = mSipGroups.isEmpty(); createGroup(localProfile); if (addingFirstProfile && !mSipGroups.isEmpty()) registerReceivers(); } catch (SipException e) { Log.e(TAG, "openToMakeCalls()", e); // TODO: how to send the exception back } }
public synchronized ISipSession createSession( SipProfile localProfile, ISipSessionListener listener) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); localProfile.setCallingUid(Binder.getCallingUid()); if (!mConnected) return null; try { SipSessionGroupExt group = createGroup(localProfile); return group.createSession(listener); } catch (SipException e) { if (DEBUG) Log.d(TAG, "createSession()", e); return null; } }
@Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); // Dump the state of all the app widget providers synchronized (mAppWidgetServices) { IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); for (int i = 0; i < mAppWidgetServices.size(); i++) { pw.println("User: " + mAppWidgetServices.keyAt(i)); ipw.increaseIndent(); AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i); service.dump(fd, ipw, args); ipw.decreaseIndent(); } } }
public synchronized void close(String localProfileUri) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); SipSessionGroupExt group = mSipGroups.get(localProfileUri); if (group == null) return; if (!isCallerCreatorOrRadio(group)) { Log.w(TAG, "only creator or radio can close this profile"); return; } group = mSipGroups.remove(localProfileUri); notifyProfileRemoved(group.getLocalProfile()); group.close(); if (!anyOpenedToReceiveCalls()) { unregisterReceivers(); mMyWakeLock.reset(); // in case there's leak } }
public long getAwakeTimePlugged() { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BATTERY_STATS, null); return mStats.getAwakeTimePlugged(); }
@Override public void onReceive(Context context, Intent intent) { PreferencesProviderWrapper prefWrapper = new PreferencesProviderWrapper(context); String intentAction = intent.getAction(); // // ACTION_DATA_STATE_CHANGED // Data state change is used to detect changes in the mobile // network such as a switch of network type (GPRS, EDGE, 3G) // which are not detected by the Connectivity changed broadcast. // // // ACTION_CONNECTIVITY_CHANGED // Connectivity change is used to detect changes in the overall // data network status as well as a switch between wifi and mobile // networks. // if ( /*intentAction.equals(ACTION_DATA_STATE_CHANGED) ||*/ intentAction.equals(ConnectivityManager.CONNECTIVITY_ACTION) || intentAction.equals(Intent.ACTION_BOOT_COMPLETED)) { if (prefWrapper.isValidConnectionForIncoming() && !prefWrapper.getPreferenceBooleanValue(PreferencesProviderWrapper.HAS_BEEN_QUIT)) { Log.d(THIS_FILE, "Try to start service if not already started"); Intent sip_service_intent = new Intent(context, SipService.class); context.startService(sip_service_intent); } } else if (intentAction.equals(SipManager.INTENT_SIP_ACCOUNT_ACTIVATE)) { context.enforceCallingOrSelfPermission(SipManager.PERMISSION_CONFIGURE_SIP, null); long accId; accId = intent.getLongExtra(SipProfile.FIELD_ID, SipProfile.INVALID_ID); if (accId == SipProfile.INVALID_ID) { // allow remote side to send us integers. // previous call will warn, but that's fine, no worries accId = intent.getIntExtra(SipProfile.FIELD_ID, (int) SipProfile.INVALID_ID); } if (accId != SipProfile.INVALID_ID) { boolean active = intent.getBooleanExtra(SipProfile.FIELD_ACTIVE, true); ContentValues cv = new ContentValues(); cv.put(SipProfile.FIELD_ACTIVE, active); int done = context .getContentResolver() .update( ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, accId), cv, null, null); if (done > 0) { if (prefWrapper.isValidConnectionForIncoming()) { Intent sipServiceIntent = new Intent(context, SipService.class); context.startService(sipServiceIntent); } } } } else if (Intent.ACTION_PACKAGE_ADDED.equalsIgnoreCase(intentAction) || Intent.ACTION_PACKAGE_REMOVED.equalsIgnoreCase(intentAction)) { CallHandlerPlugin.clearAvailableCallHandlers(); RewriterPlugin.clearAvailableRewriters(); ExtraPlugins.clearDynPlugins(); PhoneCapabilityTester.deinit(); } else if (APPLY_NIGHTLY_UPLOAD.equals(intentAction)) { NightlyUpdater nu = new NightlyUpdater(context); nu.applyUpdate(intent); } }
public void clearDefaults(String packageName) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); mDeviceManager.clearDefaults(packageName); }
public boolean hasDefaults(String packageName) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); return mDeviceManager.hasDefaults(packageName); }
public void grantAccessoryPermission(UsbAccessory accessory, int uid) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); mDeviceManager.grantAccessoryPermission(accessory, uid); }
public void setAccessoryPackage(UsbAccessory accessory, String packageName) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); mDeviceManager.setAccessoryPackage(accessory, packageName); }
@Override public void removeListener(ITorchCallback l) throws RemoteException { mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_TORCH_SERVICE, null); mListeners.unregister(l); }
@Override public boolean isTorchOn() { mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_TORCH_SERVICE, null); return mTorchEnabled; }
@Override public void toggleTorch() { mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_TORCH_SERVICE, null); setTorchEnabled(!mTorchEnabled); }
public synchronized ISipSession getPendingSession(String callId) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.USE_SIP, null); if (callId == null) return null; return mPendingSessions.get(callId); }