Loading packages/CarrierDefaultApp/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ <intent-filter> <action android:name="com.android.internal.telephony.CARRIER_SIGNAL_REDIRECTED" /> <action android:name="com.android.internal.telephony.CARRIER_SIGNAL_RESET" /> <action android:name="android.intent.action.LOCALE_CHANGED" /> </intent-filter> </receiver> <service android:name="com.android.carrierdefaultapp.ProvisionObserver" Loading packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierActionUtils.java +19 −18 Original line number Diff line number Diff line Loading @@ -112,8 +112,6 @@ public class CarrierActionUtils { private static void onShowCaptivePortalNotification(Intent intent, Context context) { logd("onShowCaptivePortalNotification"); final NotificationManager notificationMgr = context.getSystemService( NotificationManager.class); Intent portalIntent = new Intent(context, CaptivePortalLoginActivity.class); portalIntent.putExtras(intent); portalIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT Loading @@ -123,7 +121,8 @@ public class CarrierActionUtils { Notification notification = getNotification(context, R.string.portal_notification_id, R.string.portal_notification_detail, pendingIntent); try { notificationMgr.notify(PORTAL_NOTIFICATION_TAG, PORTAL_NOTIFICATION_ID, notification); context.getSystemService(NotificationManager.class) .notify(PORTAL_NOTIFICATION_TAG, PORTAL_NOTIFICATION_ID, notification); } catch (NullPointerException npe) { loge("setNotificationVisible: " + npe); } Loading @@ -131,12 +130,11 @@ public class CarrierActionUtils { private static void onShowNoDataServiceNotification(Context context) { logd("onShowNoDataServiceNotification"); final NotificationManager notificationMgr = context.getSystemService( NotificationManager.class); Notification notification = getNotification(context, R.string.no_data_notification_id, R.string.no_data_notification_detail, null); try { notificationMgr.notify(NO_DATA_NOTIFICATION_TAG, NO_DATA_NOTIFICATION_ID, notification); context.getSystemService(NotificationManager.class) .notify(NO_DATA_NOTIFICATION_TAG, NO_DATA_NOTIFICATION_ID, notification); } catch (NullPointerException npe) { loge("setNotificationVisible: " + npe); } Loading @@ -144,26 +142,16 @@ public class CarrierActionUtils { private static void onCancelAllNotifications(Context context) { logd("onCancelAllNotifications"); final NotificationManager notificationMgr = context.getSystemService( NotificationManager.class); notificationMgr.cancelAll(); context.getSystemService(NotificationManager.class).cancelAll(); } private static Notification getNotification(Context context, int titleId, int textId, PendingIntent pendingIntent) { final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final NotificationManager notificationManager = context.getSystemService( NotificationManager.class); final Resources resources = context.getResources(); final Bundle extras = Bundle.forPair(Notification.EXTRA_SUBSTITUTE_APP_NAME, resources.getString(R.string.android_system_label)); /* Creates the notification channel and registers it with NotificationManager. If a channel * with the same ID is already registered, NotificationManager will ignore this call. */ notificationManager.createNotificationChannel(new NotificationChannel( NOTIFICATION_CHANNEL_ID_MOBILE_DATA_STATUS, resources.getString(R.string.mobile_data_status_notification_channel_name), NotificationManager.IMPORTANCE_DEFAULT)); createNotificationChannels(context); Notification.Builder builder = new Notification.Builder(context) .setContentTitle(resources.getString(titleId)) .setContentText(String.format(resources.getString(textId), Loading @@ -187,6 +175,19 @@ public class CarrierActionUtils { return builder.build(); } /** * Creates the notification channel and registers it with NotificationManager. Also used to * update an existing channel's name. */ static void createNotificationChannels(Context context) { context.getSystemService(NotificationManager.class) .createNotificationChannel(new NotificationChannel( NOTIFICATION_CHANNEL_ID_MOBILE_DATA_STATUS, context.getResources().getString( R.string.mobile_data_status_notification_channel_name), NotificationManager.IMPORTANCE_DEFAULT)); } private static void logd(String s) { Log.d(TAG, s); } Loading packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierDefaultBroadcastReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ public class CarrierDefaultBroadcastReceiver extends BroadcastReceiver{ Log.d(TAG, "skip carrier actions during provisioning"); return; } if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) { CarrierActionUtils.createNotificationChannels(context); return; } List<Integer> actionList = CustomConfigLoader.loadCarrierActionList(context, intent); for (int actionIdx : actionList) { Log.d(TAG, "apply carrier action idx: " + actionIdx); Loading Loading
packages/CarrierDefaultApp/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ <intent-filter> <action android:name="com.android.internal.telephony.CARRIER_SIGNAL_REDIRECTED" /> <action android:name="com.android.internal.telephony.CARRIER_SIGNAL_RESET" /> <action android:name="android.intent.action.LOCALE_CHANGED" /> </intent-filter> </receiver> <service android:name="com.android.carrierdefaultapp.ProvisionObserver" Loading
packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierActionUtils.java +19 −18 Original line number Diff line number Diff line Loading @@ -112,8 +112,6 @@ public class CarrierActionUtils { private static void onShowCaptivePortalNotification(Intent intent, Context context) { logd("onShowCaptivePortalNotification"); final NotificationManager notificationMgr = context.getSystemService( NotificationManager.class); Intent portalIntent = new Intent(context, CaptivePortalLoginActivity.class); portalIntent.putExtras(intent); portalIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT Loading @@ -123,7 +121,8 @@ public class CarrierActionUtils { Notification notification = getNotification(context, R.string.portal_notification_id, R.string.portal_notification_detail, pendingIntent); try { notificationMgr.notify(PORTAL_NOTIFICATION_TAG, PORTAL_NOTIFICATION_ID, notification); context.getSystemService(NotificationManager.class) .notify(PORTAL_NOTIFICATION_TAG, PORTAL_NOTIFICATION_ID, notification); } catch (NullPointerException npe) { loge("setNotificationVisible: " + npe); } Loading @@ -131,12 +130,11 @@ public class CarrierActionUtils { private static void onShowNoDataServiceNotification(Context context) { logd("onShowNoDataServiceNotification"); final NotificationManager notificationMgr = context.getSystemService( NotificationManager.class); Notification notification = getNotification(context, R.string.no_data_notification_id, R.string.no_data_notification_detail, null); try { notificationMgr.notify(NO_DATA_NOTIFICATION_TAG, NO_DATA_NOTIFICATION_ID, notification); context.getSystemService(NotificationManager.class) .notify(NO_DATA_NOTIFICATION_TAG, NO_DATA_NOTIFICATION_ID, notification); } catch (NullPointerException npe) { loge("setNotificationVisible: " + npe); } Loading @@ -144,26 +142,16 @@ public class CarrierActionUtils { private static void onCancelAllNotifications(Context context) { logd("onCancelAllNotifications"); final NotificationManager notificationMgr = context.getSystemService( NotificationManager.class); notificationMgr.cancelAll(); context.getSystemService(NotificationManager.class).cancelAll(); } private static Notification getNotification(Context context, int titleId, int textId, PendingIntent pendingIntent) { final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final NotificationManager notificationManager = context.getSystemService( NotificationManager.class); final Resources resources = context.getResources(); final Bundle extras = Bundle.forPair(Notification.EXTRA_SUBSTITUTE_APP_NAME, resources.getString(R.string.android_system_label)); /* Creates the notification channel and registers it with NotificationManager. If a channel * with the same ID is already registered, NotificationManager will ignore this call. */ notificationManager.createNotificationChannel(new NotificationChannel( NOTIFICATION_CHANNEL_ID_MOBILE_DATA_STATUS, resources.getString(R.string.mobile_data_status_notification_channel_name), NotificationManager.IMPORTANCE_DEFAULT)); createNotificationChannels(context); Notification.Builder builder = new Notification.Builder(context) .setContentTitle(resources.getString(titleId)) .setContentText(String.format(resources.getString(textId), Loading @@ -187,6 +175,19 @@ public class CarrierActionUtils { return builder.build(); } /** * Creates the notification channel and registers it with NotificationManager. Also used to * update an existing channel's name. */ static void createNotificationChannels(Context context) { context.getSystemService(NotificationManager.class) .createNotificationChannel(new NotificationChannel( NOTIFICATION_CHANNEL_ID_MOBILE_DATA_STATUS, context.getResources().getString( R.string.mobile_data_status_notification_channel_name), NotificationManager.IMPORTANCE_DEFAULT)); } private static void logd(String s) { Log.d(TAG, s); } Loading
packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierDefaultBroadcastReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ public class CarrierDefaultBroadcastReceiver extends BroadcastReceiver{ Log.d(TAG, "skip carrier actions during provisioning"); return; } if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) { CarrierActionUtils.createNotificationChannels(context); return; } List<Integer> actionList = CustomConfigLoader.loadCarrierActionList(context, intent); for (int actionIdx : actionList) { Log.d(TAG, "apply carrier action idx: " + actionIdx); Loading