diff options
30 files changed, 593 insertions, 308 deletions
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index 552c8d3b0143..0eca4d670d3d 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -44,14 +44,18 @@ public final class BluetoothGatt implements BluetoothProfile { private IBluetoothGatt mService; private BluetoothGattCallback mCallback; private int mClientIf; - private boolean mAuthRetry = false; private BluetoothDevice mDevice; private boolean mAutoConnect; + private int mAuthRetryState; private int mConnState; private final Object mStateLock = new Object(); private Boolean mDeviceBusy = false; private int mTransport; + private static final int AUTH_RETRY_STATE_IDLE = 0; + private static final int AUTH_RETRY_STATE_NO_MITM = 1; + private static final int AUTH_RETRY_STATE_MITM = 2; + private static final int CONN_STATE_IDLE = 0; private static final int CONN_STATE_CONNECTING = 1; private static final int CONN_STATE_CONNECTED = 2; @@ -262,17 +266,19 @@ public final class BluetoothGatt implements BluetoothProfile { if ((status == GATT_INSUFFICIENT_AUTHENTICATION || status == GATT_INSUFFICIENT_ENCRYPTION) - && mAuthRetry == false) { + && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) { try { - mAuthRetry = true; - mService.readCharacteristic(mClientIf, address, handle, AUTHENTICATION_MITM); + final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ? + AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM; + mService.readCharacteristic(mClientIf, address, handle, authReq); + mAuthRetryState++; return; } catch (RemoteException e) { Log.e(TAG,"",e); } } - mAuthRetry = false; + mAuthRetryState = AUTH_RETRY_STATE_IDLE; BluetoothGattCharacteristic characteristic = getCharacteristicById(mDevice, handle); if (characteristic == null) { @@ -311,19 +317,20 @@ public final class BluetoothGatt implements BluetoothProfile { if ((status == GATT_INSUFFICIENT_AUTHENTICATION || status == GATT_INSUFFICIENT_ENCRYPTION) - && mAuthRetry == false) { + && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) { try { - mAuthRetry = true; + final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ? + AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM; mService.writeCharacteristic(mClientIf, address, handle, - characteristic.getWriteType(), AUTHENTICATION_MITM, - characteristic.getValue()); + characteristic.getWriteType(), authReq, characteristic.getValue()); + mAuthRetryState++; return; } catch (RemoteException e) { Log.e(TAG,"",e); } } - mAuthRetry = false; + mAuthRetryState = AUTH_RETRY_STATE_IDLE; try { mCallback.onCharacteristicWrite(BluetoothGatt.this, characteristic, status); @@ -378,17 +385,19 @@ public final class BluetoothGatt implements BluetoothProfile { if ((status == GATT_INSUFFICIENT_AUTHENTICATION || status == GATT_INSUFFICIENT_ENCRYPTION) - && mAuthRetry == false) { + && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) { try { - mAuthRetry = true; - mService.readDescriptor(mClientIf, address, handle, AUTHENTICATION_MITM); + final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ? + AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM; + mService.readDescriptor(mClientIf, address, handle, authReq); + mAuthRetryState++; return; } catch (RemoteException e) { Log.e(TAG,"",e); } } - mAuthRetry = true; + mAuthRetryState = AUTH_RETRY_STATE_IDLE; try { mCallback.onDescriptorRead(BluetoothGatt.this, descriptor, status); @@ -417,19 +426,21 @@ public final class BluetoothGatt implements BluetoothProfile { if ((status == GATT_INSUFFICIENT_AUTHENTICATION || status == GATT_INSUFFICIENT_ENCRYPTION) - && mAuthRetry == false) { + && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) { try { - mAuthRetry = true; + final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ? + AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM; mService.writeDescriptor(mClientIf, address, handle, BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT, - AUTHENTICATION_MITM, descriptor.getValue()); + authReq, descriptor.getValue()); + mAuthRetryState++; return; } catch (RemoteException e) { Log.e(TAG,"",e); } } - mAuthRetry = false; + mAuthRetryState = AUTH_RETRY_STATE_IDLE; try { mCallback.onDescriptorWrite(BluetoothGatt.this, descriptor, status); @@ -503,6 +514,7 @@ public final class BluetoothGatt implements BluetoothProfile { mServices = new ArrayList<BluetoothGattService>(); mConnState = CONN_STATE_IDLE; + mAuthRetryState = AUTH_RETRY_STATE_IDLE; } /** @@ -516,6 +528,7 @@ public final class BluetoothGatt implements BluetoothProfile { unregisterApp(); mConnState = CONN_STATE_CLOSED; + mAuthRetryState = AUTH_RETRY_STATE_IDLE; } /** diff --git a/core/java/android/content/pm/ShortcutInfo.java b/core/java/android/content/pm/ShortcutInfo.java index ed0ac5386176..a854b899a82a 100644 --- a/core/java/android/content/pm/ShortcutInfo.java +++ b/core/java/android/content/pm/ShortcutInfo.java @@ -46,7 +46,7 @@ import java.util.List; import java.util.Set; /** - * Represents a "launcher shortcut" that can be published via {@link ShortcutManager}. + * Represents a shortcut that can be published via {@link ShortcutManager}. * * @see ShortcutManager */ @@ -776,17 +776,17 @@ public final class ShortcutInfo implements Parcelable { * activity is published using * {@link ShortcutManager#addDynamicShortcuts(List)} or * {@link ShortcutManager#setDynamicShortcuts(List)}, - * the first main activity defined in the application's <code>AndroidManifest.xml</code> + * the first main activity defined in the app's <code>AndroidManifest.xml</code> * file is used. * * <li>Only "main" activities—ones that define the {@link Intent#ACTION_MAIN} * and {@link Intent#CATEGORY_LAUNCHER} intent filters—can be target * activities. * - * <li>By default, the first main activity defined in the application manifest is + * <li>By default, the first main activity defined in the app's manifest is * the target activity. * - * <li>A target activity must belong to the publisher application. + * <li>A target activity must belong to the publisher app. * </ul> * * @see ShortcutInfo#getActivity() @@ -802,7 +802,7 @@ public final class ShortcutInfo implements Parcelable { * * <p>Icons are not available on {@link ShortcutInfo} instances * returned by {@link ShortcutManager} or {@link LauncherApps}. The default launcher - * application can use {@link LauncherApps#getShortcutIconDrawable(ShortcutInfo, int)} + * app can use {@link LauncherApps#getShortcutIconDrawable(ShortcutInfo, int)} * or {@link LauncherApps#getShortcutBadgedIconDrawable(ShortcutInfo, int)} to fetch * shortcut icons. * @@ -933,8 +933,8 @@ public final class ShortcutInfo implements Parcelable { } /** - * Sets categories for a shortcut. Launcher applications may use this information to - * categorise shortcuts. + * Sets categories for a shortcut. Launcher apps may use this information to + * categorize shortcuts. * * @see #SHORTCUT_CATEGORY_CONVERSATION * @see ShortcutInfo#getCategories() @@ -953,9 +953,9 @@ public final class ShortcutInfo implements Parcelable { * {@link ShortcutManager#addDynamicShortcuts(List)} or * {@link ShortcutManager#setDynamicShortcuts(List)}. * - * <p>A shortcut can launch any intent that the publisher application has permission to + * <p>A shortcut can launch any intent that the publisher app has permission to * launch. For example, a shortcut can launch an unexported activity within the publisher - * application. A shortcut intent doesn't have to point at the target activity. + * app. A shortcut intent doesn't have to point at the target activity. * * <p>The given {@code intent} can contain extras, but these extras must contain values * of primitive types in order for the system to persist these values. @@ -970,7 +970,9 @@ public final class ShortcutInfo implements Parcelable { /** * Sets multiple intents instead of a single intent, in order to launch an activity with - * other activities in back stack. Use {@link TaskStackBuilder} to build intents. + * other activities in back stack. Use {@link TaskStackBuilder} to build intents. The + * last element in the list represents the only intent that doesn't place an activity on + * the back stack. * See the {@link ShortcutManager} javadoc for details. * * @see Builder#setIntent(Intent) @@ -1006,9 +1008,9 @@ public final class ShortcutInfo implements Parcelable { } /** - * Extras that application can set for any purpose. + * Extras that the app can set for any purpose. * - * <p>Applications can store arbitrary shortcut metadata in extras and retrieve the + * <p>Apps can store arbitrary shortcut metadata in extras and retrieve the * metadata later using {@link ShortcutInfo#getExtras()}. */ @NonNull @@ -1029,7 +1031,7 @@ public final class ShortcutInfo implements Parcelable { /** * Returns the ID of a shortcut. * - * <p>Shortcut IDs are unique within each publisher application and must be stable across + * <p>Shortcut IDs are unique within each publisher app and must be stable across * devices so that shortcuts will still be valid when restored on a different device. * See {@link ShortcutManager} for details. */ @@ -1039,7 +1041,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return the package name of the publisher application. + * Return the package name of the publisher app. */ @NonNull public String getPackage() { @@ -1050,7 +1052,7 @@ public final class ShortcutInfo implements Parcelable { * Return the target activity. * * <p>This has nothing to do with the activity that this shortcut will launch. - * Launcher applications should show the launcher icon for the returned activity alongside + * Launcher apps should show the launcher icon for the returned activity alongside * this shortcut. * * @see Builder#setActivity @@ -1102,7 +1104,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return the shorter description of a shortcut. + * Return the short description of a shortcut. * * @see Builder#setShortLabel(CharSequence) */ @@ -1117,7 +1119,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return the longer description of a shortcut. + * Return the long description of a shortcut. * * @see Builder#setLongLabel(CharSequence) */ @@ -1161,7 +1163,7 @@ public final class ShortcutInfo implements Parcelable { * Returns the intent that is executed when the user selects this shortcut. * If setIntents() was used, then return the last intent in the array. * - * <p>Launcher applications <b>cannot</b> see the intent. If a {@link ShortcutInfo} is + * <p>Launcher apps <b>cannot</b> see the intent. If a {@link ShortcutInfo} is * obtained via {@link LauncherApps}, then this method will always return null. * Launchers can only start a shortcut intent with {@link LauncherApps#startShortcut}. * @@ -1180,7 +1182,7 @@ public final class ShortcutInfo implements Parcelable { /** * Return the intent set with {@link Builder#setIntents(Intent[])}. * - * <p>Launcher applications <b>cannot</b> see the intents. If a {@link ShortcutInfo} is + * <p>Launcher apps <b>cannot</b> see the intents. If a {@link ShortcutInfo} is * obtained via {@link LauncherApps}, then this method will always return null. * Launchers can only start a shortcut intent with {@link LauncherApps#startShortcut}. * @@ -1219,15 +1221,15 @@ public final class ShortcutInfo implements Parcelable { /** * "Rank" of a shortcut, which is a non-negative, sequential value that's unique for each - * {@link #getActivity} for each of the two kinds, dynamic shortcuts and manifest shortcuts. + * {@link #getActivity} for each of the two types of shortcuts (static and dynamic). * - * <p>Because manifest shortcuts and dynamic shortcuts have overlapping ranks, - * when a launcher application shows shortcuts for an activity, it should first show - * the manifest shortcuts followed by the dynamic shortcuts. Within each of those categories, + * <p>Because static shortcuts and dynamic shortcuts have overlapping ranks, + * when a launcher app shows shortcuts for an activity, it should first show + * the static shortcuts, followed by the dynamic shortcuts. Within each of those categories, * shortcuts should be sorted by rank in ascending order. * - * <p>"Floating" shortcuts (i.e. shortcuts that are neither dynamic nor manifest) will all - * have rank 0, because there's no sorting for them. + * <p><em>Floating shortcuts</em>, or shortcuts that are neither static nor dynamic, will all + * have rank 0, because they aren't sorted. * * See the {@link ShortcutManager}'s class javadoc for details. * @@ -1274,7 +1276,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Extras that application can set to any purposes. + * Extras that the app can set for any purpose. * * @see Builder#setExtras(PersistableBundle) */ @@ -1339,12 +1341,13 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return whether a shortcut is published from AndroidManifest.xml or not. If {@code true}, - * it's also {@link #isImmutable()}. + * Return whether a shortcut is static; that is, whether a shortcut is + * published from AndroidManifest.xml. If {@code true}, the shortcut is + * also {@link #isImmutable()}. * * <p>When an app is upgraded and a shortcut is no longer published from AndroidManifest.xml, - * this will be set to {@code false}. If the shortcut is not pinned, then it'll just disappear. - * However, if it's pinned, it will still be alive, and {@link #isEnabled()} will be + * this will be set to {@code false}. If the shortcut is not pinned, then it'll disappear. + * However, if it's pinned, it will still be visible, {@link #isEnabled()} will be * {@code false} and {@link #isImmutable()} will be {@code true}. */ public boolean isDeclaredInManifest() { @@ -1358,7 +1361,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * @return true if pinned but neither dynamic nor manifest. + * @return true if pinned but neither static nor dynamic. * @hide */ public boolean isFloating() { @@ -1374,9 +1377,10 @@ public final class ShortcutInfo implements Parcelable { * Return if a shortcut is immutable, in which case it cannot be modified with any of * {@link ShortcutManager} APIs. * - * <p>All manifest shortcuts are immutable. When a manifest shortcut is pinned and then - * disabled because the app is upgraded and its AndroidManifest.xml no longer publishes it, - * {@link #isDeclaredInManifest()} returns {@code false}, but it is still immutable. + * <p>All static shortcuts are immutable. When a static shortcut is pinned and is then + * disabled because it doesn't appear in AndroidManifest.xml for a newer version of the + * app, {@link #isDeclaredInManifest()} returns {@code false}, but the shortcut + * is still immutable. * * <p>All shortcuts originally published via the {@link ShortcutManager} APIs * are all mutable. @@ -1561,7 +1565,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Replaces the intent + * Replaces the intent. * * @throws IllegalArgumentException when extra is not compatible with {@link PersistableBundle}. * diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java index 96ad67c6f3ab..a93870ece823 100644 --- a/core/java/android/content/pm/ShortcutManager.java +++ b/core/java/android/content/pm/ShortcutManager.java @@ -31,87 +31,90 @@ import com.android.internal.annotations.VisibleForTesting; import java.util.List; /** - * The ShortcutManager manages "launcher shortcuts" (or simply "shortcuts"). Shortcuts provide - * users - * with quick access to activities other than an application's main activity in the currently-active + * The ShortcutManager manages an app's <em>shortcuts</em>. Shortcuts provide users + * with quick access to activities other than an app's main activity in the currently-active * launcher. For example, - * an email application may publish the "compose new email" action, which will directly open the + * an email app may publish the "compose new email" action, which will directly open the * compose activity. The {@link ShortcutInfo} class contains information about each of the * shortcuts themselves. * - * <h3>Dynamic Shortcuts and Manifest Shortcuts</h3> + * <h3>Static Shortcuts and Dynamic Shortcuts</h3> * - * There are two ways to publish shortcuts: manifest shortcuts and dynamic shortcuts. + * <p> + * There are two ways to publish shortcuts: static shortcuts and dynamic shortcuts. * * <ul> - * <li>Manifest shortcuts are declared in a resource - * XML, which is referenced in the publisher application's <code>AndroidManifest.xml</code> file. - * Manifest shortcuts are published when an application is installed, - * and the details of these shortcuts change when an application is upgraded with an updated XML + * <li>Static shortcuts are declared in a resource + * XML file, which is referenced in the publisher app's <code>AndroidManifest.xml</code> file. + * Static shortcuts are published when an app is installed, + * and the details of these shortcuts change when an app is upgraded with an updated XML * file. - * Manifest shortcuts are immutable, and their + * Static shortcuts are immutable, and their * definitions, such as icons and labels, cannot be changed dynamically without upgrading the - * publisher application. + * publisher app. * - * <li>Dynamic shortcuts are published at runtime using the {@link ShortcutManager} APIs. - * Applications can publish, update, and remove dynamic shortcuts at runtime. + * <li>Dynamic shortcuts are published at runtime using this class's APIs. + * Apps can publish, update, and remove dynamic shortcuts at runtime. * </ul> * - * <p>Only "main" activities—activities that handle the {@code MAIN} action and the + * <p>Only main activities—activities that handle the {@code MAIN} action and the * {@code LAUNCHER} category—can have shortcuts. - * If an application has multiple main activities, these activities will have different sets + * If an app has multiple main activities, these activities have different sets * of shortcuts. * - * <p>Dynamic shortcuts and manifest shortcuts are shown in the currently active launcher when - * the user long-presses on an application launcher icon. The actual gesture may be different - * depending on the launcher application. + * <p>Static shortcuts and dynamic shortcuts are shown in the currently active launcher when + * the user long-presses on an app's launcher icon. + * + * <p class="note"><strong>Note: </strong>The actual gesture may be different + * depending on the launcher app. * * <p>Each launcher icon can have at most {@link #getMaxShortcutCountPerActivity()} number of - * dynamic and manifest shortcuts combined. + * static and dynamic shortcuts combined. * * * <h3>Pinning Shortcuts</h3> * - * Launcher applications allow users to "pin" shortcuts so they're easier to access. Both manifest + * <p> + * Launcher apps allow users to <em>pin</em> shortcuts so they're easier to access. Both static * and dynamic shortcuts can be pinned. * Pinned shortcuts <b>cannot</b> be removed by publisher - * applications; they're removed only when the user removes them, - * when the publisher application is uninstalled, or when the - * user performs the "clear data" action on the publisher application from the device's Settings - * application. + * apps; they're removed only when the user removes them, + * when the publisher app is uninstalled, or when the + * user performs the <strong>clear data</strong> action on the publisher app from the device's Settings + * app. * - * <p>However, the publisher application can <em>disable</em> pinned shortcuts so they cannot be + * <p>However, the publisher app can <em>disable</em> pinned shortcuts so they cannot be * started. See the following sections for details. * * * <h3>Updating and Disabling Shortcuts</h3> * * <p>When a dynamic shortcut is pinned, even when the publisher removes it as a dynamic shortcut, - * the pinned shortcut will still be visible and launchable. This allows an application to have + * the pinned shortcut will still be visible and launchable. This allows an app to have * more than {@link #getMaxShortcutCountPerActivity()} number of shortcuts. * * <p>For example, suppose {@link #getMaxShortcutCountPerActivity()} is 5: - * <ul> - * <li>A chat application publishes 5 dynamic shortcuts for the 5 most recent - * conversations, "c1" - "c5". + * <ol> + * <li>A chat app publishes 5 dynamic shortcuts for the 5 most recent + * conversations (c1, c2, ..., c5). * * <li>The user pins all 5 of the shortcuts. * - * <li>Later, the user has started 3 additional conversations ("c6", "c7", and "c8"), - * so the publisher application + * <li>Later, the user has started 3 additional conversations (c6, c7, and c8), + * so the publisher app * re-publishes its dynamic shortcuts. The new dynamic shortcut list is: - * "c4", "c5", "c6", "c7", and "c8". - * The publisher application has to remove "c1", "c2", and "c3" because it can't have more than + * c4, c5, ..., c8. + * The publisher app has to remove c1, c2, and c3 because it can't have more than * 5 dynamic shortcuts. * - * <li>However, even though "c1", "c2" and "c3" are no longer dynamic shortcuts, the pinned + * <li>However, even though c1, c2, and c3 are no longer dynamic shortcuts, the pinned * shortcuts for these conversations are still available and launchable. * * <li>At this point, the user can access a total of 8 shortcuts that link to activities in - * the publisher application, including the 3 pinned - * shortcuts, even though it's allowed to have at most 5 dynamic shortcuts. + * the publisher app, including the 3 pinned + * shortcuts, even though an app can have at most 5 dynamic shortcuts. * - * <li>The application can use {@link #updateShortcuts(List)} to update any of the existing + * <li>The app can use {@link #updateShortcuts(List)} to update <em>any</em> of the existing * 8 shortcuts, when, for example, the chat peers' icons have changed. * </ul> * The {@link #addDynamicShortcuts(List)} and {@link #setDynamicShortcuts(List)} methods @@ -121,104 +124,108 @@ import java.util.List; * lists of shortcuts to dynamic shortcuts. * * - * <h4>Disabling Manifest Shortcuts</h4> - * When an application is upgraded and the new version - * no longer uses a manifest shortcut that appeared in the previous version, this deprecated - * shortcut will no longer be published as a manifest shortcut. + * <h4>Disabling Static Shortcuts</h4> + * When an app is upgraded and the new version + * no longer uses a static shortcut that appeared in the previous version, this deprecated + * shortcut will no longer be published as a static shortcut. * * <p>If the deprecated shortcut is pinned, then the pinned shortcut will remain on the launcher, * but it will be disabled automatically. - * Note that, in this case, the pinned shortcut is no longer a manifest shortcut, but it's - * still <b>immutable</b> and cannot be updated using the {@link ShortcutManager} APIs. + * Note that, in this case, the pinned shortcut is no longer a static shortcut, but it's + * still <b>immutable</b>. Therefore, it cannot be updated using this class's APIs. * * * <h4>Disabling Dynamic Shortcuts</h4> * Sometimes pinned shortcuts become obsolete and may not be usable. For example, a pinned shortcut - * to a group chat will be unusable when the associated group chat is deleted. In cases like this, - * applications should use {@link #disableShortcuts(List)}, which will remove the specified dynamic - * shortcuts and also make any specified pinned shortcuts un-launchable. + * to a group chat becomes unusable when the associated group chat is deleted. In cases like this, + * apps should use {@link #disableShortcuts(List)}, which removes the specified dynamic + * shortcuts and also makes any specified pinned shortcuts un-launchable. * The {@link #disableShortcuts(List, CharSequence)} method can also be used to disabled shortcuts * and show users a custom error message when they attempt to launch the disabled shortcuts. * * - * <h3>Publishing Manifest Shortcuts</h3> + * <h3>Publishing Static Shortcuts</h3> * - * In order to add manifest shortcuts to your application, first add + * <p> + * In order to add static shortcuts to your app, first add * {@code <meta-data android:name="android.app.shortcuts" />} to your main activity in * AndroidManifest.xml: * <pre> - * <manifest xmlns:android="http://schemas.android.com/apk/res/android" - * package="com.example.myapplication"> - * <application . . .> - * <activity android:name="Main"> - * <intent-filter> - * <action android:name="android.intent.action.MAIN" /> - * <category android:name="android.intent.category.LAUNCHER" /> - * </intent-filter> - * <b><meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/></b> - * </activity> - * </application> - * </manifest> + *<manifest xmlns:android="http://schemas.android.com/apk/res/android" + * package="com.example.myapplication"> + * <application ... > + * <activity android:name="Main"> + * <intent-filter> + * <action android:name="android.intent.action.MAIN" /> + * <category android:name="android.intent.category.LAUNCHER" /> + * </intent-filter> + * <strong><meta-data android:name="android.app.shortcuts" + * android:resource="@xml/shortcuts" /></strong> + * </activity> + * </application> + *</manifest> * </pre> * - * Then, define your application's manifest shortcuts in the <code>res/xml/shortcuts.xml</code> + * Then, define your app's static shortcuts in the <code>res/xml/shortcuts.xml</code> * file: * <pre> - * <shortcuts xmlns:android="http://schemas.android.com/apk/res/android" > - * <shortcut - * android:shortcutId="compose" - * android:enabled="true" - * android:icon="@drawable/compose_icon" - * android:shortcutShortLabel="@string/compose_shortcut_short_label1" - * android:shortcutLongLabel="@string/compose_shortcut_long_label1" - * android:shortcutDisabledMessage="@string/compose_disabled_message1" - * > - * <intent - * android:action="android.intent.action.VIEW" - * android:targetPackage="com.example.myapplication" - * android:targetClass="com.example.myapplication.ComposeActivity" /> - * <!-- more intents can go here; see below --> - * <categories android:name="android.shortcut.conversation" /> - * </shortcut> - * <!-- more shortcuts can go here --> - * </shortcuts> + *<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> + * <shortcut + * android:shortcutId="compose" + * android:enabled="true" + * android:icon="@drawable/compose_icon" + * android:shortcutShortLabel="@string/compose_shortcut_short_label1" + * android:shortcutLongLabel="@string/compose_shortcut_long_label1" + * android:shortcutDisabledMessage="@string/compose_disabled_message1"> + * <intent + * android:action="android.intent.action.VIEW" + * android:targetPackage="com.example.myapplication" + * android:targetClass="com.example.myapplication.ComposeActivity" /> + * <!-- If your shortcut is associated with multiple intents, include them + * here. The last intent in the list is what the user sees when they + * launch this shortcut. --> + * <categories android:name="android.shortcut.conversation" /> + * </shortcut> + * <!-- Specify more shortcuts here. --> + *</shortcuts> * </pre> * - * The following list includes descriptions for the different attributes within a manifest shortcut: + * The following list includes descriptions for the different attributes within a static shortcut: * <dl> - * <dt>android:shortcutId</dt> + * <dt>{@code android:shortcutId}</dt> * <dd>Mandatory shortcut ID</dd> * - * <dt>android:enabled</dt> + * <dt>{@code android:enabled}</dt> * <dd>Default is {@code true}. Can be set to {@code false} in order - * to disable a manifest shortcut that was published in a previous version and and set a custom - * disabled message. If a custom disabled message is not needed, then a manifest shortcut can + * to disable a static shortcut that was published in a previous version and set a custom + * disabled message. If a custom disabled message is not needed, then a static shortcut can * be simply removed from the XML file rather than keeping it with {@code enabled="false"}.</dd> * - * <dt>android:icon</dt> + * <dt>{@code android:icon}</dt> * <dd>Shortcut icon.</dd> * - * <dt>android:shortcutShortLabel</dt> + * <dt>{@code android:shortcutShortLabel}</dt> * <dd>Mandatory shortcut short label. * See {@link ShortcutInfo.Builder#setShortLabel(CharSequence)}.</dd> * - * <dt>android:shortcutLongLabel</dt> + * <dt>{@code android:shortcutLongLabel}</dt> * <dd>Shortcut long label. * See {@link ShortcutInfo.Builder#setLongLabel(CharSequence)}.</dd> * - * <dt>android:shortcutDisabledMessage</dt> + * <dt>{@code android:shortcutDisabledMessage}</dt> * <dd>When {@code android:enabled} is set to * {@code false}, this attribute is used to display a custom disabled message.</dd> * - * <dt>intent</dt> + * <dt>{@code intent}</dt> * <dd>Intent to launch when the user selects the shortcut. * {@code android:action} is mandatory. * See <a href="{@docRoot}guide/topics/ui/settings.html#Intents">Using intents</a> for the * other supported tags. - * You can provide multiple intents for a single shortcut so that an activity is launched - * with other activities in the back stack. See {@link android.app.TaskStackBuilder} for details. + * You can provide multiple intents for a single shortcut so that the last defined activity is launched + * with the other activities in the <a href="/guide/components/tasks-and-back-stack.html">back stack</a>. + * See {@link android.app.TaskStackBuilder} for details. * </dd> - * <dt>categories</dt> + * <dt>{@code categories}</dt> * <dd>Specify shortcut categories. Currently only * {@link ShortcutInfo#SHORTCUT_CATEGORY_CONVERSATION} is defined in the framework. * </dd> @@ -226,64 +233,68 @@ import java.util.List; * * <h3>Publishing Dynamic Shortcuts</h3> * - * Applications can publish dynamic shortcuts with {@link #setDynamicShortcuts(List)} + * <p> + * Apps can publish dynamic shortcuts with {@link #setDynamicShortcuts(List)} * or {@link #addDynamicShortcuts(List)}. The {@link #updateShortcuts(List)} method can also be * used to update existing, mutable shortcuts. * Use {@link #removeDynamicShortcuts(List)} or {@link #removeAllDynamicShortcuts()} to remove * dynamic shortcuts. * - * <p>Example: + * <p>The following code snippet shows how to create a single dynamic shortcut: * <pre> - * ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); + *ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); * - * ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1") - * .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mysite.com/"))) - * .setShortLabel("Web site") - * .setLongLabel("Open the web site") - * .setIcon(Icon.createWithResource(context, R.drawable.icon_website)) - * .build(); + *ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1") + * .setShortLabel("Web site") + * .setLongLabel("Open the web site") + * .setIcon(Icon.createWithResource(context, R.drawable.icon_website)) + * .setIntent(new Intent(Intent.ACTION_VIEW, + * Uri.parse("https://www.mysite.example.com/"))) + * .build(); * - * shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut)); + *shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut)); * </pre> * * * <h3>Shortcut Intents</h3> + * <p> * Dynamic shortcuts can be published with any set of {@link Intent#addFlags Intent} flags. * Typically, {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} is specified, possibly along with other - * flags; otherwise, if the application is already running, the application is simply brought to + * flags; otherwise, if the app is already running, the app is simply brought to * the foreground, and the target activity may not appear. * * <p>The {@link ShortcutInfo.Builder#setIntents(Intent[])} method can be used instead of * {@link ShortcutInfo.Builder#setIntent(Intent)} with {@link android.app.TaskStackBuilder} * in order to launch an activity with other activities in the back stack. * When the user selects a shortcut to load an activity with a back stack, - * then presses the back key, a "parent" activity will be shown instead of the user being - * navigated back to the launcher. + * then presses the back key, a parent activity from the same app will be shown + * instead of the user being navigated back to the launcher. * - * <p>Manifest shortcuts can also have multiple intents to achieve the same effect. + * <p>Static shortcuts can also have multiple intents to achieve the same effect. * In order to associate multiple {@link Intent} objects with a shortcut, simply list multiple * <code><intent></code> elements within a single <code><shortcut></code> element. - * The last intent specifies what the user will see when they launch a shortcut. + * The last intent specifies what the user sees when they launch a shortcut. * - * <p>Manifest shortcuts <b>cannot</b> have custom intent flags. - * The first intent of a manifest shortcut will always have {@link Intent#FLAG_ACTIVITY_NEW_TASK} + * <p>Static shortcuts <b>cannot</b> have custom intent flags. + * The first intent of a static shortcut will always have {@link Intent#FLAG_ACTIVITY_NEW_TASK} * and {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} set. - * This means, when the application is already running, all the existing activities will be - * destroyed when a manifest shortcut is launched. + * This means, when the app is already running, all the existing activities will be + * destroyed when a static shortcut is launched. * If this behavior is not desirable, you can use a <em>trampoline activity</em>, * or an invisible activity that starts another activity in {@link Activity#onCreate}, * then calls {@link Activity#finish()}. * The first activity should include an attribute setting - * of {@code android:taskAffinity=""} in the application's <code>AndroidManifest.xml</code> - * file, and the intent within the manifest shortcut should point at this first activity. + * of {@code android:taskAffinity=""} in the app's <code>AndroidManifest.xml</code> + * file, and the intent within the static shortcut should point at this first activity. * * * <h3>Showing New Information in a Shortcut</h3> + * <p> * In order to avoid confusion, you should not use {@link #updateShortcuts(List)} to update * a shortcut so that it contains conceptually different information. * - * <p>For example, a phone application may publish the most frequently called contact as a dynamic - * shortcut. Over time, this contact may change; when it does, the application should + * <p>For example, a phone app may publish the most frequently called contact as a dynamic + * shortcut. Over time, this contact may change. When it does, the app should * represent the changed contact with a new shortcut that contains a different ID, using either * {@link #setDynamicShortcuts(List)} or {@link #addDynamicShortcuts(List)}, rather than updating * the existing shortcut with {@link #updateShortcuts(List)}. @@ -291,7 +302,7 @@ import java.util.List; * it to reference a different contact will likely confuse the user. * * <p>On the other hand, when the - * contact's information has changed, such as the name or picture, the application should + * contact's information has changed, such as the name or picture, the app should * use {@link #updateShortcuts(List)} so that the pinned shortcut is updated too. * * @@ -299,21 +310,21 @@ import java.util.List; * When the launcher displays the shortcuts that are associated with a particular launcher icon, * the shortcuts should appear in the following order: * <ul> - * <li>First show manifest shortcuts + * <li>First show static shortcuts * (if {@link ShortcutInfo#isDeclaredInManifest()} is {@code true}), * and then show dynamic shortcuts (if {@link ShortcutInfo#isDynamic()} is {@code true}). - * <li>Within each category of shortcuts (manifest and dynamic), sort the shortcuts in order + * <li>Within each category of shortcuts (static and dynamic), sort the shortcuts in order * of increasing rank according to {@link ShortcutInfo#getRank()}. * </ul> - * <p>Shortcut ranks are non-negative sequential integers + * <p>Shortcut ranks are non-negative, sequential integers * that determine the order in which shortcuts appear, assuming that the shortcuts are all in * the same category. * Ranks of existing shortcuts can be updated with - * {@link #updateShortcuts(List)}; you can use {@link #addDynamicShortcuts(List)} and - * {@link #setDynamicShortcuts(List)}, too. + * {@link #updateShortcuts(List)}. You can also use {@link #addDynamicShortcuts(List)} and + * {@link #setDynamicShortcuts(List)}. * * <p>Ranks are auto-adjusted so that they're unique for each target activity in each category - * (dynamic or manifest). For example, if there are 3 dynamic shortcuts with ranks 0, 1 and 2, + * (static or dynamic). For example, if there are 3 dynamic shortcuts with ranks 0, 1 and 2, * adding another dynamic shortcut with a rank of 1 represents a request to place this shortcut at * the second position. * In response, the third and fourth shortcuts move closer to the bottom of the shortcut list, @@ -321,119 +332,120 @@ import java.util.List; * * <h3>Rate Limiting</h3> * + * <p> * Calls to {@link #setDynamicShortcuts(List)}, {@link #addDynamicShortcuts(List)}, and - * {@link #updateShortcuts(List)} may be rate-limited when called by background applications, or - * applications with no foreground activity or service. When you attempt to call these methods - * from a background application after exceeding the rate limit, these APIs return {@code false}. + * {@link #updateShortcuts(List)} may be rate-limited when called by <em>background apps</em>, or + * apps with no foreground activity or service. When you attempt to call these methods + * from a background app after exceeding the rate limit, these APIs return {@code false}. * - * <p>Applications with a foreground activity or service are not rate-limited. + * <p>Apps with a foreground activity or service are not rate-limited. * - * <p>Rate-limiting will be reset upon certain events, so that even background applications - * can call these APIs again until the rate limit is reached again. + * <p>Rate-limiting is reset upon certain events, so that even background apps + * can call these APIs until the rate limit is reached again. * These events include the following: * <ul> - * <li>When an application comes to the foreground. - * <li>When the system locale changes. - * <li>When the user performs an "inline reply" action on a notification. + * <li>An app comes to the foreground. + * <li>The system locale changes. + * <li>The user performs the <strong>inline reply</strong> action on a notification. * </ul> * * <p>When rate-limiting is active, {@link #isRateLimitingActive()} returns {@code true}. * * <h4>Resetting rate-limiting for testing</h4> * - * If your application is rate-limited during development or testing, you can use the - * "Reset ShortcutManager rate-limiting" development option or the following adb command to reset - * it: - * <pre> - * adb shell cmd shortcut reset-throttling [ --user USER-ID ] + * <p> + * If your app is rate-limited during development or testing, you can use the + * <strong>Reset ShortcutManager rate-limiting</strong> development option or + * the following {@code adb} command to reset it: + * <pre class="no-pretty-print"> + *$ adb shell cmd shortcut reset-throttling [ --user USER-ID ] * </pre> * * <h3>Handling System Locale Changes</h3> * - * Applications should update dynamic and pinned shortcuts when the system locale changes + * <p> + * Apps should update dynamic and pinned shortcuts when the system locale changes * using the {@link Intent#ACTION_LOCALE_CHANGED} broadcast. * - * <p>When the system locale changes, rate-limiting is reset, so even background applications - * can set dynamic shortcuts, add dynamic shortcuts, and update shortcuts until the rate limit - * is reached again. + * <p>When the system locale changes, rate-limiting is reset, so even background apps + * can add and update dynamic shortcuts until the rate limit is reached again. * * * <h3>Backup and Restore</h3> * - * When an application has the {@code android:allowBackup="true"} attribute assignment included + * <p> + * When an app has the {@code android:allowBackup="true"} attribute assignment included * in its <code>AndroidManifest.xml</code> file, pinned shortcuts are * backed up automatically and are restored when the user sets up a new device. * - * <h4>Categories of Shortcuts that are Backed Up</h4> + * <h4>Categories of shortcuts that are backed up</h4> * * <ul> * <li>Pinned shortcuts are backed up. Bitmap icons are not backed up by the system, - * but launcher applications should back them up and restore them so that the user still sees icons - * for pinned shortcuts on the launcher. Applications can always use + * so launcher apps should back them up and restore them so that the user still sees icons + * for pinned shortcuts on the launcher. Apps can always use * {@link #updateShortcuts(List)} to re-publish icons. * - * <li>Manifest shortcuts are not backed up, but when an application is re-installed on a new - * device, they are re-published from the <code>AndroidManifest.xml</code> file, anyway. + * <li>Static shortcuts aren't backed up, but when an app is re-installed on a new + * device, they are re-published from the <code>AndroidManifest.xml</code> file. * - * <li>Dynamic shortcuts are <b>not</b> backed up. + * <li>Dynamic shortcuts <b>aren't</b> backed up. * </ul> * - * <p>Because dynamic shortcuts are not restored, it is recommended that applications check + * <p>Because dynamic shortcuts are not restored, it is recommended that apps check * currently-published dynamic shortcuts using {@link #getDynamicShortcuts()} * each time they are launched, and they should re-publish * dynamic shortcuts when necessary. * * <pre> - * public class MainActivity extends Activity { - * public void onCreate(Bundle savedInstanceState) { - * super.onCreate(savedInstanceState); - * - * ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); - * - * if (shortcutManager.getDynamicShortcuts().size() == 0) { - * // Application restored; re-publish dynamic shortcuts. - * - * if (shortcutManager.getPinnedShortcuts().size() > 0) { - * // Pinned shortcuts have been restored. Use updateShortcuts() to make sure - * // they have up-to-date information. - * } - * } - * } - * : - * - * } + *public class MainActivity extends Activity { + * public void onCreate(Bundle savedInstanceState) { + * super.onCreate(savedInstanceState); + * ShortcutManager shortcutManager = + * getSystemService(ShortcutManager.class); + * + * if (shortcutManager.getDynamicShortcuts().size() == 0) { + * // Application restored. Need to re-publish dynamic shortcuts. + * if (shortcutManager.getPinnedShortcuts().size() > 0) { + * // Pinned shortcuts have been restored. Use + * // updateShortcuts() to make sure they contain + * // up-to-date information. + * } + * } + * } + * // ... + *} * </pre> * * * <h4>Backup/restore and shortcut IDs</h4> - * - * Because pinned shortcuts are backed up and restored on new devices, shortcut IDs should be - * meaningful across devices; that is, IDs should contain either stable, constant strings - * or server-side identifiers, + * <p> + * Because pinned shortcuts are backed up and restored on new devices, shortcut IDs + * should contain either stable, constant strings or server-side identifiers, * rather than identifiers generated locally that might not make sense on other devices. * * * <h3>Report Shortcut Usage and Prediction</h3> - * - * Launcher applications may be capable of predicting which shortcuts will most likely be + * <p> + * Launcher apps may be capable of predicting which shortcuts will most likely be * used at a given time by examining the shortcut usage history data. * - * <p>In order to provide launchers with such data, publisher applications should + * <p>In order to provide launchers with such data, publisher apps should * report the shortcuts that are used with {@link #reportShortcutUsed(String)} * when a shortcut is selected, * <b>or when an action equivalent to a shortcut is taken by the user even if it wasn't started * with the shortcut</b>. * - * <p>For example, suppose a GPS navigation application supports "navigate to work" as a shortcut. + * <p>For example, suppose a navigation app supports "navigate to work" as a shortcut. * It should then report when the user selects this shortcut <b>and</b> when the user chooses - * to navigate to work within the application itself. - * This helps the launcher application + * to navigate to work within the app itself. + * This helps the launcher app * learn that the user wants to navigate to work at a certain time every * weekday, and it can then show this shortcut in a suggestion list at the right time. * * <h3>Launcher API</h3> * - * The {@link LauncherApps} class provides APIs for launcher applications to access shortcuts. + * The {@link LauncherApps} class provides APIs for launcher apps to access shortcuts. * * * <h3>Direct Boot and Shortcuts</h3> @@ -465,7 +477,7 @@ public class ShortcutManager { } /** - * Publish the list of shortcuts. All existing dynamic shortcuts from the caller application + * Publish the list of shortcuts. All existing dynamic shortcuts from the caller app * will be replaced. If there are already pinned shortcuts with the same IDs, * the mutable pinned shortcuts are updated. * @@ -488,7 +500,7 @@ public class ShortcutManager { } /** - * Return all dynamic shortcuts from the caller application. + * Return all dynamic shortcuts from the caller app. * * @throws IllegalStateException when the user is locked. */ @@ -503,7 +515,7 @@ public class ShortcutManager { } /** - * Return all manifest shortcuts from the caller application. + * Return all static (manifest) shortcuts from the caller app. * * @throws IllegalStateException when the user is locked. */ @@ -554,7 +566,7 @@ public class ShortcutManager { } /** - * Delete all dynamic shortcuts from the caller application. + * Delete all dynamic shortcuts from the caller app. * * @throws IllegalStateException when the user is locked. */ @@ -567,7 +579,7 @@ public class ShortcutManager { } /** - * Return all pinned shortcuts from the caller application. + * Return all pinned shortcuts from the caller app. * * @throws IllegalStateException when the user is locked. */ @@ -661,7 +673,7 @@ public class ShortcutManager { /** * Re-enable pinned shortcuts that were previously disabled. If the target shortcuts - * already enabled, this method does nothing. + * are already enabled, this method does nothing. * * @throws IllegalArgumentException If trying to enable immutable shortcuts. * @@ -684,7 +696,7 @@ public class ShortcutManager { } /** - * Return the maximum number of dynamic and manifest shortcuts that each launcher icon + * Return the maximum number of static and dynamic shortcuts that each launcher icon * can have at a time. */ public int getMaxShortcutCountPerActivity() { @@ -697,7 +709,7 @@ public class ShortcutManager { } /** - * Return the number of times the caller application can call the rate-limited APIs + * Return the number of times the caller app can call the rate-limited APIs * before the rate limit counter is reset. * * @see #getRateLimitResetTime() @@ -729,7 +741,7 @@ public class ShortcutManager { } /** - * Return {@code true} when rate-limiting is active for the caller application. + * Return {@code true} when rate-limiting is active for the caller app. * * <p>See the class level javadoc for details. * @@ -769,13 +781,13 @@ public class ShortcutManager { } /** - * Applications that publish shortcuts should call this method - * whenever the user selects the shortcut containing the given ID or when the user completes - * an action in the application that is equivalent to selecting the shortcut. + * Apps that publish shortcuts should call this method whenever the user + * selects the shortcut containing the given ID or when the user completes + * an action in the app that is equivalent to selecting the shortcut. * For more details, see the Javadoc for the {@link ShortcutManager} class * * <p>The information is accessible via {@link UsageStatsManager#queryEvents} - * Typically, launcher applications use this information to build a prediction model + * Typically, launcher apps use this information to build a prediction model * so that they can promote the shortcuts that are likely to be used at the moment. * * @throws IllegalStateException when the user is locked. @@ -790,9 +802,9 @@ public class ShortcutManager { } /** - * Called internally when an application is considered to have come to foreground + * Called internally when an app is considered to have come to the foreground * even when technically it's not. This method resets the throttling for this package. - * For example, when the user sends an "inline reply" on an notification, the system UI will + * For example, when the user sends an "inline reply" on a notification, the system UI will * call it. * * @hide diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index df15d90f2c20..3f1789bf9d88 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7998,11 +7998,45 @@ public final class Settings { public static final String PAC_CHANGE_DELAY = "pac_change_delay"; /** + * Don't attempt to detect captive portals. + * + * @hide + */ + public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0; + + /** + * When detecting a captive portal, display a notification that + * prompts the user to sign in. + * + * @hide + */ + public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1; + + /** + * When detecting a captive portal, immediately disconnect from the + * network and do not reconnect to that network in the future. + * + * @hide + */ + public static final int CAPTIVE_PORTAL_MODE_AVOID = 2; + + /** + * What to do when connecting a network that presents a captive portal. + * Must be one of the CAPTIVE_PORTAL_MODE_* constants above. + * + * The default for this setting is CAPTIVE_PORTAL_MODE_PROMPT. + * @hide + */ + public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode"; + + /** * Setting to turn off captive portal detection. Feature is enabled by * default and the setting needs to be set to 0 to disable it. * + * @deprecated use CAPTIVE_PORTAL_MODE_IGNORE to disable captive portal detection * @hide */ + @Deprecated public static final String CAPTIVE_PORTAL_DETECTION_ENABLED = "captive_portal_detection_enabled"; diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 52b7ef4f7fa3..fd663cdc7fe8 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -175,7 +175,7 @@ static void verifySystemIdmaps() } // Generic idmap parameters - const char* argv[7]; + const char* argv[8]; int argc = 0; struct stat st; @@ -186,10 +186,10 @@ static void verifySystemIdmaps() argv[argc++] = AssetManager::TARGET_APK_PATH; argv[argc++] = AssetManager::IDMAP_DIR; - // Directories to scan for overlays: if OVERLAY_SKU_DIR_PROPERTY is defined, - // use OVERLAY_DIR/<value of OVERLAY_SKU_DIR_PROPERTY> in addition to OVERLAY_DIR. + // Directories to scan for overlays: if OVERLAY_THEME_DIR_PROPERTY is defined, + // use OVERLAY_DIR/<value of OVERLAY_THEME_DIR_PROPERTY> in addition to OVERLAY_DIR. char subdir[PROP_VALUE_MAX]; - int len = __system_property_get(AssetManager::OVERLAY_SKU_DIR_PROPERTY, subdir); + int len = __system_property_get(AssetManager::OVERLAY_THEME_DIR_PROPERTY, subdir); if (len > 0) { String8 overlayPath = String8(AssetManager::OVERLAY_DIR) + "/" + subdir; if (stat(overlayPath.string(), &st) == 0) { @@ -203,7 +203,7 @@ static void verifySystemIdmaps() // Finally, invoke idmap (if any overlay directory exists) if (argc > 5) { execv(AssetManager::IDMAP_BIN, (char* const*)argv); - ALOGE("failed to execl for idmap: %s", strerror(errno)); + ALOGE("failed to execv for idmap: %s", strerror(errno)); exit(1); // should never get here } else { exit(0); diff --git a/core/res/res/drawable-watch/scrollbar_vertical_thumb.xml b/core/res/res/drawable-watch/scrollbar_vertical_thumb.xml new file mode 100644 index 000000000000..51aced25e619 --- /dev/null +++ b/core/res/res/drawable-watch/scrollbar_vertical_thumb.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2016 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. +--> + +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:tint="?attr/colorControlNormal" + android:shape="rectangle"> + <solid android:color="#39757575" /> + <size android:height="10dp" /> + <corners android:radius="2dp" /> +</shape> diff --git a/core/res/res/drawable-watch/scrollbar_vertical_track.xml b/core/res/res/drawable-watch/scrollbar_vertical_track.xml new file mode 100644 index 000000000000..5a04b1ca0b2c --- /dev/null +++ b/core/res/res/drawable-watch/scrollbar_vertical_track.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2016 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. +--> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:tint="?attr/colorControlNormal" + android:shape="rectangle"> + <solid android:color="#39ffffff" /> + <size android:width="4dp" /> +</shape> diff --git a/core/res/res/layout-round-watch/alert_dialog_title_material.xml b/core/res/res/layout-round-watch/alert_dialog_title_material.xml index e543c9b69390..aefe28f7f359 100644 --- a/core/res/res/layout-round-watch/alert_dialog_title_material.xml +++ b/core/res/res/layout-round-watch/alert_dialog_title_material.xml @@ -14,25 +14,31 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> -<FrameLayout +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="top|center_horizontal" - android:minHeight="@dimen/alert_dialog_title_height"> - <ImageView android:id="@+id/icon" + android:orientation="vertical" + android:gravity="top|center_horizontal"> + <FrameLayout android:adjustViewBounds="true" - android:maxHeight="24dp" - android:maxWidth="24dp" - android:layout_marginTop="12dp" - android:layout_gravity="center_horizontal" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:src="@null" /> + android:minHeight="@dimen/screen_percentage_15"> + <ImageView android:id="@+id/icon" + android:adjustViewBounds="true" + android:maxHeight="24dp" + android:maxWidth="24dp" + android:layout_marginTop="@dimen/screen_percentage_10" + android:layout_marginBottom="8dp" + android:layout_gravity="center_horizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@null" /> + </FrameLayout> <TextView android:id="@+id/alertTitle" style="?android:attr/windowTitleStyle" - android:layout_marginTop="36dp" android:layout_marginBottom="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> -</FrameLayout> +</LinearLayout> diff --git a/core/res/res/values-in/strings.xml b/core/res/res/values-in/strings.xml index 635494c69ce3..fefca0ccd58b 100644 --- a/core/res/res/values-in/strings.xml +++ b/core/res/res/values-in/strings.xml @@ -254,7 +254,7 @@ <string name="permgrouplab_storage" msgid="1971118770546336966">"Penyimpanan"</string> <string name="permgroupdesc_storage" msgid="637758554581589203">"mengakses foto, media, dan file di perangkat"</string> <string name="permgrouplab_microphone" msgid="171539900250043464">"Mikrofon"</string> - <string name="permgroupdesc_microphone" msgid="4988812113943554584">"rekam audio"</string> + <string name="permgroupdesc_microphone" msgid="4988812113943554584">"merekam audio"</string> <string name="permgrouplab_camera" msgid="4820372495894586615">"Kamera"</string> <string name="permgroupdesc_camera" msgid="3250611594678347720">"mengambil gambar dan merekam video"</string> <string name="permgrouplab_phone" msgid="5229115638567440675">"Telepon"</string> diff --git a/core/res/res/values-watch/colors_device_defaults.xml b/core/res/res/values-watch/colors_device_defaults.xml index 9150cc409e13..15786b4a23f8 100644 --- a/core/res/res/values-watch/colors_device_defaults.xml +++ b/core/res/res/values-watch/colors_device_defaults.xml @@ -18,4 +18,7 @@ overlaying new theme colors. --> <resources> <color name="button_normal_device_default_dark">@color/btn_default_material_dark</color> + <!-- Use the same value as for accent_device_default_dark but start with #99, + i.e. 60% opacity --> + <color name="accent_device_default_dark_60_percent_opacity">#995E97f6</color> </resources> diff --git a/core/res/res/values-watch/config_material.xml b/core/res/res/values-watch/config_material.xml index 104d122e01d3..529f18b78e4d 100644 --- a/core/res/res/values-watch/config_material.xml +++ b/core/res/res/values-watch/config_material.xml @@ -29,4 +29,8 @@ <!-- Always overscan by default to ensure onApplyWindowInsets will always be called. --> <bool name="config_windowOverscanByDefault">true</bool> + + <!-- Style the scrollbars accoridngly. --> + <drawable name="config_scrollbarThumbVertical">@drawable/scrollbar_vertical_thumb</drawable> + <drawable name="config_scrollbarTrackVertical">@drawable/scrollbar_vertical_track</drawable> </resources> diff --git a/core/res/res/values/config_material.xml b/core/res/res/values/config_material.xml index 29494db40557..840a551f914f 100644 --- a/core/res/res/values/config_material.xml +++ b/core/res/res/values/config_material.xml @@ -37,4 +37,8 @@ <!-- The amount to offset when scrolling to a selection in an AlertDialog --> <dimen name="config_alertDialogSelectionScrollOffset">0dp</dimen> + + <!-- Style the scrollbars accoridngly. --> + <drawable name="config_scrollbarThumbVertical">@drawable/scrollbar_handle_material</drawable> + <drawable name="config_scrollbarTrackVertical">@null</drawable> </resources> diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml index 0eb4c8d86928..ff8693bbbdad 100644 --- a/core/res/res/values/themes_material.xml +++ b/core/res/res/values/themes_material.xml @@ -212,9 +212,9 @@ please see themes_device_defaults.xml. <item name="scrollbarDefaultDelayBeforeFade">400</item> <item name="scrollbarSize">10dp</item> <item name="scrollbarThumbHorizontal">@drawable/scrollbar_handle_material</item> - <item name="scrollbarThumbVertical">@drawable/scrollbar_handle_material</item> + <item name="scrollbarThumbVertical">@drawable/config_scrollbarThumbVertical</item> <item name="scrollbarTrackHorizontal">@null</item> - <item name="scrollbarTrackVertical">@null</item> + <item name="scrollbarTrackVertical">@drawable/config_scrollbarTrackVertical</item> <!-- Text selection handle attributes --> <item name="textSelectHandleLeft">@drawable/text_select_handle_left_material</item> @@ -573,9 +573,9 @@ please see themes_device_defaults.xml. <item name="scrollbarDefaultDelayBeforeFade">400</item> <item name="scrollbarSize">10dp</item> <item name="scrollbarThumbHorizontal">@drawable/scrollbar_handle_material</item> - <item name="scrollbarThumbVertical">@drawable/scrollbar_handle_material</item> + <item name="scrollbarThumbVertical">@drawable/config_scrollbarThumbVertical</item> <item name="scrollbarTrackHorizontal">@null</item> - <item name="scrollbarTrackVertical">@null</item> + <item name="scrollbarTrackVertical">@drawable/config_scrollbarTrackVertical</item> <!-- Text selection handle attributes --> <item name="textSelectHandleLeft">@drawable/text_select_handle_left_material</item> diff --git a/include/androidfw/AssetManager.h b/include/androidfw/AssetManager.h index 31b692d6624e..4039d9bd2140 100644 --- a/include/androidfw/AssetManager.h +++ b/include/androidfw/AssetManager.h @@ -73,11 +73,11 @@ public: static const char* IDMAP_BIN; static const char* OVERLAY_DIR; /* - * If OVERLAY_SKU_DIR_PROPERTY is set, search for runtime resource overlay - * APKs in OVERLAY_DIR/<value of OVERLAY_SKU_DIR_PROPERTY> in addition to + * If OVERLAY_THEME_DIR_PROPERTY is set, search for runtime resource overlay + * APKs in OVERLAY_DIR/<value of OVERLAY_THEME_DIR_PROPERTY> in addition to * OVERLAY_DIR. */ - static const char* OVERLAY_SKU_DIR_PROPERTY; + static const char* OVERLAY_THEME_DIR_PROPERTY; static const char* TARGET_PACKAGE_NAME; static const char* TARGET_APK_PATH; static const char* IDMAP_DIR; diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 4c1c1b935980..98168ef986a6 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -79,7 +79,7 @@ static volatile int32_t gCount = 0; const char* AssetManager::RESOURCES_FILENAME = "resources.arsc"; const char* AssetManager::IDMAP_BIN = "/system/bin/idmap"; const char* AssetManager::OVERLAY_DIR = "/vendor/overlay"; -const char* AssetManager::OVERLAY_SKU_DIR_PROPERTY = "ro.boot.vendor.overlay.sku"; +const char* AssetManager::OVERLAY_THEME_DIR_PROPERTY = "ro.boot.vendor.overlay.theme"; const char* AssetManager::TARGET_PACKAGE_NAME = "android"; const char* AssetManager::TARGET_APK_PATH = "/system/framework/framework-res.apk"; const char* AssetManager::IDMAP_DIR = "/data/resource-cache"; diff --git a/packages/SettingsLib/res/values/config.xml b/packages/SettingsLib/res/values/config.xml index e2e721c5ae6b..0aa76a024d5b 100755 --- a/packages/SettingsLib/res/values/config.xml +++ b/packages/SettingsLib/res/values/config.xml @@ -23,8 +23,8 @@ <!-- Default data warning level in mb --> <integer name="default_data_warning_level_mb">2048</integer> - <!-- Whether to send a custom package name with the PSD. translatable="false"--> - <bool name="config_sendPackageName">true</bool> + <!-- Whether to send a custom package name with the PSD.--> + <bool name="config_sendPackageName">false</bool> <!-- Name for the set of keys associating package names --> <string name="config_helpPackageNameKey" translatable="false"></string> diff --git a/packages/SystemUI/res/values-km-rKH/strings.xml b/packages/SystemUI/res/values-km-rKH/strings.xml index 7a1f95208280..f839eb648181 100644 --- a/packages/SystemUI/res/values-km-rKH/strings.xml +++ b/packages/SystemUI/res/values-km-rKH/strings.xml @@ -651,5 +651,5 @@ <string name="accessibility_quick_settings_open_settings" msgid="7806613775728380737">"បើការកំណត់ <xliff:g id="ID_1">%s</xliff:g>"</string> <string name="accessibility_quick_settings_edit" msgid="7839992848995240393">"កែលំដាប់ការកំណត់"</string> <string name="accessibility_quick_settings_page" msgid="5032979051755200721">"ទំព័រ <xliff:g id="ID_1">%1$d</xliff:g> នៃ <xliff:g id="ID_2">%2$d</xliff:g>"</string> - <string name="cant_silence_or_block" msgid="999689262131488625">"ការជូនមិនអាចបិទសំឡេង ឬរារាំងបានទេ"</string> + <string name="cant_silence_or_block" msgid="999689262131488625">"ការជូនដំណឹងមិនអាចបិទសំឡេង ឬរារាំងបានទេ"</string> </resources> diff --git a/packages/SystemUI/res/values-uz-rUZ/strings.xml b/packages/SystemUI/res/values-uz-rUZ/strings.xml index 70a32efa8bac..61195c587bc0 100644 --- a/packages/SystemUI/res/values-uz-rUZ/strings.xml +++ b/packages/SystemUI/res/values-uz-rUZ/strings.xml @@ -653,5 +653,5 @@ <string name="accessibility_quick_settings_open_settings" msgid="7806613775728380737">"<xliff:g id="ID_1">%s</xliff:g> sozlamalarini ochish."</string> <string name="accessibility_quick_settings_edit" msgid="7839992848995240393">"Sozlamalar tartibini o‘zgartirish."</string> <string name="accessibility_quick_settings_page" msgid="5032979051755200721">"<xliff:g id="ID_1">%1$d</xliff:g>-sahifa, jami: <xliff:g id="ID_2">%2$d</xliff:g> ta sahifa"</string> - <string name="cant_silence_or_block" msgid="999689262131488625">"Bildirishnomalarni o‘chirib qo‘yib yoki bloklab bo‘lmaydi"</string> + <string name="cant_silence_or_block" msgid="999689262131488625">"Bildirishnomalarni bloklab yoki ovozsiz ko‘rinadigan qilib bo‘lmaydi"</string> </resources> diff --git a/packages/SystemUI/res/values-zh-rTW/strings.xml b/packages/SystemUI/res/values-zh-rTW/strings.xml index f06644bc7609..b4f2b27dc7eb 100644 --- a/packages/SystemUI/res/values-zh-rTW/strings.xml +++ b/packages/SystemUI/res/values-zh-rTW/strings.xml @@ -651,5 +651,5 @@ <string name="accessibility_quick_settings_open_settings" msgid="7806613775728380737">"開啟「<xliff:g id="ID_1">%s</xliff:g>」設定。"</string> <string name="accessibility_quick_settings_edit" msgid="7839992848995240393">"編輯設定順序。"</string> <string name="accessibility_quick_settings_page" msgid="5032979051755200721">"第 <xliff:g id="ID_1">%1$d</xliff:g> 頁,共 <xliff:g id="ID_2">%2$d</xliff:g> 頁"</string> - <string name="cant_silence_or_block" msgid="999689262131488625">"無法將通知設為靜音或封鎖"</string> + <string name="cant_silence_or_block" msgid="999689262131488625">"無法關閉通知音效或封鎖通知"</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index f3e5c94be032..a6fe4382475e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -1853,24 +1853,34 @@ public class NotificationStackScrollLayout extends ViewGroup } updateBackgroundBounds(); if (!mCurrentBounds.equals(mBackgroundBounds)) { - if (mAnimateNextBackgroundTop || mAnimateNextBackgroundBottom || areBoundsAnimating()) { + boolean animate = mAnimateNextBackgroundTop || mAnimateNextBackgroundBottom + || areBoundsAnimating(); + if (!isExpanded()) { + abortBackgroundAnimators(); + animate = false; + } + if (animate) { startBackgroundAnimation(); } else { mCurrentBounds.set(mBackgroundBounds); applyCurrentBackgroundBounds(); } } else { - if (mBottomAnimator != null) { - mBottomAnimator.cancel(); - } - if (mTopAnimator != null) { - mTopAnimator.cancel(); - } + abortBackgroundAnimators(); } mAnimateNextBackgroundBottom = false; mAnimateNextBackgroundTop = false; } + private void abortBackgroundAnimators() { + if (mBottomAnimator != null) { + mBottomAnimator.cancel(); + } + if (mTopAnimator != null) { + mTopAnimator.cancel(); + } + } + private boolean areBoundsAnimating() { return mBottomAnimator != null || mTopAnimator != null; } diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 5f59e32ebb6b..614a94fa1e20 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -2261,11 +2261,19 @@ public class ConnectivityService extends IConnectivityManager.Stub synchronized (mNetworkForNetId) { nai = mNetworkForNetId.get(netId); } - // If captive portal status has changed, update capabilities. + // If captive portal status has changed, update capabilities or disconnect. if (nai != null && (visible != nai.lastCaptivePortalDetected)) { final int oldScore = nai.getCurrentScore(); nai.lastCaptivePortalDetected = visible; nai.everCaptivePortalDetected |= visible; + if (nai.lastCaptivePortalDetected && + Settings.Global.CAPTIVE_PORTAL_MODE_AVOID == getCaptivePortalMode()) { + if (DBG) log("Avoiding captive portal network: " + nai.name()); + nai.asyncChannel.sendMessage( + NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT); + teardownUnneededNetwork(nai); + break; + } updateCapabilities(oldScore, nai, nai.networkCapabilities); } if (!visible) { @@ -2286,6 +2294,12 @@ public class ConnectivityService extends IConnectivityManager.Stub return true; } + private int getCaptivePortalMode() { + return Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.CAPTIVE_PORTAL_MODE, + Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); + } + private boolean maybeHandleNetworkAgentInfoMessage(Message msg) { switch (msg.what) { default: diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java index 6eb89facca76..c73d1dd95437 100644 --- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java +++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java @@ -211,7 +211,9 @@ public class NetworkMonitor extends StateMachine { private final NetworkRequest mDefaultRequest; private final IpConnectivityLog mMetricsLog; - private boolean mIsCaptivePortalCheckEnabled; + @VisibleForTesting + protected boolean mIsCaptivePortalCheckEnabled; + private boolean mUseHttps; // Set if the user explicitly selected "Do not use this network" in captive portal sign-in app. @@ -265,7 +267,8 @@ public class NetworkMonitor extends StateMachine { setInitialState(mDefaultState); mIsCaptivePortalCheckEnabled = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED, 1) == 1; + Settings.Global.CAPTIVE_PORTAL_MODE, Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT) + != Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE; mUseHttps = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.CAPTIVE_PORTAL_USE_HTTPS, 1) == 1; @@ -632,7 +635,10 @@ public class NetworkMonitor extends StateMachine { @VisibleForTesting protected CaptivePortalProbeResult isCaptivePortal() { - if (!mIsCaptivePortalCheckEnabled) return new CaptivePortalProbeResult(204); + if (!mIsCaptivePortalCheckEnabled) { + validationLog("Validation disabled."); + return new CaptivePortalProbeResult(204); + } URL pacUrl = null, httpsUrl = null, httpUrl = null, fallbackUrl = null; diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 986bae9005e5..877f1e60e4c9 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -464,11 +464,11 @@ public class PackageManagerService extends IPackageManager.Stub { private static final String VENDOR_OVERLAY_DIR = "/vendor/overlay"; /** - * If VENDOR_OVERLAY_SKU_PROPERTY is set, search for runtime resource overlay APKs also in - * VENDOR_OVERLAY_DIR/<value of VENDOR_OVERLAY_SKU_PROPERTY> in addition to + * If VENDOR_OVERLAY_THEME_PROPERTY is set, search for runtime resource overlay APKs also in + * VENDOR_OVERLAY_DIR/<value of VENDOR_OVERLAY_THEME_PROPERTY> in addition to * VENDOR_OVERLAY_DIR. */ - private static final String VENDOR_OVERLAY_SKU_PROPERTY = "ro.boot.vendor.overlay.sku"; + private static final String VENDOR_OVERLAY_THEME_PROPERTY = "ro.boot.vendor.overlay.theme"; private static int DEFAULT_EPHEMERAL_HASH_PREFIX_MASK = 0xFFFFF000; private static int DEFAULT_EPHEMERAL_HASH_PREFIX_COUNT = 5; @@ -2274,9 +2274,9 @@ public class PackageManagerService extends IPackageManager.Stub { // Collect vendor overlay packages. (Do this before scanning any apps.) // For security and version matching reason, only consider // overlay packages if they reside in the right directory. - String overlaySkuDir = SystemProperties.get(VENDOR_OVERLAY_SKU_PROPERTY); - if (!overlaySkuDir.isEmpty()) { - scanDirTracedLI(new File(VENDOR_OVERLAY_DIR, overlaySkuDir), mDefParseFlags + String overlayThemeDir = SystemProperties.get(VENDOR_OVERLAY_THEME_PROPERTY); + if (!overlayThemeDir.isEmpty()) { + scanDirTracedLI(new File(VENDOR_OVERLAY_DIR, overlayThemeDir), mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR | PackageParser.PARSE_TRUSTED_OVERLAY, scanFlags | SCAN_TRUSTED_OVERLAY, 0); diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index e7ceba90bde3..aea8b39bd00b 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -346,7 +346,15 @@ class WallpaperController { Bundle sendWindowWallpaperCommand( WindowState window, String action, int x, int y, int z, Bundle extras, boolean sync) { - if (window == mWallpaperTarget + + // HACK(ewol): Custom whitelist for Wear Home app, to allow it to update the wallpaper + // regardless of what window is targeted. + // http://b/32172459 + final boolean hackWearWhitelisted = (window != null) && (window.mAttrs != null) + && "com.google.android.wearable.app".equals(window.mAttrs.packageName); + + if (hackWearWhitelisted + || window == mWallpaperTarget || window == mLowerWallpaperTarget || window == mUpperWallpaperTarget) { boolean doWait = sync; diff --git a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java index 4af1cf1a0df8..65f9399c5a80 100644 --- a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java @@ -236,6 +236,7 @@ public class ConnectivityServiceTest extends AndroidTestCase { private final IdleableHandlerThread mHandlerThread; private final ConditionVariable mDisconnected = new ConditionVariable(); private final ConditionVariable mNetworkStatusReceived = new ConditionVariable(); + private final ConditionVariable mPreventReconnectReceived = new ConditionVariable(); private int mScore; private NetworkAgent mNetworkAgent; private int mStartKeepaliveError = PacketKeepalive.ERROR_HARDWARE_UNSUPPORTED; @@ -291,6 +292,11 @@ public class ConnectivityServiceTest extends AndroidTestCase { mRedirectUrl = redirectUrl; mNetworkStatusReceived.open(); } + + @Override + protected void preventAutomaticReconnect() { + mPreventReconnectReceived.open(); + } }; // Waits for the NetworkAgent to be registered, which includes the creation of the // NetworkMonitor. @@ -375,11 +381,6 @@ public class ConnectivityServiceTest extends AndroidTestCase { mWrappedNetworkMonitor.gen204ProbeResult = 200; mWrappedNetworkMonitor.gen204ProbeRedirectUrl = redirectUrl; connect(false); - waitFor(new Criteria() { public boolean get() { - NetworkCapabilities caps = mCm.getNetworkCapabilities(getNetwork()); - return caps != null && caps.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL);} }); - mWrappedNetworkMonitor.gen204ProbeResult = 500; - mWrappedNetworkMonitor.gen204ProbeRedirectUrl = null; } public void disconnect() { @@ -391,6 +392,10 @@ public class ConnectivityServiceTest extends AndroidTestCase { return new Network(mNetworkAgent.netId); } + public ConditionVariable getPreventReconnectReceived() { + return mPreventReconnectReceived; + } + public ConditionVariable getDisconnectedCV() { return mDisconnected; } @@ -597,6 +602,7 @@ public class ConnectivityServiceTest extends AndroidTestCase { @Override protected CaptivePortalProbeResult isCaptivePortal() { + if (!mIsCaptivePortalCheckEnabled) { return new CaptivePortalProbeResult(204); } return new CaptivePortalProbeResult(gen204ProbeResult, gen204ProbeRedirectUrl, null); } } @@ -743,6 +749,9 @@ public class ConnectivityServiceTest extends AndroidTestCase { mService.systemReady(); mCm = new WrappedConnectivityManager(getContext(), mService); mCm.bindProcessToNetwork(null); + + // Ensure that the default setting for Captive Portals is used for most tests + setCaptivePortalMode(Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); } public void tearDown() throws Exception { @@ -1704,6 +1713,47 @@ public class ConnectivityServiceTest extends AndroidTestCase { validatedCallback.expectCallback(CallbackState.LOST, mWiFiNetworkAgent); } + @LargeTest + public void testAvoidOrIgnoreCaptivePortals() { + final TestNetworkCallback captivePortalCallback = new TestNetworkCallback(); + final NetworkRequest captivePortalRequest = new NetworkRequest.Builder() + .addCapability(NET_CAPABILITY_CAPTIVE_PORTAL).build(); + mCm.registerNetworkCallback(captivePortalRequest, captivePortalCallback); + + final TestNetworkCallback validatedCallback = new TestNetworkCallback(); + final NetworkRequest validatedRequest = new NetworkRequest.Builder() + .addCapability(NET_CAPABILITY_VALIDATED).build(); + mCm.registerNetworkCallback(validatedRequest, validatedCallback); + + setCaptivePortalMode(Settings.Global.CAPTIVE_PORTAL_MODE_AVOID); + // Bring up a network with a captive portal. + // Expect it to fail to connect and not result in any callbacks. + mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); + String firstRedirectUrl = "http://example.com/firstPath"; + + ConditionVariable disconnectCv = mWiFiNetworkAgent.getDisconnectedCV(); + ConditionVariable avoidCv = mWiFiNetworkAgent.getPreventReconnectReceived(); + mWiFiNetworkAgent.connectWithCaptivePortal(firstRedirectUrl); + waitFor(disconnectCv); + waitFor(avoidCv); + + assertNoCallbacks(captivePortalCallback, validatedCallback); + + // Now test ignore mode. + setCaptivePortalMode(Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE); + + // Bring up a network with a captive portal. + // Since we're ignoring captive portals, the network will validate. + mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); + String secondRedirectUrl = "http://example.com/secondPath"; + mWiFiNetworkAgent.connectWithCaptivePortal(secondRedirectUrl); + + // Expect NET_CAPABILITY_VALIDATED onAvailable callback. + validatedCallback.expectCallback(CallbackState.AVAILABLE, mWiFiNetworkAgent); + // But there should be no CaptivePortal callback. + captivePortalCallback.assertNoCallback(); + } + @SmallTest public void testInvalidNetworkSpecifier() { boolean execptionCalled = true; @@ -1844,6 +1894,11 @@ public class ConnectivityServiceTest extends AndroidTestCase { mCm.unregisterNetworkCallback(cellNetworkCallback); } + private void setCaptivePortalMode(int mode) { + ContentResolver cr = mServiceContext.getContentResolver(); + Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, mode); + } + private void setMobileDataAlwaysOn(boolean enable) { ContentResolver cr = mServiceContext.getContentResolver(); Settings.Global.putInt(cr, Settings.Global.MOBILE_DATA_ALWAYS_ON, enable ? 1 : 0); diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index c0061859bf60..8f9c7585ced6 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -420,6 +420,31 @@ public abstract class Connection extends Conferenceable { "android.telecom.extra.DISABLE_ADD_CALL"; /** + * String connection extra key on a {@link Connection} or {@link Conference} which contains the + * original Connection ID associated with the connection. Used in + * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a + * connection/conference added via + * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and + * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to + * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the + * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to + * be a way to ensure that we don't add the connection again as a duplicate. + * <p> + * For example, the TelephonyCS calls addExistingConnection for a Connection with ID + * {@code TelephonyCS@1}. The ConnectionManager learns of this via + * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this + * in a new {@link Connection} which it adds to Telecom via + * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of + * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}). + * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the + * ID it originally referred to the connection as. Thus Telecom needs to know that the + * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}. + * @hide + */ + public static final String EXTRA_ORIGINAL_CONNECTION_ID = + "android.telecom.extra.ORIGINAL_CONNECTION_ID"; + + /** * Connection event used to inform Telecom that it should play the on hold tone. This is used * to play a tone when the peer puts the current call on hold. Sent to Telecom via * {@link #sendConnectionEvent(String, Bundle)}. diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index 0c75630cab16..dd55ca9f1f19 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -1347,7 +1347,13 @@ public abstract class ConnectionService extends Service { */ private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) { String id; - if (handle == null) { + + if (connection.getExtras() != null && connection.getExtras() + .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) { + id = connection.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID); + Log.d(this, "addExistingConnectionInternal - conn %s reusing original id %s", + connection.getTelecomCallId(), id); + } else if (handle == null) { // If no phone account handle was provided, we cannot be sure the call ID is unique, // so just use a random UUID. id = UUID.randomUUID().toString(); @@ -1381,13 +1387,21 @@ public abstract class ConnectionService extends Service { } private String addConferenceInternal(Conference conference) { + String originalId = null; + if (conference.getExtras() != null && conference.getExtras() + .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) { + originalId = conference.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID); + Log.d(this, "addConferenceInternal: conf %s reusing original id %s", + conference.getTelecomCallId(), + originalId); + } if (mIdByConference.containsKey(conference)) { Log.w(this, "Re-adding an existing conference: %s.", conference); } else if (conference != null) { // Conferences do not (yet) have a PhoneAccountHandle associated with them, so we // cannot determine a ConnectionService class name to associate with the ID, so use // a unique UUID (for now). - String id = UUID.randomUUID().toString(); + String id = originalId == null ? UUID.randomUUID().toString() : originalId; mConferenceById.put(id, conference); mIdByConference.put(conference, id); conference.addListener(mConferenceListener); diff --git a/telecomm/java/android/telecom/RemoteConference.java b/telecomm/java/android/telecom/RemoteConference.java index 943da6d1a52e..0ef9ec1804c5 100644 --- a/telecomm/java/android/telecom/RemoteConference.java +++ b/telecomm/java/android/telecom/RemoteConference.java @@ -311,6 +311,9 @@ public final class RemoteConference { /** @hide */ void putExtras(final Bundle extras) { + if (extras == null) { + return; + } if (mExtras == null) { mExtras = new Bundle(); } diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java index f0301155a322..37fa374bdafd 100644 --- a/telecomm/java/android/telecom/RemoteConnection.java +++ b/telecomm/java/android/telecom/RemoteConnection.java @@ -651,6 +651,14 @@ public final class RemoteConnection { mCallerDisplayName = connection.getCallerDisplayName(); mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation(); mConference = null; + putExtras(connection.getExtras()); + + // Stash the original connection ID as it exists in the source ConnectionService. + // Telecom will use this to avoid adding duplicates later. + // See comments on Connection.EXTRA_ORIGINAL_CONNECTION_ID for more information. + Bundle newExtras = new Bundle(); + newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId); + putExtras(newExtras); } /** @@ -1348,6 +1356,9 @@ public final class RemoteConnection { /** @hide */ void putExtras(final Bundle extras) { + if (extras == null) { + return; + } if (mExtras == null) { mExtras = new Bundle(); } diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java index c4739ff13a19..1577a0f925f3 100644 --- a/telecomm/java/android/telecom/RemoteConnectionService.java +++ b/telecomm/java/android/telecom/RemoteConnectionService.java @@ -214,18 +214,27 @@ final class RemoteConnectionService { conference.addConnection(c); } } - if (conference.getConnections().size() == 0) { // A conference was created, but none of its connections are ones that have been // created by, and therefore being tracked by, this remote connection service. It // is of no interest to us. + Log.d(this, "addConferenceCall - skipping"); return; } conference.setState(parcel.getState()); conference.setConnectionCapabilities(parcel.getConnectionCapabilities()); conference.setConnectionProperties(parcel.getConnectionProperties()); + conference.putExtras(parcel.getExtras()); mConferenceById.put(callId, conference); + + // Stash the original connection ID as it exists in the source ConnectionService. + // Telecom will use this to avoid adding duplicates later. + // See comments on Connection.EXTRA_ORIGINAL_CONNECTION_ID for more information. + Bundle newExtras = new Bundle(); + newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId); + conference.putExtras(newExtras); + conference.registerCallback(new RemoteConference.Callback() { @Override public void onDestroyed(RemoteConference c) { @@ -331,12 +340,18 @@ final class RemoteConnectionService { } @Override - public void addExistingConnection(String callId, ParcelableConnection connection) { - // TODO: add contents of this method - RemoteConnection remoteConnction = new RemoteConnection(callId, + public void addExistingConnection(final String callId, ParcelableConnection connection) { + RemoteConnection remoteConnection = new RemoteConnection(callId, mOutgoingConnectionServiceRpc, connection); - - mOurConnectionServiceImpl.addRemoteExistingConnection(remoteConnction); + mConnectionById.put(callId, remoteConnection); + remoteConnection.registerCallback(new RemoteConnection.Callback() { + @Override + public void onDestroyed(RemoteConnection connection) { + mConnectionById.remove(callId); + maybeDisconnectAdapter(); + } + }); + mOurConnectionServiceImpl.addRemoteExistingConnection(remoteConnection); } @Override |