Snap for 7786608 from 83c5600879 to sc-v2-release
Change-Id: Ib3d82212dde8412023d4cdfc454d951f9712f47d
This commit is contained in:
@@ -58,11 +58,25 @@ public class ActionDisabledByAdminDialog extends Activity
|
||||
return admin;
|
||||
}
|
||||
admin.component = intent.getParcelableExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN);
|
||||
int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
|
||||
|
||||
Bundle adminDetails = null;
|
||||
if (admin.component == null) {
|
||||
DevicePolicyManager devicePolicyManager = getSystemService(DevicePolicyManager.class);
|
||||
adminDetails = devicePolicyManager.getEnforcingAdminAndUserDetails(userId,
|
||||
getRestrictionFromIntent(intent));
|
||||
if (adminDetails != null) {
|
||||
admin.component = adminDetails.getParcelable(
|
||||
DevicePolicyManager.EXTRA_DEVICE_ADMIN);
|
||||
}
|
||||
}
|
||||
|
||||
if (intent.hasExtra(Intent.EXTRA_USER)) {
|
||||
admin.user = intent.getParcelableExtra(Intent.EXTRA_USER);
|
||||
} else {
|
||||
int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
|
||||
if (adminDetails != null) {
|
||||
userId = adminDetails.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
|
||||
}
|
||||
if (userId == UserHandle.USER_NULL) {
|
||||
admin.user = null;
|
||||
} else {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -38,8 +39,9 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
|
||||
@VisibleForTesting
|
||||
protected boolean mIsBatteryPresent = true;
|
||||
@VisibleForTesting
|
||||
Preference mPreference;
|
||||
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
|
||||
private Preference mPreference;
|
||||
private BatteryInfo mBatteryInfo;
|
||||
private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
|
||||
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
|
||||
@@ -140,14 +142,26 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
}
|
||||
|
||||
if (batteryStatusUpdate) {
|
||||
if (!mBatteryStatusFeatureProvider.triggerBatteryStatusUpdate(this, info)) {
|
||||
mBatteryStatusLabel = null; // will generateLabel()
|
||||
}
|
||||
setSummaryAsync(info);
|
||||
}
|
||||
|
||||
return (mBatteryStatusLabel == null) ? generateLabel(info) : mBatteryStatusLabel;
|
||||
}
|
||||
|
||||
private void setSummaryAsync(BatteryInfo info) {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
final boolean triggerBatteryStatusUpdate =
|
||||
mBatteryStatusFeatureProvider.triggerBatteryStatusUpdate(this, info);
|
||||
ThreadUtils.postOnMainThread(() -> {
|
||||
if (!triggerBatteryStatusUpdate) {
|
||||
mBatteryStatusLabel = null; // will generateLabel()
|
||||
}
|
||||
mPreference.setSummary(
|
||||
(mBatteryStatusLabel == null) ? generateLabel(info) : mBatteryStatusLabel);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private CharSequence generateLabel(BatteryInfo info) {
|
||||
if (!info.discharging && info.chargeLabel != null) {
|
||||
return info.chargeLabel;
|
||||
|
||||
@@ -30,6 +30,8 @@ import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
DialogInterface.OnClickListener {
|
||||
|
||||
@@ -42,6 +44,9 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getWindow().addPrivateFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
|
||||
try {
|
||||
mBackend = new PaymentBackend(this);
|
||||
} catch (NullPointerException e) {
|
||||
|
||||
@@ -156,6 +156,7 @@ public class TopLevelBatteryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getDashboardLabel_returnsCorrectLabel() {
|
||||
mController.mPreference = new Preference(mContext);
|
||||
BatteryInfo info = new BatteryInfo();
|
||||
info.batteryPercentString = "3%";
|
||||
assertThat(mController.getDashboardLabel(mContext, info, true))
|
||||
|
||||
Reference in New Issue
Block a user