当前位置: 首页>>代码示例>>Java>>正文


Java DevicePolicyManager.isProfileOwnerApp方法代码示例

本文整理汇总了Java中android.app.admin.DevicePolicyManager.isProfileOwnerApp方法的典型用法代码示例。如果您正苦于以下问题:Java DevicePolicyManager.isProfileOwnerApp方法的具体用法?Java DevicePolicyManager.isProfileOwnerApp怎么用?Java DevicePolicyManager.isProfileOwnerApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.admin.DevicePolicyManager的用法示例。


在下文中一共展示了DevicePolicyManager.isProfileOwnerApp方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.app.admin.DevicePolicyManager; //导入方法依赖的package包/类
@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();
        }
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:17,代码来源:MainActivity.java

示例2: isManaged

import android.app.admin.DevicePolicyManager; //导入方法依赖的package包/类
/**
 * @return true if the device or profile is already owned
 */
public static boolean isManaged(Context context) {
    DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(
            Context.DEVICE_POLICY_SERVICE);

    List<ComponentName> admins = devicePolicyManager.getActiveAdmins();
    if (admins == null) return false;
    for (ComponentName admin : admins) {
        String adminPackageName = admin.getPackageName();
        if (devicePolicyManager.isDeviceOwnerApp(adminPackageName)
                || devicePolicyManager.isProfileOwnerApp(adminPackageName)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:20,代码来源:ProvisioningStateUtil.java

示例3: updatePasswordQualityNotification

import android.app.admin.DevicePolicyManager; //导入方法依赖的package包/类
private static void updatePasswordQualityNotification(Context context) {
    DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(
            Context.DEVICE_POLICY_SERVICE);

    if (!devicePolicyManager.isProfileOwnerApp(context.getPackageName())
            && !devicePolicyManager.isDeviceOwnerApp(context.getPackageName())) {
        // Only try to update the notification if we are a profile or device owner.
        return;
    }

    NotificationManager nm = (NotificationManager)
            context.getSystemService(Context.NOTIFICATION_SERVICE);

    if (!devicePolicyManager.isActivePasswordSufficient()) {
        NotificationCompat.Builder warn = NotificationUtil.getNotificationBuilder(context);
        warn.setOngoing(true)
                .setSmallIcon(R.drawable.ic_launcher)
                .setTicker(context.getText(R.string.password_not_compliant_title))
                .setContentTitle(context.getText(R.string.password_not_compliant_title))
                .setContentText(context.getText(R.string.password_not_compliant_content))
                .setContentIntent(PendingIntent.getActivity(context, /*requestCode*/ -1,
                        new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD), /*flags*/ 0));
        nm.notify(CHANGE_PASSWORD_NOTIFICATION_ID, warn.getNotification());
    } else {
        nm.cancel(CHANGE_PASSWORD_NOTIFICATION_ID);
    }
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:28,代码来源:DeviceAdminReceiver.java

示例4: onCreate

import android.app.admin.DevicePolicyManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    // Check arguments- see whether we're supposed to run on behalf of the parent profile.
    final Bundle arguments = getArguments();
    if (arguments != null) {
        mParentInstance = arguments.getBoolean(EXTRA_PARENT_PROFILE, false);
    }

    mAdminComponent = DeviceAdminReceiver.getComponentName(getActivity());

    // Get a device policy manager for the current user.
    mDevicePolicyManager = (DevicePolicyManager)
            getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);

    // Store whether we are the profile owner for faster lookup.
    mProfileOwner = mDevicePolicyManager.isProfileOwnerApp(getActivity().getPackageName());
    mDeviceOwner = mDevicePolicyManager.isDeviceOwnerApp(getActivity().getPackageName());

    if (mParentInstance) {
        mDevicePolicyManager = mDevicePolicyManager.getParentProfileInstance(mAdminComponent);
    }

    // Put at last to make sure all initializations above are done before subclass's
    // onCreatePreferences is called.
    super.onCreate(savedInstanceState);

    // Switch to parent profile if we are running on their behalf.
    // This needs to be called after super.onCreate because preference manager is set up
    // inside super.onCreate.
    if (mParentInstance) {
        final PreferenceManager pm = getPreferenceManager();
        pm.setSharedPreferencesName(pm.getSharedPreferencesName() + TAG_PARENT);
    }
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:35,代码来源:ProfileOrParentFragment.java

示例5: isManagedByTestDPC

import android.app.admin.DevicePolicyManager; //导入方法依赖的package包/类
/**
 * @return true if the device or profile is already owned by TestDPC
 */
public static boolean isManagedByTestDPC(Context context) {
    DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(
            Context.DEVICE_POLICY_SERVICE);
    String packageName = context.getPackageName();

    return devicePolicyManager.isProfileOwnerApp(packageName)
            || devicePolicyManager.isDeviceOwnerApp(packageName);
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:12,代码来源:ProvisioningStateUtil.java

示例6: getCurrentAdmin

import android.app.admin.DevicePolicyManager; //导入方法依赖的package包/类
private int getCurrentAdmin() {
    final DevicePolicyManager dpm =
            (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
    final String packageName = mContext.getPackageName();

    if (dpm.isDeviceOwnerApp(packageName)) {
        return ADMIN_DEVICE_OWNER;
    }
    if (dpm.isProfileOwnerApp(packageName)) {
        return ADMIN_PROFILE_OWNER;
    }
    return ADMIN_NONE;
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:14,代码来源:DpcPreferenceHelper.java

示例7: isProfileOwner

import android.app.admin.DevicePolicyManager; //导入方法依赖的package包/类
@TargetApi(VERSION_CODES.LOLLIPOP)
public static boolean isProfileOwner(Context context) {
    final DevicePolicyManager dpm = getDevicePolicyManager(context);
    return dpm.isProfileOwnerApp(context.getPackageName());
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:6,代码来源:Util.java


注:本文中的android.app.admin.DevicePolicyManager.isProfileOwnerApp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。