Add device/profile app check in background check

If app is device or profile app, we disable the background check
toggle. This cl also create an util method for this check and
remove duplicate code

Bug: 64665807
Test: RunSettingsRoboTests
Change-Id: Id8336eadaac8832327bc3653aaa7dfbacde352ac
This commit is contained in:
jackqdyulei
2017-08-22 11:25:30 -07:00
parent efcc8be05c
commit 00015fbf50
8 changed files with 95 additions and 40 deletions

View File

@@ -43,6 +43,8 @@ import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.enterprise.DevicePolicyManagerWrapper;
import com.android.settings.enterprise.DevicePolicyManagerWrapperImpl;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.applications.ApplicationsState;
@@ -73,7 +75,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
protected String mPackageName;
protected IUsbManager mUsbManager;
protected DevicePolicyManager mDpm;
protected DevicePolicyManagerWrapper mDpm;
protected UserManager mUserManager;
protected PackageManager mPm;
@@ -92,7 +94,8 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
.getApplicationFeatureProvider(activity);
mState = ApplicationsState.getInstance(activity.getApplication());
mSession = mState.newSession(this);
mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
mDpm = new DevicePolicyManagerWrapperImpl(
(DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE));
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
mPm = activity.getPackageManager();
IBinder b = ServiceManager.getService(Context.USB_SERVICE);