Merge "Exempt VPN apps from BG-FGS-launch restriction." into sc-dev
This commit is contained in:
@@ -183,6 +183,10 @@ public class PowerExemptionManager {
|
|||||||
public static final int REASON_APPOP = 66;
|
public static final int REASON_APPOP = 66;
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD = 67;
|
public static final int REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD = 67;
|
||||||
|
/** @hide */
|
||||||
|
public static final int REASON_OP_ACTIVATE_VPN = 68;
|
||||||
|
/** @hide */
|
||||||
|
public static final int REASON_OP_ACTIVATE_PLATFORM_VPN = 69;
|
||||||
|
|
||||||
/* BG-FGS-launch is allowed by temp-allow-list or system-allow-list.
|
/* BG-FGS-launch is allowed by temp-allow-list or system-allow-list.
|
||||||
Reason code for temp and system allow list starts here.
|
Reason code for temp and system allow list starts here.
|
||||||
@@ -344,6 +348,8 @@ public class PowerExemptionManager {
|
|||||||
REASON_ALLOWLISTED_PACKAGE,
|
REASON_ALLOWLISTED_PACKAGE,
|
||||||
REASON_APPOP,
|
REASON_APPOP,
|
||||||
REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD,
|
REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD,
|
||||||
|
REASON_OP_ACTIVATE_VPN,
|
||||||
|
REASON_OP_ACTIVATE_PLATFORM_VPN,
|
||||||
// temp and system allow list reasons.
|
// temp and system allow list reasons.
|
||||||
REASON_GEOFENCING,
|
REASON_GEOFENCING,
|
||||||
REASON_PUSH_MESSAGING,
|
REASON_PUSH_MESSAGING,
|
||||||
@@ -603,6 +609,10 @@ public class PowerExemptionManager {
|
|||||||
return "APPOP";
|
return "APPOP";
|
||||||
case REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD:
|
case REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD:
|
||||||
return "ACTIVITY_VISIBILITY_GRACE_PERIOD";
|
return "ACTIVITY_VISIBILITY_GRACE_PERIOD";
|
||||||
|
case REASON_OP_ACTIVATE_VPN:
|
||||||
|
return "OP_ACTIVATE_VPN";
|
||||||
|
case REASON_OP_ACTIVATE_PLATFORM_VPN:
|
||||||
|
return "OP_ACTIVATE_PLATFORM_VPN";
|
||||||
case REASON_GEOFENCING:
|
case REASON_GEOFENCING:
|
||||||
return "GEOFENCING";
|
return "GEOFENCING";
|
||||||
case REASON_PUSH_MESSAGING:
|
case REASON_PUSH_MESSAGING:
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import static android.app.ActivityManager.PROCESS_STATE_TOP;
|
|||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST;
|
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST;
|
||||||
import static android.os.PowerExemptionManager.REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD;
|
import static android.os.PowerExemptionManager.REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD;
|
||||||
|
import static android.os.PowerExemptionManager.REASON_OP_ACTIVATE_PLATFORM_VPN;
|
||||||
|
import static android.os.PowerExemptionManager.REASON_OP_ACTIVATE_VPN;
|
||||||
import static android.os.PowerWhitelistManager.REASON_ACTIVITY_STARTER;
|
import static android.os.PowerWhitelistManager.REASON_ACTIVITY_STARTER;
|
||||||
import static android.os.PowerWhitelistManager.REASON_ALLOWLISTED_PACKAGE;
|
import static android.os.PowerWhitelistManager.REASON_ALLOWLISTED_PACKAGE;
|
||||||
import static android.os.PowerWhitelistManager.REASON_BACKGROUND_ACTIVITY_PERMISSION;
|
import static android.os.PowerWhitelistManager.REASON_BACKGROUND_ACTIVITY_PERMISSION;
|
||||||
@@ -5865,6 +5867,17 @@ public final class ActiveServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret == REASON_DENIED) {
|
||||||
|
final AppOpsManager appOpsManager = mAm.getAppOpsManager();
|
||||||
|
if (appOpsManager.checkOpNoThrow(AppOpsManager.OP_ACTIVATE_VPN, callingUid,
|
||||||
|
callingPackage) == AppOpsManager.MODE_ALLOWED) {
|
||||||
|
ret = REASON_OP_ACTIVATE_VPN;
|
||||||
|
} else if (appOpsManager.checkOpNoThrow(AppOpsManager.OP_ACTIVATE_PLATFORM_VPN,
|
||||||
|
callingUid, callingPackage) == AppOpsManager.MODE_ALLOWED) {
|
||||||
|
ret = REASON_OP_ACTIVATE_PLATFORM_VPN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user