android.bp privileged prop not work

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

android.bp privileged prop not work

fanx lin
hi, I am buildding android Q , I want to build a app . and I want to use build env to control which the app installed in , I wrote a android.bp to build it. the key code as below:

//omit
//... ...

func getPrivileged(ctx android.LoadHookContext)(bool){
if ctx.AConfig().IsEnvTrue("PAX_PRI"){
fmt.Println("PAX_PRI ============= true")
return true
}else{
fmt.Println("PAX_PRI ============= false")
return false
}
}

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged bool
}
p := &props{}
p.privileged = getPrivileged(ctx)
ctx.AppendProperties(p)
}


//omit
//... ...

the code above is not work,the println is ok, I can see the print, but the privileged prop is not work, then I try to change the code as below, but is still not work:

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged *bool
}
var privileged bool
p := &props{}
privileged = getPrivileged(ctx)
p.privileged = &privileged
ctx.AppendProperties(p)
}

maybe there is some error , can someone give me a hand ?  thanks a lot!!

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/cc666c99-50dd-4afd-a6ba-b3d3c10ec36a%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: android.bp privileged prop not work

Dan Willemsen-2
I believe the problem is that you need to use `Privileged` instead of `privileged`. (In Go, uppercase leading characters in field names are exported and can be used by others, while lowercase ones are considered private)

if ctx.AConfig().IsEnvTrue("PAX_PRI"){
 
Unless this is for temporary debugging, you probably want to use the VendorConfig functions instead, so that it can be configured by the product that you're building.

- Dan

On Mon, May 18, 2020 at 10:35 AM fanx lin <[hidden email]> wrote:
hi, I am buildding android Q , I want to build a app . and I want to use build env to control which the app installed in , I wrote a android.bp to build it. the key code as below:

//omit
//... ...

func getPrivileged(ctx android.LoadHookContext)(bool){
if ctx.AConfig().IsEnvTrue("PAX_PRI"){
fmt.Println("PAX_PRI ============= true")
return true
}else{
fmt.Println("PAX_PRI ============= false")
return false
}
}

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged bool
}
p := &props{}
p.privileged = getPrivileged(ctx)
ctx.AppendProperties(p)
}


//omit
//... ...

the code above is not work,the println is ok, I can see the print, but the privileged prop is not work, then I try to change the code as below, but is still not work:

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged *bool
}
var privileged bool
p := &props{}
privileged = getPrivileged(ctx)
p.privileged = &privileged
ctx.AppendProperties(p)
}

maybe there is some error , can someone give me a hand ?  thanks a lot!!

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/cc666c99-50dd-4afd-a6ba-b3d3c10ec36a%40googlegroups.com.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/CALQgHd%3DJuRwPPsaZut71ivSGQHZABSbD5ycAH6%3DnELD0Qcae8w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: android.bp privileged prop not work

fanx lin
thank you very much。you are right, Problem solved。give you a thumb up!   thanks。

在 2020年5月19日星期二 UTC+8上午1:42:25,Dan Willemsen写道:
I believe the problem is that you need to use `Privileged` instead of `privileged`. (In Go, uppercase leading characters in field names are exported and can be used by others, while lowercase ones are considered private)

if ctx.AConfig().IsEnvTrue("PAX_PRI"){
 
Unless this is for temporary debugging, you probably want to use the VendorConfig functions instead, so that it can be configured by the product that you're building.

- Dan

On Mon, May 18, 2020 at 10:35 AM fanx lin <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kDoC8mC-BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jjlin...@...> wrote:
hi, I am buildding android Q , I want to build a app . and I want to use build env to control which the app installed in , I wrote a android.bp to build it. the key code as below:

//omit
//... ...

func getPrivileged(ctx android.LoadHookContext)(bool){
if ctx.AConfig().IsEnvTrue("PAX_PRI"){
fmt.Println("PAX_PRI ============= true")
return true
}else{
fmt.Println("PAX_PRI ============= false")
return false
}
}

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged bool
}
p := &props{}
p.privileged = getPrivileged(ctx)
ctx.AppendProperties(p)
}


//omit
//... ...

the code above is not work,the println is ok, I can see the print, but the privileged prop is not work, then I try to change the code as below, but is still not work:

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged *bool
}
var privileged bool
p := &props{}
privileged = getPrivileged(ctx)
p.privileged = &privileged
ctx.AppendProperties(p)
}

maybe there is some error , can someone give me a hand ?  thanks a lot!!

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="kDoC8mC-BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">android-...@googlegroups.com
To unsubscribe from this group, send email to
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kDoC8mC-BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">android-...@googlegroups.com
For more options, visit this group at
<a href="http://groups.google.com/group/android-building?hl=en" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/android-building?hl\x3den&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/android-building?hl\x3den&#39;;return true;">http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="kDoC8mC-BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">android-...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/android-building/cc666c99-50dd-4afd-a6ba-b3d3c10ec36a%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/android-building/cc666c99-50dd-4afd-a6ba-b3d3c10ec36a%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/android-building/cc666c99-50dd-4afd-a6ba-b3d3c10ec36a%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/android-building/cc666c99-50dd-4afd-a6ba-b3d3c10ec36a%40googlegroups.com.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/fb4c50eb-c50f-4552-bd0f-fab451b39b8f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: android.bp privileged prop not work

fanx lin
In reply to this post by fanx lin
Hi Dan, I have one more question about:

if we compile binary bin file,in go file,we write:
func testDefaultFactory()(android.Module){
 
module := cc.DefaultsFactory()
 android
.AddLoadHook(module, testDefault)
 return module
}
and if we compile shared lib,in go file ,we write:
func testDefaultFactory()(android.Module){
 
module := cc.LibrarySharedFactory()
 android
.AddLoadHook(module, testDefault)
 return module
}


but if we compile an app, I want to change the prop that only belong to app module, the binary module does not have. how do we write? I tried to write like this:
import (
//omit
"android/soong/java")

func testDefaultFactory()(android.Module){
 
module := app.AndroidAppFactory()
 android
.AddLoadHook(module, testDefault)
 return module
}


there is a compile error:can't find import: "android/soong/java". would you give me some help? thanks!


在 2020年5月19日星期二 UTC+8上午1:35:53,fanx lin写道:
hi, I am buildding android Q , I want to build a app . and I want to use build env to control which the app installed in , I wrote a android.bp to build it. the key code as below:

//omit
//... ...

func getPrivileged(ctx android.LoadHookContext)(bool){
if ctx.AConfig().IsEnvTrue("PAX_PRI"){
fmt.Println("PAX_PRI ============= true")
return true
}else{
fmt.Println("PAX_PRI ============= false")
return false
}
}

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged bool
}
p := &props{}
p.privileged = getPrivileged(ctx)
ctx.AppendProperties(p)
}


//omit
//... ...

the code above is not work,the println is ok, I can see the print, but the privileged prop is not work, then I try to change the code as below, but is still not work:

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged *bool
}
var privileged bool
p := &props{}
privileged = getPrivileged(ctx)
p.privileged = &privileged
ctx.AppendProperties(p)
}

maybe there is some error , can someone give me a hand ?  thanks a lot!!

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/ec7139e6-7d2b-4b95-9257-e96c687b2b4d%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: android.bp privileged prop not work

Dan Willemsen-2
The Android.bp next to that go file is going to have a dep entry of "soong-cc" (which gives you access to the "android/soong/cc" package). "soong-java" will allow you to reference the "android/soong/java" package.

- Dan

On Tue, May 19, 2020 at 12:00 AM fanx lin <[hidden email]> wrote:
Hi Dan, I have one more question about:

if we compile binary bin file,in go file,we write:
func testDefaultFactory()(android.Module){
 
module := cc.DefaultsFactory()
 android
.AddLoadHook(module, testDefault)
 return module
}
and if we compile shared lib,in go file ,we write:
func testDefaultFactory()(android.Module){
 
module := cc.LibrarySharedFactory()
 android
.AddLoadHook(module, testDefault)
 return module
}


but if we compile an app, I want to change the prop that only belong to app module, the binary module does not have. how do we write? I tried to write like this:
import (
//omit
"android/soong/java")

func testDefaultFactory()(android.Module){
 
module := app.AndroidAppFactory()
 android
.AddLoadHook(module, testDefault)
 return module
}


there is a compile error:can't find import: "android/soong/java". would you give me some help? thanks!


在 2020年5月19日星期二 UTC+8上午1:35:53,fanx lin写道:
hi, I am buildding android Q , I want to build a app . and I want to use build env to control which the app installed in , I wrote a android.bp to build it. the key code as below:

//omit
//... ...

func getPrivileged(ctx android.LoadHookContext)(bool){
if ctx.AConfig().IsEnvTrue("PAX_PRI"){
fmt.Println("PAX_PRI ============= true")
return true
}else{
fmt.Println("PAX_PRI ============= false")
return false
}
}

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged bool
}
p := &props{}
p.privileged = getPrivileged(ctx)
ctx.AppendProperties(p)
}


//omit
//... ...

the code above is not work,the println is ok, I can see the print, but the privileged prop is not work, then I try to change the code as below, but is still not work:

func testDefault(ctx android.LoadHookContext){
type props struct {
privileged *bool
}
var privileged bool
p := &props{}
privileged = getPrivileged(ctx)
p.privileged = &privileged
ctx.AppendProperties(p)
}

maybe there is some error , can someone give me a hand ?  thanks a lot!!

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/ec7139e6-7d2b-4b95-9257-e96c687b2b4d%40googlegroups.com.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/CALQgHdkw%2Bezp24vtb_ty5BwZaUi0LfHTa3UW1Oxoy8%3DJNG1ZGA%40mail.gmail.com.