@@ -66,16 +66,47 @@ test('resolveAndroidPackageForOpen retains the native requested intent package w
6666 'package' ,
6767 'resolve-activity' ,
6868 '--brief' ,
69- '-a' ,
70- 'android.settings.SETTINGS' ,
7169 '-c' ,
7270 'android.intent.category.DEFAULT' ,
71+ '-a' ,
72+ 'android.settings.SETTINGS' ,
7373 ] ,
7474 { allowFailure : true , timeoutMs : 2_000 } ,
7575 ) ;
7676 expect ( getAndroidAppState ) . not . toHaveBeenCalled ( ) ;
7777} ) ;
7878
79+ test ( 'intent launch and ownership resolve the same overriding component arguments' , async ( ) => {
80+ const { openAndroidApp } = await import ( './app-lifecycle.ts' ) ;
81+ const launchArgs = [ '-n' , 'com.example.app/.MainActivity' ] ;
82+ resolveAndroidApp . mockResolvedValue ( { type : 'intent' , value : 'android.settings.SETTINGS' } ) ;
83+ runAndroidShell . mockImplementation ( async ( _device , args : string [ ] ) => ( {
84+ stdout : args . includes ( 'com.example.app/.MainActivity' )
85+ ? 'com.example.app/.MainActivity'
86+ : 'com.android.settings/.Settings' ,
87+ stderr : '' ,
88+ exitCode : 0 ,
89+ } ) ) ;
90+
91+ await openAndroidApp ( androidDevice , 'settings' , { launchArgs } ) ;
92+ await expect ( resolveAndroidPackageForOpen ( androidDevice , 'settings' , launchArgs ) ) . resolves . toBe (
93+ 'com.example.app' ,
94+ ) ;
95+ const commands = runAndroidShell . mock . calls . map ( ( call ) => call [ 1 ] ) ;
96+ const intentArgs = [ '-a' , 'android.settings.SETTINGS' , ...launchArgs ] ;
97+ expect ( commands [ 0 ] ) . toEqual ( [ 'am' , 'start' , '-W' , ...intentArgs ] ) ;
98+ expect ( commands [ 1 ] ) . toEqual ( [
99+ 'cmd' ,
100+ 'package' ,
101+ 'resolve-activity' ,
102+ '--brief' ,
103+ '-c' ,
104+ 'android.intent.category.DEFAULT' ,
105+ ...intentArgs ,
106+ ] ) ;
107+ expect ( getAndroidAppState ) . not . toHaveBeenCalled ( ) ;
108+ } ) ;
109+
79110test . each ( [
80111 'No activity found' ,
81112 'com.android.settings/Invalid-Class' ,
@@ -100,7 +131,12 @@ test('intent package ownership does not adopt a component from a failed native r
100131 stderr : '' ,
101132 exitCode : 1 ,
102133 } ) ;
103- await expect ( resolveAndroidPackageForOpen ( androidDevice , 'settings' ) ) . resolves . toBeUndefined ( ) ;
134+ await expect (
135+ resolveAndroidPackageForOpen ( androidDevice , 'settings' , [
136+ '-n' ,
137+ 'com.example.app/.MainActivity' ,
138+ ] ) ,
139+ ) . resolves . toBeUndefined ( ) ;
104140} ) ;
105141
106142test ( 'intent package ownership reads its native handler rather than assuming the Settings package' , async ( ) => {
0 commit comments