Context enforceCallingOrSelfPermission - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Context enforceCallingOrSelfPermission method.

This code example shows how to use the following methods:enforceCallingOrSelfPermission
     * Retrieves the complete voice mail number. 
     * 
     * @hide 
     */ 
    public String getCompleteVoiceMailNumber() {
        mContext.enforceCallingOrSelfPermission(CALL_PRIVILEGED,
                "Requires CALL_PRIVILEGED"); 
        String number = mPhone.getVoiceMailNumber();
        Log.d(LOG_TAG, "VM: PhoneSubInfo.getCompleteVoiceMailNUmber: "); // + number);
        return number;
    } 
 
    /** 
     * Retrieves the alpha identifier associated with the voice mail number. 
     */ 
    public String getVoiceMailAlphaTag() {
        mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, "Requires READ_PHONE_STATE");
        return (String) mPhone.getVoiceMailAlphaTag();
    } 
 
7
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
    public void releaseUpdateLock(IBinder token) throws RemoteException {
        if (DEBUG) {
            Slog.d(TAG, "release(" + token + ')');
        } 
 
        mContext.enforceCallingOrSelfPermission(PERMISSION, "releaseUpdateLock");
        mLocks.release(token);
    }; 
 
    private String makeTag(String tag) {
        return "{tag=" + tag
                + " uid=" + Binder.getCallingUid()
                + " pid=" + Binder.getCallingPid() + '}';
    } 
 
    @Override 
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                != PackageManager.PERMISSION_GRANTED) {
            pw.println("Permission Denial: can't dump update lock service from from pid="
7
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
                false, new SamplingProfilerSettingsObserver(contentResolver));
    } 
 
    @Override 
    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
 
        pw.println("SamplingProfilerService:");
        pw.println("Watching directory: " + SNAPSHOT_DIR);
    } 
 
    private class SamplingProfilerSettingsObserver extends ContentObserver {
        private ContentResolver mContentResolver;
        public SamplingProfilerSettingsObserver(ContentResolver contentResolver) {
            super(null); 
            mContentResolver = contentResolver;
            onChange(false); 
        } 
        @Override 
        public void onChange(boolean selfChange) {
6
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
        return false; 
    } 
 
    private void checkListenerPermission(int events) {
        if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
 
        } 
 
        if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
 
        } 
 
        if ((events & PHONE_STATE_PERMISSION_MASK) != 0) {
            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.READ_PHONE_STATE, null);
        } 

6
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
        return false; 
    } 
 
    private void checkListenerPermission(int events) {
        if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
 
        } 
 
        if ((events & PHONE_STATE_PERMISSION_MASK) != 0) {
            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.READ_PHONE_STATE, null);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
    public void releaseUpdateLock(IBinder token) throws RemoteException {
        if (DEBUG) {
            Slog.d(TAG, "release(" + token + ')');
        } 
 
        mContext.enforceCallingOrSelfPermission(PERMISSION, "releaseUpdateLock");
        mLocks.release(token);
    }; 
 
    private String makeTag(String tag) {
        return "{tag=" + tag
                + " uid=" + Binder.getCallingUid()
                + " pid=" + Binder.getCallingPid() + '}';
    } 
 
    @Override 
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                != PackageManager.PERMISSION_GRANTED) {
            pw.println("Permission Denial: can't dump update lock service from from pid="
6
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
     * Retrieves the complete voice mail number. 
     * 
     * @hide 
     */ 
    public String getCompleteVoiceMailNumber() {
        mContext.enforceCallingOrSelfPermission(CALL_PRIVILEGED,
                "Requires CALL_PRIVILEGED"); 
        String number = mPhone.getVoiceMailNumber();
        Log.d(LOG_TAG, "VM: PhoneSubInfo.getCompleteVoiceMailNUmber: "); // + number);
        return number;
    } 
 
    /** 
     * Retrieves the alpha identifier associated with the voice mail number. 
     */ 
    public String getVoiceMailAlphaTag() {
        mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, "Requires READ_PHONE_STATE");
        return (String) mPhone.getVoiceMailAlphaTag();
    } 
 
6
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
            Binder.restoreCallingIdentity(identity);
        } 
    } 
 
    public void cancelVibrate() { 
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.VIBRATE,
                "cancelVibrate"); 
 
        // so wakelock calls will succeed 
        long identity = Binder.clearCallingIdentity();
        try { 
            doCancelVibrate(); 
        } 
        finally { 
            Binder.restoreCallingIdentity(identity);
        } 
    } 
     
    public boolean getFlashlightEnabled() { 
5
CodeRank
This code example shows how to use the following methods:enforceCallingOrSelfPermission
                + " trigger=" + adjustedTriggerTime + " orig=" + triggerAtTime);
        setRepeating(type, adjustedTriggerTime, interval, operation);
    } 
 
    public void setTime(long millis) {
        mContext.enforceCallingOrSelfPermission(
                "android.permission.SET_TIME", 
                "setTime"); 
 
        SystemClock.setCurrentTimeMillis(millis);
    } 
 
    public void setTimeZone(String tz) {
        mContext.enforceCallingOrSelfPermission(
                "android.permission.SET_TIME_ZONE", 
                "setTimeZone"); 
 
        if (TextUtils.isEmpty(tz)) return;
        TimeZone zone = TimeZone.getTimeZone(tz);
        // Prevent reentrant calls from stepping on each other when writing 
5
CodeRank
enforceCallingOrSelfPermission Method Overview
If neither you nor the calling process of an IPC you are handling has been granted a particular permission, throw a SecurityException.
See Code Examples for other Android Context Methods: