diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 7 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 1 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 10 | ||||
| -rw-r--r-- | services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java | 8 | ||||
| -rw-r--r-- | services/core/jni/Android.bp | 1 | ||||
| -rw-r--r-- | services/core/jni/com_android_server_VibratorService.cpp | 144 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellBroadcastService.java | 9 | ||||
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 32 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 6 |
10 files changed, 207 insertions, 12 deletions
diff --git a/api/current.txt b/api/current.txt index c818205e56f1..80acaee8b53c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -45021,6 +45021,7 @@ package android.telephony { method @Nullable public CharSequence getSimSpecificCarrierIdName(); method public int getSimState(); method public int getSimState(int); + method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getSubIdForPhoneAccountHandle(@NonNull android.telecom.PhoneAccountHandle); method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getSubscriberId(); method public int getSupportedModemCount(); method @Nullable public String getTypeAllocationCode(); diff --git a/api/system-current.txt b/api/system-current.txt index 9946f6dd3983..f903470bff75 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -7246,9 +7246,9 @@ package android.telephony { public abstract class CellBroadcastService extends android.app.Service { ctor public CellBroadcastService(); - method @CallSuper public android.os.IBinder onBind(android.content.Intent); - method public abstract void onCdmaCellBroadcastSms(int, byte[]); - method public abstract void onGsmCellBroadcastSms(int, byte[]); + method @CallSuper @NonNull public android.os.IBinder onBind(@Nullable android.content.Intent); + method public abstract void onCdmaCellBroadcastSms(int, @NonNull byte[]); + method public abstract void onGsmCellBroadcastSms(int, @NonNull byte[]); field public static final String CELL_BROADCAST_SERVICE_INTERFACE = "android.telephony.CellBroadcastService"; } @@ -8236,6 +8236,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void toggleRadioOnOff(); method public void updateServiceLocation(); field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_ANOMALY_REPORTED = "android.telephony.action.ANOMALY_REPORTED"; + field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_OTA_EMERGENCY_NUMBER_DB_INSTALLED = "android.telephony.action.OTA_EMERGENCY_NUMBER_DB_INSTALLED"; field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED"; field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED"; diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 9aacbe65e480..1f20d7afb983 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -497,6 +497,7 @@ <protected-broadcast android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" /> <protected-broadcast android:name="android.telephony.action.DEFAULT_SUBSCRIPTION_CHANGED" /> <protected-broadcast android:name="android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED" /> + <protected-broadcast android:name="android.telephony.action.OTA_EMERGENCY_NUMBER_DB_INSTALLED" /> <protected-broadcast android:name="android.telephony.action.SECRET_CODE" /> <protected-broadcast android:name="android.telephony.action.SHOW_VOICEMAIL_NOTIFICATION" /> <protected-broadcast android:name="android.telephony.action.SUBSCRIPTION_PLANS_CHANGED" /> diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 0460a80b1dc0..461743e9ba53 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -9334,6 +9334,16 @@ public class PackageManagerService extends IPackageManager.Stub pkgSetting = originalPkgSetting == null ? installedPkgSetting : originalPkgSetting; pkgAlreadyExists = pkgSetting != null; final String disabledPkgName = pkgAlreadyExists ? pkgSetting.name : pkg.packageName; + if (scanSystemPartition && !pkgAlreadyExists + && mSettings.getDisabledSystemPkgLPr(disabledPkgName) != null) { + // The updated-package data for /system apk remains inconsistently + // after the package data for /data apk is lost accidentally. + // To recover it, enable /system apk and install it as non-updated system app. + Slog.w(TAG, "Inconsistent package setting of updated system app for " + + disabledPkgName + ". To recover it, enable the system app" + + "and install it as non-updated system app."); + mSettings.removeDisabledSystemPackageLPw(disabledPkgName); + } disabledPkgSetting = mSettings.getDisabledSystemPkgLPr(disabledPkgName); isSystemPkgUpdated = disabledPkgSetting != null; diff --git a/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java b/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java index 852f70779f77..cb0b45ceaf05 100644 --- a/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java +++ b/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java @@ -18,6 +18,7 @@ package com.android.server.updates; import android.content.Context; import android.content.Intent; +import android.telephony.TelephonyManager; import android.util.Slog; /** @@ -34,6 +35,11 @@ public class EmergencyNumberDbInstallReceiver extends ConfigUpdateInstallReceive @Override protected void postInstall(Context context, Intent intent) { Slog.i(TAG, "Emergency number database is updated in file partition"); - // TODO Send a notification to EmergencyNumberTracker for updating of emergency number db. + + // Notify EmergencyNumberTracker for emergency number installation complete. + Intent notifyInstallComplete = new Intent( + TelephonyManager.ACTION_OTA_EMERGENCY_NUMBER_DB_INSTALLED); + context.sendBroadcast( + notifyInstallComplete, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); } } diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp index 248baf791335..d6fbd35b849f 100644 --- a/services/core/jni/Android.bp +++ b/services/core/jni/Android.bp @@ -136,6 +136,7 @@ cc_defaults { "android.frameworks.sensorservice@1.0", "android.system.suspend@1.0", "suspend_control_aidl_interface-cpp", + "vintf-vibrator-cpp", ], static_libs: [ diff --git a/services/core/jni/com_android_server_VibratorService.cpp b/services/core/jni/com_android_server_VibratorService.cpp index 64c7935efff9..8ddb86b08ea3 100644 --- a/services/core/jni/com_android_server_VibratorService.cpp +++ b/services/core/jni/com_android_server_VibratorService.cpp @@ -17,6 +17,9 @@ #define LOG_TAG "VibratorService" #include <android/hardware/vibrator/1.4/IVibrator.h> +#include <android/hardware/vibrator/BnVibratorCallback.h> +#include <android/hardware/vibrator/IVibrator.h> +#include <binder/IServiceManager.h> #include "jni.h" #include <nativehelper/JNIHelp.h> @@ -41,11 +44,147 @@ namespace V1_1 = android::hardware::vibrator::V1_1; namespace V1_2 = android::hardware::vibrator::V1_2; namespace V1_3 = android::hardware::vibrator::V1_3; namespace V1_4 = android::hardware::vibrator::V1_4; +namespace aidl = android::hardware::vibrator; namespace android { static jmethodID sMethodIdOnComplete; +// TODO(b/141828236): remove HIDL 1.4 and re-write all of this code to remove +// shim +class VibratorShim : public V1_4::IVibrator { + public: + VibratorShim(const sp<aidl::IVibrator>& vib) : mVib(vib) {} + + Return<V1_0::Status> on(uint32_t timeoutMs) override { + return on_1_4(timeoutMs, nullptr); + } + + Return<V1_0::Status> off() override { + return toHidlStatus(mVib->off()); + } + + Return<bool> supportsAmplitudeControl() override { + int32_t cap = 0; + if (!mVib->getCapabilities(&cap).isOk()) return false; + return (cap & aidl::IVibrator::CAP_AMPLITUDE_CONTROL) > 0; + } + + Return<V1_0::Status> setAmplitude(uint8_t amplitude) override { + return toHidlStatus(mVib->setAmplitude(amplitude)); + } + + Return<void> perform(V1_0::Effect effect, V1_0::EffectStrength strength, + perform_cb _hidl_cb) override { + return perform_1_4(static_cast<V1_3::Effect>(effect), strength, nullptr, _hidl_cb); + } + + Return<void> perform_1_1(V1_1::Effect_1_1 effect, V1_0::EffectStrength strength, + perform_1_1_cb _hidl_cb) override { + return perform_1_4(static_cast<V1_3::Effect>(effect), strength, nullptr, _hidl_cb); + } + + Return<void> perform_1_2(V1_2::Effect effect, V1_0::EffectStrength strength, + perform_1_2_cb _hidl_cb) override { + return perform_1_4(static_cast<V1_3::Effect>(effect), strength, nullptr, _hidl_cb); + } + + Return<bool> supportsExternalControl() override { + int32_t cap = 0; + if (!mVib->getCapabilities(&cap).isOk()) return false; + return (cap & aidl::IVibrator::CAP_EXTERNAL_CONTROL) > 0; + } + + Return<V1_0::Status> setExternalControl(bool enabled) override { + return toHidlStatus(mVib->setExternalControl(enabled)); + } + + Return<void> perform_1_3(V1_3::Effect effect, V1_0::EffectStrength strength, + perform_1_3_cb _hidl_cb) override { + return perform_1_4(static_cast<V1_3::Effect>(effect), strength, nullptr, _hidl_cb); + } + + Return<uint32_t> getCapabilities() override { + static_assert(static_cast<int32_t>(V1_4::Capabilities::ON_COMPLETION_CALLBACK) == + static_cast<int32_t>(aidl::IVibrator::CAP_ON_CALLBACK)); + static_assert(static_cast<int32_t>(V1_4::Capabilities::PERFORM_COMPLETION_CALLBACK) == + static_cast<int32_t>(aidl::IVibrator::CAP_PERFORM_CALLBACK)); + + int32_t cap; + if (!mVib->getCapabilities(&cap).isOk()) return 0; + return (cap & (aidl::IVibrator::CAP_ON_CALLBACK | + aidl::IVibrator::CAP_PERFORM_CALLBACK)) > 0; + } + + Return<V1_0::Status> on_1_4(uint32_t timeoutMs, + const sp<V1_4::IVibratorCallback>& callback) override { + sp<aidl::IVibratorCallback> cb = callback ? new CallbackShim(callback) : nullptr; + return toHidlStatus(mVib->on(timeoutMs, cb)); + } + + Return<void> perform_1_4(V1_3::Effect effect, V1_0::EffectStrength strength, + const sp<V1_4::IVibratorCallback>& callback, + perform_1_4_cb _hidl_cb) override { + static_assert(static_cast<uint8_t>(V1_0::EffectStrength::LIGHT) == + static_cast<uint8_t>(aidl::EffectStrength::LIGHT)); + static_assert(static_cast<uint8_t>(V1_0::EffectStrength::MEDIUM) == + static_cast<uint8_t>(aidl::EffectStrength::MEDIUM)); + static_assert(static_cast<uint8_t>(V1_0::EffectStrength::STRONG) == + static_cast<uint8_t>(aidl::EffectStrength::STRONG)); + static_assert(static_cast<uint8_t>(V1_3::Effect::CLICK) == + static_cast<uint8_t>(aidl::Effect::CLICK)); + static_assert(static_cast<uint8_t>(V1_3::Effect::DOUBLE_CLICK) == + static_cast<uint8_t>(aidl::Effect::DOUBLE_CLICK)); + static_assert(static_cast<uint8_t>(V1_3::Effect::TICK) == + static_cast<uint8_t>(aidl::Effect::TICK)); + static_assert(static_cast<uint8_t>(V1_3::Effect::THUD) == + static_cast<uint8_t>(aidl::Effect::THUD)); + static_assert(static_cast<uint8_t>(V1_3::Effect::POP) == + static_cast<uint8_t>(aidl::Effect::POP)); + static_assert(static_cast<uint8_t>(V1_3::Effect::HEAVY_CLICK) == + static_cast<uint8_t>(aidl::Effect::HEAVY_CLICK)); + static_assert(static_cast<uint8_t>(V1_3::Effect::RINGTONE_1) == + static_cast<uint8_t>(aidl::Effect::RINGTONE_1)); + static_assert(static_cast<uint8_t>(V1_3::Effect::RINGTONE_2) == + static_cast<uint8_t>(aidl::Effect::RINGTONE_2)); + static_assert(static_cast<uint8_t>(V1_3::Effect::RINGTONE_15) == + static_cast<uint8_t>(aidl::Effect::RINGTONE_15)); + static_assert(static_cast<uint8_t>(V1_3::Effect::TEXTURE_TICK) == + static_cast<uint8_t>(aidl::Effect::TEXTURE_TICK)); + + sp<aidl::IVibratorCallback> cb = callback ? new CallbackShim(callback) : nullptr; + int timeoutMs = 0; + V1_0::Status status = toHidlStatus( + mVib->perform(static_cast<aidl::Effect>(effect), + static_cast<aidl::EffectStrength>(strength), cb, &timeoutMs)); + _hidl_cb(status, timeoutMs); + return android::hardware::Status::ok(); + } + private: + sp<aidl::IVibrator> mVib; + + V1_0::Status toHidlStatus(const android::binder::Status& status) { + switch(status.exceptionCode()) { + using android::hardware::Status; + case Status::EX_NONE: return V1_0::Status::OK; + case Status::EX_ILLEGAL_ARGUMENT: return V1_0::Status::BAD_VALUE; + case Status::EX_UNSUPPORTED_OPERATION: return V1_0::Status::UNSUPPORTED_OPERATION; + } + return V1_0::Status::UNKNOWN_ERROR; + } + + class CallbackShim : public aidl::BnVibratorCallback { + public: + CallbackShim(const sp<V1_4::IVibratorCallback>& cb) : mCb(cb) {} + binder::Status onComplete() { + mCb->onComplete(); + return binder::Status::ok(); // oneway, local call + } + private: + sp<V1_4::IVibratorCallback> mCb; + }; +}; + class VibratorCallback : public V1_4::IVibratorCallback { public: VibratorCallback(JNIEnv *env, jobject vibration) : @@ -79,6 +218,11 @@ template <typename I> class HalWrapper { public: static std::unique_ptr<HalWrapper> Create() { + sp<aidl::IVibrator> aidlVib = waitForVintfService<aidl::IVibrator>(); + if (aidlVib) { + return std::unique_ptr<HalWrapper>(new HalWrapper(new VibratorShim(aidlVib))); + } + // Assume that if getService returns a nullptr, HAL is not available on the // device. auto hal = I::getService(); diff --git a/telephony/java/android/telephony/CellBroadcastService.java b/telephony/java/android/telephony/CellBroadcastService.java index d5e447e6c73d..25babe5bb608 100644 --- a/telephony/java/android/telephony/CellBroadcastService.java +++ b/telephony/java/android/telephony/CellBroadcastService.java @@ -17,6 +17,8 @@ package android.telephony; import android.annotation.CallSuper; +import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.app.Service; import android.content.Intent; @@ -64,14 +66,14 @@ public abstract class CellBroadcastService extends Service { * @param slotIndex the index of the slot which received the message * @param message the SMS PDU */ - public abstract void onGsmCellBroadcastSms(int slotIndex, byte[] message); + public abstract void onGsmCellBroadcastSms(int slotIndex, @NonNull byte[] message); /** * Handle a CDMA cell broadcast SMS message forwarded from the system. * @param slotIndex the index of the slot which received the message * @param message the SMS PDU */ - public abstract void onCdmaCellBroadcastSms(int slotIndex, byte[] message); + public abstract void onCdmaCellBroadcastSms(int slotIndex, @NonNull byte[] message); /** * If overriding this method, call through to the super method for any unknown actions. @@ -79,7 +81,8 @@ public abstract class CellBroadcastService extends Service { */ @Override @CallSuper - public IBinder onBind(Intent intent) { + @NonNull + public IBinder onBind(@Nullable Intent intent) { return mStubWrapper; } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index c9440a66ab96..48fbf573c406 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -9448,16 +9448,28 @@ public class TelephonyManager { return returnValue; } - private int getSubIdForPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle) { + /** + * Returns the subscription ID for the given phone account handle. + * + * @param phoneAccountHandle the phone account handle for outgoing calls + * @return subscription ID for the given phone account handle; or + * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} + * if not available; or throw a SecurityException if the caller doesn't have the + * permission. + */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) + public int getSubIdForPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) { int retval = SubscriptionManager.INVALID_SUBSCRIPTION_ID; try { - ITelecomService service = getTelecomService(); + ITelephony service = getITelephony(); if (service != null) { - retval = getSubIdForPhoneAccount(service.getPhoneAccount(phoneAccountHandle)); + retval = service.getSubIdForPhoneAccountHandle( + phoneAccountHandle, mContext.getOpPackageName()); } - } catch (RemoteException e) { + } catch (RemoteException ex) { + Log.e(TAG, "getSubIdForPhoneAccountHandle RemoteException", ex); + ex.rethrowAsRuntimeException(); } - return retval; } @@ -10826,6 +10838,16 @@ public class TelephonyManager { } /** + * Broadcast intent action for Ota emergency number database installation complete. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @SystemApi + public static final String ACTION_OTA_EMERGENCY_NUMBER_DB_INSTALLED = + "android.telephony.action.OTA_EMERGENCY_NUMBER_DB_INSTALLED"; + + /** * Returns whether {@link TelephonyManager#ACTION_EMERGENCY_ASSISTANCE emergency assistance} is * available on the device. * <p> diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index db0eac287423..414693ef6362 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1309,6 +1309,12 @@ interface ITelephony { int getSubIdForPhoneAccount(in PhoneAccount phoneAccount); /** + * Returns the subscription ID associated with the specified PhoneAccountHandle. + */ + int getSubIdForPhoneAccountHandle(in PhoneAccountHandle phoneAccountHandle, + String callingPackage); + + /** * Returns the PhoneAccountHandle associated with a subscription ID. */ PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subscriptionId); |