diff options
| author | 2024-01-25 00:28:13 +0000 | |
|---|---|---|
| committer | 2024-02-02 00:40:11 +0000 | |
| commit | d9bc1e8ca0f15e9e14c32fc63202e47b7f4fd06c (patch) | |
| tree | 89f717659b989ccb5bfa0f8b6fb5ff9e5ed1fb02 | |
| parent | 4ba5c58ba07796adff3907e93d7d86b89e747f39 (diff) | |
Create Service for IssueRecording Notifications and Tracing.
This shares most of its functional code with RecordingService.
Bug: 305049544
Flag: ACONFIG record_issue_qs_tile DEVELOPMENT
Test: Manually tested that everything works on device.
Change-Id: I08c6639e944b9d15c88ac7be7b140b8e9c4cd11c
9 files changed, 253 insertions, 58 deletions
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 0050676ace84..1aa846757464 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -475,6 +475,9 @@ <service android:name=".screenrecord.RecordingService" android:foregroundServiceType="systemExempted"/> + <service android:name=".recordissue.IssueRecordingService" + android:foregroundServiceType="systemExempted"/> + <receiver android:name=".SysuiRestartReceiver" android:exported="false"> <intent-filter> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 8971859256e5..f0cbe7af4a89 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -305,6 +305,27 @@ <!-- A toast message shown when the screen recording cannot be started due to a generic error [CHAR LIMIT=NONE] --> <string name="screenrecord_start_error">Error starting screen recording</string> + <!-- Notification title displayed for issue recording [CHAR LIMIT=50]--> + <string name="issuerecord_title">Issue Recorder</string> + <!-- Processing issue recoding data in the background [CHAR LIMIT=30]--> + <string name="issuerecord_background_processing_label">Processing issue recording</string> + <!-- Description of the screen recording notification channel [CHAR LIMIT=NONE]--> + <string name="issuerecord_channel_description">Ongoing notification for an issue collection session</string> + + <!-- Notification text displayed when we are recording the screen [CHAR LIMIT=100]--> + <string name="issuerecord_ongoing_screen_only">Recording issue</string> + <!-- Label for notification action to share issue recording [CHAR LIMIT=35] --> + <string name="issuerecord_share_label">Share</string> + <!-- A toast message shown after successfully canceling a issue recording [CHAR LIMIT=NONE] --> + <!-- Notification text shown after saving a issue recording [CHAR LIMIT=100] --> + <string name="issuerecord_save_title">Issue recording saved</string> + <!-- Subtext for a notification shown after saving a issue recording to prompt the user to view it [CHAR_LIMIT=100] --> + <string name="issuerecord_save_text">Tap to view</string> + <!-- A toast message shown when there is an error saving a issue recording [CHAR LIMIT=NONE] --> + <string name="issuerecord_save_error">Error saving issue recording</string> + <!-- A toast message shown when the issue recording cannot be started due to a generic error [CHAR LIMIT=NONE] --> + <string name="issuerecord_start_error">Error starting issue recording</string> + <!-- Cling help message title when hiding the navigation bar entering immersive mode [CHAR LIMIT=none] --> <string name="immersive_cling_title">Viewing full screen</string> <!-- Cling help message description when hiding the navigation bar entering immersive mode [CHAR LIMIT=none] --> diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java index 92eeace648ad..904d5898fcf8 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java @@ -23,6 +23,7 @@ import com.android.systemui.doze.DozeService; import com.android.systemui.dreams.DreamOverlayService; import com.android.systemui.dump.SystemUIAuxiliaryDumpService; import com.android.systemui.keyguard.KeyguardService; +import com.android.systemui.recordissue.IssueRecordingService; import com.android.systemui.screenrecord.RecordingService; import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins; import com.android.systemui.wallpapers.ImageWallpaper; @@ -85,4 +86,11 @@ public abstract class DefaultServiceBinder { @IntoMap @ClassKey(RecordingService.class) public abstract Service bindRecordingService(RecordingService service); + + /** Inject into IssueRecordingService */ + @Binds + @IntoMap + @ClassKey(IssueRecordingService.class) + public abstract Service bindIssueRecordingService(IssueRecordingService service); + } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt index 88863cbad1ee..a4748686a784 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt @@ -42,6 +42,7 @@ import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl +import com.android.systemui.recordissue.IssueRecordingService import com.android.systemui.recordissue.RecordIssueDialogDelegate import com.android.systemui.res.R import com.android.systemui.screenrecord.RecordingService @@ -107,7 +108,7 @@ constructor( PendingIntent.getService( userContextProvider.userContext, RecordingService.REQUEST_CODE, - RecordingService.getStopIntent(userContextProvider.userContext), + IssueRecordingService.getStopIntent(userContextProvider.userContext), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) .send(BroadcastOptions.makeBasic().apply { isInteractive = true }.toBundle()) diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt new file mode 100644 index 000000000000..f4872589b3bf --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2024 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 com.android.systemui.recordissue + +import android.app.NotificationManager +import android.content.Context +import android.content.Intent +import android.content.res.Resources +import android.os.Handler +import com.android.internal.logging.UiEventLogger +import com.android.systemui.dagger.qualifiers.LongRunning +import com.android.systemui.dagger.qualifiers.Main +import com.android.systemui.res.R +import com.android.systemui.screenrecord.RecordingController +import com.android.systemui.screenrecord.RecordingService +import com.android.systemui.screenrecord.RecordingServiceStrings +import com.android.systemui.settings.UserContextProvider +import com.android.systemui.statusbar.phone.KeyguardDismissUtil +import java.util.concurrent.Executor +import javax.inject.Inject + +class IssueRecordingService +@Inject +constructor( + controller: RecordingController, + @LongRunning executor: Executor, + @Main handler: Handler, + uiEventLogger: UiEventLogger, + notificationManager: NotificationManager, + userContextProvider: UserContextProvider, + keyguardDismissUtil: KeyguardDismissUtil +) : + RecordingService( + controller, + executor, + handler, + uiEventLogger, + notificationManager, + userContextProvider, + keyguardDismissUtil + ) { + + override fun getTag(): String = TAG + + override fun getChannelId(): String = CHANNEL_ID + + override fun provideRecordingServiceStrings(): RecordingServiceStrings = IrsStrings(resources) + + companion object { + private const val TAG = "IssueRecordingService" + private const val CHANNEL_ID = "issue_record" + + /** + * Get an intent to stop the issue recording service. + * + * @param context Context from the requesting activity + * @return + */ + fun getStopIntent(context: Context): Intent = + Intent(context, RecordingService::class.java) + .setAction(ACTION_STOP) + .putExtra(Intent.EXTRA_USER_HANDLE, context.userId) + + /** + * Get an intent to start the issue recording service. + * + * @param context Context from the requesting activity + */ + fun getStartIntent(context: Context): Intent = + Intent(context, RecordingService::class.java).setAction(ACTION_START) + } +} + +private class IrsStrings(private val res: Resources) : RecordingServiceStrings(res) { + override val title + get() = res.getString(R.string.issuerecord_title) + override val notificationChannelDescription + get() = res.getString(R.string.issuerecord_channel_description) + override val startErrorResId + get() = R.string.issuerecord_start_error + override val startError + get() = res.getString(R.string.issuerecord_start_error) + override val saveErrorResId + get() = R.string.issuerecord_save_error + override val saveError + get() = res.getString(R.string.issuerecord_save_error) + override val ongoingRecording + get() = res.getString(R.string.issuerecord_ongoing_screen_only) + override val backgroundProcessingLabel + get() = res.getString(R.string.issuerecord_background_processing_label) + override val saveTitle + get() = res.getString(R.string.issuerecord_save_title) +} diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt index e051df4e6c7b..80f11f1e1874 100644 --- a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt +++ b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt @@ -17,7 +17,6 @@ package com.android.systemui.recordissue import android.annotation.SuppressLint -import android.app.Activity import android.app.BroadcastOptions import android.app.PendingIntent import android.content.Context @@ -45,7 +44,6 @@ import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDisabledDi import com.android.systemui.qs.tiles.RecordIssueTile import com.android.systemui.res.R import com.android.systemui.screenrecord.RecordingService -import com.android.systemui.screenrecord.ScreenRecordingAudioSource import com.android.systemui.settings.UserContextProvider import com.android.systemui.settings.UserFileManager import com.android.systemui.settings.UserTracker @@ -183,13 +181,7 @@ constructor( PendingIntent.getForegroundService( userContextProvider.userContext, RecordingService.REQUEST_CODE, - RecordingService.getStartIntent( - userContextProvider.userContext, - Activity.RESULT_OK, - ScreenRecordingAudioSource.NONE.ordinal, - false, - null - ), + IssueRecordingService.getStartIntent(userContextProvider.userContext), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) .send(BroadcastOptions.makeBasic().apply { isInteractive = true }.toBundle()) diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java index b5a13138a278..b355d2d6b4f8 100644 --- a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java +++ b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java @@ -24,7 +24,6 @@ import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; -import android.content.res.Resources; import android.graphics.drawable.Icon; import android.media.MediaRecorder; import android.net.Uri; @@ -71,8 +70,8 @@ public class RecordingService extends Service implements ScreenMediaRecorderList private static final String EXTRA_SHOW_TAPS = "extra_showTaps"; private static final String EXTRA_CAPTURE_TARGET = "extra_captureTarget"; - private static final String ACTION_START = "com.android.systemui.screenrecord.START"; - private static final String ACTION_STOP = "com.android.systemui.screenrecord.STOP"; + protected static final String ACTION_START = "com.android.systemui.screenrecord.START"; + protected static final String ACTION_STOP = "com.android.systemui.screenrecord.STOP"; private static final String ACTION_STOP_NOTIF = "com.android.systemui.screenrecord.STOP_FROM_NOTIF"; private static final String ACTION_SHARE = "com.android.systemui.screenrecord.SHARE"; @@ -90,6 +89,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList private final NotificationManager mNotificationManager; private final UserContextProvider mUserContextTracker; private int mNotificationId = NOTIF_BASE_ID; + private RecordingServiceStrings mStrings; @Inject public RecordingService(RecordingController controller, @LongRunning Executor executor, @@ -134,9 +134,9 @@ public class RecordingService extends Service implements ScreenMediaRecorderList return Service.START_NOT_STICKY; } String action = intent.getAction(); - Log.d(TAG, "onStartCommand " + action); + Log.d(getTag(), "onStartCommand " + action); NotificationChannel channel = new NotificationChannel( - CHANNEL_ID, + getChannelId(), getString(R.string.screenrecord_title), NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(getString(R.string.screenrecord_channel_description)); @@ -152,7 +152,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList mNotificationId = NOTIF_BASE_ID + (int) SystemClock.uptimeMillis(); mAudioSource = ScreenRecordingAudioSource .values()[intent.getIntExtra(EXTRA_AUDIO_SOURCE, 0)]; - Log.d(TAG, "recording with audio source " + mAudioSource); + Log.d(getTag(), "recording with audio source " + mAudioSource); mShowTaps = intent.getBooleanExtra(EXTRA_SHOW_TAPS, false); MediaProjectionCaptureTarget captureTarget = intent.getParcelableExtra(EXTRA_CAPTURE_TARGET, @@ -207,7 +207,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList .setType("video/mp4") .putExtra(Intent.EXTRA_STREAM, shareUri); mKeyguardDismissUtil.executeWhenUnlocked(() -> { - String shareLabel = getResources().getString(R.string.screenrecord_share_label); + String shareLabel = strings().getShareLabel(); startActivity(Intent.createChooser(shareIntent, shareLabel) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); // Remove notification @@ -270,13 +270,11 @@ public class RecordingService extends Service implements ScreenMediaRecorderList */ @VisibleForTesting protected void createErrorNotification() { - Resources res = getResources(); Bundle extras = new Bundle(); - extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, - res.getString(R.string.screenrecord_title)); - String notificationTitle = res.getString(R.string.screenrecord_start_error); + extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, strings().getTitle()); + String notificationTitle = strings().getStartError(); - Notification.Builder builder = new Notification.Builder(this, CHANNEL_ID) + Notification.Builder builder = new Notification.Builder(this, getChannelId()) .setSmallIcon(R.drawable.ic_screenrecord) .setContentTitle(notificationTitle) .addExtras(extras); @@ -290,14 +288,12 @@ public class RecordingService extends Service implements ScreenMediaRecorderList @VisibleForTesting protected void createRecordingNotification() { - Resources res = getResources(); Bundle extras = new Bundle(); - extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, - res.getString(R.string.screenrecord_title)); + extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, strings().getTitle()); String notificationTitle = mAudioSource == ScreenRecordingAudioSource.NONE - ? res.getString(R.string.screenrecord_ongoing_screen_only) - : res.getString(R.string.screenrecord_ongoing_screen_and_audio); + ? strings().getOngoingRecording() + : strings().getOngoingRecordingWithAudio(); PendingIntent pendingIntent = PendingIntent.getService( this, @@ -306,9 +302,9 @@ public class RecordingService extends Service implements ScreenMediaRecorderList PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); Notification.Action stopAction = new Notification.Action.Builder( Icon.createWithResource(this, R.drawable.ic_android), - getResources().getString(R.string.screenrecord_stop_label), + strings().getStopLabel(), pendingIntent).build(); - Notification.Builder builder = new Notification.Builder(this, CHANNEL_ID) + Notification.Builder builder = new Notification.Builder(this, getChannelId()) .setSmallIcon(R.drawable.ic_screenrecord) .setContentTitle(notificationTitle) .setUsesChronometer(true) @@ -323,19 +319,17 @@ public class RecordingService extends Service implements ScreenMediaRecorderList @VisibleForTesting protected Notification createProcessingNotification() { - Resources res = getApplicationContext().getResources(); String notificationTitle = mAudioSource == ScreenRecordingAudioSource.NONE - ? res.getString(R.string.screenrecord_ongoing_screen_only) - : res.getString(R.string.screenrecord_ongoing_screen_and_audio); + ? strings().getOngoingRecording() + : strings().getOngoingRecordingWithAudio(); Bundle extras = new Bundle(); - extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, - res.getString(R.string.screenrecord_title)); + extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, strings().getTitle()); - Notification.Builder builder = new Notification.Builder(this, CHANNEL_ID) + Notification.Builder builder = new Notification.Builder(this, getChannelId()) .setContentTitle(notificationTitle) .setContentText( - getResources().getString(R.string.screenrecord_background_processing_label)) + strings().getBackgroundProcessingLabel()) .setSmallIcon(R.drawable.ic_screenrecord) .setGroup(GROUP_KEY) .addExtras(extras); @@ -351,7 +345,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList Notification.Action shareAction = new Notification.Action.Builder( Icon.createWithResource(this, R.drawable.ic_screenrecord), - getResources().getString(R.string.screenrecord_share_label), + strings().getShareLabel(), PendingIntent.getService( this, REQUEST_CODE, @@ -360,13 +354,12 @@ public class RecordingService extends Service implements ScreenMediaRecorderList .build(); Bundle extras = new Bundle(); - extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, - getResources().getString(R.string.screenrecord_title)); + extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, strings().getTitle()); - Notification.Builder builder = new Notification.Builder(this, CHANNEL_ID) + Notification.Builder builder = new Notification.Builder(this, getChannelId()) .setSmallIcon(R.drawable.ic_screenrecord) - .setContentTitle(getResources().getString(R.string.screenrecord_save_title)) - .setContentText(getResources().getString(R.string.screenrecord_save_text)) + .setContentTitle(strings().getSaveTitle()) + .setContentText(strings().getSaveText()) .setContentIntent(PendingIntent.getActivity( this, REQUEST_CODE, @@ -394,15 +387,15 @@ public class RecordingService extends Service implements ScreenMediaRecorderList private void postGroupNotification(UserHandle currentUser) { Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, - getResources().getString(R.string.screenrecord_title)); - Notification groupNotif = new Notification.Builder(this, CHANNEL_ID) + strings().getTitle()); + Notification groupNotif = new Notification.Builder(this, getChannelId()) .setSmallIcon(R.drawable.ic_screenrecord) - .setContentTitle(getResources().getString(R.string.screenrecord_save_title)) + .setContentTitle(strings().getSaveTitle()) .setGroup(GROUP_KEY) .setGroupSummary(true) .setExtras(extras) .build(); - mNotificationManager.notifyAsUser(TAG, NOTIF_BASE_ID, groupNotif, currentUser); + mNotificationManager.notifyAsUser(getTag(), NOTIF_BASE_ID, groupNotif, currentUser); } private void stopService() { @@ -413,7 +406,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList if (userId == USER_ID_NOT_SPECIFIED) { userId = mUserContextTracker.getUserContext().getUserId(); } - Log.d(TAG, "notifying for user " + userId); + Log.d(getTag(), "notifying for user " + userId); setTapsVisible(mOriginalShowTaps); if (getRecorder() != null) { try { @@ -424,7 +417,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList // let's release the recorder and delete all temporary files in this case getRecorder().release(); showErrorToast(R.string.screenrecord_start_error); - Log.e(TAG, "stopRecording called, but there was an error when ending" + Log.e(getTag(), "stopRecording called, but there was an error when ending" + "recording"); exception.printStackTrace(); createErrorNotification(); @@ -435,7 +428,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList throw new RuntimeException(throwable); } } else { - Log.e(TAG, "stopRecording called, but recorder was null"); + Log.e(getTag(), "stopRecording called, but recorder was null"); } updateState(false); stopForeground(STOP_FOREGROUND_DETACH); @@ -449,13 +442,13 @@ public class RecordingService extends Service implements ScreenMediaRecorderList mLongExecutor.execute(() -> { try { - Log.d(TAG, "saving recording"); + Log.d(getTag(), "saving recording"); Notification notification = createSaveNotification(getRecorder().save()); postGroupNotification(currentUser); mNotificationManager.notifyAsUser(null, mNotificationId, notification, currentUser); } catch (IOException | IllegalStateException e) { - Log.e(TAG, "Error saving screen recording: " + e.getMessage()); + Log.e(getTag(), "Error saving screen recording: " + e.getMessage()); e.printStackTrace(); showErrorToast(R.string.screenrecord_save_error); mNotificationManager.cancelAsUser(null, mNotificationId, currentUser); @@ -468,6 +461,26 @@ public class RecordingService extends Service implements ScreenMediaRecorderList Settings.System.putInt(getContentResolver(), Settings.System.SHOW_TOUCHES, value); } + protected String getTag() { + return TAG; + } + + protected String getChannelId() { + return CHANNEL_ID; + } + + private RecordingServiceStrings strings() { + if (mStrings == null) { + mStrings = provideRecordingServiceStrings(); + } + return mStrings; + } + + protected RecordingServiceStrings provideRecordingServiceStrings() { + return new RecordingServiceStrings(getResources()); + } + + /** * Get an intent to stop the recording service. * @param context Context from the requesting activity @@ -484,25 +497,25 @@ public class RecordingService extends Service implements ScreenMediaRecorderList * @param context * @return */ - protected static Intent getNotificationIntent(Context context) { - return new Intent(context, RecordingService.class).setAction(ACTION_STOP_NOTIF); + protected Intent getNotificationIntent(Context context) { + return new Intent(context, this.getClass()).setAction(ACTION_STOP_NOTIF); } - private static Intent getShareIntent(Context context, String path) { - return new Intent(context, RecordingService.class).setAction(ACTION_SHARE) + private Intent getShareIntent(Context context, String path) { + return new Intent(context, this.getClass()).setAction(ACTION_SHARE) .putExtra(EXTRA_PATH, path); } @Override public void onInfo(MediaRecorder mr, int what, int extra) { - Log.d(TAG, "Media recorder info: " + what); + Log.d(getTag(), "Media recorder info: " + what); onStartCommand(getStopIntent(this), 0, 0); } @Override public void onStopped() { if (mController.isRecording()) { - Log.d(TAG, "Stopping recording because the system requested the stop"); + Log.d(getTag(), "Stopping recording because the system requested the stop"); stopService(); } } diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingServiceStrings.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingServiceStrings.kt new file mode 100644 index 000000000000..fdb1eb6af298 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingServiceStrings.kt @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2024 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 com.android.systemui.screenrecord + +import android.content.res.Resources +import com.android.systemui.res.R + +open class RecordingServiceStrings(private val res: Resources) { + open val title + get() = res.getString(R.string.screenrecord_title) + open val notificationChannelDescription + get() = res.getString(R.string.screenrecord_channel_description) + open val startErrorResId + get() = R.string.screenrecord_start_error + open val startError + get() = res.getString(R.string.screenrecord_start_error) + open val saveErrorResId + get() = R.string.screenrecord_save_error + open val saveError + get() = res.getString(R.string.screenrecord_save_error) + open val ongoingRecording + get() = res.getString(R.string.screenrecord_ongoing_screen_only) + open val backgroundProcessingLabel + get() = res.getString(R.string.screenrecord_background_processing_label) + open val saveTitle + get() = res.getString(R.string.screenrecord_save_title) + + val saveText + get() = res.getString(R.string.screenrecord_save_text) + val ongoingRecordingWithAudio + get() = res.getString(R.string.screenrecord_ongoing_screen_and_audio) + val stopLabel + get() = res.getString(R.string.screenrecord_stop_label) + val shareLabel + get() = res.getString(R.string.screenrecord_share_label) +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingServiceTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingServiceTest.java index 9ce77e58a5f2..deecc5bb5a03 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingServiceTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingServiceTest.java @@ -166,7 +166,7 @@ public class RecordingServiceTest extends SysuiTestCase { @Test public void testLogStopFromNotificationIntent() { - Intent stopIntent = RecordingService.getNotificationIntent(mContext); + Intent stopIntent = mRecordingService.getNotificationIntent(mContext); mRecordingService.onStartCommand(stopIntent, 0, 0); // Verify that we log the correct event |