Merge commit '2a12d8520ea6f41bd2db8577a8da82204e341c51' into manual_merge_2a12d85

Test: compiled everything, CTS verifier passes
Change-Id: I96641860890e413342bcb6a3b24e87d6aeff0c99
This commit is contained in:
Nancy Zheng
2016-11-21 12:58:16 -08:00
2 changed files with 19 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ import android.annotation.RequiresPermission;
import android.app.trust.ITrustManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Binder;
import android.os.RemoteException;
@@ -45,6 +46,7 @@ public class KeyguardManager {
private IWindowManager mWM;
private ITrustManager mTrustManager;
private IUserManager mUserManager;
private Context mContext;
/**
* Intent used to prompt user for device credentials.
@@ -87,8 +89,12 @@ public class KeyguardManager {
Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL);
intent.putExtra(EXTRA_TITLE, title);
intent.putExtra(EXTRA_DESCRIPTION, description);
// For security reasons, only allow this to come from system settings.
intent.setPackage("com.android.settings");
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
intent.setPackage("com.google.android.apps.wearable.settings");
} else {
// For security reasons, only allow this to come from system settings.
intent.setPackage("com.android.settings");
}
return intent;
}
@@ -109,8 +115,12 @@ public class KeyguardManager {
intent.putExtra(EXTRA_TITLE, title);
intent.putExtra(EXTRA_DESCRIPTION, description);
intent.putExtra(Intent.EXTRA_USER_ID, userId);
// For security reasons, only allow this to come from system settings.
intent.setPackage("com.android.settings");
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
intent.setPackage("com.google.android.apps.wearable.settings");
} else {
// For security reasons, only allow this to come from system settings.
intent.setPackage("com.android.settings");
}
return intent;
}
@@ -193,7 +203,8 @@ public class KeyguardManager {
}
KeyguardManager() throws ServiceNotFoundException {
KeyguardManager(Context context) throws ServiceNotFoundException {
mContext = context;
mWM = WindowManagerGlobal.getWindowManagerService();
mTrustManager = ITrustManager.Stub.asInterface(
ServiceManager.getServiceOrThrow(Context.TRUST_SERVICE));

View File

@@ -322,10 +322,10 @@ final class SystemServiceRegistry {
}});
registerService(Context.KEYGUARD_SERVICE, KeyguardManager.class,
new StaticServiceFetcher<KeyguardManager>() {
new CachedServiceFetcher<KeyguardManager>() {
@Override
public KeyguardManager createService() throws ServiceNotFoundException {
return new KeyguardManager();
public KeyguardManager createService(ContextImpl ctx) throws ServiceNotFoundException {
return new KeyguardManager(ctx);
}});
registerService(Context.LAYOUT_INFLATER_SERVICE, LayoutInflater.class,