code: public void setIsRestrictedProfile(boolean isRestrictedProfile) {
      UserInfo userInfo = getUserInfo(UserHandle.myUserId());
      if (isRestrictedProfile) {
        userInfo.flags |= UserInfo.FLAG_RESTRICTED;
      } else {
        userInfo.flags &= ~UserInfo.FLAG_RESTRICTED;
      }
    }
docs: Sets this process running under a restricted profile; controls the return value of {@link
  UserManager#isRestrictedProfile()}.