Merge "Start quiet mode from a background thread." into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-16 11:11:31 +00:00
committed by Android (Google) Code Review
5 changed files with 20 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.IPackageManager;
import android.content.pm.ResolveInfo;
import android.os.AsyncTask;
import android.os.UserHandle;
import android.os.UserManager;
import android.stats.devicepolicy.DevicePolicyEnums;
@@ -90,7 +91,9 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
@Override
public void requestQuietModeEnabled(boolean enabled, UserHandle workProfileUserHandle) {
userManager.requestQuietModeEnabled(enabled, workProfileUserHandle);
AsyncTask.THREAD_POOL_EXECUTOR.execute(() -> {
userManager.requestQuietModeEnabled(enabled, workProfileUserHandle);
});
mIsWaitingToEnableWorkProfile = true;
}
};
@@ -284,7 +287,7 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
}
private int userHandleToPageIndex(UserHandle userHandle) {
if (userHandle == getPersonalListAdapter().mResolverListController.getUserHandle()) {
if (userHandle.equals(getPersonalListAdapter().mResolverListController.getUserHandle())) {
return PROFILE_PERSONAL;
} else {
return PROFILE_WORK;
@@ -293,7 +296,7 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
private boolean rebuildTab(ResolverListAdapter activeListAdapter, boolean doPostProcessing) {
UserHandle listUserHandle = activeListAdapter.getUserHandle();
if (listUserHandle == mWorkProfileUserHandle
if (listUserHandle.equals(mWorkProfileUserHandle)
&& mInjector.isQuietModeEnabled(mWorkProfileUserHandle)) {
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.RESOLVER_EMPTY_STATE_WORK_APPS_DISABLED)
@@ -311,7 +314,7 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
if (UserHandle.myUserId() != listUserHandle.getIdentifier()) {
if (!mInjector.hasCrossProfileIntents(activeListAdapter.getIntents(),
UserHandle.myUserId(), listUserHandle.getIdentifier())) {
if (listUserHandle == mPersonalProfileUserHandle) {
if (listUserHandle.equals(mPersonalProfileUserHandle)) {
DevicePolicyEventLogger.createEvent(
DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_PERSONAL)
.setStrings(getMetricsCategory())

View File

@@ -2140,7 +2140,7 @@ public class ChooserActivity extends ResolverActivity implements
return null;
}
if (getPersonalProfileUserHandle() == userHandle) {
if (getPersonalProfileUserHandle().equals(userHandle)) {
if (mPersonalAppPredictor != null) {
return mPersonalAppPredictor;
}
@@ -2166,7 +2166,7 @@ public class ChooserActivity extends ResolverActivity implements
.getSystemService(AppPredictionManager.class);
AppPredictor appPredictionSession = appPredictionManager.createAppPredictionSession(
appPredictionContext);
if (getPersonalProfileUserHandle() == userHandle) {
if (getPersonalProfileUserHandle().equals(userHandle)) {
mPersonalAppPredictor = appPredictionSession;
} else {
mWorkAppPredictor = appPredictionSession;
@@ -2566,7 +2566,7 @@ public class ChooserActivity extends ResolverActivity implements
ChooserListAdapter chooserListAdapter = (ChooserListAdapter) listAdapter;
if (chooserListAdapter.getUserHandle()
== mChooserMultiProfilePagerAdapter.getCurrentUserHandle()) {
.equals(mChooserMultiProfilePagerAdapter.getCurrentUserHandle())) {
mChooserMultiProfilePagerAdapter.getActiveAdapterView()
.setAdapter(mChooserMultiProfilePagerAdapter.getCurrentRootAdapter());
mChooserMultiProfilePagerAdapter

View File

@@ -93,10 +93,10 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
@Override
@Nullable
ChooserListAdapter getListAdapterForUserHandle(UserHandle userHandle) {
if (getActiveListAdapter().getUserHandle() == userHandle) {
if (getActiveListAdapter().getUserHandle().equals(userHandle)) {
return getActiveListAdapter();
} else if (getInactiveListAdapter() != null
&& getInactiveListAdapter().getUserHandle() == userHandle) {
&& getInactiveListAdapter().getUserHandle().equals(userHandle)) {
return getInactiveListAdapter();
}
return null;

View File

@@ -1242,12 +1242,12 @@ public class ResolverActivity extends Activity implements
}
private void maybeLogCrossProfileTargetLaunch(TargetInfo cti, UserHandle currentUserHandle) {
if (!hasWorkProfile() || currentUserHandle == getUser()) {
if (!hasWorkProfile() || currentUserHandle.equals(getUser())) {
return;
}
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.RESOLVER_CROSS_PROFILE_TARGET_OPENED)
.setBoolean(currentUserHandle == getPersonalProfileUserHandle())
.setBoolean(currentUserHandle.equals(getPersonalProfileUserHandle()))
.setStrings(getMetricsCategory(),
cti instanceof ChooserTargetInfo ? "direct_share" : "other_target")
.write();
@@ -1486,7 +1486,8 @@ public class ResolverActivity extends Activity implements
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.RESOLVER_AUTOLAUNCH_CROSS_PROFILE_TARGET)
.setBoolean(activeListAdapter.getUserHandle() == getPersonalProfileUserHandle())
.setBoolean(activeListAdapter.getUserHandle()
.equals(getPersonalProfileUserHandle()))
.setStrings(getMetricsCategory())
.write();
safelyStartActivity(activeProfileTarget);
@@ -1778,7 +1779,7 @@ public class ResolverActivity extends Activity implements
@Override // ResolverListCommunicator
public void onHandlePackagesChanged(ResolverListAdapter listAdapter) {
if (listAdapter == mMultiProfilePagerAdapter.getActiveListAdapter()) {
if (listAdapter.getUserHandle() == getWorkProfileUserHandle()
if (listAdapter.getUserHandle().equals(getWorkProfileUserHandle())
&& mMultiProfilePagerAdapter.isWaitingToEnableWorkProfile()) {
// We have just turned on the work profile and entered the pass code to start it,
// now we are waiting to receive the ACTION_USER_UNLOCKED broadcast. There is no
@@ -1819,7 +1820,7 @@ public class ResolverActivity extends Activity implements
mMultiProfilePagerAdapter.markWorkProfileEnabledBroadcastReceived();
}
if (mMultiProfilePagerAdapter.getCurrentUserHandle()
== getWorkProfileUserHandle()) {
.equals(getWorkProfileUserHandle())) {
mMultiProfilePagerAdapter.rebuildActiveTab(true);
} else {
mMultiProfilePagerAdapter.clearInactiveProfileCache();

View File

@@ -103,10 +103,10 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA
@Override
@Nullable
ResolverListAdapter getListAdapterForUserHandle(UserHandle userHandle) {
if (getActiveListAdapter().getUserHandle() == userHandle) {
if (getActiveListAdapter().getUserHandle().equals(userHandle)) {
return getActiveListAdapter();
} else if (getInactiveListAdapter() != null
&& getInactiveListAdapter().getUserHandle() == userHandle) {
&& getInactiveListAdapter().getUserHandle().equals(userHandle)) {
return getInactiveListAdapter();
}
return null;