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;
|
return admin;
|
||||||
}
|
}
|
||||||
admin.component = intent.getParcelableExtra(DevicePolicyManager.EXTRA_DEVICE_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)) {
|
if (intent.hasExtra(Intent.EXTRA_USER)) {
|
||||||
admin.user = intent.getParcelableExtra(Intent.EXTRA_USER);
|
admin.user = intent.getParcelableExtra(Intent.EXTRA_USER);
|
||||||
} else {
|
} 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) {
|
if (userId == UserHandle.USER_NULL) {
|
||||||
admin.user = null;
|
admin.user = null;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.android.settings.overlay.FeatureFactory;
|
|||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -38,8 +39,9 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean mIsBatteryPresent = true;
|
protected boolean mIsBatteryPresent = true;
|
||||||
|
@VisibleForTesting
|
||||||
|
Preference mPreference;
|
||||||
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
|
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
|
||||||
private Preference mPreference;
|
|
||||||
private BatteryInfo mBatteryInfo;
|
private BatteryInfo mBatteryInfo;
|
||||||
private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
|
private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
|
||||||
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
|
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
|
||||||
@@ -140,14 +142,26 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (batteryStatusUpdate) {
|
if (batteryStatusUpdate) {
|
||||||
if (!mBatteryStatusFeatureProvider.triggerBatteryStatusUpdate(this, info)) {
|
setSummaryAsync(info);
|
||||||
mBatteryStatusLabel = null; // will generateLabel()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mBatteryStatusLabel == null) ? generateLabel(info) : mBatteryStatusLabel;
|
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) {
|
private CharSequence generateLabel(BatteryInfo info) {
|
||||||
if (!info.discharging && info.chargeLabel != null) {
|
if (!info.discharging && info.chargeLabel != null) {
|
||||||
return info.chargeLabel;
|
return info.chargeLabel;
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
|
|
||||||
public final class PaymentDefaultDialog extends AlertActivity implements
|
public final class PaymentDefaultDialog extends AlertActivity implements
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
|
|
||||||
@@ -42,6 +44,9 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
getWindow().addPrivateFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mBackend = new PaymentBackend(this);
|
mBackend = new PaymentBackend(this);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ public class TopLevelBatteryPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDashboardLabel_returnsCorrectLabel() {
|
public void getDashboardLabel_returnsCorrectLabel() {
|
||||||
|
mController.mPreference = new Preference(mContext);
|
||||||
BatteryInfo info = new BatteryInfo();
|
BatteryInfo info = new BatteryInfo();
|
||||||
info.batteryPercentString = "3%";
|
info.batteryPercentString = "3%";
|
||||||
assertThat(mController.getDashboardLabel(mContext, info, true))
|
assertThat(mController.getDashboardLabel(mContext, info, true))
|
||||||
|
|||||||
Reference in New Issue
Block a user