diff options
13 files changed, 240 insertions, 34 deletions
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 7045eafabbd5..8c64484969bb 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -7508,6 +7508,8 @@ <attr name="title" /> <!-- @SystemApi Summary for the same preference as the title. @hide --> <attr name="summary" /> + <!-- @SystemApi Whether trust agent can unlock a user profile @hide --> + <attr name="unlockProfile" format="boolean"/> </declare-styleable> <!-- =============================== --> @@ -8378,13 +8380,13 @@ <attr name="color" /> </declare-styleable> - <!-- @hide Attributes which will be read by the Activity to intialize the + <!-- @hide Attributes which will be read by the Activity to intialize the base activity TaskDescription. --> <declare-styleable name="ActivityTaskDescription"> <!-- @hide From Theme.colorPrimary, used for the TaskDescription primary color. --> <attr name="colorPrimary" /> - <!-- @hide From Theme.colorBackground, used for the TaskDescription background + <!-- @hide From Theme.colorBackground, used for the TaskDescription background color. --> <attr name="colorBackground" /> </declare-styleable> diff --git a/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml b/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml index a7c91058283b..edcea0e64ac7 100644 --- a/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml +++ b/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml @@ -24,6 +24,7 @@ android:name=".SampleTrustAgent" android:label="@string/app_name" android:permission="android.permission.BIND_TRUST_AGENT" + android:directBootAware="true" android:exported="true"> <intent-filter> <action android:name="android.service.trust.TrustAgentService" /> diff --git a/packages/Keyguard/test/SampleTrustAgent/res/layout-v26/sample_trust_agent_settings.xml b/packages/Keyguard/test/SampleTrustAgent/res/layout-v26/sample_trust_agent_settings.xml new file mode 100644 index 000000000000..4669971e9be3 --- /dev/null +++ b/packages/Keyguard/test/SampleTrustAgent/res/layout-v26/sample_trust_agent_settings.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + ~ Copyright (C) 2014 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <Button android:id="@+id/enable_trust" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Grant trust for 30 seconds" /> + <Button android:id="@+id/revoke_trust" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Revoke trust" /> + <Button android:id="@+id/crash" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Crash" /> + <CheckBox android:id="@+id/managing_trust" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:text="Managing trust" /> + <CheckBox android:id="@+id/managing_trust_direct_boot" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:text="Managing trust direct boot"/> + + <CheckBox android:id="@+id/report_unlock_attempts" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:text="Report unlock attempts" /> + <CheckBox android:id="@+id/report_device_locked" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:text="Report device locked or unlocked" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <Button android:id="@+id/check_device_locked" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Device locked?" /> + <TextView android:id="@+id/check_device_locked_result" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" /> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/packages/Keyguard/test/SampleTrustAgent/res/xml-v26/sample_trust_agent.xml b/packages/Keyguard/test/SampleTrustAgent/res/xml-v26/sample_trust_agent.xml new file mode 100644 index 000000000000..26d5aa0c26f3 --- /dev/null +++ b/packages/Keyguard/test/SampleTrustAgent/res/xml-v26/sample_trust_agent.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2014 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> +<trust-agent xmlns:android="http://schemas.android.com/apk/res/android" + android:settingsActivity=".SampleTrustAgentSettings" + android:unlockProfile="true" /> diff --git a/packages/Keyguard/test/SampleTrustAgent/res/xml/sample_trust_agent.xml b/packages/Keyguard/test/SampleTrustAgent/res/xml/sample_trust_agent.xml index b363ab459c6d..6cd34bbab8e0 100644 --- a/packages/Keyguard/test/SampleTrustAgent/res/xml/sample_trust_agent.xml +++ b/packages/Keyguard/test/SampleTrustAgent/res/xml/sample_trust_agent.xml @@ -15,4 +15,4 @@ ~ limitations under the License --> <trust-agent xmlns:android="http://schemas.android.com/apk/res/android" - android:settingsActivity=".SampleTrustAgentSettings" /> + android:settingsActivity=".SampleTrustAgentSettings" /> diff --git a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java index b8f16e7929dc..4b50cf8c9fd5 100644 --- a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java +++ b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.os.PersistableBundle; +import android.os.UserManager; import android.preference.PreferenceManager; import android.service.trust.TrustAgentService; import android.support.v4.content.LocalBroadcastManager; @@ -57,26 +58,47 @@ public class SampleTrustAgent extends TrustAgentService = "preference.report_unlock_attempts"; private static final String PREFERENCE_MANAGING_TRUST = "preference.managing_trust"; + private static final String PREFERENCE_MANAGING_TRUST_DIRECT_BOOT + = "preference.managing_trust_direct_boot"; private static final String PREFERENCE_REPORT_DEVICE_LOCKED = "preference.report_device_locked"; private static final String TAG = "SampleTrustAgent"; + private static final BroadcastReceiver mUnlockReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + + } + }; + + private boolean mIsUserUnlocked; + @Override public void onCreate() { super.onCreate(); + UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); + mIsUserUnlocked = um.isUserUnlocked(); + Log.i(TAG,, "onCreate, is user unlocked=" + mIsUserUnlocked); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_GRANT_TRUST); filter.addAction(ACTION_REVOKE_TRUST); + if (!mIsUserUnlocked) { + filter.addAction(Intent.ACTION_BOOT_COMPLETED); + } mLocalBroadcastManager.registerReceiver(mReceiver, filter); if (ALLOW_EXTERNAL_BROADCASTS) { registerReceiver(mReceiver, filter); } - setManagingTrust(getIsManagingTrust(this)); - PreferenceManager.getDefaultSharedPreferences(this) - .registerOnSharedPreferenceChangeListener(this); + if (!mIsUserUnlocked) { + boolean trustManaged = getIsManagingTrustDirectBoot(this); + Log.i(TAG, "in Direct boot." + (trustManaged ? "manage" : "cannot manage") + "trust"); + setManagingTrust(getIsManagingTrustDirectBoot(this)); + } else { + onBootCompleted(); + } } @Override @@ -137,6 +159,12 @@ public class SampleTrustAgent extends TrustAgentService .unregisterOnSharedPreferenceChangeListener(this); } + private void onBootCompleted() { + PreferenceManager.getDefaultSharedPreferences(this) + .registerOnSharedPreferenceChangeListener(this); + setManagingTrust(getIsManagingTrust(this)); + } + private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -158,6 +186,9 @@ public class SampleTrustAgent extends TrustAgentService } } else if (ACTION_REVOKE_TRUST.equals(action)) { revokeTrust(); + } else if (intent.ACTION_BOOT_COMPLETED.equals(action)) { + Log.d(TAG, "User unlocked and boot completed."); + onBootCompleted(); } } }; @@ -203,6 +234,7 @@ public class SampleTrustAgent extends TrustAgentService public static void setIsManagingTrust(Context context, boolean enabled) { SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(context); + Log.d("AAAA", "save manage trust preference. Enabled=" + enabled); sharedPreferences.edit().putBoolean(PREFERENCE_MANAGING_TRUST, enabled).apply(); } @@ -212,6 +244,21 @@ public class SampleTrustAgent extends TrustAgentService return sharedPreferences.getBoolean(PREFERENCE_MANAGING_TRUST, false); } + public static void setIsManagingTrustDirectBoot(Context context, boolean enabled) { + Context directBootContext = context.createDeviceProtectedStorageContext(); + SharedPreferences sharedPreferences = PreferenceManager + .getDefaultSharedPreferences(directBootContext); + Log.d("AAAA", "save to direct boot preference. Enabled=" + enabled); + sharedPreferences.edit().putBoolean(PREFERENCE_MANAGING_TRUST_DIRECT_BOOT, enabled).apply(); + } + + public static boolean getIsManagingTrustDirectBoot(Context context) { + Context directBootContext = context.createDeviceProtectedStorageContext(); + SharedPreferences sharedPreferences = PreferenceManager + .getDefaultSharedPreferences(directBootContext); + return sharedPreferences.getBoolean(PREFERENCE_MANAGING_TRUST_DIRECT_BOOT, false); + } + @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (PREFERENCE_MANAGING_TRUST.equals(key)) { diff --git a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java index 29b15cbff1fd..1b171693a6c9 100644 --- a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java +++ b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java @@ -33,6 +33,7 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi private CheckBox mReportUnlockAttempts; private CheckBox mReportDeviceLocked; private CheckBox mManagingTrust; + private CheckBox mManagingTrustDirectBoot; private TextView mCheckDeviceLockedResult; private KeyguardManager mKeyguardManager; @@ -59,6 +60,8 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi mManagingTrust = (CheckBox) findViewById(R.id.managing_trust); mManagingTrust.setOnCheckedChangeListener(this); + mManagingTrustDirectBoot = (CheckBox) findViewById(R.id.managing_trust_direct_boot); + mManagingTrustDirectBoot.setOnCheckedChangeListener(this); mCheckDeviceLockedResult = (TextView) findViewById(R.id.check_device_locked_result); } @@ -68,6 +71,8 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi super.onResume(); mReportUnlockAttempts.setChecked(SampleTrustAgent.getReportUnlockAttempts(this)); mManagingTrust.setChecked(SampleTrustAgent.getIsManagingTrust(this)); + mManagingTrustDirectBoot.setChecked( + SampleTrustAgent.getIsManagingTrustDirectBoot(this)); updateTrustedState(); } @@ -94,6 +99,8 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi SampleTrustAgent.setIsManagingTrust(this, isChecked); } else if (buttonView == mReportDeviceLocked) { SampleTrustAgent.setReportDeviceLocked(this, isChecked); + } else if (buttonView == mManagingTrustDirectBoot) { + SampleTrustAgent.setIsManagingTrustDirectBoot(this, isChecked); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java index 32f8ebbbd539..a6e730d01c33 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java @@ -208,6 +208,7 @@ public class NotificationData { expandedIcon = null; throw new IconException("Couldn't create icon: " + ic); } + expandedIcon.setVisibility(View.INVISIBLE); expandedIcon.setOnVisibilityChangedListener( newVisibility -> { if (row != null) { diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java index 8092b4af1a4a..9f63e30d061a 100644 --- a/services/core/java/com/android/server/DeviceIdleController.java +++ b/services/core/java/com/android/server/DeviceIdleController.java @@ -211,7 +211,10 @@ public class DeviceIdleController extends SystemService private long mMaintenanceStartTime; private int mActiveIdleOpCount; - private PowerManager.WakeLock mActiveIdleWakeLock; + private PowerManager.WakeLock mActiveIdleWakeLock; // held when there are operations in progress + private PowerManager.WakeLock mGoingIdleWakeLock; // held when we are going idle so hardware + // (especially NetworkPolicyManager) can shut + // down. private boolean mJobsActive; private boolean mAlarmsActive; private boolean mReportedMaintenanceActivity; @@ -998,14 +1001,14 @@ public class DeviceIdleController extends SystemService } } - static final int MSG_WRITE_CONFIG = 1; - static final int MSG_REPORT_IDLE_ON = 2; - static final int MSG_REPORT_IDLE_ON_LIGHT = 3; - static final int MSG_REPORT_IDLE_OFF = 4; - static final int MSG_REPORT_ACTIVE = 5; - static final int MSG_TEMP_APP_WHITELIST_TIMEOUT = 6; - static final int MSG_REPORT_MAINTENANCE_ACTIVITY = 7; - static final int MSG_FINISH_IDLE_OP = 8; + private static final int MSG_WRITE_CONFIG = 1; + private static final int MSG_REPORT_IDLE_ON = 2; + private static final int MSG_REPORT_IDLE_ON_LIGHT = 3; + private static final int MSG_REPORT_IDLE_OFF = 4; + private static final int MSG_REPORT_ACTIVE = 5; + private static final int MSG_TEMP_APP_WHITELIST_TIMEOUT = 6; + private static final int MSG_REPORT_MAINTENANCE_ACTIVITY = 7; + private static final int MSG_FINISH_IDLE_OP = 8; final class MyHandler extends Handler { MyHandler(Looper looper) { @@ -1016,10 +1019,12 @@ public class DeviceIdleController extends SystemService if (DEBUG) Slog.d(TAG, "handleMessage(" + msg.what + ")"); switch (msg.what) { case MSG_WRITE_CONFIG: { + // Does not hold a wakelock. Just let this happen whenever. handleWriteConfigFile(); } break; case MSG_REPORT_IDLE_ON: case MSG_REPORT_IDLE_ON_LIGHT: { + // mGoingIdleWakeLock is held at this point EventLogTags.writeDeviceIdleOnStart(); final boolean deepChanged; final boolean lightChanged; @@ -1044,8 +1049,10 @@ public class DeviceIdleController extends SystemService getContext().sendBroadcastAsUser(mLightIdleIntent, UserHandle.ALL); } EventLogTags.writeDeviceIdleOnComplete(); + mGoingIdleWakeLock.release(); } break; case MSG_REPORT_IDLE_OFF: { + // mActiveIdleWakeLock is held at this point EventLogTags.writeDeviceIdleOffStart("unknown"); final boolean deepChanged = mLocalPowerManager.setDeviceIdleMode(false); final boolean lightChanged = mLocalPowerManager.setLightDeviceIdleMode(false); @@ -1071,6 +1078,7 @@ public class DeviceIdleController extends SystemService EventLogTags.writeDeviceIdleOffComplete(); } break; case MSG_REPORT_ACTIVE: { + // The device is awake at this point, so no wakelock necessary. String activeReason = (String)msg.obj; int activeUid = msg.arg1; EventLogTags.writeDeviceIdleOffStart( @@ -1092,10 +1100,12 @@ public class DeviceIdleController extends SystemService EventLogTags.writeDeviceIdleOffComplete(); } break; case MSG_TEMP_APP_WHITELIST_TIMEOUT: { + // TODO: What is keeping the device awake at this point? Does it need to be? int uid = msg.arg1; checkTempAppWhitelistTimeout(uid); } break; case MSG_REPORT_MAINTENANCE_ACTIVITY: { + // TODO: What is keeping the device awake at this point? Does it need to be? boolean active = (msg.arg1 == 1); final int size = mMaintenanceActivityListeners.beginBroadcast(); try { @@ -1111,6 +1121,7 @@ public class DeviceIdleController extends SystemService } } break; case MSG_FINISH_IDLE_OP: { + // mActiveIdleWakeLock is held at this point decActiveIdleOps(); } break; } @@ -1356,6 +1367,9 @@ public class DeviceIdleController extends SystemService mActiveIdleWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "deviceidle_maint"); mActiveIdleWakeLock.setReferenceCounted(false); + mGoingIdleWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, + "deviceidle_going_idle"); + mGoingIdleWakeLock.setReferenceCounted(true); mConnectivityService = (ConnectivityService)ServiceManager.getService( Context.CONNECTIVITY_SERVICE); mLocalAlarmManager = getLocalService(AlarmManagerService.LocalService.class); @@ -1898,6 +1912,7 @@ public class DeviceIdleController extends SystemService mLightState = LIGHT_STATE_IDLE; EventLogTags.writeDeviceIdleLight(mLightState, reason); addEvent(EVENT_LIGHT_IDLE); + mGoingIdleWakeLock.acquire(); mHandler.sendEmptyMessage(MSG_REPORT_IDLE_ON_LIGHT); break; case LIGHT_STATE_IDLE: @@ -2023,6 +2038,7 @@ public class DeviceIdleController extends SystemService } EventLogTags.writeDeviceIdle(mState, reason); addEvent(EVENT_DEEP_IDLE); + mGoingIdleWakeLock.acquire(); mHandler.sendEmptyMessage(MSG_REPORT_IDLE_ON); break; case STATE_IDLE: diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java index 9d02940e21a5..cca8cc886246 100644 --- a/services/core/java/com/android/server/trust/TrustManagerService.java +++ b/services/core/java/com/android/server/trust/TrustManagerService.java @@ -169,7 +169,7 @@ public class TrustManagerService extends SystemService { CharSequence label; Drawable icon; ComponentName component; // service that implements ITrustAgent - ComponentName settings; // setting to launch to modify agent. + SettingsAttrs settings; // setting to launch to modify agent. TrustAgentWrapper agent; int userId; @@ -258,11 +258,6 @@ public class TrustManagerService extends SystemService { + ": switchToByUser=false"); continue; } - if (!StorageManager.isUserKeyUnlocked(userInfo.id)) { - if (DEBUG) Slog.d(TAG, "refreshAgentList: skipping user " + userInfo.id - + ": FDE still locked"); - continue; - } if (!mActivityManager.isUserRunning(userInfo.id)) { if (DEBUG) Slog.d(TAG, "refreshAgentList: skipping user " + userInfo.id + ": user not started"); @@ -273,13 +268,7 @@ public class TrustManagerService extends SystemService { + ": no secure credential"); continue; } - if (!mStrongAuthTracker.canAgentsRunForUser(userInfo.id)) { - if (DEBUG) Slog.d(TAG, "refreshAgentList: skipping user " + userInfo.id - + ": prevented by StrongAuthTracker = 0x" - + Integer.toHexString(mStrongAuthTracker.getStrongAuthForUser( - userInfo.id))); - continue; - } + DevicePolicyManager dpm = lockPatternUtils.getDevicePolicyManager(); int disabledFeatures = dpm.getKeyguardDisabledFeatures(null, userInfo.id); final boolean disableTrustAgents = @@ -312,16 +301,49 @@ public class TrustManagerService extends SystemService { continue; } } - AgentInfo agentInfo = new AgentInfo(); agentInfo.component = name; agentInfo.userId = userInfo.id; if (!mActiveAgents.contains(agentInfo)) { agentInfo.label = resolveInfo.loadLabel(pm); agentInfo.icon = resolveInfo.loadIcon(pm); - agentInfo.settings = getSettingsComponentName(pm, resolveInfo); + agentInfo.settings = getSettingsAttrs(pm, resolveInfo); agentInfo.agent = new TrustAgentWrapper(mContext, this, new Intent().setComponent(name), userInfo.getUserHandle()); + } else { + int index = mActiveAgents.indexOf(agentInfo); + agentInfo = mActiveAgents.valueAt(index); + } + + boolean directUnlock = resolveInfo.serviceInfo.directBootAware + && agentInfo.settings.canUnlockProfile; + + if (directUnlock) { + if (DEBUG) Slog.d(TAG, "refreshAgentList: trustagent " + name + + "of user " + userInfo.id + "can unlock user profile."); + } + + if (!StorageManager.isUserKeyUnlocked(userInfo.id) + && !directUnlock) { + if (DEBUG) Slog.d(TAG, "refreshAgentList: skipping user " + userInfo.id + + "'s trust agent " + name + ": FDE still locked and " + + " the agent cannot unlock user profile."); + continue; + } + + if (!mStrongAuthTracker.canAgentsRunForUser(userInfo.id)) { + int flag = mStrongAuthTracker.getStrongAuthForUser(userInfo.id); + if (flag != StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT + || !directUnlock) { + if (DEBUG) Slog.d(TAG, "refreshAgentList: skipping user " + userInfo.id + + ": prevented by StrongAuthTracker = 0x" + + Integer.toHexString(mStrongAuthTracker.getStrongAuthForUser( + userInfo.id))); + continue; + } + } + + if (!mActiveAgents.contains(agentInfo)) { mActiveAgents.add(agentInfo); } else { obsoleteAgents.remove(agentInfo); @@ -468,10 +490,12 @@ public class TrustManagerService extends SystemService { refreshAgentList(userId); } - private ComponentName getSettingsComponentName(PackageManager pm, ResolveInfo resolveInfo) { + private SettingsAttrs getSettingsAttrs(PackageManager pm, ResolveInfo resolveInfo) { if (resolveInfo == null || resolveInfo.serviceInfo == null || resolveInfo.serviceInfo.metaData == null) return null; String cn = null; + boolean canUnlockProfile = false; + XmlResourceParser parser = null; Exception caughtException = null; try { @@ -496,6 +520,8 @@ public class TrustManagerService extends SystemService { TypedArray sa = res .obtainAttributes(attrs, com.android.internal.R.styleable.TrustAgent); cn = sa.getString(com.android.internal.R.styleable.TrustAgent_settingsActivity); + canUnlockProfile = sa.getBoolean( + com.android.internal.R.styleable.TrustAgent_unlockProfile, false); sa.recycle(); } catch (PackageManager.NameNotFoundException e) { caughtException = e; @@ -516,7 +542,7 @@ public class TrustManagerService extends SystemService { if (cn.indexOf('/') < 0) { cn = resolveInfo.serviceInfo.packageName + "/" + cn; } - return ComponentName.unflattenFromString(cn); + return new SettingsAttrs(ComponentName.unflattenFromString(cn), canUnlockProfile); } private ComponentName getComponentName(ResolveInfo resolveInfo) { @@ -554,6 +580,7 @@ public class TrustManagerService extends SystemService { private List<ResolveInfo> resolveAllowedTrustAgents(PackageManager pm, int userId) { List<ResolveInfo> resolveInfos = pm.queryIntentServicesAsUser(TRUST_AGENT_INTENT, + PackageManager.GET_META_DATA | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId); ArrayList<ResolveInfo> allowedAgents = new ArrayList<>(resolveInfos.size()); @@ -991,6 +1018,18 @@ public class TrustManagerService extends SystemService { } }; + private static class SettingsAttrs { + public ComponentName componentName; + public boolean canUnlockProfile; + + public SettingsAttrs( + ComponentName componentName, + boolean canUnlockProfile) { + this.componentName = componentName; + this.canUnlockProfile = canUnlockProfile; + } + }; + private class Receiver extends BroadcastReceiver { @Override diff --git a/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java index aec6decccac3..1260a5369f50 100644 --- a/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java @@ -44,7 +44,6 @@ import static org.junit.Assert.assertTrue; * runtest frameworks-services -c com.android.server.wm.TaskPositionerTests */ @SmallTest -@Presubmit @RunWith(AndroidJUnit4.class) public class TaskPositionerTests extends WindowTestsBase { diff --git a/services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java b/services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java index 36bd13af7ea9..a820eb1171d5 100644 --- a/services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java @@ -45,7 +45,6 @@ import org.mockito.invocation.InvocationOnMock; * runtest frameworks-services -c com.android.server.wm.UnknownVisibilityControllerTest */ @SmallTest -@Presubmit @RunWith(AndroidJUnit4.class) public class UnknownAppVisibilityControllerTest { diff --git a/tools/preload2/Android.mk b/tools/preload2/Android.mk index 769db6bd3ead..d3ee1d370855 100644 --- a/tools/preload2/Android.mk +++ b/tools/preload2/Android.mk @@ -17,6 +17,8 @@ LOCAL_STATIC_JAVA_LIBRARIES += apache-harmony-jdwp-tests-host junit-host LOCAL_MODULE:= preload2 include $(BUILD_HOST_JAVA_LIBRARY) +# Copy to build artifacts +$(call dist-for-goals,dist_files,$(LOCAL_BUILT_MODULE):$(LOCAL_MODULE).jar) # Copy the preload-tool shell script to the host's bin directory. include $(CLEAR_VARS) |