Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d6dbb2b authored by Svet Ganov's avatar Svet Ganov
Browse files

Adjust default app op behavior based on feature state

If the CallLog/SMS permission restriction is not enabled we keep
the old default app op state for the relevant ops and if the
feature is enabled we switch to the new default value.

Test: Manual

Change-Id: Ic5f5b95f4152047455ecac06a596eee0f3bdc4ba
parent 0036c05f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserManager;
import android.provider.Settings;
import android.util.ArrayMap;

import com.android.internal.app.IAppOpsActiveCallback;
@@ -1555,6 +1556,26 @@ public class AppOpsManager {
     * @hide
     */
    public static int opToDefaultMode(int op) {
        // STOPSHIP b/118520006: Hardcode the default values once the feature is stable.
        switch (op) {
            // SMS permissions
            case AppOpsManager.OP_SEND_SMS:
            case AppOpsManager.OP_RECEIVE_SMS:
            case AppOpsManager.OP_READ_SMS:
            case AppOpsManager.OP_RECEIVE_WAP_PUSH:
            case AppOpsManager.OP_RECEIVE_MMS:
            case AppOpsManager.OP_READ_CELL_BROADCASTS:
            // CallLog permissions
            case AppOpsManager.OP_READ_CALL_LOG:
            case AppOpsManager.OP_WRITE_CALL_LOG:
            case AppOpsManager.OP_PROCESS_OUTGOING_CALLS: {
                // ActivityThread.currentApplication() is never null
                if (Settings.Global.getInt(ActivityThread.currentApplication().getContentResolver(),
                        Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 0) == 1) {
                    return AppOpsManager.MODE_DEFAULT;
                }
            }
        }
        return sOpDefaultMode[op];
    }