@Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main_real);
   if (savedInstanceState == null) {
     DevicePolicyManager manager =
         (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
     if (manager.isProfileOwnerApp(getApplicationContext().getPackageName())) {
       // If the managed profile is already set up, we show the main screen.
       showMainFragment();
     } else {
       // If not, we show the set up screen.
       showSetupProfile();
     }
   }
 }
 @Override
 protected void tearDown() throws Exception {
   if (mDevicePolicyManager.isDeviceOwnerApp(PACKAGE_NAME)
       || mDevicePolicyManager.isProfileOwnerApp(PACKAGE_NAME)) {
     mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, false);
   }
   try {
     mContext.unregisterReceiver(mBroadcastReceiver);
   } catch (IllegalArgumentException e) {
     // ignore
   }
   if (mSession != null) {
     mSession.abandon();
   }
   super.tearDown();
 }
Ejemplo n.º 3
0
 private boolean isManagedProfile() {
   String adminPackage = BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT.getPackageName();
   return mDevicePolicyManager.isProfileOwnerApp(adminPackage);
 }
 private boolean isProfileOwner() {
   return mDevicePolicyManager.isAdminActive(mAdminReceiverComponent)
       && mDevicePolicyManager.isProfileOwnerApp(mAdminReceiverComponent.getPackageName());
 }