diff options
26 files changed, 353 insertions, 240 deletions
diff --git a/Android.mk b/Android.mk index d33307425968..ba153ee76b0a 100644 --- a/Android.mk +++ b/Android.mk @@ -87,6 +87,7 @@ $(INTERNAL_PLATFORM_HIDDENAPI_WHITELIST): \ frameworks/base/tools/hiddenapi/generate_hiddenapi_lists.py \ frameworks/base/config/hiddenapi-light-greylist.txt \ frameworks/base/config/hiddenapi-vendor-list.txt \ + frameworks/base/config/hiddenapi-max-sdk-p-blacklist.txt \ frameworks/base/config/hiddenapi-force-blacklist.txt \ $(INTERNAL_PLATFORM_HIDDENAPI_PUBLIC_LIST) \ $(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST) \ @@ -98,6 +99,7 @@ $(INTERNAL_PLATFORM_HIDDENAPI_WHITELIST): \ --input-greylists \ frameworks/base/config/hiddenapi-light-greylist.txt \ frameworks/base/config/hiddenapi-vendor-list.txt \ + frameworks/base/config/hiddenapi-max-sdk-p-blacklist.txt \ <(comm -12 <(sort $(INTERNAL_PLATFORM_REMOVED_DEX_API_FILE)) \ $(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST)) \ $(PRIVATE_GREYLIST_INPUTS) \ diff --git a/config/hiddenapi-max-sdk-p-blacklist.txt b/config/hiddenapi-max-sdk-p-blacklist.txt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/config/hiddenapi-max-sdk-p-blacklist.txt diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index c496ff4a3bd5..1fbfa40d5d64 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -2731,7 +2731,10 @@ public class ConnectivityManager { * * @hide */ - @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) + @RequiresPermission(anyOf = { + android.Manifest.permission.NETWORK_SETTINGS, + android.Manifest.permission.NETWORK_SETUP_WIZARD, + android.Manifest.permission.NETWORK_STACK}) @SystemApi public void setAirplaneMode(boolean enable) { try { diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index 20ca19bc04aa..c9c42058bad0 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -388,10 +388,10 @@ interface INetworkManagementService /** * Setup a new physical network. - * @param permission null if no permissions required to access this network. PERMISSION_NETWORK - * or PERMISSION_SYSTEM to set respective permission. + * @param permission PERMISSION_NONE if no permissions required to access this network. + * PERMISSION_NETWORK or PERMISSION_SYSTEM to set respective permission. */ - void createPhysicalNetwork(int netId, String permission); + void createPhysicalNetwork(int netId, int permission); /** * Setup a new VPN. @@ -420,10 +420,10 @@ interface INetworkManagementService /** * Set permission for a network. - * @param permission null to clear permissions. PERMISSION_NETWORK or PERMISSION_SYSTEM to set - * permission. + * @param permission PERMISSION_NONE to clear permissions. + * PERMISSION_NETWORK or PERMISSION_SYSTEM to set permission. */ - void setNetworkPermission(int netId, String permission); + void setNetworkPermission(int netId, int permission); void setPermission(String permission, in int[] uids); void clearPermission(in int[] uids); diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index cec0df02247c..959534d24f59 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -34,6 +34,8 @@ public class FeatureFlagUtils { public static final String FFLAG_PREFIX = "sys.fflag."; public static final String FFLAG_OVERRIDE_PREFIX = FFLAG_PREFIX + "override."; public static final String EMERGENCY_DIAL_SHORTCUTS = "settings_emergency_dial_shortcuts"; + public static final String PERSIST_PREFIX = "persist." + FFLAG_OVERRIDE_PREFIX; + public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid"; private static final Map<String, String> DEFAULT_FLAGS; static { @@ -46,6 +48,7 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put("settings_audio_switcher", "true"); DEFAULT_FLAGS.put("settings_systemui_theme", "true"); DEFAULT_FLAGS.put(EMERGENCY_DIAL_SHORTCUTS, "false"); + DEFAULT_FLAGS.put(HEARING_AID_SETTINGS, "true"); } /** diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index c3ba9ba82826..9341d9a48913 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -23,6 +23,7 @@ #include <atomic> #include <fcntl.h> #include <inttypes.h> +#include <mutex> #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> @@ -69,6 +70,7 @@ static struct bindernative_offsets_t // Class state. jclass mClass; jmethodID mExecTransact; + jmethodID mGetInterfaceDescriptor; // Object state. jfieldID mObject; @@ -328,8 +330,32 @@ protected: env->DeleteGlobalRef(mObject); } - virtual status_t onTransact( - uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0) + const String16& getInterfaceDescriptor() const override + { + call_once(mPopulateDescriptor, [this] { + JNIEnv* env = javavm_to_jnienv(mVM); + + ALOGV("getInterfaceDescriptor() on %p calling object %p in env %p vm %p\n", this, mObject, env, mVM); + + jstring descriptor = (jstring)env->CallObjectMethod(mObject, gBinderOffsets.mGetInterfaceDescriptor); + + if (descriptor == nullptr) { + return; + } + + static_assert(sizeof(jchar) == sizeof(char16_t), ""); + const jchar* descriptorChars = env->GetStringChars(descriptor, nullptr); + const char16_t* rawDescriptor = reinterpret_cast<const char16_t*>(descriptorChars); + jsize rawDescriptorLen = env->GetStringLength(descriptor); + mDescriptor = String16(rawDescriptor, rawDescriptorLen); + env->ReleaseStringChars(descriptor, descriptorChars); + }); + + return mDescriptor; + } + + status_t onTransact( + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0) override { JNIEnv* env = javavm_to_jnienv(mVM); @@ -378,7 +404,7 @@ protected: return res != JNI_FALSE ? NO_ERROR : UNKNOWN_TRANSACTION; } - virtual status_t dump(int fd, const Vector<String16>& args) + status_t dump(int fd, const Vector<String16>& args) override { return 0; } @@ -386,6 +412,9 @@ protected: private: JavaVM* const mVM; jobject const mObject; // GlobalRef to Java Binder + + mutable std::once_flag mPopulateDescriptor; + mutable String16 mDescriptor; }; // ---------------------------------------------------------------------------- @@ -939,6 +968,8 @@ static int int_register_android_os_Binder(JNIEnv* env) gBinderOffsets.mClass = MakeGlobalRefOrDie(env, clazz); gBinderOffsets.mExecTransact = GetMethodIDOrDie(env, clazz, "execTransact", "(IJJI)Z"); + gBinderOffsets.mGetInterfaceDescriptor = GetMethodIDOrDie(env, clazz, "getInterfaceDescriptor", + "()Ljava/lang/String;"); gBinderOffsets.mObject = GetFieldIDOrDie(env, clazz, "mObject", "J"); return RegisterMethodsOrDie( diff --git a/core/tests/coretests/Android.mk b/core/tests/coretests/Android.mk index 307e2e8671b2..041fb7eeb6b3 100644 --- a/core/tests/coretests/Android.mk +++ b/core/tests/coretests/Android.mk @@ -47,7 +47,6 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ LOCAL_JAVA_LIBRARIES := \ android.test.runner \ - conscrypt \ telephony-common \ org.apache.http.legacy \ android.test.base \ diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp index 8f58f74d4652..66a547723b2f 100644 --- a/libs/androidfw/ApkAssets.cpp +++ b/libs/androidfw/ApkAssets.cpp @@ -39,7 +39,7 @@ using base::unique_fd; static const std::string kResourcesArsc("resources.arsc"); -ApkAssets::ApkAssets(void* unmanaged_handle, const std::string& path) +ApkAssets::ApkAssets(ZipArchiveHandle unmanaged_handle, const std::string& path) : zip_handle_(unmanaged_handle, ::CloseArchive), path_(path) { } diff --git a/libs/androidfw/include/androidfw/ApkAssets.h b/libs/androidfw/include/androidfw/ApkAssets.h index 69702e314442..db2d0382bcf6 100644 --- a/libs/androidfw/include/androidfw/ApkAssets.h +++ b/libs/androidfw/include/androidfw/ApkAssets.h @@ -27,6 +27,9 @@ #include "androidfw/LoadedArsc.h" #include "androidfw/misc.h" +struct ZipArchive; +typedef ZipArchive* ZipArchiveHandle; + namespace android { class LoadedIdmap; @@ -88,9 +91,9 @@ class ApkAssets { // Creates an Asset from any file on the file system. static std::unique_ptr<Asset> CreateAssetFromFile(const std::string& path); - ApkAssets(void* unmanaged_handle, const std::string& path); + ApkAssets(ZipArchiveHandle unmanaged_handle, const std::string& path); - using ZipArchivePtr = std::unique_ptr<void, void(*)(void*)>; + using ZipArchivePtr = std::unique_ptr<ZipArchive, void(*)(ZipArchiveHandle)>; ZipArchivePtr zip_handle_; const std::string path_; diff --git a/libs/androidfw/include/androidfw/ZipFileRO.h b/libs/androidfw/include/androidfw/ZipFileRO.h index 03154d04def1..c221e3b7aeae 100644 --- a/libs/androidfw/include/androidfw/ZipFileRO.h +++ b/libs/androidfw/include/androidfw/ZipFileRO.h @@ -41,7 +41,8 @@ #include <unistd.h> #include <time.h> -typedef void* ZipArchiveHandle; +struct ZipArchive; +typedef ZipArchive* ZipArchiveHandle; namespace android { diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml index a090f6dc63df..abce8cfd2d39 100644 --- a/packages/Shell/AndroidManifest.xml +++ b/packages/Shell/AndroidManifest.xml @@ -55,6 +55,7 @@ <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" /> + <uses-permission android:name="android.permission.MANAGE_ACCESSIBILITY" /> <!-- Development tool permissions granted to the shell. --> <uses-permission android:name="android.permission.SET_DEBUG_APP" /> <uses-permission android:name="android.permission.SET_PROCESS_LIMIT" /> diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index f0436dea9207..d033057cdb78 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -49,11 +49,6 @@ android:paddingEnd="@dimen/status_bar_padding_end" android:orientation="horizontal" > - <ViewStub - android:id="@+id/operator_name" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout="@layout/operator_name" /> <FrameLayout android:layout_height="match_parent" android:layout_width="0dp" @@ -70,6 +65,12 @@ android:layout_width="match_parent" android:clipChildren="false" > + <ViewStub + android:id="@+id/operator_name" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout="@layout/operator_name" /> + <com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:layout_width="wrap_content" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 409a78391975..118f1e297779 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -47,6 +47,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, private final NotificationStackScrollLayout mStackScroller; private final HeadsUpStatusBarView mHeadsUpStatusBarView; private final View mClockView; + private final View mOperatorNameView; private final DarkIconDispatcher mDarkIconDispatcher; private final NotificationPanelView mPanelView; private final Consumer<ExpandableNotificationRow> @@ -61,8 +62,10 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener = (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> updatePanelTranslation(); + private boolean mAnimationsEnabled = true; Point mPoint; + public HeadsUpAppearanceController( NotificationIconAreaController notificationIconAreaController, HeadsUpManagerPhone headsUpManager, @@ -71,7 +74,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, statusbarView.findViewById(R.id.heads_up_status_bar_view), statusbarView.findViewById(R.id.notification_stack_scroller), statusbarView.findViewById(R.id.notification_panel), - statusbarView.findViewById(R.id.clock)); + statusbarView.findViewById(R.id.clock), + statusbarView.findViewById(R.id.operator_name_frame)); } @VisibleForTesting @@ -81,7 +85,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, HeadsUpStatusBarView headsUpStatusBarView, NotificationStackScrollLayout stackScroller, NotificationPanelView panelView, - View clockView) { + View clockView, + View operatorNameView) { mNotificationIconAreaController = notificationIconAreaController; mHeadsUpManager = headsUpManager; mHeadsUpManager.addListener(this); @@ -97,6 +102,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener); mStackScroller.setHeadsUpAppearanceController(this); mClockView = clockView; + mOperatorNameView = operatorNameView; mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class); mDarkIconDispatcher.addDarkReceiver(this); } @@ -205,20 +211,52 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, mShown = isShown; if (isShown) { mHeadsUpStatusBarView.setVisibility(View.VISIBLE); - CrossFadeHelper.fadeIn(mHeadsUpStatusBarView, CONTENT_FADE_DURATION /* duration */, - CONTENT_FADE_DELAY /* delay */); - CrossFadeHelper.fadeOut(mClockView, CONTENT_FADE_DURATION/* duration */, - 0 /* delay */, () -> mClockView.setVisibility(View.INVISIBLE)); + show(mHeadsUpStatusBarView); + hide(mClockView, View.INVISIBLE); + if (mOperatorNameView != null) { + hide(mOperatorNameView, View.INVISIBLE); + } } else { - CrossFadeHelper.fadeIn(mClockView, CONTENT_FADE_DURATION /* duration */, - CONTENT_FADE_DELAY /* delay */); - CrossFadeHelper.fadeOut(mHeadsUpStatusBarView, CONTENT_FADE_DURATION/* duration */, - 0 /* delay */, () -> mHeadsUpStatusBarView.setVisibility(View.GONE)); - + show(mClockView); + if (mOperatorNameView != null) { + show(mOperatorNameView); + } + hide(mHeadsUpStatusBarView, View.GONE); } } } + /** + * Hides the view and sets the state to endState when finished. + * + * @param view The view to hide. + * @param endState One of {@link View#INVISIBLE} or {@link View#GONE}. + * @see View#setVisibility(int) + * + */ + private void hide(View view, int endState) { + if (mAnimationsEnabled) { + CrossFadeHelper.fadeOut(view, CONTENT_FADE_DURATION /* duration */, + 0 /* delay */, () -> view.setVisibility(endState)); + } else { + view.setVisibility(endState); + } + } + + private void show(View view) { + if (mAnimationsEnabled) { + CrossFadeHelper.fadeIn(view, CONTENT_FADE_DURATION /* duration */, + CONTENT_FADE_DELAY /* delay */); + } else { + view.setVisibility(View.VISIBLE); + } + } + + @VisibleForTesting + void setAnimationsEnabled(boolean enabled) { + mAnimationsEnabled = enabled; + } + @VisibleForTesting public boolean isShown() { return mShown; diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java b/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java index af99236cc393..e85dee841715 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java @@ -51,7 +51,9 @@ public class TunablePadding implements Tunable { public void onTuningChanged(String key, String newValue) { int dimen = mDefaultSize; if (newValue != null) { - dimen = (int) (Integer.parseInt(newValue) * mDensity); + try { + dimen = (int) (Integer.parseInt(newValue) * mDensity); + } catch (NumberFormatException ex) {} } int left = mView.isLayoutRtl() ? FLAG_END : FLAG_START; int right = mView.isLayoutRtl() ? FLAG_START : FLAG_END; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java index 537bfd4be66c..3c5c0b883e08 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java @@ -61,6 +61,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { private ExpandableNotificationRow mFirst; private HeadsUpStatusBarView mHeadsUpStatusBarView; private HeadsUpManagerPhone mHeadsUpManager; + private View mOperatorNameView; @Before public void setUp() throws Exception { @@ -70,13 +71,15 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mHeadsUpStatusBarView = new HeadsUpStatusBarView(mContext, mock(View.class), mock(TextView.class)); mHeadsUpManager = mock(HeadsUpManagerPhone.class); + mOperatorNameView = new View(mContext); mHeadsUpAppearanceController = new HeadsUpAppearanceController( mock(NotificationIconAreaController.class), mHeadsUpManager, mHeadsUpStatusBarView, mStackScroller, mPanelView, - new View(mContext)); + new View(mContext), + mOperatorNameView); mHeadsUpAppearanceController.setExpandedHeight(0.0f, 0.0f); } @@ -123,6 +126,22 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { } @Test + public void testOperatorNameViewUpdated() { + mHeadsUpAppearanceController.setAnimationsEnabled(false); + + mFirst.setPinned(true); + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); + when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry()); + mHeadsUpAppearanceController.onHeadsUpPinned(mFirst); + Assert.assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility()); + + mFirst.setPinned(false); + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); + mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst); + Assert.assertEquals(View.VISIBLE, mOperatorNameView.getVisibility()); + } + + @Test public void testDestroy() { reset(mHeadsUpManager); reset(mDarkIconDispatcher); diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 99e0056254fd..49de4b157776 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -53,12 +53,16 @@ import android.os.Process; import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.SystemClock; +import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.os.UserManagerInternal.UserRestrictionsListener; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; +import android.text.TextUtils; +import android.util.FeatureFlagUtils; +import android.util.Log; import android.util.Slog; import android.util.StatsLog; @@ -386,6 +390,15 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mCallbacks = new RemoteCallbackList<IBluetoothManagerCallback>(); mStateChangeCallbacks = new RemoteCallbackList<IBluetoothStateChangeCallback>(); + // TODO: We need a more generic way to initialize the persist keys of FeatureFlagUtils + boolean isHearingAidEnabled; + String value = SystemProperties.get(FeatureFlagUtils.PERSIST_PREFIX + FeatureFlagUtils.HEARING_AID_SETTINGS); + if (!TextUtils.isEmpty(value)) { + isHearingAidEnabled = Boolean.parseBoolean(value); + Log.v(TAG, "set feature flag HEARING_AID_SETTINGS to " + isHearingAidEnabled); + FeatureFlagUtils.setEnabled(context, FeatureFlagUtils.HEARING_AID_SETTINGS, isHearingAidEnabled); + } + IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED); filter.addAction(BluetoothAdapter.ACTION_BLUETOOTH_ADDRESS_CHANGED); diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index d9394e810e28..b750d7959167 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1679,6 +1679,16 @@ public class ConnectivityService extends IConnectivityManager.Stub "ConnectivityService"); } + private void enforceAnyPermissionOf(String... permissions) { + for (String permission : permissions) { + if (mContext.checkCallingOrSelfPermission(permission) == PERMISSION_GRANTED) { + return; + } + } + throw new SecurityException( + "Requires one of the following permissions: " + String.join(", ", permissions) + "."); + } + private void enforceInternetPermission() { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERNET, @@ -1723,6 +1733,13 @@ public class ConnectivityService extends IConnectivityManager.Stub "ConnectivityService"); } + private void enforceNetworkStackSettingsOrSetup() { + enforceAnyPermissionOf( + android.Manifest.permission.NETWORK_SETTINGS, + android.Manifest.permission.NETWORK_SETUP_WIZARD, + android.Manifest.permission.NETWORK_STACK); + } + private boolean checkNetworkStackPermission() { return PERMISSION_GRANTED == mContext.checkCallingOrSelfPermission( android.Manifest.permission.NETWORK_STACK); @@ -3984,7 +4001,7 @@ public class ConnectivityService extends IConnectivityManager.Stub @Override public void setAirplaneMode(boolean enable) { - enforceConnectivityInternalPermission(); + enforceNetworkStackSettingsOrSetup(); final long ident = Binder.clearCallingIdentity(); try { final ContentResolver cr = mContext.getContentResolver(); @@ -4765,15 +4782,14 @@ public class ConnectivityService extends IConnectivityManager.Stub } } - private String getNetworkPermission(NetworkCapabilities nc) { - // TODO: make these permission strings AIDL constants instead. + private int getNetworkPermission(NetworkCapabilities nc) { if (!nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)) { - return NetworkManagementService.PERMISSION_SYSTEM; + return INetd.PERMISSION_SYSTEM; } if (!nc.hasCapability(NET_CAPABILITY_FOREGROUND)) { - return NetworkManagementService.PERMISSION_NETWORK; + return INetd.PERMISSION_NETWORK; } - return null; + return INetd.PERMISSION_NONE; } /** @@ -4846,9 +4862,9 @@ public class ConnectivityService extends IConnectivityManager.Stub if (Objects.equals(nai.networkCapabilities, newNc)) return; - final String oldPermission = getNetworkPermission(nai.networkCapabilities); - final String newPermission = getNetworkPermission(newNc); - if (!Objects.equals(oldPermission, newPermission) && nai.created && !nai.isVPN()) { + final int oldPermission = getNetworkPermission(nai.networkCapabilities); + final int newPermission = getNetworkPermission(newNc); + if (oldPermission != newPermission && nai.created && !nai.isVPN()) { try { mNMS.setNetworkPermission(nai.network.netId, newPermission); } catch (RemoteException e) { diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index 94a15f7d7312..ab5005927c4e 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -169,19 +169,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub */ public static final String LIMIT_GLOBAL_ALERT = "globalAlert"; - /** - * String to pass to netd to indicate that a network is only accessible - * to apps that have the CHANGE_NETWORK_STATE permission. - */ - public static final String PERMISSION_NETWORK = "NETWORK"; - - /** - * String to pass to netd to indicate that a network is only - * accessible to system apps and those with the CONNECTIVITY_INTERNAL - * permission. - */ - public static final String PERMISSION_SYSTEM = "SYSTEM"; - static class NetdResponseCode { /* Keep in sync with system/netd/server/ResponseCode.h */ public static final int InterfaceListResult = 110; @@ -222,6 +209,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub static final int DAEMON_MSG_MOBILE_CONN_REAL_TIME_INFO = 1; + static final boolean MODIFY_OPERATION_ADD = true; + static final boolean MODIFY_OPERATION_REMOVE = false; + /** * Binder context for this service */ @@ -1117,41 +1107,47 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void addRoute(int netId, RouteInfo route) { - modifyRoute("add", "" + netId, route); + modifyRoute(MODIFY_OPERATION_ADD, netId, route); } @Override public void removeRoute(int netId, RouteInfo route) { - modifyRoute("remove", "" + netId, route); + modifyRoute(MODIFY_OPERATION_REMOVE, netId, route); } - private void modifyRoute(String action, String netId, RouteInfo route) { + private void modifyRoute(boolean add, int netId, RouteInfo route) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - final Command cmd = new Command("network", "route", action, netId); - - // create triplet: interface dest-ip-addr/prefixlength gateway-ip-addr - cmd.appendArg(route.getInterface()); - cmd.appendArg(route.getDestination().toString()); + final String ifName = route.getInterface(); + final String dst = route.getDestination().toString(); + final String nextHop; switch (route.getType()) { case RouteInfo.RTN_UNICAST: if (route.hasGateway()) { - cmd.appendArg(route.getGateway().getHostAddress()); + nextHop = route.getGateway().getHostAddress(); + } else { + nextHop = INetd.NEXTHOP_NONE; } break; case RouteInfo.RTN_UNREACHABLE: - cmd.appendArg("unreachable"); + nextHop = INetd.NEXTHOP_UNREACHABLE; break; case RouteInfo.RTN_THROW: - cmd.appendArg("throw"); + nextHop = INetd.NEXTHOP_THROW; + break; + default: + nextHop = INetd.NEXTHOP_NONE; break; } - try { - mConnector.execute(cmd); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + if (add) { + mNetdService.networkAddRoute(netId, ifName, dst, nextHop); + } else { + mNetdService.networkRemoveRoute(netId, ifName, dst, nextHop); + } + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -1911,44 +1907,21 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void addVpnUidRanges(int netId, UidRange[] ranges) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[3 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "users"; - argv[1] = "add"; - argv[2] = netId; - int argc = 3; - // Avoid overly long commands by limiting number of UID ranges per command. - for (int i = 0; i < ranges.length; i++) { - argv[argc++] = ranges[i].toString(); - if (i == (ranges.length - 1) || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 3; - } + + try { + mNetdService.networkAddUidRanges(netId, ranges); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @Override public void removeVpnUidRanges(int netId, UidRange[] ranges) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[3 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "users"; - argv[1] = "remove"; - argv[2] = netId; - int argc = 3; - // Avoid overly long commands by limiting number of UID ranges per command. - for (int i = 0; i < ranges.length; i++) { - argv[argc++] = ranges[i].toString(); - if (i == (ranges.length - 1) || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 3; - } + try { + mNetdService.networkRemoveUidRanges(netId, ranges); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2406,17 +2379,13 @@ public class NetworkManagementService extends INetworkManagementService.Stub } @Override - public void createPhysicalNetwork(int netId, String permission) { + public void createPhysicalNetwork(int netId, int permission) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - if (permission != null) { - mConnector.execute("network", "create", netId, permission); - } else { - mConnector.execute("network", "create", netId); - } - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkCreatePhysical(netId, permission); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2425,10 +2394,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "create", netId, "vpn", hasDNS ? "1" : "0", - secure ? "1" : "0"); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkCreateVpn(netId, hasDNS, secure); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2449,20 +2417,24 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void addInterfaceToNetwork(String iface, int netId) { - modifyInterfaceInNetwork("add", "" + netId, iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_ADD, netId, iface); } @Override public void removeInterfaceFromNetwork(String iface, int netId) { - modifyInterfaceInNetwork("remove", "" + netId, iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_REMOVE, netId, iface); } - private void modifyInterfaceInNetwork(String action, String netId, String iface) { + private void modifyInterfaceInNetwork(boolean add, int netId, String iface) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "interface", action, netId, iface); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + if (add) { + mNetdService.networkAddInterface(netId, iface); + } else { + mNetdService.networkRemoveInterface(netId, iface); + } + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2470,20 +2442,20 @@ public class NetworkManagementService extends INetworkManagementService.Stub public void addLegacyRouteForNetId(int netId, RouteInfo routeInfo, int uid) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - final Command cmd = new Command("network", "route", "legacy", uid, "add", netId); - - // create triplet: interface dest-ip-addr/prefixlength gateway-ip-addr final LinkAddress la = routeInfo.getDestinationLinkAddress(); - cmd.appendArg(routeInfo.getInterface()); - cmd.appendArg(la.getAddress().getHostAddress() + "/" + la.getPrefixLength()); + final String ifName = routeInfo.getInterface(); + final String dst = la.toString(); + final String nextHop; + if (routeInfo.hasGateway()) { - cmd.appendArg(routeInfo.getGateway().getHostAddress()); + nextHop = routeInfo.getGateway().getHostAddress(); + } else { + nextHop = ""; } - try { - mConnector.execute(cmd); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkAddLegacyRoute(netId, ifName, dst, nextHop, uid); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2492,9 +2464,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "default", "set", netId); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetDefault(netId); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2503,49 +2475,41 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "default", "clear"); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkClearDefault(); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @Override - public void setNetworkPermission(int netId, String permission) { + public void setNetworkPermission(int netId, int permission) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - if (permission != null) { - mConnector.execute("network", "permission", "network", "set", permission, netId); - } else { - mConnector.execute("network", "permission", "network", "clear", netId); - } - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetPermissionForNetwork(netId, permission); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } + private int parsePermission(String permission) { + if (permission.equals("NETWORK")) { + return INetd.PERMISSION_NETWORK; + } + if (permission.equals("SYSTEM")) { + return INetd.PERMISSION_SYSTEM; + } + return INetd.PERMISSION_NONE; + } @Override public void setPermission(String permission, int[] uids) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[4 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "permission"; - argv[1] = "user"; - argv[2] = "set"; - argv[3] = permission; - int argc = 4; - // Avoid overly long commands by limiting number of UIDs per command. - for (int i = 0; i < uids.length; ++i) { - argv[argc++] = uids[i]; - if (i == uids.length - 1 || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 4; - } + try { + mNetdService.networkSetPermissionForUser(parsePermission(permission), uids); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2553,22 +2517,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub public void clearPermission(int[] uids) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[3 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "permission"; - argv[1] = "user"; - argv[2] = "clear"; - int argc = 3; - // Avoid overly long commands by limiting number of UIDs per command. - for (int i = 0; i < uids.length; ++i) { - argv[argc++] = uids[i]; - if (i == uids.length - 1 || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 3; - } + try { + mNetdService.networkClearPermissionForUser(uids); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2577,9 +2529,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "protect", "allow", uid); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetProtectAllow(uid); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2588,26 +2540,26 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "protect", "deny", uid); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetProtectDeny(uid); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @Override public void addInterfaceToLocalNetwork(String iface, List<RouteInfo> routes) { - modifyInterfaceInNetwork("add", "local", iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_ADD, INetd.NETID_LOCAL, iface); for (RouteInfo route : routes) { if (!route.isDefaultRoute()) { - modifyRoute("add", "local", route); + modifyRoute(MODIFY_OPERATION_ADD, INetd.NETID_LOCAL, route); } } } @Override public void removeInterfaceFromLocalNetwork(String iface) { - modifyInterfaceInNetwork("remove", "local", iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_REMOVE, INetd.NETID_LOCAL, iface); } @Override @@ -2616,7 +2568,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub for (RouteInfo route : routes) { try { - modifyRoute("remove", "local", route); + modifyRoute(MODIFY_OPERATION_REMOVE, INetd.NETID_LOCAL, route); } catch (IllegalStateException e) { failures++; } diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 784d62e51966..302e1950b9a9 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -157,9 +157,11 @@ public final class ProcessList { // LMK_TARGET <minfree> <minkillprio> ... (up to 6 pairs) // LMK_PROCPRIO <pid> <uid> <prio> // LMK_PROCREMOVE <pid> + // LMK_PROCPURGE static final byte LMK_TARGET = 0; static final byte LMK_PROCPRIO = 1; static final byte LMK_PROCREMOVE = 2; + static final byte LMK_PROCPURGE = 3; // These are the various interesting memory levels that we will give to // the OOM killer. Note that the OOM killer only supports 6 slots, so we @@ -808,31 +810,46 @@ public final class ProcessList { return true; } + // Never call directly, use writeLmkd() instead + private static boolean writeLmkdCommand(ByteBuffer buf) { + try { + sLmkdOutputStream.write(buf.array(), 0, buf.position()); + } catch (IOException ex) { + Slog.w(TAG, "Error writing to lowmemorykiller socket"); + + try { + sLmkdSocket.close(); + } catch (IOException ex2) { + } + + sLmkdSocket = null; + return false; + } + return true; + } + private static void writeLmkd(ByteBuffer buf) { for (int i = 0; i < 3; i++) { if (sLmkdSocket == null) { - if (openLmkdSocket() == false) { - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - } - continue; + if (openLmkdSocket() == false) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { } - } - - try { - sLmkdOutputStream.write(buf.array(), 0, buf.position()); - return; - } catch (IOException ex) { - Slog.w(TAG, "Error writing to lowmemorykiller socket"); - - try { - sLmkdSocket.close(); - } catch (IOException ex2) { + continue; } - sLmkdSocket = null; + // Purge any previously registered pids + ByteBuffer purge_buf = ByteBuffer.allocate(4); + purge_buf.putInt(LMK_PROCPURGE); + if (writeLmkdCommand(purge_buf) == false) { + // Write failed, skip the rest and retry + continue; + } + } + if (writeLmkdCommand(buf)) { + return; } } } diff --git a/services/robotests/Android.mk b/services/robotests/Android.mk index 3d7fdbdd7436..de54c4b537e4 100644 --- a/services/robotests/Android.mk +++ b/services/robotests/Android.mk @@ -80,7 +80,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ LOCAL_JAVA_LIBRARIES := \ junit \ - platform-robolectric-3.6.1-prebuilt + platform-robolectric-3.6.2-prebuilt LOCAL_INSTRUMENTATION_FOR := FrameworksServicesLib LOCAL_MODULE := FrameworksServicesRoboTests @@ -105,4 +105,4 @@ LOCAL_TEST_PACKAGE := FrameworksServicesLib LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))backup/java -include prebuilts/misc/common/robolectric/3.6.1/run_robotests.mk +include prebuilts/misc/common/robolectric/3.6.2/run_robotests.mk diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java index 942a07acbf9f..96ac93536a8a 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java @@ -121,7 +121,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { cal.set(Calendar.MINUTE, 15); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 1; mScheduleInfo.endHour = 3; mScheduleInfo.startMinute = 15; @@ -149,7 +149,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { cal.set(Calendar.MINUTE, 15); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 22; mScheduleInfo.endHour = 3; mScheduleInfo.startMinute = 15; @@ -250,7 +250,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { calAlarm.add(Calendar.DATE, 1); // add a day // ScheduleInfo: day 1, day 2: 9pm-7am - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 21; mScheduleInfo.endHour = 7; mScheduleInfo.startMinute = 0; @@ -418,7 +418,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { now.set(Calendar.MILLISECOND, 0); now.add(Calendar.DATE, 1); // add a day - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 22; mScheduleInfo.startMinute = 15; mScheduleInfo.endHour = 3; @@ -446,7 +446,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { now.set(Calendar.MILLISECOND, 0); now.add(Calendar.DATE, 1); // add a day - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 22; mScheduleInfo.startMinute = 15; mScheduleInfo.endHour = 3; @@ -464,4 +464,10 @@ public class ScheduleCalendarTest extends UiServiceTestCase { private int getTodayDay() { return new GregorianCalendar().get(Calendar.DAY_OF_WEEK); } + + private int getTodayDay(int offset) { + Calendar cal = new GregorianCalendar(); + cal.add(Calendar.DATE, offset); + return cal.get(Calendar.DAY_OF_WEEK); + } } diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index d33a537f2194..3127b3584dd9 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -676,7 +676,7 @@ public class TelecomManager { /** * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelecomManager from(Context context) { return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); } diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index e0ec2c50ab5b..bfbcd5751bf4 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -21,6 +21,7 @@ import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; @@ -246,7 +247,7 @@ public class ServiceState implements Parcelable { private String mDataOperatorAlphaLong; private String mDataOperatorAlphaShort; private String mDataOperatorNumeric; - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private boolean mIsManualNetworkSelection; private boolean mIsEmergencyOnly; @@ -256,9 +257,9 @@ public class ServiceState implements Parcelable { @UnsupportedAppUsage private boolean mCssIndicator; - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private int mNetworkId; - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private int mSystemId; @UnsupportedAppUsage private int mCdmaRoamingIndicator; @@ -456,7 +457,7 @@ public class ServiceState implements Parcelable { * * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getVoiceRegState() { return mVoiceRegState; } @@ -471,7 +472,7 @@ public class ServiceState implements Parcelable { * * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getDataRegState() { return mDataRegState; } @@ -532,7 +533,7 @@ public class ServiceState implements Parcelable { * @return roaming status * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public boolean getVoiceRoaming() { return getVoiceRoamingType() != ROAMING_TYPE_NOT_ROAMING; } @@ -556,7 +557,7 @@ public class ServiceState implements Parcelable { * @return roaming type * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public boolean getDataRoaming() { return getDataRoamingType() != ROAMING_TYPE_NOT_ROAMING; } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index b0b7e7bdb748..876655c44cdb 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -43,6 +43,7 @@ import android.database.ContentObserver; import android.net.INetworkPolicyManager; import android.net.NetworkCapabilities; import android.net.Uri; +import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -1368,7 +1369,7 @@ public class SubscriptionManager { } /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static int getPhoneId(int subId) { if (!isValidSubscriptionId(subId)) { if (DBG) { @@ -1664,7 +1665,7 @@ public class SubscriptionManager { * usable subId means its neither a INVALID_SUBSCRIPTION_ID nor a DEFAULT_SUB_ID. * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static boolean isUsableSubIdValue(int subId) { return subId >= MIN_SUBSCRIPTION_ID_VALUE && subId <= MAX_SUBSCRIPTION_ID_VALUE; } @@ -1682,7 +1683,7 @@ public class SubscriptionManager { } /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId) { int[] subIds = SubscriptionManager.getSubId(phoneId); if (subIds != null && subIds.length > 0) { diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index e4204482aa3d..fd2f2fbacccc 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -41,6 +41,7 @@ import android.net.NetworkStats; import android.net.Uri; import android.os.AsyncTask; import android.os.BatteryStats; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.PersistableBundle; @@ -230,7 +231,8 @@ public class TelephonyManager { /** @hide /* @deprecated - use getSystemService as described above */ - @UnsupportedAppUsage + @Deprecated + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelephonyManager getDefault() { return sInstance; } @@ -319,7 +321,7 @@ public class TelephonyManager { } /** {@hide} */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelephonyManager from(Context context) { return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); } @@ -1879,7 +1881,7 @@ public class TelephonyManager { * @param subId * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getNetworkOperatorName(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ALPHA, ""); @@ -1907,7 +1909,7 @@ public class TelephonyManager { * @param subId * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getNetworkOperator(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getNetworkOperatorForPhone(phoneId); @@ -2231,7 +2233,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getDataNetworkType(int subId) { try{ ITelephony telephony = getITelephony(); @@ -2267,7 +2269,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getVoiceNetworkType(int subId) { try{ ITelephony telephony = getITelephony(); @@ -2750,7 +2752,7 @@ public class TelephonyManager { * @param subId for which SimOperator is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperator(int subId) { return getSimOperatorNumeric(subId); } @@ -2764,7 +2766,7 @@ public class TelephonyManager { * @see #getSimState * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorNumeric() { int subId = mSubId; if (!SubscriptionManager.isUsableSubIdValue(subId)) { @@ -2793,7 +2795,7 @@ public class TelephonyManager { * @param subId for which SimOperator is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorNumeric(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getSimOperatorNumericForPhone(phoneId); @@ -2807,7 +2809,7 @@ public class TelephonyManager { * @param phoneId for which SimOperator is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorNumericForPhone(int phoneId) { return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, ""); @@ -2834,7 +2836,7 @@ public class TelephonyManager { * @param subId for which SimOperatorName is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorName(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getSimOperatorNameForPhone(phoneId); @@ -2864,7 +2866,7 @@ public class TelephonyManager { * @param subId for which SimCountryIso is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimCountryIso(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getSimCountryIsoForPhone(phoneId); @@ -3054,7 +3056,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSubscriberId(int subId) { try { IPhoneSubInfo info = getSubscriberInfo(); @@ -3439,7 +3441,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getMsisdn(int subId) { try { IPhoneSubInfo info = getSubscriberInfo(); @@ -4405,7 +4407,7 @@ public class TelephonyManager { /** * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private ITelephony getITelephony() { return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); } @@ -7930,7 +7932,7 @@ public class TelephonyManager { * either READ_PRIVILEGED_PHONE_STATE or READ_PHONE_STATE to retrieve the information. * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public ServiceState getServiceStateForSubscriber(int subId) { try { ITelephony service = getITelephony(); diff --git a/tools/hiddenapi/sort_api.sh b/tools/hiddenapi/sort_api.sh index 76a2f2d6eba1..7cdcf18bb3fc 100755 --- a/tools/hiddenapi/sort_api.sh +++ b/tools/hiddenapi/sort_api.sh @@ -21,4 +21,6 @@ A=( $(uniq <<< "${A[*]}") ) A=( ${C[*]} ${A[*]} ) unset IFS # Dump array back into the file -printf '%s\n' "${A[@]}" > "$dest_list" +if [ ${#A[@]} -neq 0 ]; then + printf '%s\n' "${A[@]}" > "$dest_list" +fi |