Camera ITS HOST 环境配置:
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@-3738,8+3738,9@@publicclassDevicePolicyManagerServiceextendsIDevicePolicyManager.Stub{
"Trying to set device owner but device owner is already set.");
}
-// Shutting down backup manager service permanently.
-long ident =Binder.clearCallingIdentity();
+if(!packageName.contains("com.android.cts.deviceowner")){
+// Shutting down backup manager service permanently.
+long ident =Binder.clearCallingIdentity();
try{
IBackupManager ibm =IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
@@-3749,7+3750,7@@publicclassDevicePolicyManagerServiceextendsIDevicePolicyManager.Stub{
}finally{
Binder.restoreCallingIdentity(ident);
}
-
+}
if(mDeviceOwner ==null){
// Device owner is not set and does not exist, set it.
mDeviceOwner =DeviceOwner.createWithDeviceOwner(packageName, ownerName);
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@-36,6+36,8@@import com.android.settings.widget.SwitchBar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import android.app.ActivityManager;
+import android.app.ActivityManager.RunningTaskInfo;
/**
* Location access settings.
@@ -81,6 +83,19 @@ public class LocationSettings extends LocationSettingsBase
@Override
public void onResume() {
super.onResume();
+
+ //fix cts bug
+ String MY_PKG_NAME = "com.google.android.xts.location";
+ ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
+ List<RunningTaskInfo> list = am.getRunningTasks(100);
+ for (RunningTaskInfo info : list) {
+ if (info.topActivity.getPackageName().equals(MY_PKG_NAME)
+ && info.baseActivity.getPackageName().equals(MY_PKG_NAME)) {
+ am.restartPackage("com.google.android.gms");
+ break;
+ }
+ }
+
createPreferenceHierarchy();
if (!mValidListener) {