Query for the settings package in KeyguardManager instead of hardcoding it.
am: e256a18dcd
Change-Id: I3eb7f475c44f815ad2f0e8e1f85c39e555774fcc
This commit is contained in:
@@ -22,18 +22,19 @@ import android.app.trust.ITrustManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.IUserManager;
|
import android.os.IUserManager;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
|
||||||
import android.view.IWindowManager;
|
|
||||||
import android.view.IOnKeyguardExitResult;
|
import android.view.IOnKeyguardExitResult;
|
||||||
|
import android.view.IWindowManager;
|
||||||
import android.view.WindowManagerGlobal;
|
import android.view.WindowManagerGlobal;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that can be used to lock and unlock the keyboard. Get an instance of this
|
* Class that can be used to lock and unlock the keyboard. Get an instance of this
|
||||||
* class by calling {@link android.content.Context#getSystemService(java.lang.String)}
|
* class by calling {@link android.content.Context#getSystemService(java.lang.String)}
|
||||||
@@ -88,12 +89,9 @@ public class KeyguardManager {
|
|||||||
Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL);
|
Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL);
|
||||||
intent.putExtra(EXTRA_TITLE, title);
|
intent.putExtra(EXTRA_TITLE, title);
|
||||||
intent.putExtra(EXTRA_DESCRIPTION, description);
|
intent.putExtra(EXTRA_DESCRIPTION, description);
|
||||||
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
|
|
||||||
intent.setPackage("com.google.android.apps.wearable.settings");
|
// explicitly set the package for security
|
||||||
} else {
|
intent.setPackage(getSettingsPackageForIntent(intent));
|
||||||
// For security reasons, only allow this to come from system settings.
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
}
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,15 +112,23 @@ public class KeyguardManager {
|
|||||||
intent.putExtra(EXTRA_TITLE, title);
|
intent.putExtra(EXTRA_TITLE, title);
|
||||||
intent.putExtra(EXTRA_DESCRIPTION, description);
|
intent.putExtra(EXTRA_DESCRIPTION, description);
|
||||||
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||||
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
|
|
||||||
intent.setPackage("com.google.android.apps.wearable.settings");
|
// explicitly set the package for security
|
||||||
} else {
|
intent.setPackage(getSettingsPackageForIntent(intent));
|
||||||
// For security reasons, only allow this to come from system settings.
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
}
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getSettingsPackageForIntent(Intent intent) {
|
||||||
|
List<ResolveInfo> resolveInfos = mContext.getPackageManager()
|
||||||
|
.queryIntentActivities(intent, PackageManager.MATCH_SYSTEM_ONLY);
|
||||||
|
for (int i = 0; i < resolveInfos.size(); i++) {
|
||||||
|
return resolveInfos.get(i).activityInfo.packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "com.android.settings";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD}
|
* @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD}
|
||||||
* and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED}
|
* and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED}
|
||||||
|
|||||||
Reference in New Issue
Block a user