Use explicit APIs to get device owner information

Bug 24676413

Change-Id: Id346c2f01658173c9671edcfd34bc33f1b25faa4
This commit is contained in:
Makoto Onuki
2015-11-19 13:47:55 -08:00
parent 03e1bee786
commit 4cfe39f539
5 changed files with 18 additions and 12 deletions

View File

@@ -22,6 +22,7 @@ import android.app.AppGlobals;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -985,11 +986,12 @@ public class WifiSettings extends RestrictedSettingsFragment
boolean isConfigEligibleForLockdown = false;
if (dpm != null) {
final String deviceOwnerPackageName = dpm.getDeviceOwner();
if (deviceOwnerPackageName != null) {
final ComponentName deviceOwner = dpm.getDeviceOwnerComponentOnAnyUser();
if (deviceOwner != null) {
final int deviceOwnerUserId = dpm.getDeviceOwnerUserId();
try {
final int deviceOwnerUid = pm.getPackageUid(deviceOwnerPackageName,
UserHandle.USER_SYSTEM);
final int deviceOwnerUid = pm.getPackageUid(deviceOwner.getPackageName(),
deviceOwnerUserId);
isConfigEligibleForLockdown = deviceOwnerUid == config.creatorUid;
} catch (NameNotFoundException e) {
// don't care