diff options
22 files changed, 272 insertions, 178 deletions
diff --git a/api/current.txt b/api/current.txt index 21fe3e2febc4..21ff787df176 100644 --- a/api/current.txt +++ b/api/current.txt @@ -62850,7 +62850,10 @@ package java.util.zip {      method public java.lang.String getComment();      method public long getCompressedSize();      method public long getCrc(); +    method public java.nio.file.attribute.FileTime getCreationTime();      method public byte[] getExtra(); +    method public java.nio.file.attribute.FileTime getLastAccessTime(); +    method public java.nio.file.attribute.FileTime getLastModifiedTime();      method public int getMethod();      method public java.lang.String getName();      method public long getSize(); @@ -62859,7 +62862,10 @@ package java.util.zip {      method public void setComment(java.lang.String);      method public void setCompressedSize(long);      method public void setCrc(long); +    method public java.util.zip.ZipEntry setCreationTime(java.nio.file.attribute.FileTime);      method public void setExtra(byte[]); +    method public java.util.zip.ZipEntry setLastAccessTime(java.nio.file.attribute.FileTime); +    method public java.util.zip.ZipEntry setLastModifiedTime(java.nio.file.attribute.FileTime);      method public void setMethod(int);      method public void setSize(long);      method public void setTime(long); @@ -62930,6 +62936,7 @@ package java.util.zip {      method public java.io.InputStream getInputStream(java.util.zip.ZipEntry) throws java.io.IOException;      method public java.lang.String getName();      method public int size(); +    method public java.util.stream.Stream<? extends java.util.zip.ZipEntry> stream();      field public static final int CENATT = 36; // 0x24      field public static final int CENATX = 38; // 0x26      field public static final int CENCOM = 32; // 0x20 diff --git a/api/system-current.txt b/api/system-current.txt index 974db45e2430..6645d53613b1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -66207,7 +66207,10 @@ package java.util.zip {      method public java.lang.String getComment();      method public long getCompressedSize();      method public long getCrc(); +    method public java.nio.file.attribute.FileTime getCreationTime();      method public byte[] getExtra(); +    method public java.nio.file.attribute.FileTime getLastAccessTime(); +    method public java.nio.file.attribute.FileTime getLastModifiedTime();      method public int getMethod();      method public java.lang.String getName();      method public long getSize(); @@ -66216,7 +66219,10 @@ package java.util.zip {      method public void setComment(java.lang.String);      method public void setCompressedSize(long);      method public void setCrc(long); +    method public java.util.zip.ZipEntry setCreationTime(java.nio.file.attribute.FileTime);      method public void setExtra(byte[]); +    method public java.util.zip.ZipEntry setLastAccessTime(java.nio.file.attribute.FileTime); +    method public java.util.zip.ZipEntry setLastModifiedTime(java.nio.file.attribute.FileTime);      method public void setMethod(int);      method public void setSize(long);      method public void setTime(long); @@ -66287,6 +66293,7 @@ package java.util.zip {      method public java.io.InputStream getInputStream(java.util.zip.ZipEntry) throws java.io.IOException;      method public java.lang.String getName();      method public int size(); +    method public java.util.stream.Stream<? extends java.util.zip.ZipEntry> stream();      field public static final int CENATT = 36; // 0x24      field public static final int CENATX = 38; // 0x26      field public static final int CENCOM = 32; // 0x20 diff --git a/api/test-current.txt b/api/test-current.txt index 29de7a5af703..5301443f930b 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -62930,7 +62930,10 @@ package java.util.zip {      method public java.lang.String getComment();      method public long getCompressedSize();      method public long getCrc(); +    method public java.nio.file.attribute.FileTime getCreationTime();      method public byte[] getExtra(); +    method public java.nio.file.attribute.FileTime getLastAccessTime(); +    method public java.nio.file.attribute.FileTime getLastModifiedTime();      method public int getMethod();      method public java.lang.String getName();      method public long getSize(); @@ -62939,7 +62942,10 @@ package java.util.zip {      method public void setComment(java.lang.String);      method public void setCompressedSize(long);      method public void setCrc(long); +    method public java.util.zip.ZipEntry setCreationTime(java.nio.file.attribute.FileTime);      method public void setExtra(byte[]); +    method public java.util.zip.ZipEntry setLastAccessTime(java.nio.file.attribute.FileTime); +    method public java.util.zip.ZipEntry setLastModifiedTime(java.nio.file.attribute.FileTime);      method public void setMethod(int);      method public void setSize(long);      method public void setTime(long); @@ -63010,6 +63016,7 @@ package java.util.zip {      method public java.io.InputStream getInputStream(java.util.zip.ZipEntry) throws java.io.IOException;      method public java.lang.String getName();      method public int size(); +    method public java.util.stream.Stream<? extends java.util.zip.ZipEntry> stream();      field public static final int CENATT = 36; // 0x24      field public static final int CENATX = 38; // 0x26      field public static final int CENCOM = 32; // 0x20 diff --git a/cmds/svc/src/com/android/commands/svc/UsbCommand.java b/cmds/svc/src/com/android/commands/svc/UsbCommand.java index a6ef25fc4479..4dcb05e4f85d 100644 --- a/cmds/svc/src/com/android/commands/svc/UsbCommand.java +++ b/cmds/svc/src/com/android/commands/svc/UsbCommand.java @@ -50,7 +50,7 @@ public class UsbCommand extends Svc.Command {                  IUsbManager usbMgr = IUsbManager.Stub.asInterface(ServiceManager.getService(                          Context.USB_SERVICE));                  try { -                    usbMgr.setCurrentFunction((args.length >=3 ? args[2] : null)); +                    usbMgr.setCurrentFunction((args.length >=3 ? args[2] : null), false);                  } catch (RemoteException e) {                      System.err.println("Error communicating with UsbManager: " + e);                  } diff --git a/core/java/android/hardware/usb/IUsbManager.aidl b/core/java/android/hardware/usb/IUsbManager.aidl index 6e4c9de1c8ef..00b0bffdd1f5 100644 --- a/core/java/android/hardware/usb/IUsbManager.aidl +++ b/core/java/android/hardware/usb/IUsbManager.aidl @@ -87,15 +87,13 @@ interface IUsbManager      /* Returns true if the specified USB function is enabled. */      boolean isFunctionEnabled(String function); -    /* Sets the current USB function. */ -    void setCurrentFunction(String function); - -    /* Sets whether USB data (for example, MTP exposed pictures) should be made -     * available on the USB connection. Unlocking data should only be done with -     * user involvement, since exposing pictures or other data could leak sensitive -     * user information. +    /* Sets the current USB function as well as whether USB data +     * (for example, MTP exposed pictures) should be made available +     * on the USB connection. Unlocking data should only be done with +     * user involvement, since exposing pictures or other data could +     * leak sensitive user information.       */ -    void setUsbDataUnlocked(boolean unlock); +    void setCurrentFunction(String function, boolean usbDataUnlocked);      /* Allow USB debugging from the attached host. If alwaysAllow is true, add the       * the public key to list of host keys that the user has approved. diff --git a/core/java/android/hardware/usb/UsbManager.java b/core/java/android/hardware/usb/UsbManager.java index f9a7d192b5bb..6341cbc79f3f 100644 --- a/core/java/android/hardware/usb/UsbManager.java +++ b/core/java/android/hardware/usb/UsbManager.java @@ -509,33 +509,23 @@ public class UsbManager {       * {@link #USB_FUNCTION_MIDI}, {@link #USB_FUNCTION_MTP}, {@link #USB_FUNCTION_PTP},       * or {@link #USB_FUNCTION_RNDIS}.       * </p><p> +     * Also sets whether USB data (for example, MTP exposed pictures) should be made available +     * on the USB connection when in device mode. Unlocking usb data should only be done with +     * user involvement, since exposing pictures or other data could leak sensitive +     * user information. +     * </p><p>       * Note: This function is asynchronous and may fail silently without applying       * the requested changes.       * </p>       *       * @param function name of the USB function, or null to restore the default function +     * @param usbDataUnlocked whether user data is accessible       *       * {@hide}       */ -    public void setCurrentFunction(String function) { -        try { -            mService.setCurrentFunction(function); -        } catch (RemoteException e) { -            throw e.rethrowFromSystemServer(); -        } -    } - -    /** -     * Sets whether USB data (for example, MTP exposed pictures) should be made available -     * on the USB connection when in device mode. Unlocking usb data should only be done with -     * user involvement, since exposing pictures or other data could leak sensitive -     * user information. -     * -     * {@hide} -     */ -    public void setUsbDataUnlocked(boolean unlocked) { +    public void setCurrentFunction(String function, boolean usbDataUnlocked) {          try { -            mService.setUsbDataUnlocked(unlocked); +            mService.setCurrentFunction(function, usbDataUnlocked);          } catch (RemoteException e) {              throw e.rethrowFromSystemServer();          } diff --git a/core/java/android/os/CountDownTimer.java b/core/java/android/os/CountDownTimer.java index 58acbcf5684b..c7bf0fd6ba49 100644 --- a/core/java/android/os/CountDownTimer.java +++ b/core/java/android/os/CountDownTimer.java @@ -125,19 +125,28 @@ public abstract class CountDownTimer {                  if (millisLeft <= 0) {                      onFinish(); -                } else if (millisLeft < mCountdownInterval) { -                    // no tick, just delay until done -                    sendMessageDelayed(obtainMessage(MSG), millisLeft);                  } else {                      long lastTickStart = SystemClock.elapsedRealtime();                      onTick(millisLeft);                      // take into account user's onTick taking time to execute -                    long delay = lastTickStart + mCountdownInterval - SystemClock.elapsedRealtime(); - -                    // special case: user's onTick took more than interval to -                    // complete, skip to next interval -                    while (delay < 0) delay += mCountdownInterval; +                    long lastTickDuration = SystemClock.elapsedRealtime() - lastTickStart; +                    long delay; + +                    if (millisLeft < mCountdownInterval) { +                        // just delay until done +                        delay = millisLeft - lastTickDuration; + +                        // special case: user's onTick took more than interval to +                        // complete, trigger onFinish without delay +                        if (delay < 0) delay = 0; +                    } else { +                        delay = mCountdownInterval - lastTickDuration; + +                        // special case: user's onTick took more than interval to +                        // complete, skip to next interval +                        while (delay < 0) delay += mCountdownInterval; +                    }                      sendMessageDelayed(obtainMessage(MSG), delay);                  } diff --git a/core/jni/android_os_HwBlob.h b/core/jni/android_os_HwBlob.h index 6bd82e98e911..09204880881b 100644 --- a/core/jni/android_os_HwBlob.h +++ b/core/jni/android_os_HwBlob.h @@ -20,6 +20,7 @@  #include <android-base/macros.h>  #include <jni.h>  #include <hidl/HidlSupport.h> +#include <hwbinder/Parcel.h>  #include <utils/RefBase.h>  #include <utils/Vector.h> diff --git a/core/jni/android_os_HwParcel.cpp b/core/jni/android_os_HwParcel.cpp index 1a67ceebac1c..a10d80746e46 100644 --- a/core/jni/android_os_HwParcel.cpp +++ b/core/jni/android_os_HwParcel.cpp @@ -26,6 +26,7 @@  #include <JNIHelp.h>  #include <android_runtime/AndroidRuntime.h> +#include <hidl/HidlTransportSupport.h>  #include <hidl/Status.h>  #include <nativehelper/ScopedLocalRef.h> @@ -383,7 +384,7 @@ static void JHwParcel_native_writeStatus(      hardware::Parcel *parcel =          JHwParcel::GetNativeContext(env, thiz)->getParcel(); -    status_t err = status.writeToParcel(parcel); +    status_t err = ::android::hardware::writeToParcel(status, parcel);      signalExceptionForError(env, err);  } @@ -394,7 +395,7 @@ static void JHwParcel_native_verifySuccess(JNIEnv *env, jobject thiz) {          JHwParcel::GetNativeContext(env, thiz)->getParcel();      Status status; -    status_t err = status.readFromParcel(*parcel); +    status_t err = ::android::hardware::readFromParcel(&status, *parcel);      signalExceptionForError(env, err);  } diff --git a/core/tests/coretests/apks/install_jni_lib/Android.mk b/core/tests/coretests/apks/install_jni_lib/Android.mk index 9e45d099b669..d7b38e844b5e 100644 --- a/core/tests/coretests/apks/install_jni_lib/Android.mk +++ b/core/tests/coretests/apks/install_jni_lib/Android.mk @@ -19,8 +19,7 @@ include $(CLEAR_VARS)  LOCAL_SRC_FILES := \      com_android_frameworks_coretests_JNITest.cpp -LOCAL_SHARED_LIBRARIES := \ -    libnativehelper +LOCAL_SDK_VERSION := 16  LOCAL_CFLAGS += -Wall -Werror diff --git a/core/tests/coretests/apks/install_jni_lib/com_android_frameworks_coretests_JNITest.cpp b/core/tests/coretests/apks/install_jni_lib/com_android_frameworks_coretests_JNITest.cpp index 8d9119275bc8..0cf3a84a3859 100644 --- a/core/tests/coretests/apks/install_jni_lib/com_android_frameworks_coretests_JNITest.cpp +++ b/core/tests/coretests/apks/install_jni_lib/com_android_frameworks_coretests_JNITest.cpp @@ -14,41 +14,23 @@   * limitations under the License.   */ -#include "nativehelper/JNIHelp.h" +#include <jni.h> -namespace android { - -static jint checkFunction(JNIEnv*, jclass) { +extern "C" JNIEXPORT +jint JNICALL Java_com_android_frameworks_coretests_JNITests_checkFunction(JNIEnv*, jclass) {      return 1;  } -static const JNINativeMethod sMethods[] = { -    /* name, signature, funcPtr */ -    { "checkFunction", "()I", (void*) checkFunction }, -}; - -int register_com_android_frameworks_coretests_JNITests(JNIEnv* env) { -    return jniRegisterNativeMethods(env, "com/android/frameworks/coretests/JNITests", sMethods, -            NELEM(sMethods)); -} - -} -  /*   * JNI Initialization   */  jint JNI_OnLoad(JavaVM *jvm, void */* reserved */) {      JNIEnv *e; -    int status;      // Check JNI version      if (jvm->GetEnv((void **) &e, JNI_VERSION_1_6)) {          return JNI_ERR;      } -    if ((status = android::register_com_android_frameworks_coretests_JNITests(e)) < 0) { -        return JNI_ERR; -    } -      return JNI_VERSION_1_6;  } diff --git a/libs/hwui/tests/microbench/FrameBuilderBench.cpp b/libs/hwui/tests/microbench/FrameBuilderBench.cpp index 84ef9c2575f5..362890b52b61 100644 --- a/libs/hwui/tests/microbench/FrameBuilderBench.cpp +++ b/libs/hwui/tests/microbench/FrameBuilderBench.cpp @@ -113,7 +113,7 @@ static auto SCENES = {  void BM_FrameBuilder_defer_scene(benchmark::State& state) {      TestUtils::runOnRenderThread([&state](RenderThread& thread) { -        const char* sceneName = *(SCENES.begin() + state.range_x()); +        const char* sceneName = *(SCENES.begin() + state.range(0));          state.SetLabel(sceneName);          auto node = getSyncedSceneNode(sceneName);          while (state.KeepRunning()) { @@ -129,7 +129,7 @@ BENCHMARK(BM_FrameBuilder_defer_scene)->DenseRange(0, SCENES.size() - 1);  void BM_FrameBuilder_deferAndRender_scene(benchmark::State& state) {      TestUtils::runOnRenderThread([&state](RenderThread& thread) { -        const char* sceneName = *(SCENES.begin() + state.range_x()); +        const char* sceneName = *(SCENES.begin() + state.range(0));          state.SetLabel(sceneName);          auto node = getSyncedSceneNode(sceneName); diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java index 9608daad70e9..24ede164fbdd 100755 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java @@ -116,6 +116,10 @@ public final class A2dpProfile implements LocalBluetoothProfile {          List<BluetoothDevice> sinks = getConnectedDevices();          if (sinks != null) {              for (BluetoothDevice sink : sinks) { +                if (sink.equals(device)) { +                    Log.w(TAG, "Connecting to device " + device + " : disconnect skipped"); +                    continue; +                }                  mService.disconnect(sink);              }          } diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java index e888faaac075..cec4141a41f6 100644 --- a/services/core/java/com/android/server/connectivity/Tethering.java +++ b/services/core/java/com/android/server/connectivity/Tethering.java @@ -900,7 +900,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering                      }                  } else {                      mUsbTetherRequested = true; -                    usbManager.setCurrentFunction(UsbManager.USB_FUNCTION_RNDIS); +                    usbManager.setCurrentFunction(UsbManager.USB_FUNCTION_RNDIS, false);                  }              } else {                  final long ident = Binder.clearCallingIdentity(); @@ -910,7 +910,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering                      Binder.restoreCallingIdentity(ident);                  }                  if (mRndisEnabled) { -                    usbManager.setCurrentFunction(null); +                    usbManager.setCurrentFunction(null, false);                  }                  mUsbTetherRequested = false;              } diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index dfd6dfe1c775..99a6979d3436 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -1410,7 +1410,6 @@ final class Settings {          VersionInfo ver = mVersion.get(volumeUuid);          if (ver == null) {              ver = new VersionInfo(); -            ver.forceCurrent();              mVersion.put(volumeUuid, ver);          }          return ver; @@ -2795,8 +2794,8 @@ final class Settings {                              "No settings file; creating initial state");                      // It's enough to just touch version details to create them                      // with default values -                    findOrCreateVersion(StorageManager.UUID_PRIVATE_INTERNAL); -                    findOrCreateVersion(StorageManager.UUID_PRIMARY_PHYSICAL); +                    findOrCreateVersion(StorageManager.UUID_PRIVATE_INTERNAL).forceCurrent(); +                    findOrCreateVersion(StorageManager.UUID_PRIMARY_PHYSICAL).forceCurrent();                      return false;                  }                  str = new FileInputStream(mSettingsFilename); diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index df9242dc0aa1..43b8fa51a80e 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -108,9 +108,8 @@ public class UsbDeviceManager {      private static final int MSG_SYSTEM_READY = 3;      private static final int MSG_BOOT_COMPLETED = 4;      private static final int MSG_USER_SWITCHED = 5; -    private static final int MSG_SET_USB_DATA_UNLOCKED = 6; -    private static final int MSG_UPDATE_USER_RESTRICTIONS = 7; -    private static final int MSG_UPDATE_HOST_STATE = 8; +    private static final int MSG_UPDATE_USER_RESTRICTIONS = 6; +    private static final int MSG_UPDATE_HOST_STATE = 7;      private static final int AUDIO_MODE_SOURCE = 1; @@ -287,7 +286,7 @@ public class UsbDeviceManager {          if (functions != null) {              mAccessoryModeRequestTime = SystemClock.elapsedRealtime(); -            setCurrentFunctions(functions); +            setCurrentFunctions(functions, false);          }      } @@ -335,14 +334,22 @@ public class UsbDeviceManager {                  // Restore default functions.                  mCurrentFunctions = SystemProperties.get(USB_CONFIG_PROPERTY,                          UsbManager.USB_FUNCTION_NONE); -                if (UsbManager.USB_FUNCTION_NONE.equals(mCurrentFunctions)) { -                    mCurrentFunctions = UsbManager.USB_FUNCTION_MTP; -                }                  mCurrentFunctionsApplied = mCurrentFunctions.equals(                          SystemProperties.get(USB_STATE_PROPERTY));                  mAdbEnabled = UsbManager.containsFunction(getDefaultFunctions(),                          UsbManager.USB_FUNCTION_ADB); -                setEnabledFunctions(null, false); + +                /** +                 * Remove MTP from persistent config, to bring usb to a good state +                 * after fixes to b/31814300. This block can be removed after the update +                 */ +                String persisted = SystemProperties.get(USB_PERSISTENT_CONFIG_PROPERTY); +                if (UsbManager.containsFunction(persisted, UsbManager.USB_FUNCTION_MTP)) { +                    SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, +                            UsbManager.removeFunction(persisted, UsbManager.USB_FUNCTION_MTP)); +                } + +                setEnabledFunctions(null, false, false);                  String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim();                  updateState(state); @@ -374,6 +381,14 @@ public class UsbDeviceManager {              sendMessage(m);          } +        public void sendMessage(int what, Object arg, boolean arg1) { +            removeMessages(what); +            Message m = Message.obtain(this, what); +            m.obj = arg; +            m.arg1 = (arg1 ? 1 : 0); +            sendMessage(m); +        } +          public void updateState(String state) {              int connected, configured; @@ -427,29 +442,24 @@ public class UsbDeviceManager {              return waitForState(config);          } -        private void setUsbDataUnlocked(boolean enable) { -            if (DEBUG) Slog.d(TAG, "setUsbDataUnlocked: " + enable); -            mUsbDataUnlocked = enable; -            updateUsbNotification(); -            updateUsbStateBroadcastIfNeeded(); -            setEnabledFunctions(mCurrentFunctions, true); -        } -          private void setAdbEnabled(boolean enable) {              if (DEBUG) Slog.d(TAG, "setAdbEnabled: " + enable);              if (enable != mAdbEnabled) {                  mAdbEnabled = enable; +                String oldFunctions = mCurrentFunctions; + +                // Persist the adb setting +                String newFunction = applyAdbFunction(SystemProperties.get( +                            USB_PERSISTENT_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE)); +                SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, newFunction); -                // Due to the persist.sys.usb.config property trigger, changing adb state requires -                // persisting default function -                String oldFunctions = getDefaultFunctions(); -                String newFunctions = applyAdbFunction(oldFunctions); -                if (!oldFunctions.equals(newFunctions)) { -                    SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, newFunctions); +                // Remove mtp from the config if file transfer is not enabled +                if (oldFunctions.equals(UsbManager.USB_FUNCTION_MTP) && +                        !mUsbDataUnlocked && enable) { +                    oldFunctions = UsbManager.USB_FUNCTION_NONE;                  } -                // After persisting them use the lock-down aware function set -                setEnabledFunctions(mCurrentFunctions, false); +                setEnabledFunctions(oldFunctions, true, mUsbDataUnlocked);                  updateAdbNotification();              } @@ -461,10 +471,17 @@ public class UsbDeviceManager {          /**           * Evaluates USB function policies and applies the change accordingly.           */ -        private void setEnabledFunctions(String functions, boolean forceRestart) { +        private void setEnabledFunctions(String functions, boolean forceRestart, +                boolean usbDataUnlocked) {              if (DEBUG) Slog.d(TAG, "setEnabledFunctions functions=" + functions + ", "                      + "forceRestart=" + forceRestart); +            if (usbDataUnlocked != mUsbDataUnlocked) { +                mUsbDataUnlocked = usbDataUnlocked; +                updateUsbNotification(); +                forceRestart = true; +            } +              // Try to set the enabled functions.              final String oldFunctions = mCurrentFunctions;              final boolean oldFunctionsApplied = mCurrentFunctionsApplied; @@ -501,7 +518,8 @@ public class UsbDeviceManager {          }          private boolean trySetEnabledFunctions(String functions, boolean forceRestart) { -            if (functions == null) { +            if (functions == null || applyAdbFunction(functions) +                    .equals(UsbManager.USB_FUNCTION_NONE)) {                  functions = getDefaultFunctions();              }              functions = applyAdbFunction(functions); @@ -566,7 +584,7 @@ public class UsbDeviceManager {                  // make sure accessory mode is off                  // and restore default functions                  Slog.d(TAG, "exited USB accessory mode"); -                setEnabledFunctions(null, false); +                setEnabledFunctions(null, false, false);                  if (mCurrentAccessory != null) {                      if (mBootCompleted) { @@ -583,10 +601,6 @@ public class UsbDeviceManager {              if (mBroadcastedIntent == null) {                  for (String key : keySet) {                      if (intent.getBooleanExtra(key, false)) { -                        // MTP function is enabled by default. -                        if (UsbManager.USB_FUNCTION_MTP.equals(key)) { -                            continue; -                        }                          return true;                      }                  } @@ -699,10 +713,7 @@ public class UsbDeviceManager {                  case MSG_UPDATE_STATE:                      mConnected = (msg.arg1 == 1);                      mConfigured = (msg.arg2 == 1); -                    if (!mConnected) { -                        // When a disconnect occurs, relock access to sensitive user data -                        mUsbDataUnlocked = false; -                    } +                      updateUsbNotification();                      updateAdbNotification();                      if (UsbManager.containsFunction(mCurrentFunctions, @@ -710,7 +721,7 @@ public class UsbDeviceManager {                          updateCurrentAccessory();                      } else if (!mConnected) {                          // restore defaults when USB is disconnected -                        setEnabledFunctions(null, false); +                        setEnabledFunctions(null, false, false);                      }                      if (mBootCompleted) {                          updateUsbStateBroadcastIfNeeded(); @@ -730,13 +741,10 @@ public class UsbDeviceManager {                      break;                  case MSG_SET_CURRENT_FUNCTIONS:                      String functions = (String)msg.obj; -                    setEnabledFunctions(functions, false); +                    setEnabledFunctions(functions, false, msg.arg1 == 1);                      break;                  case MSG_UPDATE_USER_RESTRICTIONS: -                    setEnabledFunctions(mCurrentFunctions, false); -                    break; -                case MSG_SET_USB_DATA_UNLOCKED: -                    setUsbDataUnlocked(msg.arg1 == 1); +                    setEnabledFunctions(mCurrentFunctions, false, mUsbDataUnlocked);                      break;                  case MSG_SYSTEM_READY:                      updateUsbNotification(); @@ -764,8 +772,7 @@ public class UsbDeviceManager {                              Slog.v(TAG, "Current user switched to " + mCurrentUser                                      + "; resetting USB host stack for MTP or PTP");                              // avoid leaking sensitive data from previous user -                            mUsbDataUnlocked = false; -                            setEnabledFunctions(mCurrentFunctions, true); +                            setEnabledFunctions(mCurrentFunctions, true, false);                          }                          mCurrentUser = msg.arg1;                      } @@ -944,14 +951,10 @@ public class UsbDeviceManager {          return UsbManager.containsFunction(SystemProperties.get(USB_CONFIG_PROPERTY), function);      } -    public void setCurrentFunctions(String functions) { -        if (DEBUG) Slog.d(TAG, "setCurrentFunctions(" + functions + ")"); -        mHandler.sendMessage(MSG_SET_CURRENT_FUNCTIONS, functions); -    } - -    public void setUsbDataUnlocked(boolean unlocked) { -        if (DEBUG) Slog.d(TAG, "setUsbDataUnlocked(" + unlocked + ")"); -        mHandler.sendMessage(MSG_SET_USB_DATA_UNLOCKED, unlocked); +    public void setCurrentFunctions(String functions, boolean usbDataUnlocked) { +        if (DEBUG) Slog.d(TAG, "setCurrentFunctions(" + functions + ", " + +				usbDataUnlocked + ")"); +        mHandler.sendMessage(MSG_SET_CURRENT_FUNCTIONS, functions, usbDataUnlocked);      }      private void readOemUsbOverrideConfig() { diff --git a/services/usb/java/com/android/server/usb/UsbService.java b/services/usb/java/com/android/server/usb/UsbService.java index d6dbe90584f5..daccc00ad80c 100644 --- a/services/usb/java/com/android/server/usb/UsbService.java +++ b/services/usb/java/com/android/server/usb/UsbService.java @@ -287,7 +287,7 @@ public class UsbService extends IUsbManager.Stub {      }      @Override -    public void setCurrentFunction(String function) { +    public void setCurrentFunction(String function, boolean usbDataUnlocked) {          mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null);          if (!isSupportedCurrentFunction(function)) { @@ -297,7 +297,7 @@ public class UsbService extends IUsbManager.Stub {          }          if (mDeviceManager != null) { -            mDeviceManager.setCurrentFunctions(function); +            mDeviceManager.setCurrentFunctions(function, usbDataUnlocked);          } else {              throw new IllegalStateException("USB device mode not supported");          } @@ -320,12 +320,6 @@ public class UsbService extends IUsbManager.Stub {      }      @Override -    public void setUsbDataUnlocked(boolean unlocked) { -        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); -        mDeviceManager.setUsbDataUnlocked(unlocked); -    } - -    @Override      public void allowUsbDebugging(boolean alwaysAllow, String publicKey) {          mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null);          mDeviceManager.allowUsbDebugging(alwaysAllow, publicKey); diff --git a/tools/preload2/Android.mk b/tools/preload2/Android.mk index ce877b3696c2..09d95ffe3506 100644 --- a/tools/preload2/Android.mk +++ b/tools/preload2/Android.mk @@ -5,7 +5,7 @@ include $(CLEAR_VARS)  LOCAL_SRC_FILES := $(call all-java-files-under,src)  # To connect to devices (and take hprof dumps). -LOCAL_STATIC_JAVA_LIBRARIES := ddmlib-prebuilt +LOCAL_STATIC_JAVA_LIBRARIES := ddmlib-prebuilt tools-common-prebuilt  # To process hprof dumps.  LOCAL_STATIC_JAVA_LIBRARIES += perflib-prebuilt trove-prebuilt guavalib diff --git a/wifi/java/android/net/wifi/EAPConstants.java b/wifi/java/android/net/wifi/EAPConstants.java new file mode 100644 index 000000000000..b5f7c946ff05 --- /dev/null +++ b/wifi/java/android/net/wifi/EAPConstants.java @@ -0,0 +1,57 @@ +/** + * 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. + */ + +package android.net.wifi; + +/** + * Utility class containing EAP (Extensible Authentication Protocol) Related constants. + * + * @hide + */ +public final class EAPConstants { +    // Constant definition for EAP types. Refer to +    // http://www.iana.org/assignments/eap-numbers/eap-numbers.xhtml for more info. +    public static final int EAP_MD5 = 4; +    public static final int EAP_OTP = 5; +    public static final int EAP_RSA = 9; +    public static final int EAP_KEA = 11; +    public static final int EAP_KEA_VALIDATE = 12; +    public static final int EAP_TLS = 13; +    public static final int EAP_LEAP = 17; +    public static final int EAP_SIM = 18; +    public static final int EAP_TTLS = 21; +    public static final int EAP_AKA = 23; +    public static final int EAP_3Com = 24; +    public static final int EAP_MSCHAPv2 = 26; +    public static final int EAP_PEAP = 29; +    public static final int EAP_POTP = 32; +    public static final int EAP_ActiontecWireless = 35; +    public static final int EAP_HTTPDigest = 38; +    public static final int EAP_SPEKE = 41; +    public static final int EAP_MOBAC = 42; +    public static final int EAP_FAST = 43; +    public static final int EAP_ZLXEAP = 44; +    public static final int EAP_Link = 45; +    public static final int EAP_PAX = 46; +    public static final int EAP_PSK = 47; +    public static final int EAP_SAKE = 48; +    public static final int EAP_IKEv2 = 49; +    public static final int EAP_AKA_PRIME = 50; +    public static final int EAP_GPSK = 51; +    public static final int EAP_PWD = 52; +    public static final int EAP_EKE = 53; +    public static final int EAP_TEAP = 55; +} diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index bc382848a59b..9e897bff1122 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -59,11 +59,6 @@ interface IWifiManager      int addOrUpdateNetwork(in WifiConfiguration config); -    int addPasspointManagementObject(String mo); - -    int modifyPasspointManagementObject(String fqdn, -                                        in List<PasspointManagementObjectDefinition> mos); -      boolean addPasspointConfiguration(in PasspointConfiguration config);      boolean removePasspointConfiguration(in String fqdn); @@ -132,8 +127,6 @@ interface IWifiManager      WifiConfiguration getWifiApConfiguration(); -    WifiConfiguration buildWifiConfig(String uriString, String mimeType, in byte[] data); -      void setWifiApConfiguration(in WifiConfiguration wifiConfig);      Messenger getWifiServiceMessenger(); diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java index 465addfc1469..da8713555889 100644 --- a/wifi/java/android/net/wifi/ScanResult.java +++ b/wifi/java/android/net/wifi/ScanResult.java @@ -66,6 +66,93 @@ public class ScanResult implements Parcelable {       * supported by the access point.       */      public String capabilities; + +    /** +     * @hide +     * No security protocol. +     */ +    public static final int PROTOCOL_NONE = 0; +    /** +     * @hide +     * Security protocol type: WPA version 1. +     */ +    public static final int PROTOCOL_WPA = 1; +    /** +     * @hide +     * Security protocol type: WPA version 2, also called RSN. +     */ +    public static final int PROTOCOL_WPA2 = 2; +    /** +     * @hide +     * Security protocol type: +     * OSU Server-only authenticated layer 2 Encryption Network. +     * Used for Hotspot 2.0. +     */ +    public static final int PROTOCOL_OSEN = 3; + +    /** +     * @hide +     * No security key management scheme. +     */ +    public static final int KEY_MGMT_NONE = 0; +    /** +     * @hide +     * Security key management scheme: PSK. +     */ +    public static final int KEY_MGMT_PSK = 1; +    /** +     * @hide +     * Security key management scheme: EAP. +     */ +    public static final int KEY_MGMT_EAP = 2; +    /** +     * @hide +     * Security key management scheme: FT_PSK. +     */ +    public static final int KEY_MGMT_FT_PSK = 3; +    /** +     * @hide +     * Security key management scheme: FT_EAP. +     */ +    public static final int KEY_MGMT_FT_EAP = 4; +    /** +     * @hide +     * Security key management scheme: PSK_SHA256 +     */ +    public static final int KEY_MGMT_PSK_SHA256 = 5; +    /** +     * @hide +     * Security key management scheme: EAP_SHA256. +     */ +    public static final int KEY_MGMT_EAP_SHA256 = 6; +    /** +     * @hide +     * Security key management scheme: OSEN. +     * Used for Hotspot 2.0. +     */ +    public static final int KEY_MGMT_OSEN = 7; + +    /** +     * @hide +     * No cipher suite. +     */ +    public static final int CIPHER_NONE = 0; +    /** +     * @hide +     * No group addressed, only used for group data cipher. +     */ +    public static final int CIPHER_NO_GROUP_ADDRESSED = 1; +    /** +     * @hide +     * Cipher suite: TKIP +     */ +    public static final int CIPHER_TKIP = 2; +    /** +     * @hide +     * Cipher suite: CCMP +     */ +    public static final int CIPHER_CCMP = 3; +      /**       * The detected signal level in dBm, also known as the RSSI.       * diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 3520a3c66745..a42bef465b75 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -840,36 +840,6 @@ public class WifiManager {      }      /** -     * Add a Hotspot 2.0 release 2 Management Object -     * @param mo The MO in XML form -     * @return -1 for failure -     * @hide -     */ -    public int addPasspointManagementObject(String mo) { -        try { -            return mService.addPasspointManagementObject(mo); -        } catch (RemoteException e) { -            throw e.rethrowFromSystemServer(); -        } -    } - -    /** -     * Modify a Hotspot 2.0 release 2 Management Object -     * @param fqdn The FQDN of the service provider -     * @param mos A List of MO definitions to be updated -     * @return the number of nodes updated, or -1 for failure -     * @hide -     */ -    public int modifyPasspointManagementObject(String fqdn, -                                               List<PasspointManagementObjectDefinition> mos) { -        try { -            return mService.modifyPasspointManagementObject(fqdn, mos); -        } catch (RemoteException e) { -            throw e.rethrowFromSystemServer(); -        } -    } - -    /**       * Add a Passpoint configuration.  The configuration provides a credential       * for connecting to Passpoint networks that are operated by the Passpoint       * service provider specified in the configuration. @@ -1626,20 +1596,6 @@ public class WifiManager {      }      /** -     * Builds a WifiConfiguration from Hotspot 2.0 MIME file. -     * @return AP details in WifiConfiguration -     * -     * @hide Dont open yet -     */ -    public WifiConfiguration buildWifiConfig(String uriString, String mimeType, byte[] data) { -        try { -            return mService.buildWifiConfig(uriString, mimeType, data); -        } catch (RemoteException e) { -            throw e.rethrowFromSystemServer(); -        } -    } - -    /**       * Sets the Wi-Fi AP Configuration.       * @return {@code true} if the operation succeeded, {@code false} otherwise       *  |