diff options
Diffstat (limited to 'services')
25 files changed, 424 insertions, 210 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index bfe8b5c..6c1023c 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -9368,44 +9368,47 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF throw new SecurityException("No permission to restore other packages"); } - // So far so good; we're allowed to try to restore this package. Now - // check whether there is data for it in the current dataset, falling back - // to the ancestral dataset if not. - long token = getAvailableRestoreToken(packageName); - if (DEBUG) Slog.v(TAG, "restorePackage pkg=" + packageName - + " token=" + Long.toHexString(token)); - - // If we didn't come up with a place to look -- no ancestral dataset and - // the app has never been backed up from this device -- there's nothing - // to do but return failure. - if (token == 0) { - if (DEBUG) Slog.w(TAG, "No data available for this package; not restoring"); - return -1; - } - - String dirName; + // So far so good; we're allowed to try to restore this package. + long oldId = Binder.clearCallingIdentity(); try { - dirName = mRestoreTransport.transportDirName(); - } catch (RemoteException e) { - // Transport went AWOL; fail. - Slog.e(TAG, "Unable to contact transport for restore"); - return -1; - } + // Check whether there is data for it in the current dataset, falling back + // to the ancestral dataset if not. + long token = getAvailableRestoreToken(packageName); + if (DEBUG) Slog.v(TAG, "restorePackage pkg=" + packageName + + " token=" + Long.toHexString(token)); + + // If we didn't come up with a place to look -- no ancestral dataset and + // the app has never been backed up from this device -- there's nothing + // to do but return failure. + if (token == 0) { + if (DEBUG) Slog.w(TAG, "No data available for this package; not restoring"); + return -1; + } - // Stop the session timeout until we finalize the restore - mBackupHandler.removeMessages(MSG_RESTORE_TIMEOUT); + String dirName; + try { + dirName = mRestoreTransport.transportDirName(); + } catch (RemoteException e) { + // Transport went AWOL; fail. + Slog.e(TAG, "Unable to contact transport for restore"); + return -1; + } - // Ready to go: enqueue the restore request and claim success - long oldId = Binder.clearCallingIdentity(); - mWakelock.acquire(); - if (MORE_DEBUG) { - Slog.d(TAG, "restorePackage() : " + packageName); + // Stop the session timeout until we finalize the restore + mBackupHandler.removeMessages(MSG_RESTORE_TIMEOUT); + + // Ready to go: enqueue the restore request and claim success + mWakelock.acquire(); + if (MORE_DEBUG) { + Slog.d(TAG, "restorePackage() : " + packageName); + } + Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE); + msg.obj = new RestoreParams(mRestoreTransport, dirName, + observer, token, app, 0); + mBackupHandler.sendMessage(msg); + } finally { + Binder.restoreCallingIdentity(oldId); } - Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE); - msg.obj = new RestoreParams(mRestoreTransport, dirName, - observer, token, app, 0); - mBackupHandler.sendMessage(msg); - Binder.restoreCallingIdentity(oldId); return 0; } diff --git a/services/core/java/com/android/server/AssetAtlasService.java b/services/core/java/com/android/server/AssetAtlasService.java index 26f4232..ebc810f 100644 --- a/services/core/java/com/android/server/AssetAtlasService.java +++ b/services/core/java/com/android/server/AssetAtlasService.java @@ -119,7 +119,6 @@ public class AssetAtlasService extends IAssetAtlas.Stub { // long0: SkBitmap*, the native bitmap object // long1: x position // long2: y position - // long3: rotated, 1 if the bitmap must be rotated, 0 otherwise private long[] mAtlasMap; /** @@ -236,7 +235,7 @@ public class AssetAtlasService extends IAssetAtlas.Stub { /** * Renders a list of bitmaps into the atlas. The position of each bitmap * was decided by the packing algorithm and will be honored by this - * method. If need be this method will also rotate bitmaps. + * method. * * @param buffer The buffer to render the atlas entries into * @param atlas The atlas to pack the bitmaps into @@ -280,16 +279,11 @@ public class AssetAtlasService extends IAssetAtlas.Stub { canvas.save(); canvas.translate(entry.x, entry.y); - if (entry.rotated) { - canvas.translate(bitmap.getHeight(), 0.0f); - canvas.rotate(90.0f); - } canvas.drawBitmap(bitmap, 0.0f, 0.0f, null); canvas.restore(); atlasMap[mapIndex++] = bitmap.refSkPixelRef(); atlasMap[mapIndex++] = entry.x; atlasMap[mapIndex++] = entry.y; - atlasMap[mapIndex++] = entry.rotated ? 1 : 0; } } diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 1019faa..32b91d2 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -512,7 +512,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private void onBluetoothGattServiceUp() { if (DBG) Log.d(TAG,"BluetoothGatt Service is Up"); try{ - if (isBleAppPresent() == false && mBluetooth.getState() == BluetoothAdapter.STATE_BLE_ON) { + if (isBleAppPresent() == false && mBluetooth != null + && mBluetooth.getState() == BluetoothAdapter.STATE_BLE_ON) { mBluetooth.onLeServiceUp(); // waive WRITE_SECURE_SETTINGS permission check @@ -531,32 +532,26 @@ class BluetoothManagerService extends IBluetoothManager.Stub { */ private void sendBrEdrDownCallback() { if (DBG) Log.d(TAG,"Calling sendBrEdrDownCallback callbacks"); - int n = mCallbacks.beginBroadcast(); + + if(mBluetooth == null) { + Log.w(TAG, "Bluetooth handle is null"); + return; + } if (isBleAppPresent() == false) { try { mBluetooth.onBrEdrDown(); } catch(RemoteException e) { - Log.e(TAG,"Unable to call onBrEdrDown", e); + Log.e(TAG, "Call to onBrEdrDown() failed.", e); } - } - else{//need to stay at BLE ON. disconnect all Gatt connections + } else { + // Need to stay at BLE ON. Disconnect all Gatt connections try{ - mBluetoothGatt.unregAll();//disconnectAll(); + mBluetoothGatt.unregAll(); } catch(RemoteException e) { - Log.e(TAG,"Unable to disconn all", e); - } - } - - Log.d(TAG,"Broadcasting onBrEdrDown() to " + n + " receivers."); - for (int i=0; i <n; i++) { - try { - mCallbacks.getBroadcastItem(i).onBrEdrDown(); - } catch (RemoteException e) { - Log.e(TAG, "Unable to call sendBrEdrDownCallback() on callback #" + i, e); + Log.e(TAG, "Unable to disconnect all apps.", e); } } - mCallbacks.finishBroadcast(); } /** @hide*/ diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 8d1d124..1dc2d7e 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -190,7 +190,7 @@ public class ConnectivityService extends IConnectivityManager.Stub /** Set of ifaces that are costly. */ private HashSet<String> mMeteredIfaces = Sets.newHashSet(); - private Context mContext; + final private Context mContext; private int mNetworkPreference; // 0 is full bad, 100 is full good private int mDefaultInetConditionPublished = 0; @@ -344,6 +344,11 @@ public class ConnectivityService extends IConnectivityManager.Stub */ private static final int EVENT_PROMPT_UNVALIDATED = 29; + /** + * used internally to (re)configure mobile data always-on settings. + */ + private static final int EVENT_CONFIGURE_MOBILE_DATA_ALWAYS_ON = 30; + /** Handler used for internal events. */ final private InternalHandler mHandler; /** Handler used for incoming {@link NetworkStateTracker} events. */ @@ -374,7 +379,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private PacManager mPacManager = null; - private SettingsObserver mSettingsObserver; + final private SettingsObserver mSettingsObserver; private UserManager mUserManager; @@ -555,13 +560,12 @@ public class ConnectivityService extends IConnectivityManager.Stub INetworkStatsService statsService, INetworkPolicyManager policyManager) { if (DBG) log("ConnectivityService starting up"); - NetworkCapabilities netCap = new NetworkCapabilities(); - netCap.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); - netCap.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED); - mDefaultRequest = new NetworkRequest(netCap, TYPE_NONE, nextNetworkRequestId()); - NetworkRequestInfo nri = new NetworkRequestInfo(null, mDefaultRequest, new Binder(), - NetworkRequestInfo.REQUEST); - mNetworkRequests.put(mDefaultRequest, nri); + mDefaultRequest = createInternetRequestForTransport(-1); + mNetworkRequests.put(mDefaultRequest, new NetworkRequestInfo( + null, mDefaultRequest, new Binder(), NetworkRequestInfo.REQUEST)); + + mDefaultMobileDataRequest = createInternetRequestForTransport( + NetworkCapabilities.TRANSPORT_CELLULAR); HandlerThread handlerThread = new HandlerThread("ConnectivityServiceThread"); handlerThread.start(); @@ -696,8 +700,8 @@ public class ConnectivityService extends IConnectivityManager.Stub mInetLog = new ArrayList(); } - mSettingsObserver = new SettingsObserver(mHandler, EVENT_APPLY_GLOBAL_HTTP_PROXY); - mSettingsObserver.observe(mContext); + mSettingsObserver = new SettingsObserver(mContext, mHandler); + registerSettingsCallbacks(); mDataConnectionStats = new DataConnectionStats(mContext); mDataConnectionStats.startMonitoring(); @@ -707,6 +711,44 @@ public class ConnectivityService extends IConnectivityManager.Stub mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE); } + private NetworkRequest createInternetRequestForTransport(int transportType) { + NetworkCapabilities netCap = new NetworkCapabilities(); + netCap.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); + netCap.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED); + if (transportType > -1) { + netCap.addTransportType(transportType); + } + return new NetworkRequest(netCap, TYPE_NONE, nextNetworkRequestId()); + } + + private void handleMobileDataAlwaysOn() { + final boolean enable = (Settings.Global.getInt( + mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON, 0) == 1); + final boolean isEnabled = (mNetworkRequests.get(mDefaultMobileDataRequest) != null); + if (enable == isEnabled) { + return; // Nothing to do. + } + + if (enable) { + handleRegisterNetworkRequest(new NetworkRequestInfo( + null, mDefaultMobileDataRequest, new Binder(), NetworkRequestInfo.REQUEST)); + } else { + handleReleaseNetworkRequest(mDefaultMobileDataRequest, Process.SYSTEM_UID); + } + } + + private void registerSettingsCallbacks() { + // Watch for global HTTP proxy changes. + mSettingsObserver.observe( + Settings.Global.getUriFor(Settings.Global.HTTP_PROXY), + EVENT_APPLY_GLOBAL_HTTP_PROXY); + + // Watch for whether or not to keep mobile data always on. + mSettingsObserver.observe( + Settings.Global.getUriFor(Settings.Global.MOBILE_DATA_ALWAYS_ON), + EVENT_CONFIGURE_MOBILE_DATA_ALWAYS_ON); + } + private synchronized int nextNetworkRequestId() { return mNextNetworkRequestId++; } @@ -1491,6 +1533,9 @@ public class ConnectivityService extends IConnectivityManager.Stub mContext.registerReceiver(mUserPresentReceiver, filter); } + // Configure whether mobile data is always on. + mHandler.sendMessage(mHandler.obtainMessage(EVENT_CONFIGURE_MOBILE_DATA_ALWAYS_ON)); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_SYSTEM_READY)); mPermissionMonitor.startMonitoring(); @@ -2107,12 +2152,10 @@ public class ConnectivityService extends IConnectivityManager.Stub + nri.request + " because their intents matched."); handleReleaseNetworkRequest(existingRequest.request, getCallingUid()); } - handleRegisterNetworkRequest(msg); + handleRegisterNetworkRequest(nri); } - private void handleRegisterNetworkRequest(Message msg) { - final NetworkRequestInfo nri = (NetworkRequestInfo) (msg.obj); - + private void handleRegisterNetworkRequest(NetworkRequestInfo nri) { mNetworkRequests.put(nri.request, nri); // TODO: This logic may be better replaced with a call to rematchNetworkAndRequests @@ -2423,7 +2466,7 @@ public class ConnectivityService extends IConnectivityManager.Stub } case EVENT_REGISTER_NETWORK_REQUEST: case EVENT_REGISTER_NETWORK_LISTENER: { - handleRegisterNetworkRequest(msg); + handleRegisterNetworkRequest((NetworkRequestInfo) msg.obj); break; } case EVENT_REGISTER_NETWORK_REQUEST_WITH_INTENT: { @@ -2446,6 +2489,10 @@ public class ConnectivityService extends IConnectivityManager.Stub handlePromptUnvalidated((Network) msg.obj); break; } + case EVENT_CONFIGURE_MOBILE_DATA_ALWAYS_ON: { + handleMobileDataAlwaysOn(); + break; + } case EVENT_SYSTEM_READY: { for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { nai.networkMonitor.systemReady = true; @@ -2837,23 +2884,36 @@ public class ConnectivityService extends IConnectivityManager.Stub } private static class SettingsObserver extends ContentObserver { - private int mWhat; - private Handler mHandler; - SettingsObserver(Handler handler, int what) { - super(handler); + final private HashMap<Uri, Integer> mUriEventMap; + final private Context mContext; + final private Handler mHandler; + + SettingsObserver(Context context, Handler handler) { + super(null); + mUriEventMap = new HashMap<Uri, Integer>(); + mContext = context; mHandler = handler; - mWhat = what; } - void observe(Context context) { - ContentResolver resolver = context.getContentResolver(); - resolver.registerContentObserver(Settings.Global.getUriFor( - Settings.Global.HTTP_PROXY), false, this); + void observe(Uri uri, int what) { + mUriEventMap.put(uri, what); + final ContentResolver resolver = mContext.getContentResolver(); + resolver.registerContentObserver(uri, false, this); } @Override public void onChange(boolean selfChange) { - mHandler.obtainMessage(mWhat).sendToTarget(); + Slog.wtf(TAG, "Should never be reached."); + } + + @Override + public void onChange(boolean selfChange, Uri uri) { + final Integer what = mUriEventMap.get(uri); + if (what != null) { + mHandler.obtainMessage(what.intValue()).sendToTarget(); + } else { + loge("No matching event to send for URI=" + uri); + } } } @@ -3643,6 +3703,10 @@ public class ConnectivityService extends IConnectivityManager.Stub // Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated. private final NetworkRequest mDefaultRequest; + // Request used to optionally keep mobile data active even when higher + // priority networks like Wi-Fi are active. + private final NetworkRequest mDefaultMobileDataRequest; + private NetworkAgentInfo getDefaultNetwork() { return mNetworkForRequestId.get(mDefaultRequest.requestId); } diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 45909db..9511f54 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -2038,11 +2038,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (!mIWindowManager.inputMethodClientHasFocus(client)) { if (DEBUG) Slog.w(TAG, "Ignoring hideSoftInput of uid " + uid + ": " + client); - setImeWindowVisibilityStatusHiddenLocked(); return false; } } catch (RemoteException e) { - setImeWindowVisibilityStatusHiddenLocked(); return false; } } @@ -2238,7 +2236,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } @Override - public void showInputMethodPickerFromClient(IInputMethodClient client) { + public void showInputMethodPickerFromClient( + IInputMethodClient client, int auxiliarySubtypeMode) { if (!calledFromValidUser()) { return; } @@ -2251,7 +2250,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Always call subtype picker, because subtype picker is a superset of input method // picker. - mHandler.sendEmptyMessage(MSG_SHOW_IM_SUBTYPE_PICKER); + mHandler.sendMessage(mCaller.obtainMessageI( + MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode)); } } @@ -2597,7 +2597,25 @@ public class InputMethodManagerService extends IInputMethodManager.Stub SomeArgs args; switch (msg.what) { case MSG_SHOW_IM_SUBTYPE_PICKER: - showInputMethodMenu(); + final boolean showAuxSubtypes; + switch (msg.arg1) { + case InputMethodManager.SHOW_IM_PICKER_MODE_AUTO: + // This is undocumented so far, but IMM#showInputMethodPicker() has been + // implemented so that auxiliary subtypes will be excluded when the soft + // keyboard is invisible. + showAuxSubtypes = mInputShown; + break; + case InputMethodManager.SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES: + showAuxSubtypes = true; + break; + case InputMethodManager.SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES: + showAuxSubtypes = false; + break; + default: + Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1); + return false; + } + showInputMethodMenu(showAuxSubtypes); return true; case MSG_SHOW_IM_SUBTYPE_ENABLER: @@ -2880,8 +2898,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub && mKeyguardManager.isKeyguardLocked() && mKeyguardManager.isKeyguardSecure(); } - private void showInputMethodMenu() { - if (DEBUG) Slog.v(TAG, "Show switching menu"); + private void showInputMethodMenu(boolean showAuxSubtypes) { + if (DEBUG) Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes); final Context context = mContext; final boolean isScreenLocked = isScreenLocked(); @@ -2902,7 +2920,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub final List<ImeSubtypeListItem> imList = mSwitchingController.getSortedInputMethodAndSubtypeListLocked( - true /* showSubtypes */, mInputShown, isScreenLocked); + true /* showSubtypes */, showAuxSubtypes, isScreenLocked); if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) { final InputMethodSubtype currentSubtype = getCurrentInputMethodSubtypeLocked(); diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index a07591c9..ac55292 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -488,7 +488,8 @@ public class Vpn { try { // Restricted users are not allowed to create VPNs, they are tied to Owner UserInfo user = mgr.getUserInfo(mUserHandle); - if (user.isRestricted() || mgr.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) { + if (user.isRestricted() || mgr.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN, + new UserHandle(mUserHandle))) { throw new SecurityException("Restricted users cannot establish VPNs"); } @@ -896,7 +897,8 @@ public class Vpn { } UserManager mgr = UserManager.get(mContext); UserInfo user = mgr.getUserInfo(mUserHandle); - if (user.isRestricted() || mgr.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) { + if (user.isRestricted() || mgr.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN, + new UserHandle(mUserHandle))) { throw new SecurityException("Restricted users cannot establish VPNs"); } diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java index 7cccef2..3dc282b 100644 --- a/services/core/java/com/android/server/content/SyncManager.java +++ b/services/core/java/com/android/server/content/SyncManager.java @@ -52,6 +52,7 @@ import android.content.pm.RegisteredServicesCache; import android.content.pm.RegisteredServicesCacheListener; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; +import android.database.ContentObserver; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.BatteryStats; @@ -99,6 +100,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Random; @@ -157,7 +159,19 @@ public class SyncManager { /** * How long to wait before considering an active sync to have timed-out, and cancelling it. */ - private static final long ACTIVE_SYNC_TIMEOUT_MILLIS = 30L * 60 * 1000; // 30 mins. + private static final long ACTIVE_SYNC_TIMEOUT_MILLIS = 30L * 60 * 1000; // 30 mins + + /** + * How long to delay each queued {@link SyncHandler} message that may have occurred before boot + * or befor the device became provisioned. + */ + private static final long PER_SYNC_BOOT_DELAY_MILLIS = 3000L; // 3 seconds + + /** + * The maximum amount of time we're willing to delay syncs out of boot, after device has been + * provisioned, etc. + */ + private static final long MAX_SYNC_BOOT_DELAY_MILLIS = 120000L; // 2 minutes private static final String SYNC_WAKE_LOCK_PREFIX = "*sync*/"; private static final String HANDLE_SYNC_ALARM_WAKE_LOCK = "SyncManagerHandleSyncAlarm"; @@ -198,6 +212,9 @@ public class SyncManager { // its accessor, getConnManager(). private ConnectivityManager mConnManagerDoNotUseDirectly; + /** Track whether the device has already been provisioned. */ + private boolean mProvisioned; + protected SyncAdaptersCache mSyncAdapters; private final AppIdleMonitor mAppIdleMonitor; @@ -242,6 +259,7 @@ public class SyncManager { private BroadcastReceiver mBootCompletedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { + mBootCompleted = true; mSyncHandler.onBootCompleted(); } }; @@ -491,12 +509,41 @@ public class SyncManager { mSyncStorageEngine.addStatusChangeListener( ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, new ISyncStatusObserver.Stub() { - @Override - public void onStatusChanged(int which) { - // force the sync loop to run if the settings change - sendCheckAlarmsMessage(); + @Override + public void onStatusChanged(int which) { + // force the sync loop to run if the settings change + sendCheckAlarmsMessage(); + } + }); + + mProvisioned = isDeviceProvisioned(); + if (!mProvisioned) { + final ContentResolver resolver = context.getContentResolver(); + ContentObserver provisionedObserver = + new ContentObserver(null /* current thread */) { + public void onChange(boolean selfChange) { + mProvisioned |= isDeviceProvisioned(); + if (mProvisioned) { + mSyncHandler.onDeviceProvisioned(); + resolver.unregisterContentObserver(this); + } + } + }; + + synchronized (mSyncHandler) { + resolver.registerContentObserver( + Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), + false /* notifyForDescendents */, + provisionedObserver); + + // The device *may* have been provisioned while we were registering above observer. + // Check again to make sure. + mProvisioned |= isDeviceProvisioned(); + if (mProvisioned) { + resolver.unregisterContentObserver(provisionedObserver); + } } - }); + } if (!factoryTest) { // Register for account list updates for all users @@ -510,6 +557,10 @@ public class SyncManager { mSyncRandomOffsetMillis = mSyncStorageEngine.getSyncRandomOffset() * 1000; } + private boolean isDeviceProvisioned() { + final ContentResolver resolver = mContext.getContentResolver(); + return (Settings.Global.getInt(resolver, Settings.Global.DEVICE_PROVISIONED, 0) != 0); + } /** * Return a random value v that satisfies minValue <= v < maxValue. The difference between * maxValue and minValue must be less than Integer.MAX_VALUE. @@ -2000,20 +2051,36 @@ public class SyncManager { public final SyncTimeTracker mSyncTimeTracker = new SyncTimeTracker(); private final HashMap<String, PowerManager.WakeLock> mWakeLocks = Maps.newHashMap(); - private List<Message> mBootQueue = new ArrayList<Message>(); + private List<Message> mUnreadyQueue = new ArrayList<Message>(); - public void onBootCompleted() { + void onBootCompleted() { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Boot completed, clearing boot queue."); } doDatabaseCleanup(); synchronized(this) { // Dispatch any stashed messages. - for (Message message : mBootQueue) { - sendMessage(message); + maybeEmptyUnreadyQueueLocked(); + } + } + + void onDeviceProvisioned() { + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "mProvisioned=" + mProvisioned); + } + synchronized (this) { + maybeEmptyUnreadyQueueLocked(); + } + } + + private void maybeEmptyUnreadyQueueLocked() { + if (mProvisioned && mBootCompleted) { + // Dispatch any stashed messages. + for (int i=0; i<mUnreadyQueue.size(); i++) { + sendMessageDelayed(mUnreadyQueue.get(i), + Math.max(PER_SYNC_BOOT_DELAY_MILLIS * i, MAX_SYNC_BOOT_DELAY_MILLIS)); } - mBootQueue = null; - mBootCompleted = true; + mUnreadyQueue = null; } } @@ -2030,20 +2097,23 @@ public class SyncManager { } /** - * Stash any messages that come to the handler before boot is complete. - * {@link #onBootCompleted()} will disable this and dispatch all the messages collected. + * Stash any messages that come to the handler before boot is complete or before the device + * is properly provisioned (i.e. out of set-up wizard). + * {@link #onBootCompleted()} and {@link #onDeviceProvisioned(boolean)} both need to come + * in before we start syncing. * @param msg Message to dispatch at a later point. * @return true if a message was enqueued, false otherwise. This is to avoid losing the * message if we manage to acquire the lock but by the time we do boot has completed. */ private boolean tryEnqueueMessageUntilReadyToRun(Message msg) { synchronized (this) { - if (!mBootCompleted) { + if (!mBootCompleted || !mProvisioned) { // Need to copy the message bc looper will recycle it. - mBootQueue.add(Message.obtain(msg)); + mUnreadyQueue.add(Message.obtain(msg)); return true; + } else { + return false; } - return false; } } @@ -2100,7 +2170,7 @@ public class SyncManager { } cancelActiveSync(expiredContext.mSyncOperation.target, expiredContext.mSyncOperation.extras); - nextPendingSyncTime = maybeStartNextSyncLocked(); + nextPendingSyncTime = maybeStartNextSyncH(); break; case SyncHandler.MESSAGE_CANCEL: { @@ -2111,7 +2181,7 @@ public class SyncManager { + payload + " bundle: " + extras); } cancelActiveSyncLocked(payload, extras); - nextPendingSyncTime = maybeStartNextSyncLocked(); + nextPendingSyncTime = maybeStartNextSyncH(); break; } @@ -2120,17 +2190,17 @@ public class SyncManager { Log.v(TAG, "handleSyncHandlerMessage: MESSAGE_SYNC_FINISHED"); } SyncHandlerMessagePayload payload = (SyncHandlerMessagePayload) msg.obj; - if (!isSyncStillActive(payload.activeSyncContext)) { + if (!isSyncStillActiveH(payload.activeSyncContext)) { Log.d(TAG, "handleSyncHandlerMessage: dropping since the " + "sync is no longer active: " + payload.activeSyncContext); break; } - runSyncFinishedOrCanceledLocked(payload.syncResult, + runSyncFinishedOrCanceledH(payload.syncResult, payload.activeSyncContext); // since a sync just finished check if it is time to start a new sync - nextPendingSyncTime = maybeStartNextSyncLocked(); + nextPendingSyncTime = maybeStartNextSyncH(); break; case SyncHandler.MESSAGE_SERVICE_CONNECTED: { @@ -2140,7 +2210,7 @@ public class SyncManager { + msgData.activeSyncContext); } // check that this isn't an old message - if (isSyncStillActive(msgData.activeSyncContext)) { + if (isSyncStillActiveH(msgData.activeSyncContext)) { runBoundToAdapter( msgData.activeSyncContext, msgData.adapter); @@ -2156,7 +2226,7 @@ public class SyncManager { + currentSyncContext); } // check that this isn't an old message - if (isSyncStillActive(currentSyncContext)) { + if (isSyncStillActiveH(currentSyncContext)) { // cancel the sync if we have a syncadapter, which means one is // outstanding try { @@ -2174,10 +2244,10 @@ public class SyncManager { // which is a soft error SyncResult syncResult = new SyncResult(); syncResult.stats.numIoExceptions++; - runSyncFinishedOrCanceledLocked(syncResult, currentSyncContext); + runSyncFinishedOrCanceledH(syncResult, currentSyncContext); // since a sync just finished check if it is time to start a new sync - nextPendingSyncTime = maybeStartNextSyncLocked(); + nextPendingSyncTime = maybeStartNextSyncH(); } break; @@ -2190,7 +2260,7 @@ public class SyncManager { } mAlarmScheduleTime = null; try { - nextPendingSyncTime = maybeStartNextSyncLocked(); + nextPendingSyncTime = maybeStartNextSyncH(); } finally { mHandleAlarmWakeLock.release(); } @@ -2201,7 +2271,7 @@ public class SyncManager { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "handleSyncHandlerMessage: MESSAGE_CHECK_ALARMS"); } - nextPendingSyncTime = maybeStartNextSyncLocked(); + nextPendingSyncTime = maybeStartNextSyncH(); break; } } finally { @@ -2393,7 +2463,7 @@ public class SyncManager { 0 : (earliestFuturePollTime - nowAbsolute)); } - private long maybeStartNextSyncLocked() { + private long maybeStartNextSyncH() { final boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); if (isLoggable) Log.v(TAG, "maybeStartNextSync"); @@ -2612,7 +2682,7 @@ public class SyncManager { } if (toReschedule != null) { - runSyncFinishedOrCanceledLocked(null, toReschedule); + runSyncFinishedOrCanceledH(null, toReschedule); scheduleSyncOperation(toReschedule.mSyncOperation); } synchronized (mSyncQueue) { @@ -2845,14 +2915,14 @@ public class SyncManager { false /* no config settings */)) { continue; } - runSyncFinishedOrCanceledLocked(null /* no result since this is a cancel */, + runSyncFinishedOrCanceledH(null /* no result since this is a cancel */, activeSyncContext); } } } - private void runSyncFinishedOrCanceledLocked(SyncResult syncResult, - ActiveSyncContext activeSyncContext) { + private void runSyncFinishedOrCanceledH(SyncResult syncResult, + ActiveSyncContext activeSyncContext) { boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); final SyncOperation syncOperation = activeSyncContext.mSyncOperation; @@ -3257,7 +3327,7 @@ public class SyncManager { } } - private boolean isSyncStillActive(ActiveSyncContext activeSyncContext) { + private boolean isSyncStillActiveH(ActiveSyncContext activeSyncContext) { for (ActiveSyncContext sync : mActiveSyncContexts) { if (sync == activeSyncContext) { return true; diff --git a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java index 6f59b54..7f961ae 100644 --- a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java +++ b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java @@ -82,7 +82,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { appToken.linkToDeath(device, 0); } catch (RemoteException ex) { mVirtualDisplayDevices.remove(appToken); - device.destroyLocked(); + device.destroyLocked(false); return null; } @@ -110,7 +110,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { public DisplayDevice releaseVirtualDisplayLocked(IBinder appToken) { VirtualDisplayDevice device = mVirtualDisplayDevices.remove(appToken); if (device != null) { - device.destroyLocked(); + device.destroyLocked(true); appToken.unlinkToDeath(device, 0); } @@ -147,7 +147,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { if (device != null) { Slog.i(TAG, "Virtual display device released because application token died: " + device.mOwnerPackageName); - device.destroyLocked(); + device.destroyLocked(false); sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_REMOVED); } } @@ -205,19 +205,19 @@ final class VirtualDisplayAdapter extends DisplayAdapter { @Override public void binderDied() { synchronized (getSyncRoot()) { - if (mSurface != null) { - handleBinderDiedLocked(mAppToken); - } + handleBinderDiedLocked(mAppToken); } } - public void destroyLocked() { + public void destroyLocked(boolean binderAlive) { if (mSurface != null) { mSurface.release(); mSurface = null; } SurfaceControl.destroyDisplay(getDisplayTokenLocked()); - mCallback.dispatchDisplayStopped(); + if (binderAlive) { + mCallback.dispatchDisplayStopped(); + } } @Override diff --git a/services/core/java/com/android/server/hdmi/Constants.java b/services/core/java/com/android/server/hdmi/Constants.java index e434f39..8c12060 100644 --- a/services/core/java/com/android/server/hdmi/Constants.java +++ b/services/core/java/com/android/server/hdmi/Constants.java @@ -214,6 +214,10 @@ final class Constants { // values which denotes the device type in HDMI Spec 1.4. static final String PROPERTY_DEVICE_TYPE = "ro.hdmi.device_type"; + // TODO(OEM): Set this to false to keep the playback device in sleep upon hotplug event. + // True by default. + static final String PROPERTY_WAKE_ON_HOTPLUG = "ro.hdmi.wake_on_hotplug"; + // Set to false to allow playback device to go to suspend mode even // when it's an active source. True by default. static final String PROPERTY_KEEP_AWAKE = "persist.sys.hdmi.keep_awake"; diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java index 89ffe45..fd3364a 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java @@ -34,6 +34,9 @@ import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly; final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { private static final String TAG = "HdmiCecLocalDevicePlayback"; + private static final boolean WAKE_ON_HOTPLUG = + SystemProperties.getBoolean(Constants.PROPERTY_WAKE_ON_HOTPLUG, true); + private boolean mIsActiveSource = false; // Used to keep the device awake while it is the active source. For devices that @@ -130,7 +133,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { assertRunOnServiceThread(); mCecMessageCache.flushAll(); // We'll not clear mIsActiveSource on the hotplug event to pass CETC 11.2.2-2 ~ 3. - if (connected && mService.isPowerStandbyOrTransient()) { + if (WAKE_ON_HOTPLUG && connected && mService.isPowerStandbyOrTransient()) { mService.wakeUp(); } if (!connected) { diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java index 5ac027d..e650456 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java @@ -486,6 +486,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { HdmiLogger.debug("Input not ready for device: %X; buffering the command", info.getId()); mDelayedMessageBuffer.add(message); } else { + updateDevicePowerStatus(logicalAddress, HdmiControlManager.POWER_STATUS_ON); ActiveSource activeSource = ActiveSource.of(logicalAddress, physicalAddress); ActiveSourceHandler.create(this, null).process(activeSource, info.getDeviceType()); } @@ -1613,6 +1614,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { super.disableDevice(initiatedByCec, callback); clearDeviceInfoList(); + getActiveSource().invalidate(); + setActivePath(Constants.INVALID_PHYSICAL_ADDRESS); checkIfPendingActionsCleared(); } diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index 09d0501..dca762c 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -27,9 +27,6 @@ import android.media.MediaDescription; import android.media.MediaMetadata; import android.media.Rating; import android.media.VolumeProvider; -import android.media.routing.IMediaRouter; -import android.media.routing.IMediaRouterDelegate; -import android.media.routing.IMediaRouterStateCallback; import android.media.session.ISession; import android.media.session.ISessionCallback; import android.media.session.ISessionController; @@ -718,11 +715,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } @Override - public void setMediaRouter(IMediaRouter router) { - mHandler.post(MessageHandler.MSG_UPDATE_SESSION_STATE); - } - - @Override public void setMediaButtonReceiver(PendingIntent pi) { mMediaButtonReceiver = pi; } @@ -1209,13 +1201,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { public boolean isTransportControlEnabled() { return MediaSessionRecord.this.isTransportControlEnabled(); } - - @Override - public IMediaRouterDelegate createMediaRouterDelegate( - IMediaRouterStateCallback callback) { - // todo - return null; - } } private class MessageHandler extends Handler { diff --git a/services/core/java/com/android/server/notification/CalendarTracker.java b/services/core/java/com/android/server/notification/CalendarTracker.java index c82df48..28da73c 100644 --- a/services/core/java/com/android/server/notification/CalendarTracker.java +++ b/services/core/java/com/android/server/notification/CalendarTracker.java @@ -47,6 +47,7 @@ public class CalendarTracker { Instances.EVENT_ID, Instances.OWNER_ACCOUNT, Instances.CALENDAR_ID, + Instances.AVAILABILITY, }; private static final String INSTANCE_ORDER_BY = Instances.BEGIN + " ASC"; @@ -143,11 +144,14 @@ public class CalendarTracker { final int eventId = cursor.getInt(4); final String owner = cursor.getString(5); final long calendarId = cursor.getLong(6); - if (DEBUG) Log.d(TAG, String.format("%s %s-%s v=%s eid=%s o=%s cid=%s", title, - new Date(begin), new Date(end), visible, eventId, owner, calendarId)); + final int availability = cursor.getInt(7); + if (DEBUG) Log.d(TAG, String.format("%s %s-%s v=%s a=%s eid=%s o=%s cid=%s", title, + new Date(begin), new Date(end), visible, availabilityToString(availability), + eventId, owner, calendarId)); final boolean meetsTime = time >= begin && time < end; final boolean meetsCalendar = visible - && (filter.calendar == 0 || filter.calendar == calendarId); + && (filter.calendar == 0 || filter.calendar == calendarId) + && availability != Instances.AVAILABILITY_FREE; if (meetsCalendar) { if (DEBUG) Log.d(TAG, " MEETS CALENDAR"); final boolean meetsAttendee = meetsAttendee(filter, eventId, owner); @@ -228,6 +232,15 @@ public class CalendarTracker { } } + private static String availabilityToString(int availability) { + switch (availability) { + case Instances.AVAILABILITY_BUSY: return "AVAILABILITY_BUSY"; + case Instances.AVAILABILITY_FREE: return "AVAILABILITY_FREE"; + case Instances.AVAILABILITY_TENTATIVE: return "AVAILABILITY_TENTATIVE"; + default: return "AVAILABILITY_UNKNOWN_" + availability; + } + } + private static boolean meetsReply(int reply, int attendeeStatus) { switch (reply) { case EventInfo.REPLY_YES: diff --git a/services/core/java/com/android/server/notification/ZenModeFiltering.java b/services/core/java/com/android/server/notification/ZenModeFiltering.java index 2aaeb9d..80dc523 100644 --- a/services/core/java/com/android/server/notification/ZenModeFiltering.java +++ b/services/core/java/com/android/server/notification/ZenModeFiltering.java @@ -86,7 +86,7 @@ public class ZenModeFiltering { if (validator != null) { final float contactAffinity = validator.getContactAffinity(userHandle, extras, contactsTimeoutMs, timeoutAffinity); - return audienceMatches(config, contactAffinity); + return audienceMatches(config.allowCallsFrom, contactAffinity); } } return true; @@ -133,14 +133,14 @@ public class ZenModeFiltering { ZenLog.traceIntercepted(record, "!allowCalls"); return true; } - return shouldInterceptAudience(config, record); + return shouldInterceptAudience(config.allowCallsFrom, record); } if (isMessage(record)) { if (!config.allowMessages) { ZenLog.traceIntercepted(record, "!allowMessages"); return true; } - return shouldInterceptAudience(config, record); + return shouldInterceptAudience(config.allowMessagesFrom, record); } if (isEvent(record)) { if (!config.allowEvents) { @@ -163,9 +163,8 @@ public class ZenModeFiltering { } } - private static boolean shouldInterceptAudience(ZenModeConfig config, - NotificationRecord record) { - if (!audienceMatches(config, record.getContactAffinity())) { + private static boolean shouldInterceptAudience(int source, NotificationRecord record) { + if (!audienceMatches(source, record.getContactAffinity())) { ZenLog.traceIntercepted(record, "!audienceMatches"); return true; } @@ -219,8 +218,8 @@ public class ZenModeFiltering { return record.isCategory(Notification.CATEGORY_MESSAGE) || isDefaultMessagingApp(record); } - private static boolean audienceMatches(ZenModeConfig config, float contactAffinity) { - switch (config.allowFrom) { + private static boolean audienceMatches(int source, float contactAffinity) { + switch (source) { case ZenModeConfig.SOURCE_ANYONE: return true; case ZenModeConfig.SOURCE_CONTACT: @@ -228,7 +227,7 @@ public class ZenModeFiltering { case ZenModeConfig.SOURCE_STAR: return contactAffinity >= ValidateNotificationPeople.STARRED_CONTACT; default: - Slog.w(TAG, "Encountered unknown source: " + config.allowFrom); + Slog.w(TAG, "Encountered unknown source: " + source); return true; } } diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java index 83f0bcf..e97def8 100644 --- a/services/core/java/com/android/server/notification/ZenModeHelper.java +++ b/services/core/java/com/android/server/notification/ZenModeHelper.java @@ -209,9 +209,11 @@ public class ZenModeHelper { pw.println(config); return; } - pw.printf("allow(calls=%s,repeatCallers=%s,events=%s,from=%s,messages=%s,reminders=%s)\n", - config.allowCalls, config.allowRepeatCallers, config.allowEvents, config.allowFrom, - config.allowMessages, config.allowReminders); + pw.printf("allow(calls=%s,callsFrom=%s,repeatCallers=%s,messages=%s,messagesFrom=%s," + + "events=%s,reminders=%s)\n", + config.allowCalls, config.allowCallsFrom, config.allowRepeatCallers, + config.allowMessages, config.allowMessagesFrom, + config.allowEvents, config.allowReminders); pw.print(prefix); pw.print(" manualRule="); pw.println(config.manualRule); if (config.automaticRules.isEmpty()) return; final int N = config.automaticRules.size(); @@ -483,8 +485,9 @@ public class ZenModeHelper { final ZenModeConfig rt = new ZenModeConfig(); rt.allowCalls = v1.allowCalls; rt.allowEvents = v1.allowEvents; - rt.allowFrom = v1.allowFrom; + rt.allowCallsFrom = v1.allowFrom; rt.allowMessages = v1.allowMessages; + rt.allowMessagesFrom = v1.allowFrom; rt.allowReminders = v1.allowReminders; // don't migrate current exit condition final int[] days = ZenModeConfig.XmlV1.tryParseDays(v1.sleepMode); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index f30a5674..a120c1f 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -11853,6 +11853,7 @@ public class PackageManagerService extends IPackageManager.Stub { synchronized (mPackages) { if (deletedPs != null) { if ((flags&PackageManager.DELETE_KEEP_DATA) == 0) { + clearIntentFilterVerificationsLPw(deletedPs.name, UserHandle.USER_ALL); if (outInfo != null) { mSettings.mKeySetManagerService.removeAppKeySetDataLPw(packageName); outInfo.removedAppId = mSettings.removePackageLPw(packageName); @@ -11883,7 +11884,6 @@ public class PackageManagerService extends IPackageManager.Stub { } } clearPackagePreferredActivitiesLPw(deletedPs.name, UserHandle.USER_ALL); - clearIntentFilterVerificationsLPw(deletedPs.name, UserHandle.USER_ALL); } // make sure to preserve per-user disabled state if this removal was just // a downgrade of a system app to the factory package @@ -12744,13 +12744,16 @@ public class PackageManagerService extends IPackageManager.Stub { /** This method takes a specific user id as well as UserHandle.USER_ALL. */ void clearIntentFilterVerificationsLPw(String packageName, int userId) { if (userId == UserHandle.USER_ALL) { - mSettings.removeIntentFilterVerificationLPw(packageName, sUserManager.getUserIds()); - for (int oneUserId : sUserManager.getUserIds()) { - scheduleWritePackageRestrictionsLocked(oneUserId); + if (mSettings.removeIntentFilterVerificationLPw(packageName, + sUserManager.getUserIds())) { + for (int oneUserId : sUserManager.getUserIds()) { + scheduleWritePackageRestrictionsLocked(oneUserId); + } } } else { - mSettings.removeIntentFilterVerificationLPw(packageName, userId); - scheduleWritePackageRestrictionsLocked(userId); + if (mSettings.removeIntentFilterVerificationLPw(packageName, userId)) { + scheduleWritePackageRestrictionsLocked(userId); + } } } diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index d476bfde..fd70ce1 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -1067,19 +1067,22 @@ final class Settings { return result; } - void removeIntentFilterVerificationLPw(String packageName, int userId) { + boolean removeIntentFilterVerificationLPw(String packageName, int userId) { PackageSetting ps = mPackages.get(packageName); if (ps == null) { Slog.w(PackageManagerService.TAG, "No package known for name: " + packageName); - return; + return false; } ps.clearDomainVerificationStatusForUser(userId); + return true; } - void removeIntentFilterVerificationLPw(String packageName, int[] userIds) { + boolean removeIntentFilterVerificationLPw(String packageName, int[] userIds) { + boolean result = false; for (int userId : userIds) { - removeIntentFilterVerificationLPw(packageName, userId); + result |= removeIntentFilterVerificationLPw(packageName, userId); } + return result; } boolean setDefaultBrowserPackageNameLPr(String packageName, int userId) { diff --git a/services/core/java/com/android/server/policy/BarController.java b/services/core/java/com/android/server/policy/BarController.java index e972ec7..5877b3e 100644 --- a/services/core/java/com/android/server/policy/BarController.java +++ b/services/core/java/com/android/server/policy/BarController.java @@ -58,6 +58,9 @@ public class BarController { private int mTransientBarState; private boolean mPendingShow; private long mLastTranslucent; + private boolean mShowTransparent; + private boolean mSetUnHideFlagWhenNextTransparent; + private boolean mNoAnimationOnNextShow; public BarController(String tag, int transientFlag, int unhideFlag, int translucentFlag, int statusBarManagerId, int translucentWmFlag) { @@ -74,6 +77,14 @@ public class BarController { mWin = win; } + public void setShowTransparent(boolean transparent) { + if (transparent != mShowTransparent) { + mShowTransparent = transparent; + mSetUnHideFlagWhenNextTransparent = transparent; + mNoAnimationOnNextShow = true; + } + } + public void showTransient() { if (mWin != null) { setTransientBarState(TRANSIENT_BAR_SHOW_REQUESTED); @@ -135,7 +146,9 @@ public class BarController { } final boolean wasVis = mWin.isVisibleLw(); final boolean wasAnim = mWin.isAnimatingLw(); - final boolean change = show ? mWin.showLw(true) : mWin.hideLw(true); + final boolean change = show ? mWin.showLw(!mNoAnimationOnNextShow) + : mWin.hideLw(!mNoAnimationOnNextShow); + mNoAnimationOnNextShow = false; final int state = computeStateLw(wasVis, wasAnim, mWin, change); final boolean stateChanged = updateStateLw(state); return change || stateChanged; @@ -233,6 +246,13 @@ public class BarController { setTransientBarState(TRANSIENT_BAR_NONE); // request denied } } + if (mShowTransparent) { + vis |= View.SYSTEM_UI_TRANSPARENT; + if (mSetUnHideFlagWhenNextTransparent) { + vis |= mUnhideFlag; + mSetUnHideFlagWhenNextTransparent = false; + } + } if (mTransientBarState != TRANSIENT_BAR_NONE) { vis |= mTransientFlag; // ignore clear requests until transition completes vis &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; // never show transient bars in low profile diff --git a/services/core/java/com/android/server/policy/GlobalActions.java b/services/core/java/com/android/server/policy/GlobalActions.java index b431b33..3cee927 100644 --- a/services/core/java/com/android/server/policy/GlobalActions.java +++ b/services/core/java/com/android/server/policy/GlobalActions.java @@ -1138,7 +1138,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac public GlobalActionsDialog(Context context, AlertParams params) { super(context, getDialogTheme(context)); - mContext = context; + mContext = getContext(); mAlert = new AlertController(mContext, this, getWindow()); mAdapter = (MyAdapter) params.mAdapter; mWindowTouchSlop = ViewConfiguration.get(context).getScaledWindowTouchSlop(); diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 51503ec..185ef03 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -93,7 +93,7 @@ import android.view.KeyCharacterMap; import android.view.KeyCharacterMap.FallbackAction; import android.view.KeyEvent; import android.view.MotionEvent; -import android.view.PhoneWindow; +import com.android.internal.policy.PhoneWindow; import android.view.Surface; import android.view.View; import android.view.ViewConfiguration; @@ -476,6 +476,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mTopIsFullscreen; boolean mForceStatusBar; boolean mForceStatusBarFromKeyguard; + private boolean mForceStatusBarTransparent; boolean mHideLockScreen; boolean mForcingShowNavBar; int mForcingShowNavBarLayer; @@ -4129,6 +4130,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mAppsThatDismissKeyguard.clear(); mForceStatusBar = false; mForceStatusBarFromKeyguard = false; + mForceStatusBarTransparent = false; mForcingShowNavBar = false; mForcingShowNavBarLayer = -1; @@ -4154,8 +4156,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { mForcingShowNavBar = true; mForcingShowNavBarLayer = win.getSurfaceLayer(); } - if (attrs.type == TYPE_STATUS_BAR && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { - mForceStatusBarFromKeyguard = true; + if (attrs.type == TYPE_STATUS_BAR) { + if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { + mForceStatusBarFromKeyguard = true; + } + if ((attrs.privateFlags & PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT) != 0) { + mForceStatusBarTransparent = true; + } } boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW @@ -4302,7 +4309,15 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar + " forcefkg=" + mForceStatusBarFromKeyguard + " top=" + mTopFullscreenOpaqueWindowState); - if (mForceStatusBar || mForceStatusBarFromKeyguard) { + boolean shouldBeTransparent = mForceStatusBarTransparent + && !mForceStatusBar + && !mForceStatusBarFromKeyguard; + if (!shouldBeTransparent) { + mStatusBarController.setShowTransparent(false /* transparent */); + } else if (!mStatusBar.isVisibleLw()) { + mStatusBarController.setShowTransparent(true /* transparent */); + } + if (mForceStatusBar || mForceStatusBarFromKeyguard || mForceStatusBarTransparent) { if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); if (mStatusBarController.setBarShowingLw(true)) { changes |= FINISH_LAYOUT_REDO_LAYOUT; diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java index c48367e..fd98010 100644 --- a/services/core/java/com/android/server/power/Notifier.java +++ b/services/core/java/com/android/server/power/Notifier.java @@ -539,9 +539,11 @@ final class Notifier { }; private void playWirelessChargingStartedSound() { + final boolean enabled = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.CHARGING_SOUNDS_ENABLED, 1) != 0; final String soundPath = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.WIRELESS_CHARGING_STARTED_SOUND); - if (soundPath != null) { + if (enabled && soundPath != null) { final Uri soundUri = Uri.parse("file://" + soundPath); if (soundUri != null) { final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index c886c4c..6f01ca0 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -161,7 +161,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { private static final String TAG_STATUS_BAR = "statusbar"; - private static final String ATTR_ENABLED = "enabled"; + private static final String ATTR_DISABLED = "disabled"; private static final String DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML = "do-not-ask-credentials-on-boot"; @@ -313,7 +313,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // This is the list of component allowed to start lock task mode. List<String> mLockTaskPackages = new ArrayList<>(); - boolean mStatusBarEnabledState = true; + boolean mStatusBarDisabled = false; ComponentName mRestrictionsProvider; @@ -1476,9 +1476,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { out.endTag(null, TAG_LOCK_TASK_COMPONENTS); } - if (!policy.mStatusBarEnabledState) { + if (policy.mStatusBarDisabled) { out.startTag(null, TAG_STATUS_BAR); - out.attribute(null, ATTR_ENABLED, Boolean.toString(policy.mStatusBarEnabledState)); + out.attribute(null, ATTR_DISABLED, Boolean.toString(policy.mStatusBarDisabled)); out.endTag(null, TAG_STATUS_BAR); } @@ -1615,8 +1615,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } else if (TAG_LOCK_TASK_COMPONENTS.equals(tag)) { policy.mLockTaskPackages.add(parser.getAttributeValue(null, "name")); } else if (TAG_STATUS_BAR.equals(tag)) { - policy.mStatusBarEnabledState = Boolean.parseBoolean( - parser.getAttributeValue(null, ATTR_ENABLED)); + policy.mStatusBarDisabled = Boolean.parseBoolean( + parser.getAttributeValue(null, ATTR_DISABLED)); } else if (DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML.equals(tag)) { policy.doNotAskCredentialsOnBoot = true; } else { @@ -1678,8 +1678,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { updateMaximumTimeToLockLocked(policy); addDeviceInitializerToLockTaskPackagesLocked(userHandle); updateLockTaskPackagesLocked(policy.mLockTaskPackages, userHandle); - if (!policy.mStatusBarEnabledState) { - setStatusBarEnabledStateInternal(policy.mStatusBarEnabledState, userHandle); + if (policy.mStatusBarDisabled) { + setStatusBarDisabledInternal(policy.mStatusBarDisabled, userHandle); } updatePreferredSetupActivityLocked(userHandle); } @@ -4275,7 +4275,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { DevicePolicyData policy = getUserData(userId); policy.mPermissionPolicy = DevicePolicyManager.PERMISSION_POLICY_PROMPT; policy.mDelegatedCertInstallerPackage = null; - policy.mStatusBarEnabledState = true; + policy.mStatusBarDisabled = false; saveSettingsLocked(userId); long ident = Binder.clearCallingIdentity(); @@ -6026,7 +6026,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public boolean setKeyguardEnabledState(ComponentName who, boolean enabled) { + public boolean setKeyguardDisabled(ComponentName who, boolean disabled) { Preconditions.checkNotNull(who, "ComponentName is null"); synchronized (this) { getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); @@ -6037,10 +6037,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { long ident = Binder.clearCallingIdentity(); try { // disallow disabling the keyguard if a password is currently set - if (!enabled && utils.isSecure(userId)) { + if (disabled && utils.isSecure(userId)) { return false; } - utils.setLockScreenDisabled(!enabled, userId); + utils.setLockScreenDisabled(disabled, userId); } finally { Binder.restoreCallingIdentity(ident); } @@ -6048,35 +6048,40 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public void setStatusBarEnabledState(ComponentName who, boolean enabled) { + public boolean setStatusBarDisabled(ComponentName who, boolean disabled) { int userId = UserHandle.getCallingUserId(); synchronized (this) { getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); DevicePolicyData policy = getUserData(userId); - if (policy.mStatusBarEnabledState != enabled) { - policy.mStatusBarEnabledState = enabled; - setStatusBarEnabledStateInternal(enabled, userId); + if (policy.mStatusBarDisabled != disabled) { + if (!setStatusBarDisabledInternal(disabled, userId)) { + return false; + } + policy.mStatusBarDisabled = disabled; saveSettingsLocked(userId); } } + return true; } - private void setStatusBarEnabledStateInternal(boolean enabled, int userId) { + private boolean setStatusBarDisabledInternal(boolean disabled, int userId) { long ident = Binder.clearCallingIdentity(); try { IStatusBarService statusBarService = IStatusBarService.Stub.asInterface( ServiceManager.checkService(Context.STATUS_BAR_SERVICE)); if (statusBarService != null) { - int flags1 = enabled ? StatusBarManager.DISABLE_NONE : STATUS_BAR_DISABLE_MASK; - int flags2 = enabled ? StatusBarManager.DISABLE2_NONE : STATUS_BAR_DISABLE2_MASK; + int flags1 = disabled ? STATUS_BAR_DISABLE_MASK : StatusBarManager.DISABLE_NONE; + int flags2 = disabled ? STATUS_BAR_DISABLE2_MASK : StatusBarManager.DISABLE2_NONE; statusBarService.disableForUser(flags1, mToken, mContext.getPackageName(), userId); statusBarService.disable2ForUser(flags2, mToken, mContext.getPackageName(), userId); + return true; } } catch (RemoteException e) { Slog.e(LOG_TAG, "Failed to disable the status bar", e); } finally { Binder.restoreCallingIdentity(ident); } + return false; } /** @@ -6313,7 +6318,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { public void setPermissionPolicy(ComponentName admin, int policy) throws RemoteException { int userId = UserHandle.getCallingUserId(); synchronized (this) { - getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); + getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); DevicePolicyData userPolicy = getUserData(userId); if (userPolicy.mPermissionPolicy != policy) { userPolicy.mPermissionPolicy = policy; @@ -6336,7 +6341,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { String permission, boolean granted) throws RemoteException { UserHandle user = Binder.getCallingUserHandle(); synchronized (this) { - getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); + getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); long ident = Binder.clearCallingIdentity(); try { if (granted) { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 2d265e2..925a609 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -28,6 +28,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; +import android.content.res.Resources.Theme; import android.os.Build; import android.os.Environment; import android.os.FactoryTest; @@ -291,7 +292,7 @@ public final class SystemServer { private void createSystemContext() { ActivityThread activityThread = ActivityThread.systemMain(); mSystemContext = activityThread.getSystemContext(); - mSystemContext.setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar); + mSystemContext.setTheme(android.R.style.Theme_Material_DayNight_DarkActionBar); } /** @@ -1026,6 +1027,12 @@ public final class SystemServer { w.getDefaultDisplay().getMetrics(metrics); context.getResources().updateConfiguration(config, metrics); + // The system context's theme may be configuration-dependent. + final Theme systemTheme = context.getTheme(); + if (systemTheme.getChangingConfigurations() != 0) { + systemTheme.rebase(); + } + try { // TODO: use boot phase mPowerManagerService.systemReady(mActivityManagerService.getAppOpsService()); diff --git a/services/midi/java/com/android/server/midi/MidiService.java b/services/midi/java/com/android/server/midi/MidiService.java index c1c5c56..176f54b 100644 --- a/services/midi/java/com/android/server/midi/MidiService.java +++ b/services/midi/java/com/android/server/midi/MidiService.java @@ -294,8 +294,10 @@ public class MidiService extends IMidiManager.Stub { @Override public String toString() { - StringBuilder sb = new StringBuilder("Device: "); + StringBuilder sb = new StringBuilder("Device Info: "); sb.append(mDeviceInfo); + sb.append(" Status: "); + sb.append(mDeviceStatus); sb.append(" UID: "); sb.append(mUid); return sb.toString(); diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index 2897c61..fcdb6d6 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -754,7 +754,7 @@ public class VoiceInteractionManagerService extends SystemService { public boolean activeServiceSupportsAssist() { enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); synchronized (this) { - return mImpl != null && mImpl.mInfo.getSupportsAssist(); + return mImpl != null && mImpl.mInfo != null && mImpl.mInfo.getSupportsAssist(); } } @@ -762,7 +762,8 @@ public class VoiceInteractionManagerService extends SystemService { public boolean activeServiceSupportsLaunchFromKeyguard() throws RemoteException { enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); synchronized (this) { - return mImpl != null && mImpl.mInfo.getSupportsLaunchFromKeyguard(); + return mImpl != null && mImpl.mInfo != null + && mImpl.mInfo.getSupportsLaunchFromKeyguard(); } } |