קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Google משתמשת בדגלים להשקת תכונות כדי לוודא שההסתעפויות של הקוד יציבות. הדגלים האלה נדרשים גם לסוגים מסוימים של תרומות ל-AOSP. לפני שמטמיעים את התיוג של השקת התכונה, צריך לקבוע אם הדגל הנדרש לשינוי. אם יש צורך בדגל, צריך לקבוע את סוג הדגל שבו רוצים להשתמש.
איך בודקים את השימוש בדגלים
כדי לקבוע מתי להשתמש בדגל להשקת תכונה, יש לפעול לפי ההנחיות הבאות:
אם אתם מבצעים שינוי שעלול לגרום לקוד הבסיסי של AOSP להיות לא יציב, כמו הוספת תכונה חדשה או תיקון באג מורכב במיוחד, צריך להשתמש בדגל השקה של התכונה.
לעומת זאת, אם אתם מבצעים שינוי בקוד שלא צפוי לגרום ליציבות של קוד הבסיס להיות לא יציבה, כמו שינוי של תגובות, אין צורך להשתמש בדגל להשקת תכונה.
קביעת סוג הדגל
יש שני סוגים של דגלים: דגלי aconfig ודגלי build.
דגלי aconfig
דגלים של aconfig משמשים להפרדה בין הפעלת קוד שלא פורסם לבין הפעלת קוד שפורסם במהלך תהליך הבדיקה וההפצה. הדגלים של aconfig יכולים להיות לקריאה ולכתיבה או לקריאה בלבד:
דגלים של aconfig לקריאה וכתיבה הם משתני בוליאני שאפשר להפעיל (להגדיר לערך true) או להשבית (להגדיר לערך false) במהלך זמן הריצה. שימוש בדגל קריאה-כתיבה כדי לבדוק ולפרסם שינויים בלי להשפיע על היציבות של ההסתעפות הראשית.
דגלים של aconfig לקריאה בלבד הם ערכי קבועים בוליאנים שאי אפשר לשנות בסביבת זמן הריצה. אפשר להמיר דגלים של aconfig לקריאה וכתיבה לדגלים של aconfig לקריאה בלבד עבור קוד יציב ומוכן להשקה.
בנוסף, בהתאם למהדר שאתם משתמשים בו, כשמשתמשים בדגל לקריאה בלבד, יכול להיות שהקוד שלא מבוצע יוחרג מה-build. לכן, אפשר להשתמש בדגלים לקריאה בלבד כדי להסתיר קוד שלא מוכן להיכלל בגרסה.
דגלים ל-build
דגלים של build הם קבועים (מחרוזות) בזמן ה-build, ואי אפשר לשנות אותם במהלך זמן הריצה. משתמשים בדגלים האלה במצבים שבהם אי אפשר להשתמש בדגלי aconfig, למשל:
יש לכם קטע קוד שנוצר מראש או נוצר מראש שרוצים לכלול ב-build.
אתם רוצים לבצע שינויים במערכת ה-build עצמה.
אתם רוצים להוסיף דגלים לקשרי התלות כדי לנהל את גודל הקוד.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],null,["# Determine flag usage and type\n\nFeature launch flags are used by Google as an approach to ensuring stable\ncode branches. These flags are also required for certain types of contributions\nto AOSP. Before implementing feature launch flagging, determine if\na flag is necessary for your change. And, if a flag is necessary, you should\ndetermine the type of flag to use.\n\nDetermine flag usage\n--------------------\n\nTo determine when to use a feature launch flag, follow these guidelines:\n\n- If you are making a change that could cause the AOSP codebase to be unstable,\n such as adding a new feature or fixing a particularly complex bug, use a feature\n launch flag.\n\n- Conversely, if you are making a code change that isn't apt to cause the\n codebase to be unstable, such as modifying comments, you don't need to use a\n feature launch flag.\n\nDetermine flag type\n-------------------\n\nThere are two types of flags: *aconfig flags* and *build flags*.\n\n### Aconfig flags\n\nAconfig flags are used to separate the execution of unreleased code from\nreleased code during the testing and release process. Aconfig flags can be\nread-write or read-only:\n\n- *Read-write aconfig flags* are boolean variables that you can enable (set to\n `true`) or disable (set to `false`) at runtime. Use a read-write flag to test\n and release changes without affecting the stability of a main branch.\n\n- *Read-only aconfig flags* are boolean constants that you can't change at\n runtime. You can convert read-write aconfig flags to read-only aconfig flags\n for code that is stable and ready to release.\n\n Additionally, depending on the compiler you're using, when a read-only flag\n is used, the code that isn't executed might be excluded\n from the build. Therefore, you can use read-only flags to hide any code that\n isn't ready to be part of a release.\n\n### Build flags\n\nBuild flags are build-time constants (strings) and you can't change them during\nruntime. Use these flags in circumstances where you can't use aconfig flags,\nsuch as:\n\n- You have a precompiled or prebuilt piece of code that you want to include in the build.\n- You want to make changes to build system itself.\n- You want to put flags around dependencies to manage code size.\n\n| **Note:** Build flags have special encodings for boolean values (`false: {empty string}, true: \"true\"`)."]]