DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master
Bug: 120502534 Change-Id: I63bedf30fa0a4629cfab1dbe94359b4d36cf9ac1
This commit is contained in:
@@ -23,10 +23,14 @@ import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.bluetooth.BluetoothPairingDialogFragment.BluetoothPairingDialogListener;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@@ -50,8 +54,10 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
|
||||
|
||||
// Bluetooth dependencies for the connection we are trying to establish
|
||||
private LocalBluetoothManager mBluetoothManager;
|
||||
private BluetoothDevice mDevice;
|
||||
private int mType;
|
||||
@VisibleForTesting
|
||||
BluetoothDevice mDevice;
|
||||
@VisibleForTesting
|
||||
int mType;
|
||||
private String mUserInput;
|
||||
private String mPasskeyFormatted;
|
||||
private int mPasskey;
|
||||
@@ -82,7 +88,6 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
|
||||
mDeviceName = mBluetoothManager.getCachedDeviceManager().getName(mDevice);
|
||||
mPbapClientProfile = mBluetoothManager.getProfileManager().getPbapClientProfile();
|
||||
mPasskeyFormatted = formatKey(mPasskey);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,12 +101,13 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
|
||||
|
||||
@Override
|
||||
public void onDialogPositiveClick(BluetoothPairingDialogFragment dialog) {
|
||||
if (mPbapAllowed) {
|
||||
mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
|
||||
} else {
|
||||
mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
|
||||
}
|
||||
|
||||
if (getDialogType() == USER_ENTRY_DIALOG) {
|
||||
if (mPbapAllowed) {
|
||||
mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
|
||||
} else {
|
||||
mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
|
||||
}
|
||||
onPair(mUserInput);
|
||||
} else {
|
||||
onPair(null);
|
||||
|
@@ -33,6 +33,7 @@ import com.android.settings.wrapper.OverlayManagerWrapper;
|
||||
import com.android.settings.wrapper.OverlayManagerWrapper.OverlayInfo;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class EmulateDisplayCutoutPreferenceController extends
|
||||
@@ -40,6 +41,8 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
PreferenceControllerMixin {
|
||||
|
||||
private static final String KEY = "display_cutout_emulation";
|
||||
private static final Comparator<OverlayInfo> OVERLAY_INFO_COMPARATOR =
|
||||
Comparator.comparingInt(a -> a.priority);
|
||||
|
||||
private final OverlayManagerWrapper mOverlayManager;
|
||||
private final boolean mAvailable;
|
||||
@@ -120,7 +123,7 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
|
||||
int current = 0;
|
||||
pkgs[0] = "";
|
||||
labels[0] = mContext.getString(R.string.display_cutout_emulation_none);
|
||||
labels[0] = mContext.getString(R.string.display_cutout_emulation_device_default);
|
||||
|
||||
for (int i = 0; i < overlays.length; i++) {
|
||||
OverlayInfo o = overlays[i];
|
||||
@@ -153,6 +156,7 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
overlayInfos.remove(i);
|
||||
}
|
||||
}
|
||||
overlayInfos.sort(OVERLAY_INFO_COMPARATOR);
|
||||
return overlayInfos.toArray(new OverlayInfo[overlayInfos.size()]);
|
||||
}
|
||||
|
||||
|
@@ -24,8 +24,8 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.Bundle;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
@@ -35,7 +35,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseLongArray;
|
||||
@@ -48,7 +47,6 @@ import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.fuelgauge.batterytip.AnomalyInfo;
|
||||
import com.android.settings.fuelgauge.batterytip.StatsManagerConfig;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.utils.PowerUtil;
|
||||
|
||||
@@ -93,14 +91,14 @@ public class BatteryUtils {
|
||||
|
||||
public static BatteryUtils getInstance(Context context) {
|
||||
if (sInstance == null || sInstance.isDataCorrupted()) {
|
||||
sInstance = new BatteryUtils(context);
|
||||
sInstance = new BatteryUtils(context.getApplicationContext());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
BatteryUtils(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mContext = context;
|
||||
mPackageManager = context.getPackageManager();
|
||||
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
mPowerUsageFeatureProvider = FeatureFactory.getFactory(
|
||||
|
@@ -94,7 +94,8 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
|
||||
if (mPowerUsageFeatureProvider == null) {
|
||||
mPowerUsageFeatureProvider = new PowerUsageFeatureProviderImpl(context);
|
||||
mPowerUsageFeatureProvider = new PowerUsageFeatureProviderImpl(
|
||||
context.getApplicationContext());
|
||||
}
|
||||
return mPowerUsageFeatureProvider;
|
||||
}
|
||||
@@ -102,7 +103,8 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public DashboardFeatureProvider getDashboardFeatureProvider(Context context) {
|
||||
if (mDashboardFeatureProvider == null) {
|
||||
mDashboardFeatureProvider = new DashboardFeatureProviderImpl(context);
|
||||
mDashboardFeatureProvider = new DashboardFeatureProviderImpl(
|
||||
context.getApplicationContext());
|
||||
}
|
||||
return mDashboardFeatureProvider;
|
||||
}
|
||||
@@ -118,10 +120,11 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
||||
if (mApplicationFeatureProvider == null) {
|
||||
mApplicationFeatureProvider = new ApplicationFeatureProviderImpl(context,
|
||||
new PackageManagerWrapper(context.getPackageManager()),
|
||||
final Context appContext = context.getApplicationContext();
|
||||
mApplicationFeatureProvider = new ApplicationFeatureProviderImpl(appContext,
|
||||
new PackageManagerWrapper(appContext.getPackageManager()),
|
||||
AppGlobals.getPackageManager(),
|
||||
(DevicePolicyManager) context
|
||||
(DevicePolicyManager) appContext
|
||||
.getSystemService(Context.DEVICE_POLICY_SERVICE));
|
||||
}
|
||||
return mApplicationFeatureProvider;
|
||||
@@ -138,12 +141,14 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public EnterprisePrivacyFeatureProvider getEnterprisePrivacyFeatureProvider(Context context) {
|
||||
if (mEnterprisePrivacyFeatureProvider == null) {
|
||||
mEnterprisePrivacyFeatureProvider = new EnterprisePrivacyFeatureProviderImpl(context,
|
||||
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE),
|
||||
new PackageManagerWrapper(context.getPackageManager()),
|
||||
UserManager.get(context),
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE),
|
||||
context.getResources());
|
||||
final Context appContext = context.getApplicationContext();
|
||||
mEnterprisePrivacyFeatureProvider = new EnterprisePrivacyFeatureProviderImpl(appContext,
|
||||
(DevicePolicyManager) appContext
|
||||
.getSystemService(Context.DEVICE_POLICY_SERVICE),
|
||||
new PackageManagerWrapper(appContext.getPackageManager()),
|
||||
UserManager.get(appContext),
|
||||
(ConnectivityManager) appContext.getSystemService(Context.CONNECTIVITY_SERVICE),
|
||||
appContext.getResources());
|
||||
}
|
||||
return mEnterprisePrivacyFeatureProvider;
|
||||
}
|
||||
@@ -172,7 +177,8 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public SuggestionFeatureProvider getSuggestionFeatureProvider(Context context) {
|
||||
if (mSuggestionFeatureProvider == null) {
|
||||
mSuggestionFeatureProvider = new SuggestionFeatureProviderImpl(context);
|
||||
mSuggestionFeatureProvider = new SuggestionFeatureProviderImpl(
|
||||
context.getApplicationContext());
|
||||
}
|
||||
return mSuggestionFeatureProvider;
|
||||
}
|
||||
@@ -180,7 +186,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public UserFeatureProvider getUserFeatureProvider(Context context) {
|
||||
if (mUserFeatureProvider == null) {
|
||||
mUserFeatureProvider = new UserFeatureProviderImpl(context);
|
||||
mUserFeatureProvider = new UserFeatureProviderImpl(context.getApplicationContext());
|
||||
}
|
||||
return mUserFeatureProvider;
|
||||
}
|
||||
|
@@ -382,7 +382,7 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
void registerIntentToUri(IntentFilter intentFilter, Uri sliceUri) {
|
||||
Log.d(TAG, "Registering Uri for broadcast relay: " + sliceUri);
|
||||
mRegisteredUris.add(sliceUri);
|
||||
SliceBroadcastRelay.registerReceiver(getContext(), sliceUri, SliceBroadcastReceiver.class,
|
||||
SliceBroadcastRelay.registerReceiver(getContext(), sliceUri, SliceRelayReceiver.class,
|
||||
intentFilter);
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,6 @@ import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.notification.ZenModeSliceBuilder;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.wifi.WifiSliceBuilder;
|
||||
import com.android.settingslib.SliceBroadcastRelay;
|
||||
|
||||
/**
|
||||
* Responds to actions performed on slices and notifies slices of updates in state changes.
|
||||
@@ -84,12 +83,6 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
|
||||
case ACTION_ZEN_MODE_SLICE_CHANGED:
|
||||
ZenModeSliceBuilder.handleUriChange(context, intent);
|
||||
break;
|
||||
default:
|
||||
final String uriString = intent.getStringExtra(SliceBroadcastRelay.EXTRA_URI);
|
||||
if (!TextUtils.isEmpty(uriString)) {
|
||||
final Uri uri = Uri.parse(uriString);
|
||||
context.getContentResolver().notifyChange(uri, null /* observer */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
39
src/com/android/settings/slices/SliceRelayReceiver.java
Normal file
39
src/com/android/settings/slices/SliceRelayReceiver.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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
|
||||
*/
|
||||
|
||||
package com.android.settings.slices;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import com.android.settingslib.SliceBroadcastRelay;
|
||||
|
||||
/**
|
||||
* Receives broadcasts to notify that Settings Slices are potentially stale.
|
||||
*/
|
||||
public class SliceRelayReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String uriString = intent.getStringExtra(SliceBroadcastRelay.EXTRA_URI);
|
||||
if (!TextUtils.isEmpty(uriString)) {
|
||||
final Uri uri = Uri.parse(uriString);
|
||||
context.getContentResolver().notifyChange(uri, null /* observer */);
|
||||
}
|
||||
}
|
||||
}
|
@@ -81,18 +81,21 @@ public class OverlayManagerWrapper {
|
||||
public static final String CATEGORY_THEME = android.content.om.OverlayInfo.CATEGORY_THEME;
|
||||
public final String packageName;
|
||||
public final String category;
|
||||
public final int priority;
|
||||
private final boolean mEnabled;
|
||||
|
||||
public OverlayInfo(String packageName, String category, boolean enabled) {
|
||||
public OverlayInfo(String packageName, String category, boolean enabled, int priority) {
|
||||
this.packageName = packageName;
|
||||
this.category = category;
|
||||
mEnabled = enabled;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public OverlayInfo(android.content.om.OverlayInfo info) {
|
||||
mEnabled = info.isEnabled();
|
||||
category = info.category;
|
||||
packageName = info.packageName;
|
||||
priority = info.priority;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
|
Reference in New Issue
Block a user